I wanted to take some time to give those taking the OSCP and similar exams, a bit of food for thought when taking these exams. The food will come via taking time to create a repeatable framework in order to perform necessary objectives on the road to "owning the box." Be it Windows, Linux, BSD, the flavor is irrelevant. I urge anyone taking the exam to go over the PTES (Penetration Testing Execution Standard) as it more detailed than what you will see here.
The OSCP exam seems to eat up a lot of time for a lot of individuals taking the exam. Time is crucial in this exam as you are going to be allotted 24 hours. In the real world, your SOW will also have a cut off time. So how can you maximize your time without having your work all over the place. The answer is to create
yourself a framework.
In the following mindmap (
http://www.infiltrated.net/mgz/oscp.jpeg), I have a target and the tasks I would take in trying to exploit the target. In the enumeration/identification step, I will begin with, but not rely on, NMAP. I try to use p0f whenever possible since it offers a better mechanism of identifying a target.
I try to use p0f especially when identifying webservers, since I can use a proxy server to connect without triggering anything out of the ordinary. In the following snippet, I will connect from my desktop (FreeBSD 9.0) to a forensic workstation I created using Ubuntu, on port 80.
[root@kenji ~]# uname -a
FreeBSD kenji 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Mar 20 10:42:10 EDT 2012 root@kenji:/usr/obj/usr/src/sys/SARU i386
[root@kenji ~]# nmap -sS -P0 -sV -T2 -vvv 10.4.4.86
Starting Nmap 5.61TEST5 ( http://nmap.org ) at 2012-04-09 14:47 EDT
NSE: Loaded 16 scripts for scanning.
Initiating Parallel DNS resolution of 1 host. at 14:47
Completed Parallel DNS resolution of 1 host. at 14:47, 0.03s elapsed
DNS resolution of 1 IPs took 0.03s. Mode: Async [#: 3, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating SYN Stealth Scan at 14:47
Scanning 10.4.4.86 [1000 ports]
Discovered open port 22/tcp on 10.4.4.86
Discovered open port 80/tcp on 10.4.4.86
Completed SYN Stealth Scan at 14:54, 401.81s elapsed (1000 total ports)
Initiating Service scan at 14:54
Scanning 2 services on 10.4.4.86
Completed Service scan at 14:54, 6.38s elapsed (2 services on 1 host)
NSE: Script scanning 10.4.4.86.
NSE: Starting runlevel 1 (of 1) scan.
Nmap scan report for 10.4.4.86
Host is up (0.00038s latency).
Scanned at 2012-04-09 14:47:38 EDT for 409s
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.8p1 Debian 7ubuntu1 (protocol 2.0)
80/tcp open http Apache httpd 2.2.20 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:kernel
Read data files from: /usr/local/share/nmap
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 408.69 seconds
Raw packets sent: 1000 (44.000KB) | Rcvd: 1000 (40.008KB)
NMAP states this is Ubuntu, what does p0f state?
[root@kenji ~]# p0f -o /tmp/p0f.output
.-[ 10.4.4.72/16070 -> 10.4.4.86/80 (syn) ]-
|
| client = 10.4.4.72/16070
| os = FreeBSD 9.x
| dist = 0
| params = none
| raw_sig = 4:64+0:0:1460:65535,6:mss,nop,ws,sok,ts:df,id+:0
|
`----
.-[ 10.4.4.72/16070 -> 10.4.4.86/80 (mtu) ]-
|
| client = 10.4.4.72/16070
| link = Ethernet or modem
| raw_mtu = 1500
|
`----
.-[ 10.4.4.72/16070 -> 10.4.4.86/80 (uptime) ]-
|
| client = 10.4.4.72/16070
| uptime = 20 days 2 hrs 47 min (modulo 49 days)
| raw_freq = 999.93 Hz
|
`----
.-[ 10.4.4.72/16070 -> 10.4.4.86/80 (syn+ack) ]-
|
| server = 10.4.4.86/80
| os = Linux 3.x
| dist = 0
| params = none
| raw_sig = 4:64+0:0:1460:mss*10,4:mss,sok,ts,nop,ws:df:0
|
`----
.-[ 10.4.4.72/16070 -> 10.4.4.86/80 (mtu) ]-
|
| server = 10.4.4.86/80
| link = Ethernet or modem
| raw_mtu = 1500
|
`----
.-[ 10.4.4.72/16070 -> 10.4.4.86/80 (http request) ]-
|
| client = 10.4.4.72/16070
| app = ???
| lang = English
| params = none
| raw_sig =
1:Host,User-Agent,Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8],Accept-Language=[en-us,en;q=0.5],Accept-Encoding=[gzip,deflate],Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7],Keep-Alive=[115],Proxy-Connection=[keep-alive],?If-Modified-Since,?If-None-Match:Connection:Mozilla/5.0
(X11; U; FreeBSD i386; en-US; rv:1.9.2.27) Gecko/20120314 Firefox/3.6.27
|
`----
.-[ 10.4.4.72/16070 -> 10.4.4.86/80 (http response) ]-
|
| server = 10.4.4.86/80
| app = ???
| lang = none
| params = none
| raw_sig = 1:Date,Server,?ETag,?Vary:Content-Type,Connection,Keep-Alive,Accept-Ranges:Apache/2.2.20 (Ubuntu)
|
`----
We can validate whether or not out nmap output is accurate but we can assess how long the server has been running and get an idea of the patch level of a machine. Now, in order to minimize time, I might sweep a subnet for specifics: HTTP, SMTP, POP and so forth. The reasoning for this, is that when under time constraints, it allows me to focus specific attacks and probes against those specific targets that I know are running the service. This allows me to spend time elsewhere (running other nmap sweeps, etc)
For example, I can sweep a /24 for ONLY port 80, begin launching more probes in the background, while I launch other scans and other probes at another service.
printf "Enter host\n\n"
read HOST
WEB=`nmap -sS -p80 $HOST -v | awk '/open port/{print $2}' |grep -vi dis`
if [ "$WEB" == open ]
then
nikto -host $HOST
fi
exit 0
In any event, if you're doing ONE thing and
ONE THING only on the OSCP exam, you're wasting time. There is nothing stopping you from opening a terminal and creating your own little framework for doing this exam:
mkdir {HTTP-OUTPUT,HYDRA-RECON,NIKTO-OUTPUT,SNMP-OUTPUT}
printf "Enter host\n\n"
read HOST
WEB=`nmap -sS -p80 $HOST -v | awk '/open port/{print $2}' |grep -vi dis`
if [ "$WEB" == open ]
then
cd HTTP-OUTPUT
nikto -host $HOST > $HOST.nikto,output
echo "Completed Nikto" | wall
fi
exit 0
Get the picture?
1) Make relevant directories (way beforehand)
2) Enter a target
3) Go check if the target is running anything on port 80
4) If it is, then run nikto against it
5) When done write it everywhere in case I am on 50 different terminals
You can continue something like this to fire off dozens of tests, probes, and so on. What you do with your time is always going to be critical since time is irreplaceable. Same applies when performing real world testing. You may be in a bind for time, if you're waiting on the output of one tool, you're wasting time. Moving back to the mindmap, take some time to think about a structured way to attack this exam. There is no reason you cannot fork off processes way before you even get started. Practice in your own environment:
if $THIS_TARGET is running SNMP
then run hydra
else if $THIS_TARGET is running HTTP
then use $TOOL_OF_CHOICE
fi
Same applies in the real world. When performing tests, it is critical that not only you perform necessary testing, but it is also critical you manage your time while doing so. (Time is money) Creativity goes a long way in this field (pentesting) however, it makes no sense to throw paint on a canvas and once done, determine you are now going to start painting the Mona Lisa. Planning goes a long way
Food for though