
Biblioteca Nim para Desenvolvimento de Segurança Ofensiva
Bitmancer é uma biblioteca para desenvolvimento de Ferramentas de Segurança Ofensiva para o sistema operacional Windows, escrita em Nim. Ela visa fornecer APIs, rotinas e macros comuns com implementações altamente configuráveis, independentes de posição e autônomas.
Se você está procurando desenvolver um Implant, testar um PoC rápido ou escrever uma ferramenta nova e brilhante - Bitmancer pode ajudar você a começar!
⚠️ Este repositório é atualmente um enorme WIP! Pode haver problemas ao usá-lo e não há garantias de estabilidade por enquanto. ⚠️
Bitmancer usa parcialmente winim para seus tipos. Para instalar, execute:
nimble install winim
Bitmancer ainda não faz parte do repositório nimble. Por enquanto, você pode instalá-lo a partir do Github simplesmente executando:
nimble install https://github.com/zimawhit3/Bitmancer
MingW e Nim introduzirão dependências de MSVCRT e Kernel32, bem como variáveis globais usadas pelo módulo System do Nim. Se você quiser evitar isso para código independente de posição, use o nim.cfg fornecido.
Para compilar:
nim c -d:mingw <Your_Nim_File>
Para todos os módulos:
import Bitmancer
Se você não precisar de rotinas NTDLL ou syscalls, basta usar:
import Bitmancer/core
Apenas para os procedimentos de hash:
import Bitmancer/core/obfuscation/hash
Se houver um recurso/técnica que você gostaria de ver implementado, me avise!
Stack Strings:
var wStr {.stackStringW.} = "Hello!"
var cStr {.stackStringA.} = "World!"
Se você está procurando gerar um wrapper em torno de um syscall que não está disponível atualmente, o fluxo básico é o seguinte:
## 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)
Veja o exemplo runShellCode para um exemplo completo.
Mais exemplos também podem ser encontrados em ntdll.