Chuyển đến nội dung
Skillpedia
Bảo mật10k · #11960

offensive-shellcode

Skill này làm gì

Skill này là tài liệu tham khảo để viết shellcode cấp thấp cho hệ thống x86 và x64, bao quát mã độc lập vị trí và các loader. Nó dành cho nhà nghiên cứu bảo mật và người phát triển exploit làm việc trong các dự án được ủy quyền.

Khi nào nên dùng

  • ✓Khi bạn đang nghiên cứu phát triển exploit được ủy quyền trên hệ thống x86 hoặc x64.
  • ✓Khi bạn cần hiểu mã độc lập vị trí cho một dự án nghiên cứu bảo mật.
  • ✓Khi bạn nghiên cứu cách loader và payload nhiều giai đoạn hoạt động để phân tích phòng thủ.

Liên kết skill

https://github.com/SnailSploit/Claude-Red/blob/main/Skills/infrastructure/offensive-shellcode/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/SnailSploit/Claude-Red/blob/main/Skills/infrastructure/offensive-shellcode/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Trong phòng thí nghiệm nghiên cứu bảo mật được ủy quyền của chúng tôi, hãy giải thích mã độc lập vị trí trên Windows x64.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill phác thảo quy trình từ việc xác định nền tảng mục tiêu đến viết và kiểm thử assembly độc lập vị trí trong môi trường được kiểm soát. Nó cũng bao quát các khái niệm cơ bản về xử lý bộ nhớ trên Windows.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Shellcode Development Workflow

  1. Define concept and target platform (x86/x64, Windows/Linux/macOS)
  2. Write assembly using position-independent techniques
  3. Extract binary and test in controlled environment
  4. Apply null byte avoidance and optimizations
  5. Encode/encrypt to evade static detection
  6. Package with loader and choose delivery method

Basic Concepts

Execution Pattern (Allocate-Write-Execute)

Avoid direct PAGE_EXECUTE_READWRITE — prefer:

  1. Allocate with PAGE_READWRITE
  2. Write shellcode to allocated region
  3. Call VirtualProtect to switch to PAGE_EXECUTE_READ
char *dest = VirtualAlloc(NULL, 0x1234, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
memcpy(dest, shellcode, 0x1234);
VirtualProtect(dest, 0x1234, PAGE_EXECUTE_READ, &old);
((void(*)())dest)();

Position-Independent Code (PIC) Techniques

Method Platform Notes
Call/Pop Windows Push next addr, pop into register
FPU state Windows fstenv saves instruction pointer
SEH Windows Exception handler stores EIP
GOT Linux Global Offset Table
VDSO Linux Kernel-provided shared object

Windows API Resolution (PEB Walk)

Identifying kernel32.dll without imports:

  1. Get PEB via gs:[0x60] (x64) or fs:[0x30] (x86)
  2. Walk PEB->Ldr.InMemoryOrderModuleList — order: exe → ntdll → kernel32
  3. Hash-compare module names to locate kernel32
  4. Parse the Export Address Table (EAT)
  5. Find GetProcAddress by name hash, then resolve LoadLibraryA
  6. Use LoadLibraryA to load WS2_32.dll, resolve Winsock functions

WinDbg helpers for debugging PEB walk:

dt nt!_TEB -y ProcessEnvironmentBlock @$teb
dt nt!_PEB -y Ldr <peb_addr>
dt -r _PEB_LDR_DATA <ldr_addr>
dt _LDR_DATA_TABLE_ENTRY (<init_flink_addr> - 0x10)
lm m kernel32   # verify base address
r @r8           # check register

Shellcode Loaders

Loader Responsibilities

  • Environment verification / keying (sandbox detection)
  • Shellcode decryption
  • Safe memory allocation and injection
  • Ends its duties after injecting

Recommended languages: Zig (small, no runtime), Rust (secure), Nim, Go (watch for runtime signatures)

Allocation Phase

Avoid RWX allocations — use two-step:

  • VirtualAllocEx / NtAllocateVirtualMemory — allocate RW
  • ZwCreateSection + NtMapViewOfSection — alternative approach
  • After writing: VirtualProtectEx to switch to RX

Other options: code caves, stack/heap (with DEP disabled)

Write Phase

  • WriteProcessMemory / NtWriteVirtualMemory
  • memcpy to mapped section

Evasion tips:

  • Prepend shellcode with dummy opcodes
  • Split into chunks, write in randomized order
  • Add delays between writes

Execute Phase

Most scrutinized step — EDR checks thread start address against image-backed memory:

Technique Notes
CreateRemoteThread / ZwCreateThreadEx Loud, heavily monitored
NtSetContextThread Hijack suspended thread
NtQueueApcThreadEx APC injection
API trampolines Overwrite function prologue
ThreadlessInject No new threads created

Indirect execution resources:


PE-to-Shellcode Conversion

Tool Purpose
Donut EXE/DLL → shellcode
sRDI DLL → position-independent shellcode
Pe2shc PE → shellcode
Amber Reflective PE packer

Open-source loaders:

  • ScareCrow
  • NimPackt-v1
  • NullGate — indirect syscalls + junk-write sequencing
  • DripLoader — chunked RW writes + direct syscalls + JMP trampoline
  • ProtectMyTooling — chain multiple protections
  • Direct-syscall helpers: SysWhispers3, FreshyCalls (now baseline requirements)

Shellcode Storage & Hiding

Location Risk Notes
Hardcoded in .text Medium Requires recompile; stored RW/RO
PE Resources (RCDATA) High Most sc
Câu hỏi thường gặp

Nó bao quát những nền tảng nào?

Nó bao quát Windows, Linux và macOS trên x86 và x64.

Đây có dành cho dùng trong phòng thí nghiệm không?

Skill giả định việc kiểm thử diễn ra trong môi trường được kiểm soát và có ủy quyền.

Nó có bao quát việc chuyển đổi file không?

Có. Nó cũng bao quát việc chuyển file PE thành shellcode cho nghiên cứu.

Chi tiết

Mô tả gốc của tác giả

Shellcode development reference for offensive security engagements. Use when writing custom x86/x64 shellcode, implementing position-independent code (PIC), building shellcode loaders, evading AV/EDR detection, or converting PE files to shellcode. Covers null byte avoidance, API hashing, encoder/decoder patterns, staged vs stageless payloads, Windows PEB traversal, and cross-platform shellcode techniques.

repo: SnailSploit/Claude-Red

Độ phổ biến

Sao GitHub
10k
Vị trí xếp hạng
#11960
Giấy phép
MIT
Cập nhật
12/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự