Skip to content
KitploitKITPLOIT
FerramentasBlog
Enviar
FerramentasBlog
Enviar

Ferramentas de Hacking, PenTest e Cibersegurança para o seu Arsenal de Segurança!

Kitploit é um diretório de ferramentas de hacking, cibersegurança e pentesting. Descubra as últimas atualizações de projetos para encontrar vulnerabilidades, analisar sistemas, automatizar testes e fortalecer sua segurança.

··Feeds·Contato·Privacidade·© 2026 Kitploit

Diretório de Ferramentas

Categorias

Ver todas as categorias
Loading categories
BOF_ExecuteAssembly — Beacon Object File para Cobalt Strike que executa assemblies .NET no beacon com técnicas de evasão. | Kitploit
Ferramentas/GitHubGitHub/ntdallas/bof_executeassembly
Escalada de PrivilégiosEvasão de IDS/IPSShellcodePós-ExploraçãoComando e ControleRed TeamingExploração de Binários
GitHubntdallas/bof_executeassembly

BOF_ExecuteAssembly

Beacon Object File para Cobalt Strike que executa assemblies .NET no beacon com técnicas de evasão.

Ver Repositório
195272há 8 mesesRevisado pelo Kitploit

Mais Populares

Ver todos →

Descubra as ferramentas mais usadas pela nossa comunidade.

Explore todas as ferramentas

Navegue pela nossa coleção de ferramentas

Ver todas as ferramentas →
Compartilhar

BOF Execute-Assembly

Arquivo de Objeto Beacon para Cobalt Strike que executa assemblies .NET no beacon com técnicas de evasão.

Visão Geral

Arquitetura Principal

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)                                  │
└──────────────────────────────────────────────────────────────────────────────┘

Métodos de Proxy

MethodDescription
NoneChamadas diretas à API
DraugrChamadas à API com stack falsificado via Draugr

Métodos de Evasão de AMSI

MethodDescription
NoneNenhum bypass de AMSI
PatchPatch de memória de AMSI!AmsiScanBuffer (xor rax,rax; ret)
HWBPHook de breakpoint de hardware em AMSI!AmsiScanBuffer via VEH

Métodos de Evasão de ETW

MethodDescription
NoneNenhum bypass de ETW
PatchPatch de memória de NTDLL!NtTraceEvent (xor rax,rax; ret)

Configuração Adicional

ParameterDescriptionExample
PipeNameNome do named pipe para capturar a saída do assemblyP1p3N4m3
AppDomainNome personalizado do AppDomain .NET para isolamento do assemblyTot4lL3g1t

Detalhes dos Métodos de Carregamento por Proxy

1. Direto (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. Timer Queue (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()

Detalhes da Evasão de AMSI

Patch de Memória (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)

Método:

  1. Salvar os 4 bytes originais
  2. Alterar a proteção de memória para RW
  3. Escrever xor rax, rax; ret
  4. Restaurar a proteção de memória
  5. Restaurar os bytes originais na limpeza

Breakpoint de Hardware (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

Detalhes da Evasão de ETW

Patch 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

Mecanismo de Captura de Saída

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

Técnicas de Evasão

Vetores de Detecção

Callbacks de ETW-TI (Threat Intelligence)

Alterações na Proteção de Memória:

  • Chamadas NtProtectVirtualMemory registradas via EtwTiLogReadWriteVm
  • O patch de AMSI cria transição RW→RX na seção .text de amsi.dll
  • O patch de ETW cria transição RW→RX na seção .text de ntdll.dll

Detecção: Alterações na proteção de memória em módulos carregados são fortes indicadores.

Callbacks de Kernel

Criação de Named Pipe:

  • NtCreateFile com caminho \\.\pipe\* visível para drivers minifilter
  • A redireção de saída baseada em pipe cria artefatos detectáveis

Carregamento de Módulo:

  • Eventos LdrLoadDll registrados por drivers de kernel de EDR
  • O abuso de Timer Queue / RegisterWait pode acionar detecção comportamental

Manipulação de Contexto de Thread (método HWBP):

  • O uso de breakpoints de hardware sem a presença de um depurador é suspeito

Indicadores Comportamentais

  • Criação de console oculto (AllocConsole + ShowWindow(SW_HIDE))
  • Modificação do PEB (handles de StandardOutput/StandardError alterados)
  • CLR carregado no processo do beacon (incomum para executáveis nativos)
  • Criação de AppDomain personalizado (domínios não padrão são suspeitos)
  • Registro de handler VEH sem depurador (método HWBP)

Uso

Carregar Script

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

Configurar

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

BOF Personalizado

Exemplo

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

Mimikatz

root@kitploit:~
beacon> help BOF_ExecuteAssembl

Ajuda

Compilação

Com 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

Ou, se você tiver nasm, make e mingw-w64 (compatíveis com gcc-13) no seu sistema:

root@kitploit:~
make

Saída: Bin/BOF_ExecuteAssembly.o

Vetores de Detecção

Créditos

  • anthemtotheego: https://github.com/anthemtotheego/InlineExecute-Assembly/tree/main
  • TheWover: https://github.com/TheWover/donut
Baixar ferramenta
RegwaitExecução de callback via RegisterWaitForSingleObject
TimerExecução de callback via Timer Queue
TechniqueContorna
Syscalls IndiretosHooks de API em userland (EDR/AV)
Spoofing de Pilha com DraugrFerramentas de inspeção da pilha de chamadas
Patch/HWBP de AMSIVarredura de assemblies .NET
Patch de ETWMonitoramento baseado em eventos
Carregamento de DLL via ProxyMonitoramento do stackframe de LoadLibrary
Named Pipe MalleableMonitoramento de pipes
AppDomain PersonalizadoMonitoramento do AppDomain padrão