Skip to content
KitploitKITPLOIT
उपकरणब्लॉग
जमा करें
उपकरणब्लॉग
जमा करें

हैकिंग, पेनटेस्ट और साइबर सुरक्षा उपकरण आपके सुरक्षा शस्त्रागार के लिए!

Kitploit हैकिंग, साइबर सुरक्षा और पेंटेस्टिंग टूल्स की एक निर्देशिका है। कमजोरियों को खोजने, सिस्टम का विश्लेषण करने, परीक्षण को स्वचालित करने और अपनी सुरक्षा को मजबूत करने के लिए नवीनतम प्रोजेक्ट अपडेट खोजें।

··फ़ीड·संपर्क·गोपनीयता·© 2026 Kitploit

टूल निर्देशिका

श्रेणियाँ

सभी श्रेणियाँ देखें
Loading categories
उपकरण/GitHubGitHub/ntdallas/bof_executeassembly
विशेषाधिकार वृद्धिआईडीएस/आईपीएस से बचनाशेलकोडपोस्ट-शोषणकमांड एंड कंट्रोलरेड टीमिंगबाइनरी शोषण
GitHubntdallas/bof_executeassembly

BOF_ExecuteAssembly

Cobalt Strike के लिए Beacon Object File जो evasion तकनीकों के साथ beacon में .NET assemblies को निष्पादित करता है।

रिपॉजिटरी देखें
195278 महीने पहलेKitploit द्वारा समीक्षित

सबसे लोकप्रिय

सभी देखें →

हमारे समुदाय द्वारा सबसे अधिक उपयोग किए जाने वाले उपकरण खोजें।

सभी उपकरण खोजें

हमारे उपकरणों का संग्रह ब्राउज़ करें

सभी उपकरण देखें →
साझा करें

BOF Execute-Assembly

Cobalt Strike के लिए Beacon Object File जो बीकन में एवेज़न तकनीकों के साथ .NET असेम्बली निष्पादित करता है।

अवलोकन

मुख्य आर्किटेक्चर

root@kitploit:~
┌──────────────────────────────────────────────────────────────────────────────┐
│                         Cobalt Strike Beacon                                 │
│                         (Parent Process)                                     │
└──────────────────────────────────┬───────────────────────────────────────────┘
                                   │
                                   │ beacon_inline_execute()
                                   │ - Parse packed arguments
                                   │ - Call go()
                                   ▼
┌──────────────────────────────────────────────────────────────────────────────┐
│                      BOF Execute-Assembly Entry (go)                         │
│  ┌────────────────────────────────────────────────────────────────────────┐  │
│  │ Configuration Parsing                                                  │  │
│  │  • ProxyMethod (None/Draugr/Timer/RegWait)                             │  │
│  │  • AmsiEvasion (None/Patch/HWBP)                                       │  │
│  │  • EtwEvasion (None/Patch)                                             │  │
│  │  • PipeName, AppDomainName, Assembly bytes, Arguments                  │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ Framework Initialization                                               │  │
│  │  • InitVxTable() - Resolve syscall numbers                             │  │
│  │    └─> NtProtectVirtualMemory, NtContinue, NtCreateEvent,              │  │
│  │        NtSetEvent, NtWaitForSingleObject, NtClose                      │  │
│  │  • DraugrInit() - Setup synthetic stack frames                         │  │
│  │    └─> Locate RtlUserThreadStart, BaseThreadInitThunk                  │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ DLL Loading (ProxyLoadLibraryA)                                        │  │
│  │  • amsi.dll, OleAut32.dll, mscoree.dll, User32.dll                     │  │
│  │                                                                        │  │
│  │  PROXY_NONE:     LoadLibraryA() directly                               │  │
│  │  PROXY_DRAUGR:   DRAUGR_API(LoadLibraryA) - spoofed stack              │  │
│  │  PROXY_TIMER:    CreateTimerQueue → Timer callback                     │  │
│  │  PROXY_REGWAIT:  RegisterWaitForSingleObject → Event callback          │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ AMSI Evasion Setup                                                     │  │
│  │                                                                        │  │
│  │  AMSI_PATCH:                         AMSI_HWBP:                        │  │
│  │  ┌─────────────────────────┐         ┌──────────────────────────────┐  │  │
│  │  │ 1. Backup 4 bytes       │         │ 1. Add VEH Handler           │  │  │
│  │  │ 2. NtProtectVirtualMem  │         │ 2. RtlCaptureContext         │  │  │
│  │  │    (RW)                 │         │ 3. Set DR0 = AmsiScanBuffer  │  │  │
│  │  │ 3. Write:               │         │ 4. Enable DR7 breakpoint     │  │  │
│  │  │    48 31 C0  xor rax,rax│         │ 5. NtContinue (apply ctx)    │  │  │
│  │  │    C3        ret        │         │                              │  │  │
│  │  │ 4. NtProtectVirtualMem  │         │ On AmsiScanBuffer call:      │  │  │
│  │  │    (restore)            │         │   → #BP Exception            │  │  │
│  │  └─────────────────────────┘         │   → VEH redirects to RET     │  │  │
│  │                                      │   → RAX = 0                  │  │  │
│  │                                      └──────────────────────────────┘  │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ ETW Evasion (if enabled)                                               │  │
│  │  • NtProtectVirtualMemory(NtTraceEvent, RW)                            │  │
│  │  • Backup 4 bytes                                                      │  │
│  │  • Write: 48 31 C0 C3 (xor rax,rax; ret)                               │  │
│  │  • NtProtectVirtualMemory(restore protection)                          │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ Output Redirection Setup                                               │  │
│  │  ┌──────────────────────────────────────────────────────────────────┐  │  │
│  │  │ 1. CreateNamedPipeW(\\.\pipe\{CustomName})  → hPipe              │  │  │
│  │  │ 2. CreateFileW(pipe path)                   → hFile              │  │  │
│  │  │ 3. AllocConsole() + ShowWindow(SW_HIDE)     → Hidden console     │  │  │
│  │  │                                                                  │  │  │
│  │  │ 4. PEB Manipulation:                                             │  │  │
│  │  │    • Backup: hCurrentStdOut = PEB->ProcessParameters->StdOut     │  │  │
│  │  │    • Backup: hCurrentStdErr = PEB->ProcessParameters->StdErr     │  │  │
│  │  │    • Redirect: PEB->StdOut = hFile                               │  │  │
│  │  │    • Redirect: PEB->StdErr = hFile                               │  │  │
│  │  └──────────────────────────────────────────────────────────────────┘  │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ CLR Hosting & Assembly Execution (ExecuteAssembly)                     │  │
│  │  ┌──────────────────────────────────────────────────────────────────┐  │  │
│  │  │ 1. CLR Version Detection                                         │  │  │
│  │  │    • Scan assembly bytes for "v2.0.50727" or "v4.0.30319"        │  │  │
│  │  │                                                                  │  │  │
│  │  │ 2. CLR Initialization                                            │  │  │
│  │  │    • CLRCreateInstance → ICLRMetaHost                            │  │  │
│  │  │    • GetRuntime(v2/v4) → ICLRRuntimeInfo                         │  │  │
│  │  │    • GetInterface → ICorRuntimeHost                              │  │  │
│  │  │    • Start()                                                     │  │  │
│  │  │                                                                  │  │  │
│  │  │ 3. AppDomain Management                                          │  │  │
│  │  │    • GetDefaultDomain() → Default AppDomain                      │  │  │
│  │  │    • CreateDomain(CustomName) → Isolated AppDomain               │  │  │
│  │  │                                                                  │  │  │
│  │  │ 4. Assembly Loading                                              │  │  │
│  │  │    • Create SAFEARRAY (VT_UI1) with assembly bytes               │  │  │
│  │  │    • SafeArrayAccessData → Copy assembly to safe array           │  │  │
│  │  │    • CustomAppDomain->Load_3(safearray) → Load in memory         │  │  │
│  │  │                                                                  │  │  │
│  │  │ 5. Argument Preparation                                          │  │  │
│  │  │    • Parse space-delimited arguments                             │  │  │
│  │  │    • Create SAFEARRAY(VT_BSTR) for each argument                 │  │  │
│  │  │    • Wrap in VARIANT structure                                   │  │  │
│  │  │                                                                  │  │  │
│  │  │ 6. Execution                                                     │  │  │
│  │  │    • Assembly->EntryPoint() → Get Main() MethodInfo              │  │  │
│  │  │    • MethodInfo->Invoke_3(arguments) → Execute                   │  │  │
│  │  │       └─> Assembly writes to Console                             │  │  │
│  │  │           └─> Redirected to hFile → Named Pipe                   │  │  │
│  │  │                                                                  │  │  │
│  │  │ 7. Cleanup                                                       │  │  │
│  │  │    • Release COM interfaces (MethodInfo, Assembly, etc.)         │  │  │
│  │  │    • UnloadDomain(CustomAppDomain) → Full unload                 │  │  │
│  │  │    • FreeLibrary(mscoree.dll)                                    │  │  │
│  │  └──────────────────────────────────────────────────────────────────┘  │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ Output Capture & Display                                               │  │
│  │  • Restore PEB: StdOut/StdErr = original handles                       │  │
│  │  • Allocate buffer (0x10000 bytes)                                     │  │
│  │  • ReadFile(hPipe) → Capture assembly output                           │  │
│  │  • BeaconPrintf(CALLBACK_OUTPUT, output) → Display to operator         │  │
│  └────────────────────────────────┬───────────────────────────────────────┘  │
│                                   │                                          │
│  ┌────────────────────────────────▼───────────────────────────────────────┐  │
│  │ Cleanup & Restoration                                                  │  │
│  │  • free(pAssemblyStdOut)                                               │  │
│  │  • NtClose(hFile, hPipe)                                               │  │
│  │  • FreeConsole()                                                       │  │
│  │                                                                        │  │
│  │  if (AMSI_PATCH):                                                      │  │
│  │    • RestoreAmsi() - Write original 4 bytes back                       │  │
│  │                                                                        │  │
│  │  if (AMSI_HWBP):                                                       │  │
│  │    • RemoveHwbp() - Clear debug registers                              │  │
│  │    • RemoveVectoredExceptionHandler(VehHandler)                        │  │
│  │                                                                        │  │
│  │  if (ETW_PATCH):                                                       │  │
│  │    • RestoreEtw() - Write original 4 bytes back                        │  │
│  │                                                                        │  │
│  │  • Restore PEB: StdOut/StdErr = original                               │  │
│  └────────────────────────────────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────────────────────────────────┘
                                   │
                                   │ Return to Beacon
                                   ▼
┌──────────────────────────────────────────────────────────────────────────────┐
│                     Beacon continues execution                               │
│                     (BOF memory cleaned up)                                  │
└──────────────────────────────────────────────────────────────────────────────┘

प्रॉक्सी विधियाँ

विधिविवरण
Noneसीधे API कॉल
DraugrDraugr के माध्यम से स्टैक-स्पूफ्ड API कॉल
Regwait

AMSI एवेज़न विधियाँ

विधिविवरण
Noneकोई AMSI बाईपास नहीं
PatchAMSI!AmsiScanBuffer का मेमोरी पैच (xor rax,rax; ret)
HWBPVEH के माध्यम से AMSI!AmsiScanBuffer पर हार्डवेयर ब्रेकपॉइंट हुक

ETW एवेज़न विधियाँ

विधिविवरण
Noneकोई ETW बाईपास नहीं
PatchNTDLL!NtTraceEvent का मेमोरी पैच (xor rax,rax; ret)

अतिरिक्त कॉन्फ़िगरेशन

पैरामीटरविवरणउदाहरण
PipeNameअसेम्बली आउटपुट कैप्चर करने हेतु नेम्ड पाइप का नामP1p3N4m3
AppDomainअसेम्बली अलगाव के लिए कस्टम .NET AppDomain नामTot4lL3g1t

प्रॉक्सी लोडिंग विधियों का विवरण

1. डायरेक्ट (PROXY_NONE)

root@kitploit:~
LoadLibraryA("amsi.dll") → Direct call

2. Draugr (PROXY_DRAUGR)

root@kitploit:~
DRAUGR_API(LoadLibraryA, "amsi.dll")
    │
    ├─ Synthetic Stack Construction
    ├─ Return Address Spoofing
    └─ Indirect Execution

3. टाइमर क्यू (PROXY_TIMER)

root@kitploit:~
CreateTimerQueue() → CreateTimerQueueTimer(
    callback = LoadLibraryA,
    parameter = "amsi.dll",
    dueTime = 100ms
) → Wait → DeleteTimerQueueEx()

4. RegisterWait (PROXY_REGWAIT)

root@kitploit:~
CreateEvent() → RegisterWaitForSingleObject(
    event,
    callback = LoadLibraryA,
    context = "amsi.dll"
) → SetEvent() → UnregisterWait()

AMSI एवेज़न विवरण

मेमोरी पैचिंग (AMSI_PATCH)

root@kitploit:~
Before Patch:                    After Patch:
AmsiScanBuffer:                  AmsiScanBuffer:
  4C 8B DC     mov r11, rsp        48 31 C0     xor rax, rax
  49 89 5B 08  mov [r11+8], rbx    C3           ret
  ...                              ...

Result: All scans return S_OK (clean)

विधि:

  1. मूल 4 बाइट्स सहेजें
  2. मेमोरी सुरक्षा को RW में बदलें
  3. xor rax, rax; ret लिखें
  4. मेमोरी सुरक्षा पुनर्स्थापित करें
  5. सफाई के समय मूल बाइट्स पुनर्स्थापित करें

हार्डवेयर ब्रेकपॉइंट (AMSI_HWBP)

root@kitploit:~
Setup:
    1. AddVectoredExceptionHandler
    2. RtlCaptureContext
    3. Set DR0 = AmsiScanBuffer address
    4. Enable DR7 breakpoint flag
    5. NtContinue (apply context)

Execution Flow:
    AmsiScanBuffer called
        │
        ▼
    #BP Exception (EXCEPTION_SINGLE_STEP)
        │
        ▼
    VEH Handler intercepts
        │
        ├─ Verify RIP == AmsiScanBuffer
        ├─ Set RIP = FindRetInstruction(AmsiScanBuffer)
        ├─ Set RAX = 0 (S_OK)
        └─ Set TF (Trap Flag)
        │
        ▼
    Return with RAX=0

ETW एवेज़न विवरण

NtTraceEvent पैच करें (ETW_PATCH_NTDLL)

root@kitploit:~
Before:                          After:
NtTraceEvent:                    NtTraceEvent:
  4C 8B D1     mov r10, rcx        48 31 C0     xor rax, rax
  B8 XX XX     mov eax, syscall    C3           ret

आउटपुट कैप्चर तंत्र

root@kitploit:~
Standard Assembly (No BOF):         BOF Execute-Assembly:
    Assembly → Console.WriteLine        1. Create \\.\pipe\{name}
        │                                   │
        ▼                                   ▼
    Output lost                         2. Open pipe as file handle
                                           │
                                           ▼
                                        3. Redirect PEB handles:
                                           • StdOut → pipe
                                           • StdErr → pipe
                                           │
                                           ▼
                                        4. Execute assembly
                                           │
                                           ▼
                                        5. ReadFile(pipe)
                                           │
                                           ▼
                                        6. BeaconPrintf → Operator

एवेज़न तकनीकें

डिटेक्शन वेक्टर

ETW-TI (थ्रेट इंटेलिजेंस) कॉलबैक

मेमोरी सुरक्षा परिवर्तन:

  • NtProtectVirtualMemory कॉल्स EtwTiLogReadWriteVm के माध्यम से लॉग होते हैं
  • AMSI पैचिंग amsi.dll .text सेक्शन पर RW→RX ट्रांज़िशन बनाती है
  • ETW पैचिंग ntdll.dll .text सेक्शन पर RW→RX ट्रांज़िशन बनाती है

डिटेक्शन: लोडेड मॉड्यूल्स पर मेमोरी सुरक्षा परिवर्तन मजबूत संकेतक हैं।

कर्नेल कॉलबैक

नेम्ड पाइप निर्माण:

  • मिनीफिल्टर ड्राइवरों को दिखाई देने वाले \\.\pipe\* पाथ के साथ NtCreateFile
  • पाइप-आधारित आउटपुट रीडायरेक्शन पहचाने जाने योग्य आर्टिफैक्ट बनाता है

मॉड्यूल लोडिंग:

  • LdrLoadDll इवेंट EDR कर्नेल ड्राइवरों द्वारा लॉग किए जाते हैं
  • टाइमर क्यू / RegisterWait का दुरुपयोग व्यवहारिक डिटेक्शन ट्रिगर कर सकता है

थ्रेड कॉन्टेक्स्ट मैनिपुलेशन (HWBP विधि):

  • डीबगर की मौजूदगी के बिना हार्डवेयर ब्रेकपॉइंट का उपयोग संदिग्ध है

व्यवहारिक संकेतक

  • छिपा हुआ कंसोल निर्माण (AllocConsole + ShowWindow(SW_HIDE))
  • PEB संशोधन (StandardOutput/StandardError हैंडल बदले गए)
  • बीकन प्रोसेस में CLR लोड हुआ (नेटिव एक्ज़ीक्यूटेबल्स के लिए असामान्य)
  • कस्टम AppDomain निर्माण (गैर-डिफ़ॉल्ट डोमेन संदिग्ध)
  • डीबगर के बिना VEH हैंडलर पंजीकरण (HWBP विधि)

उपयोग

स्क्रिप्ट लोड करें

root@kitploit:~
Cobalt Strike → Script Manager → Load → BOF_ExecuteAssembly.cna

कॉन्फ़िगर करें

root@kitploit:~
Menu: Additionals postex → Execute-Assembly Config

BOF कस्टम

उदाहरण

root@kitploit:~
BOF_ExecuteAssembly --assembly /tmp/Ghostpack-CompiledBinaries/Rubeus.exe --args help

Mimikatz

root@kitploit:~
beacon> help BOF_ExecuteAssembl

सहायता

संकलन

Dockerfile के साथ:

root@kitploit:~
sudo docker build -t ubuntu-gcc-13 .
sudo docker run --rm -it -v "$PWD":/work -w /work ubuntu-gcc-13:latest make

या, यदि आपके सिस्टम पर nasm, make, और mingw-w64 (gcc-13 के साथ संगत) मौजूद हैं:

root@kitploit:~
make

आउटपुट: Bin/BOF_ExecuteAssembly.o

डिटेक्शन वेक्टर

श्रेय

  • anthemtotheego: https://github.com/anthemtotheego/InlineExecute-Assembly/tree/main
  • TheWover: https://github.com/TheWover/donut
टूल डाउनलोड करें
RegisterWaitForSingleObject कॉलबैक निष्पादन
Timerटाइमर क्यू कॉलबैक निष्पादन
तकनीकबाईपास करती है
Indirect Syscallsयूज़रलैंड API हुक (EDR/AV)
Draugr Stack Spoofingकॉल स्टैक निरीक्षण उपकरण
AMSI Patch/HWBP.NET असेम्बली स्कैनिंग
ETW Patchingइवेंट-आधारित मॉनिटरिंग
Proxy DLL LoadingLoadLibrary स्टैकफ्रेम मॉनिटरिंग
Named Pipe Malleableपाइप मॉनिटरिंग
Custom AppDomainडिफ़ॉल्ट AppDomain मॉनिटरिंग