
Libreria Nim per lo sviluppo di sicurezza offensiva
Bitmancer è una libreria per lo sviluppo di strumenti di Offensive Security per il sistema operativo Windows, scritta in Nim. Il suo obiettivo è fornire API, routine e macro comuni con implementazioni standalone altamente configurabili e indipendenti dalla posizione.
Se stai cercando di sviluppare un Implant, testare un rapido PoC o scrivere un nuovo brillante strumento, Bitmancer può aiutarti a iniziare!
⚠️ Questo repository è attualmente un enorme WIP! Potrebbero esserci problemi nell'utilizzarlo e non ci sono garanzie di stabilità per il momento. ⚠️
Bitmancer usa parzialmente winim per i suoi tipi. Per installarlo, esegui:
nimble install winim
Bitmancer non fa ancora parte del repository nimble. Per il momento puoi installarlo da Github semplicemente eseguendo:
nimble install https://github.com/zimawhit3/Bitmancer
MingW e Nim introdurranno dipendenze da MSVCRT e Kernel32, oltre a variabili globali usate dal modulo System di Nim. Se vuoi evitarle per codice indipendente dalla posizione, usa il nim.cfg fornito.
Per compilare:
nim c -d:mingw <Your_Nim_File>
Per tutti i moduli:
import Bitmancer
Se non hai bisogno delle routine NTDLL o delle syscall, puoi semplicemente usare:
import Bitmancer/core
Per solo le procedure di hashing:
import Bitmancer/core/obfuscation/hash
Se c'è una funzionalità/tecnica che vorresti fosse implementata, fammelo sapere!
Stack Strings:
var wStr {.stackStringW.} = "Hello!"
var cStr {.stackStringA.} = "World!"
Se stai cercando di generare un wrapper attorno a una syscall non attualmente disponibile, il flusso di base è il seguente:
## 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)
Vedi l'esempio runShellCode per un esempio completo.
Altri esempi possono essere trovati in ntdll.