Community코딩 & 개발github.com

yaklang/arbitrary-write-to-rce

임의 쓰기를 RCE로 전환하는 플레이북. 힙 익스플로잇, 포맷 스트링, OOB 쓰기 등으로 임의 쓰기 원시를 얻었을 때 GOT, 훅, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, C++ vtable을 공략하여 코드 실행으로 변환합니다.

arbitrary-write-to-rce란 무엇인가요?

이 스킬은 보안 연구자와 익스플로잇 개발자가 임의 쓰기 원시 공격을 코드 실행(RCE)으로 전환하는 방법을 제공하는 플레이북입니다. 힙 오버플로, 포맷 스트링 취약점, 또는 경계를 벗어난 쓰기(OOB)를 통해 획득한 임의 쓰기 능력을 활용하여 GOT, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, C++ vtable과 같은 메모리 구조체를 덮어씁니다. 다양한 GCC 컴파일 버전, ASLR, PIE, RELRO, Stack Canary, SELinux 등 보호 기법을 고려한 전략을 설명하며, 특히 현대 리눅스 바이너리(우분투 24.04, glibc 2.39)에서도 유효한 기법을 중점적으로 다룹니다. 플랫폼 의존성 없이 일반적인 C/ELF 바이너리 환경에서 사용할 수 있으며, 각 타겟 구조체의 특징과 우회 방법을 단계별로 제시합니다. 코드 예제와 CLI 명령어 등을 포함하여 실전에서 바로 적용할 수 있도록 구성되어 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yaklang/hack-skills/tree/main/skills/arbitrary-write-to-rce

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

arbitrary-write-to-rce은(는) 무엇을 하나요?

임의 쓰기(Arbitrary Write)를 RCE(원격 코드 실행)로 전환하는 플레이북입니다. 힙 익스플로잇, 포맷 스트링, 또는 OOB(Out-of-Bounds) 쓰기를 통해 임의 쓰기 원시(Primitive)를 확보한 상태에서, 이를 GOT(Global Offset Table), 훅(Hooks), _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, 또는 C++ vtable을 공략하여 코드 실행으로 변환해야 할 때 사용합니다.

지원 환경

  • 아키텍처: x86-64, ARM64 (aarch64) 지원.
  • 보호 기법: 각 기법은 다양한 GCC 버전 및 보호 설정(ASLR, PIE, RELRO, Stack Canary, FORTIFY, SELinux)을 고려합니다.
  • glibc 버전: 다양한 glibc 버전 (예: 2.31, 2.35, 2.39)에서 작동하도록 설계되었습니다. 최신 우분투 24.04 (glibc 2.39) 환경에 특히 중점을 둡니다.

플레이북 개요

  1. 타겟 선택: 다음 타겟 구조체 중 하나를 선택합니다.

    • __free_hook, __malloc_hook (glibc < 2.34)
    • _IO_FILE vtable
    • exit_funcs (__exit_funcs)
    • TLS_dtor_list
    • modprobe_path
    • .fini_array
    • C++ vtable
    • GOT 엔트리
  2. 방법 적용: 각 타겟에 대해 구체적인 덮어쓰기 전략을 따릅니다.

    • __free_hook 덮어쓰기: system 또는 원 셸(one-gadget) 주소로 덮어씁니다. (glibc 2.34부터 제거됨)
    • _IO_FILE vtable 변조: 파일 스트림 구조체를 조작하여 _IO_OVERFLOW나 _IO_FINISH와 같은 vtable 함수 포인터를 가리킵니다.
    • exit_funcs 변조: __exit_funcs 리스트에 등록된 함수 포인터를 덮어씁니다. (ASLR 우회 가능)
    • TLS_dtor_list 변조: TLS(Thread-Local Storage) 영역의 dtor_list를 조작합니다.
    • modprobe_path 변조: modprobe_path를 악성 스크립트 경로로 덮어쓰고, 알 수 없는 바이너리 실행을 트리거합니다.
    • .fini_array 변조: .fini_array 섹션의 종료 핸들러를 덮어씁니다.
    • C++ vtable 변조: 가상 함수 테이블 포인터를 조작하여 공격자가 제어하는 함수를 실행합니다.
    • GOT 덮어쓰기: 외부 라이브러리 함수의 GOT 엔트리를 덮어씁니다. (Partial RELRO 필요)
  3. 우회 기법: PIE, Full RELRO, ASLR, Stack Canary, FORTIFY, SELinux 등 보호 기법을 우회하기 위한 전략을 포함합니다.

사용 예

# 예시: __free_hook 덮어쓰기 (glibc <= 2.33)
payload = p64(libc.symbols['__free_hook'])
payload += p64(libc.symbols['system'])
write(overwrite_addr, payload)  # 임의 쓰기 함수
# 예시: _IO_FILE vtable 변조 (glibc >= 2.24)
io_file = FileStructure()
io_file._flags = 0
io_file._IO_write_ptr = 1
io_file._IO_write_end = 0
# ... 추가 필드 설정
payload = bytes(io_file)
write(io_address, payload)

주의사항

  • 모든 기법이 모든 glibc 버전, 모든 보호 설정 조합에서 동작하는 것은 아닙니다. 실험 환경에서 먼저 테스트하십시오.
  • 최신 glibc (2.34+)에서는 __free_hook, __malloc_hook이 제거되었습니다. _IO_FILE vtable 변조 또는 exit_funcs 변조를 고려하십시오.
  • 일부 기법은 SELinux 또는 AppArmor의 영향을 받을 수 있습니다.

참고 자료

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

yaklang/401-403-bypass-techniques

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

yaklang/active-directory-acl-abuse

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

yaklang/active-directory-certificate-services

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

yaklang/active-directory-kerberos-attacks

Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets, delegation abuse, or pass-the-ticket attacks.

yaklang/ai-ml-security

AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing, data privacy attacks (membership inference, model inversion), and autonomous agent security risks.

yaklang/android-pentesting-tricks

Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent redirection, root detection bypass, tapjacking, and backup extraction during authorized mobile security assessments.

yaklang/anti-debugging-techniques

Anti-debugging detection and bypass playbook. Use when reversing protected binaries that detect debuggers via ptrace, PEB flags, timing checks, or signal/exception handlers on Linux and Windows.

yaklang/api-auth-and-jwt-abuse

API authentication and JWT abuse playbook. Use when testing bearer tokens, API keys, claim trust, header spoofing, rate limits, and API auth boundary weaknesses.

yaklang/api-authorization-and-bola

API authorization and BOLA testing playbook. Use when APIs expose object identifiers, nested resources, hidden writable fields, or weak function-level authorization.

yaklang/api-recon-and-docs

API reconnaissance and documentation review playbook. Use when discovering endpoints, schemas, versions, OpenAPI specs, hidden docs, and surface area for API testing.

yaklang/api-sec

Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.

yaklang/authbypass-authentication-flaws

Authentication bypass testing playbook. Use when assessing login flows, password reset logic, account recovery, MFA bypass, token predictability, brute-force resistance, and session boundary flaws.

yaklang/auth-sec

Entry P1 category router for authentication and authorization. Use when testing login flows, sessions, object authorization, JWT, OAuth, CORS, CSRF, and enterprise SSO weaknesses before any deeper auth topic skill.

yaklang/binary-protection-bypass

Binary protection bypass playbook. Use when identifying and bypassing ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, CET, and MTE protections in ELF binaries to enable exploitation.

yaklang/browser-exploitation-v8

Browser and V8 exploitation playbook. Use when exploiting JavaScript engine vulnerabilities including JIT type confusion, incorrect bounds elimination, and V8 sandbox bypass to achieve renderer RCE and sandbox escape in Chrome/Chromium.

yaklang/business-logic-vuln

Entry P1 category router for business logic testing. Use when workflow abuse, race conditions, pricing flaws, or multi-step state attacks matter more than parser-level input injection.

yaklang/business-logic-vulnerabilities

Business logic vulnerability playbook. Use when reasoning about workflows, race conditions, price manipulation, coupon abuse, state machines, and multi-step authorization gaps.

yaklang/classical-cipher-analysis

Classical cipher analysis playbook. Use when encountering substitution ciphers, Vigenere, transposition, XOR, or encoded text in CTF challenges that requires frequency analysis, Kasiski examination, or known-plaintext cryptanalysis.

yaklang/clickjacking

Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.

yaklang/cmdi-command-injection

Command injection playbook. Use when user input may reach shell commands, process execution, converters, import pipelines, or blind out-of-band command sinks.

관련 스킬