Skip to content

Commit

Permalink
Created Mobile category. Moved Android section into Mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhi Shree committed Oct 5, 2020
1 parent 01b8740 commit 89e38a0
Show file tree
Hide file tree
Showing 86 changed files with 405 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ This repository contains hands-on training content on how to attack a Linux box.

1. [Getting Comfortable with Linux Basics](getting_comfortable_with_linux_basics/README.md)
* [Bash Scripting](getting_comfortable_with_linux_basics/documentation/bash_scripting/README.md)
* [A Few Useful Commands](getting_comfortable_with_linux_basics/documentation/commands/README.md)
* [A Few Useful Commands](getting_comfortable_with_linux_basics/documentation/commands/README.md)
* [Redirection](getting_comfortable_with_linux_basics/documentation/redirection/README.md)
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
# Redirection

*"Everything is a file."*

The shell references standard input, output and error file streams internally as file descriptors 0, 1, and 2, respectively.

1. Redirect **standard error**: `ls -l /bin/usr 2> ls-error.txt`
2. Redirect both **standard output and standard error**: `ls -l /bin/usr > ls-output.txt 2>&1`
1st, redirect standard output to a file, and then redirect file descriptor 2 (i.e., standard errror) to file descriptor 1 (i.e., standard output) using the notation **2>&1**.

Alternative, streamlined method to redirect both standard output and standard error to a file is:

ls -l /bin/usr &> ls-output.txt
ls -l /bin/usr &>> ls-output.txt

3. **Suppress error** messages from a command by redirecting error and status messages to a special file `/dev/null` (i.e., a *bit bucket*), which accepts input and does nothing with it:

ls -l /bin/usr 2> /dev/null
4. **Join** files: `cat file1 file2 ... fileN > combinedFile.out`
5. **Create** short text files using `cat`

$ cat > file.txt
Type your text here...
Press Ctrl-d when done.

6. **Pipe** the standard output of one command to standard input of another: `ls -l /bin /usr/bin | sort | uniq | wc -l`
7. Use `uniq` with `-d` option to see the **list of duplicates**

ls -l /bin /usr/bin | sort | uniq -d | less

8. Print **first N lines** of a file

head -n 5 ls-output.txt

9. Print **last N lines** of a file

ls /usr/bin | tail -n 5

10. Monitor a file in **real time**: `tail -f /var/log/messages`
11. `tee` program reads standard input and copies it to both standard output and to one or more files
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions Mobile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Mobile Pentesting

* [Android App](Android/README.md)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

This repository is intended to contain hands-on training content (and very little theory) for anyone and everyone who might be interested.

Keeping in mind the repeated demand for the same training content again and again, but for a newer audience, I am creating this repository. Anyone is free to enhance the existing content and/or use the training material provided here for self-learning or to deliver sessions in open communities.
Keeping in mind the repeated demand for the same training content again and again, but for a newer audience, this repository has been created. Anyone is free to enhance the existing content and/or use the materials provided here for self-learning or to deliver sessions in open communities.

*Note:* I am not an expert, but just someone trying to learn from work done by countless other intellectuals.

1. [Linux](Linux/README.md)
2. [Windows](Windows/README.md)
3. [Web](Web/README.md)
4. [Android](Android/README.md)
4. [Mobile](Mobile/README.md)
6 changes: 3 additions & 3 deletions Web/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Attacking a Website
# Web Pentesting

This repository contains hands-on training content on how to attack a Website.

1. [Getting comfortable with Web basics](getting_comfortable_with_web_basics/README.md)
2. *Content to be added*
1. [Web Basics](web_basics/README.md)
2. [AWS Basics](aws_basics/README.md)
189 changes: 189 additions & 0 deletions Web/aws_basics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# AWS

* Create new IAM user
* Configure AWS CLI

* $ **vim ~/.aws/credentials**

[default]
aws_access_key_id = <ACCESS_KEY>
aws_secret_access_key = <SECRET_KEY>

* $ **vim ~/.aws/config**

[default]
region=ap-south-1
output=json

* $ **aws iam get-user**

{
"User": {
"Arn": "arn:aws:iam::62NNNNNNNN21:user/username",
"UserName": "username",
"Path": "/",
"UserId": "USERID",
"CreateDate": "2020-10-05T11:06:55Z"
}
}

* Test Terraform Setup

* $ **vim terraform.tfvars**

AWS_ACCESS_KEY="<ACCESS_KEY>"
AWS_SECRET_KEY="<SECRET_KEY>"

* $ **vim terraform.code.tf**

# ************************
# vars.tf
# ************************

variable "AWS_ACCESS_KEY" {}
variable "AWS_SECRET_KEY" {}
variable "AWS_REGION" {
default = "ap-south-1"
}
variable "AMIS" {
type = "map"
default = {
ap-south-1 = "ami-03cfb5e1fb4fac428"
}
}
# ************************
# provider.tf
# ************************
provider "aws" {
access_key = "${var.AWS_ACCESS_KEY}"
secret_key = "${var.AWS_SECRET_KEY}"
region = "${var.AWS_REGION}"
}
# ************************
# instance.tf
# ************************
resource "aws_instance" "null_DEVOPS_INSTANCE" {
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
tags = { Name = "UDEMY" }
instance_type = "t2.micro"
provisioner "local-exec" {
command = "echo ${aws_instance.null_DEVOPS_INSTANCE.private_ip} >> private_ips.txt"
}
}
output "ip" {
value = "${aws_instance.null_DEVOPS_INSTANCE.public_ip}"
}

* $ **terraform init**
* $ **terraform apply**
* $ **terraform destroy**

* Create an S3 bucket: `kops.null.co.in`
* Create a hosted zone: `kops.nullbangalore.site`
* Find full zone name for your region: `aws ec2 describe-availability-zones --region ap-south-1 `

* Setup a Kubernetes cluster using Terraform

* $ **vim kops_cluster.sh**

kops create cluster \
--name=kops.nullbangalore.site \
--state=s3://kops.null.co.in \
--authorization RBAC \
--zones=ap-south-1a \
--node-count=2 \
--node-size=t2.micro \
--master-size=t2.micro \
--master-count=1 \
--dns-zone=kops.nullbangalore.site \
--out=null_terraform \
--target=terraform \
--ssh-public-key=~/.ssh/null_terraform.pub

* Troubleshooting: *"Terraform has initialized, but configuration upgrades may be needed."*

terraform 0.12upgrade
terraform init
terraform apply

**Outputs:**

cluster_name = kops.nullbangalore.site
master_autoscaling_group_ids = [
"master-ap-south-1a.masters.kops.nullbangalore.site",
]
master_security_group_ids = [
"sg-0701055adb32e03c2",
]
masters_role_arn = arn:aws:iam::625077889421:role/masters.kops.nullbangalore.site
masters_role_name = masters.kops.nullbangalore.site
node_autoscaling_group_ids = [
"nodes.kops.nullbangalore.site",
]
node_security_group_ids = [
"sg-072f49ef57ae19941",
]
node_subnet_ids = [
"subnet-07caa79d4303b009b",
]
nodes_role_arn = arn:aws:iam::625077889421:role/nodes.kops.nullbangalore.site
nodes_role_name = nodes.kops.nullbangalore.site
region = ap-south-1
route_table_public_id = rtb-08dcf341209c578f9
subnet_ap-south-1a_id = subnet-07caa79d4303b009b
vpc_cidr_block = 172.20.0.0/16
vpc_id = vpc-0624da09a3c8a3ab1

* $ **kubectl get nodes**

NAME STATUS ROLES AGE VERSION
ip-172-20-41-144.ap-south-1.compute.internal Ready node 10m v1.17.12
ip-172-20-43-234.ap-south-1.compute.internal Ready master 13m v1.17.12
ip-172-20-63-134.ap-south-1.compute.internal Ready node 10m v1.17.12

* Deploy Nginx in Kubernetes cluster AWS

kubectl \
create deployment my-nginx-deployment \
--image=nginx

---

kubectl \
expose deployment my-nginx-deployment \
--port=80 \
--type=NodePort \
--name=my-nginx-service

---

$ kubectl get nodes
$ kubectl get pods,svc

* Update `Inbound rules` for `Security group for nodes` to expose the Nginx port
* Create a **configmap** object in Kubernetes, to store NGINX content

$ kubectl create configmap nginx-content --from-file=index.html
$ kubectl get cm nginx-content
$ kubectl describe cm
* Deploy `deployment` and `service` with `Nginx`

$ kubectl create -f deployment_file.yaml
$ kubectl delete cm nginx-content
$ kubectl get pod
$ kubectl exec -it nginx-deployment-5db549b6df-4xplk -- bash
$ vim deployment_file.yaml
$ kubectl apply -f deployment_file.yaml
$ kubectl delete pod nginx-deployment-5db549b6df-4xplk

* Cleanup
* **kubectl delete all --all**
* kubectl get svc --all-namespaces
* kubectl get nodes
* kubectl delete node --all
* $ terraform state list
* $ terraform destroy

3 changes: 0 additions & 3 deletions Web/getting_comfortable_with_web_basics/README.md

This file was deleted.

Loading

0 comments on commit 89e38a0

Please sign in to comment.