
Nim-Bibliothek für Offensive-Security-Entwicklung
Bitmancer ist eine Bibliothek für die Entwicklung von Offensive-Security-Tooling für das Windows-Betriebssystem, geschrieben in Nim. Sie zielt darauf ab, gängige APIs, Routinen und Makros mit hochkonfigurierbaren, positionsunabhängigen, eigenständigen Implementierungen bereitzustellen.
Wenn du ein Implant entwickeln, eine schnelle PoC testen oder ein brandneues, glänzendes Tool schreiben möchtest – Bitmancer kann dir den Einstieg erleichtern!
⚠️ Dieses Repository ist derzeit ein massives WIP! Es könnte Probleme bei der Verwendung geben und es gibt derzeit keine Garantien für Stabilität. ⚠️
Bitmancer verwendet teilweise winim für seine Typen. Zur Installation führe Folgendes aus:
nimble install winim
Bitmancer ist noch nicht Teil des Nimble-Repositorys. Derzeit kannst du es einfach von Github installieren, indem du Folgendes ausführst:
nimble install https://github.com/zimawhit3/Bitmancer
MingW und Nim führen Abhängigkeiten auf MSVCRT und Kernel32 sowie globale Variablen ein, die von Nims System-Modul verwendet werden. Wenn du diese für positionsunabhängigen Code vermeiden möchtest, verwende die bereitgestellte nim.cfg.
Zum Kompilieren:
nim c -d:mingw <Your_Nim_File>
Für alle Module:
import Bitmancer
Wenn du keine NTDLL-Routinen oder Syscalls benötigst, kannst du einfach Folgendes verwenden:
import Bitmancer/core
Für nur die Hashing-Prozeduren:
import Bitmancer/core/obfuscation/hash
Wenn es eine Funktion/Technik gibt, die du implementiert haben möchtest, lass es mich wissen!
Stack-Strings:
var wStr {.stackStringW.} = "Hello!"
var cStr {.stackStringA.} = "World!"
Wenn du einen Wrapper um einen derzeit nicht verfügbaren Syscall generieren möchtest, ist der grundlegende Ablauf wie folgt:
## 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)
Siehe das runShellCode-Beispiel für ein vollständiges Beispiel.
Weitere Beispiele findest du auch in ntdll.