
Librería de Nim para Desarrollo de Seguridad Ofensiva
Bitmancer es una biblioteca para el desarrollo de herramientas de Seguridad Ofensiva para el sistema operativo Windows, escrita en Nim. Su objetivo es proporcionar API, rutinas y macros comunes con implementaciones altamente configurables, independientes de la posición y autónomas.
Si buscas desarrollar un Implant, probar un PoC rápido o escribir una herramienta nueva y brillante, ¡Bitmancer puede ayudarte a empezar!
⚠️ ¡Este repositorio es actualmente un enorme WIP! Puede haber problemas al usarlo y no hay garantías de estabilidad por el momento. ⚠️
Bitmancer usa parcialmente winim para sus tipos. Para instalarlo, ejecuta:
nimble install winim
Bitmancer aún no forma parte del repositorio de nimble. Por ahora, puedes instalarlo desde Github simplemente ejecutando:
nimble install https://github.com/zimawhit3/Bitmancer
MingW y Nim introducirán dependencias en MSVCRT y Kernel32, así como variables globales usadas por el módulo System de Nim. Si quieres evitarlas para código independiente de la posición, usa el nim.cfg provisto.
Para compilar:
nim c -d:mingw <Tu_Archivo_Nim>
Para todos los módulos:
import Bitmancer
Si no necesitas rutinas NTDLL o syscalls, puedes simplemente usar:
import Bitmancer/core
Para solo los procedimientos de hash:
import Bitmancer/core/obfuscation/hash
Si hay alguna característica/técnica que te gustaría que implementara, ¡házmelo saber!
Stack Strings:
var wStr {.stackStringW.} = "Hello!"
var cStr {.stackStringA.} = "World!"
Si buscas generar un wrapper alrededor de un syscall no disponible actualmente, el flujo básico es el siguiente:
## Import syscalls
import Bitmancer/syscalls
## For hashing
import Bitmancer/core/obfuscation/hash
## Define your type
type NtClose = proc(h: HANDLE): NTSTATUS {.stdcall, gcsafe.}
## Generate the wrapper
genSyscall(NtClose)
## Define configurations for how to retrieve and execute the syscall
## The procedure's symbol enumeration method - available options are:
## UseEAT - use the export address table to resolve the symbol
## UseIAT - use the import address table to resolve the symbol
## UseLdrThunks - use the NTLoader's LdrThunkSignatures to map a clean NTDLL to resolve symbols from
const symEnum = SymbolEnumeration.UseEAT
## The SSN enumeration method - available options are:
## HellsGate
## HalosGate
## TartarusGate
## ZwCounter
const ssnEnum = SsnEnumeration.HellsGate
## Finally, the execution method - available options are:
## Direct - use the direct syscall stub
## Indirect - use the indirect syscall stub
const exeEnum = SyscallExecution.Indirect
## Define an ident to use to identify the symbol
const NtCloseHash = ctDjb2 "NtClose"
## Retrive NTDLL
let Ntdll = ? NTDLL_BASE()
## Call ctGetNtSyscall, retrieving the NtSyscall object containing the SSN, pointer to the address of the function
## and a casted stub to your type.
let NtSyscall = ctGetNtSyscall[NtClose](Ntdll, ModuleHandle(NULL), NtCloseHash, symEnum, ssnEnum, exeEnum)
## Finally, call the wrapper!
NtCloseWrapper(h, NtSyscall.wSyscall, NtSyscall.pSyscall, NtSyscall.pFunction)
Consulta el ejemplo runShellCode para un ejemplo completo.
Más ejemplos también se pueden encontrar en ntdll.