
مكتبة Nim لتطوير الأمن الهجومي
Bitmancer هي مكتبة لتطوير أدوات الأمن الهجومي لنظام التشغيل Windows مكتوبة بلغة Nim. تهدف إلى توفير واجهات برمجية (APIs) وإجراءات ووحدات ماكرو شائعة مع تطبيقات مستقلة عن الموضع (position-independent) وقابلة للتكوين بدرجة كبيرة.
إذا كنت تتطلع إلى تطوير إمبلانت (Implant)، أو اختبار PoC سريع، أو كتابة أداة جديدة لامعة - يمكن أن يساعدك Bitmancer على البدء!
⚠️ هذا المستودع حاليًا قيد العمل بشكل كبير (WIP)! قد تواجه مشكلات عند استخدامه، ولا توجد ضمانات للاستقرار في الوقت الحالي. ⚠️
يعتمد Bitmancer جزئيًا على winim لأنواعه. للتثبيت، شغّل:
nimble install winim
Bitmancer ليس جزءًا من مستودع nimble بعد. في الوقت الحالي، يمكنك تثبيته من Github بمجرد تشغيل:
nimble install https://github.com/zimawhit3/Bitmancer
سيُدخل كل من MingW وNim تبعيات على MSVCRT وKernel32، بالإضافة إلى المتغيرات العامة التي يستخدمها Nim's System module. إذا كنت تريد تجنب هذه التبعيات من أجل كود مستقل عن الموضع، استخدم nim.cfg المتوفر.
للتجميع:
nim c -d:mingw <Your_Nim_File>
لكل الوحدات:
import Bitmancer
إذا لم تكن بحاجة إلى إجراءات NTDLL أو استدعاءات النظام (syscalls)، يمكنك ببساطة استخدام:
import Bitmancer/core
للحصول على إجراءات التجزئة فقط:
import Bitmancer/core/obfuscation/hash
إذا كانت هناك ميزة/تقنية تود أن تراها مُنفذة، أخبرني!
سلاسل المكدس (Stack Strings):
var wStr {.stackStringW.} = "Hello!"
var cStr {.stackStringA.} = "World!"
إذا كنت تتطلع إلى إنشاء غلاف (wrapper) حول استدعاء نظام غير متوفر حاليًا، فإن التدفق الأساسي يكون كما يلي:
## 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.