
オフェンシブセキュリティ開発のためのNimライブラリ
Bitmancer は、Nim で書かれた Windows オペレーティングシステム向けの Offensive Security ツール開発のためのライブラリです。高度に設定可能で、位置非依存かつスタンドアロンな実装を備えた、共通 API、ルーチン、マクロを提供することを目的としています。
インプラントを開発したい場合や、簡単な PoC をテストしたい場合、あるいはまったく新しい素晴らしいツールを書きたい場合、Bitmancer はあなたの開発を支援します!
⚠️ このリポジトリは現在、大規模な WIP です! 使用中に問題が発生する可能性があり、当面の間、安定性は保証されません。 ⚠️
Bitmancer はタイプ定義の一部に winim を使用しています。インストールするには、次を実行してください:
nimble install winim
Bitmancer はまだ nimble リポジトリに含まれていません。当面は、以下のコマンドを実行して Github からインストールできます:
nimble install https://github.com/zimawhit3/Bitmancer
MingW と Nim は、MSVCRT と Kernel32 への依存関係に加えて、Nim の System モジュールで使用されるグローバル変数への依存関係をもたらします。位置非依存コードのためにこれらを避けたい場合は、同梱の nim.cfg を使用してください。
コンパイルするには:
nim c -d:mingw <Your_Nim_File>
すべてのモジュールを利用する場合:
import Bitmancer
NTDLL ルーチンやシステムコールが必要ない場合は、次のように簡単に使用できます:
import Bitmancer/core
ハッシュ化プロシージャのみが必要な場合:
import Bitmancer/core/obfuscation/hash
実装してほしい機能やテクニックがあれば、お知らせください!
スタック文字列:
var wStr {.stackStringW.} = "Hello!"
var cStr {.stackStringA.} = "World!"
現在利用できないシステムコールのラッパーを生成したい場合の基本的な流れは次のとおりです:
## 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)
完全な例については runShellCode の例 を参照してください。
その他の例は ntdll にもあります。