Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
shadow — jemalloc 힙 익스플로잇 프레임워크 | Kitploit
도구/GitHubGitHub/census/shadow
Memory ForensicsExploitationReverse EngineeringDebuggersBinary Exploitation
GitHubcensus/shadow

shadow

jemalloc 힙 익스플로잇 프레임워크

저장소 보기
469714년 전Kitploit 검토 완료

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

shadow :: De Mysteriis Dom jemalloc

shadow는 jemalloc 힙 익스플로잇 프레임워크입니다. jemalloc을 힙 할당자로 사용하는 대상 애플리케이션(Android의 libc, Firefox, FreeBSD의 libc, 독립형 jemalloc 등)에 대해 독립적이도록 설계되었습니다. 현재 버전(2.0)은 다음 대상에서 광범위하게 테스트되었습니다:

  • Android 6-9 libc (ARM32 및 ARM64)
  • Firefox (x86 및 x86-64) (Windows 및 Linux)

이 저장소에는 도구의 소스 코드 외에도 shadow를 활용하기 위한 Android 사용자 영역 디버깅 환경 설정에 대한 문서, shadow를 사용한 Android의 jemalloc 구조에 대한 빠른 개요, 그리고 Android의 jemalloc에서 double, unaligned, arbitrary free() 버그가 어떻게 동작하는지에 대한 몇 가지 참고 사항이 포함되어 있습니다.

사용법

처음으로 jemalloc 특정 명령을 실행하면 shadow는 알고 있는 모든 jemalloc 메타데이터를 구문 분석하여 Python pickle 파일에 저장합니다. 이후 명령은 더 빠르게 실행하기 위해 메모리에서 메타데이터를 다시 구문 분석하는 대신 이 pickle 파일을 사용합니다.

jemalloc 메타데이터의 상태가 변경되었음을 알게 되면(예: 할당을 수행했거나 가비지 컬렉션을 트리거한 경우) jeparse 명령을 사용하여 메타데이터를 다시 구문 분석하고 pickle 파일을 다시 만듭니다.

Android 설치

첫 번째 단계는 호스트 머신에 pyrsistence를 설치하는 것입니다.

루팅된 기기에서 다음을 수행합니다:

root@kitploit:~
host$ adb shell
phone$ su root
phone# ps -e

ps 출력에서 프로세스를 선택합니다(예: com.google.process.gapps):

root@kitploit:~
...
u0_a19    4679  3214  1668980 69216 SyS_epoll_ 7fa5f41430 S com.google.process.gapps
...
phone$ cd /data/local/tmp
phone$ ./gdbserver64 :5039 --attach 4679

GDB 서버 바이너리는 "bin" 디렉토리에서 ARM32 및 ARM64용으로 찾을 수 있습니다. 또는 신뢰하지 않는다면 다음을 수행합니다:

root@kitploit:~
host$ git clone http://android.googlesource.com/toolchain/gdb
host$ cd ./gdb/gdb-7.11
host$ mkdir build64; cd build64
host$ ../configure --program-prefix=aarch64-eabi-linux- --target=aarch64-eabi-linux --disable-werror
host$ make
host$ sudo make install

그런 다음 호스트 머신에서 다음을 수행합니다:

root@kitploit:~
host$ adb forward tcp:5039 tcp:5039
host$ aarch64-eabi-linux-gdb
(gdb) target remote :5039
(gdb) source /dir/with/shadow/gdb_driver.py
(gdb) jeparse -c /dir/with/shadow/cfg/android7_64.cfg
(gdb) jeruns -c

때때로 GDB 서버가 target remote :5039 명령을 너무 오래 기다리면 수신을 중단합니다. 따라서 jeparse 명령을 실행할 때 이상한 오류가 발생하면 처음부터 다시 시작하세요.

Windows/Firefox 설치

Windows/Firefox용 shadow는 다음에서 테스트되었습니다:

  • Windows 8.1 및 10 x86-64
  • Windows 7 SP1 x86 및 x86-64
  • 다양한 WinDBG 버전
  • pykd 버전 0.3.2.8
  • 다양한 Firefox 릴리스(x86-64 및 x86 모두)(최신 안정 버전(55.0) 포함)

참고: 36.0보다 오래된 Firefox 버전을 사용하는 경우 mozjs 브랜치를 사용하세요!

먼저 WinDBG를 Mozilla의 심볼 서버로 설정해야 합니다. 또한 pykd를 설치해야 합니다. 그런 다음 GitHub에서 클론한 shadow 디렉토리를 일부 경로(예: C:\tmp\)에 복사합니다.

"windbg-init.cmd" 파일에서 예제 WinDBG 초기화 스크립트를 찾을 수 있습니다. *C:\tmp\*에 배치하고 *windbg.exe -c "$$>< C:\tmp\windbg-init.cmd"*로 WinDBG를 시작합니다.

마지막으로 WinDBG 내에서 다음 명령을 실행합니다:

root@kitploit:~
!load pykd.pyd
!py c:\\tmp\\shadow\\pykd_driver help

[shadow] De Mysteriis Dom jemalloc
[shadow] shadow v2.0
[shadow] Firefox v56.0a1 (x86-64)

[shadow] jemalloc-specific commands:
[shadow]   jechunks                : dump info on all available chunks
[shadow]   jearenas                : dump info on jemalloc arenas
[shadow]   jerun [-m] <address>    : dump info on a single run
[shadow]                                 -m : map content preview to metadata
[shadow]   jeruns [-cs]            : dump info on jemalloc runs
[shadow]                                 -c : current runs only
[shadow]                    -s <size class> : runs for the given size class only
[shadow]   jebins                  : dump info on jemalloc bins
[shadow]   jebininfo               : dump info on bin sizes 
[shadow]   jesize2bin              : convert size to bin index
[shadow]   jeregions <size class>  : dump all runs that host the regions of
[shadow]                             the given size class
[shadow]   jesearch [-cs] <hex>    : search the heap for the given hex dword
[shadow]                                 -c : current runs only
[shadow]                    -s <size class> : regions of the given size only
[shadow]   jeinfo <address>        : display all available details for an address
[shadow]   jedump [path]           : store the heap snapshot to the current
[shadow]                             working directory or to the specified path
[shadow]   jestore [path]          : jedump alias
[shadow]   jetcaches               : dump info on all tcaches
[shadow]   jetcache [-bs] <tid>    : dump info on single tcache
[shadow]                    -b <bin index>  : info for the given bin index only
[shadow]                    -s <size class> : info for the given size class only
[shadow]   jeparse [-crv]           : parse jemalloc structures from memory
[shadow]                   -c <config file> : jemalloc target config file
[shadow]                                 -r : read content preview
[shadow]                                 -v : produce debug.log
[shadow] Firefox-specific (pykd only) commands:
[shadow]   nursery                 : display info on the SpiderMonkey GC nursery
[shadow]   symbol [-vjdx] <size>   : display all Firefox symbols of the given size
[shadow]                                 -v : only class symbols with vtable
[shadow]                                 -j : only symbols from SpiderMonkey
[shadow]                                 -d : only DOM symbols
[shadow]                                 -x : only non-SpiderMonkey symbols
[shadow]   pa <address> [<length>] : modify the ArrayObject's length (default new length 0x666)
[shadow] Android-specific commands:
[shadow]   jefreecheck [-bm]                : display addresses that can be passed to free()
[shadow]                     -b <bin index> : display addresses that will be freed to
[shadow]                                      the tcache bin of <bin index>
[shadow]                          -m <name> : only search this specific module
[shadow] Generic commands:
[shadow]   jeversion               : output version number
[shadow]   jehelp                  : this help message

위의 도움말 메시지가 표시되지 않으면 뭔가 잘못한 것입니다 ;)

심볼 지원

참고: 이 기능은 현재 Firefox/Windows 전용입니다!

symbol 명령을 사용하면 특정 크기의 SpiderMonkey 및 DOM 클래스(및 구조체)를 검색할 수 있습니다. 이는 use-after-free 버그를 익스플로잇하려고 하거나 덮어쓰기/변조할 흥미로운 피해 객체를 배치하려는 경우 유용합니다.

shadow의 메인 디렉토리에는 symhex.py와 pdbdy.py(더 빠름)라는 두 개의 작은 PDB 파싱 유틸리티가 있습니다. 이를 "xul.pdb"에 실행하여 shadow가 "pdb" 디렉토리에서 예상하는 Python pickle 파일("pdb/xul-VERSION.pdb.pkl")을 생성합니다. 실행하기 전에 "msdia90.dll"이 등록되었는지 확인하십시오. 예를 들어 Windows 8.1 x86-64에서는 관리자 프롬프트에서 다음을 수행할 수 있습니다:

regsvr32 "c:\Program Files (x86)\Common Files\Microsoft Shared\VC\msdia90.dll"

또한 "comtypes" Python 모듈이 필요합니다. pip를 설치한 다음 pip install comtypes를 실행합니다.

"xul.pdb"를 얻으려면 WinDBG를 Mozilla의 심볼 서버로 설정해야 합니다.

설계

unmask_jemalloc는 처음에 세 가지 주요 디버거 및 플랫폼(WinDBG, GDB 및 LLDB)을 지원하기 위해 모듈식 설계로 재설계되었습니다. Firefox/Windows/WinDBG 전용 기능이 추가되었을 때 도구 이름이 shadow로 변경되었습니다.

다음은 새로운 설계의 개요입니다(화살표는 "임포트"로 읽음). 목표는 분명히 모든 디버거 종속 코드를 *_driver 및 *_engine 모듈에 두는 것입니다.

root@kitploit:~
---------------------------------------------------------------------------------------

                                                    debugger-required frontend (glue)


+------------+     +-------------+     +-------------+
| gdb_driver |     | lldb_driver |     | pykd_driver |
+------------+     +-------------+     +-------------+
      ^                   ^                   ^
      |                   |                   |
------+-------------------+-------------------+----------------------------------------
      |                   |                   |   
      |                   +--------+          |
      +------------------------    |    +-----+        core logic (debugger-agnostic)
                              |    |    |
                              |    |    |
                           +-----------------+
  +------+                 |                 |
  |      |---------------> |      shadow     |<-----+
  | util |        +------> |                 |      |
  |      |        |        +-----------------+      |
  +------+        |          ^  ^     ^    ^        |
    | | |         |          |  |     |    |        |   +--------+
    | | |   +-----+----------+  |     +----+--------+---| symbol |
    | | |   |     |             |          |        |   +--------+
  +-+ | |   |  +----------+     |          |        |   +---------+
  |   | |   |  | jemalloc |     |          +--------+---| nursery |
  |   | |   |  +----------+     |                   |   +---------+
  |   | |   |   ^    ^   ^      |                   |
  |   | |   |   |    |   |      |                   |
  |   | |   |   |    |   +------+--------+          |
  |   | |   |   |    |          |        |          |
  |   | +---+---+----+----------+--------+-----+    |
  |   |     |   |    |          |        |     |    |
  |   +-----+---+----+----+     |        |     |    |
  |         |   |    |    |     |        |     |    |
--+---------+---+----+----+-----+--------+-----+----+----------------------------------
  |         |   |    |    |     |        |     |    |
  |         |   |    |    |     |        |     |    |       debugger-dependent APIs
  |         |   |    |    |     |        |     |    |
  |         |   |    |    |     |        |     |    |
  |         |   |    |    v     |        |     v    |
  |  +------------+  |  +-------------+  |  +-------------+
  +->| gdb_engine |  +--| lldb_engine |  +--| pykd_engine |
     +------------+     +-------------+     +-------------+
           ^                   ^                   ^
           |                   |                   |
       +---+         +---------+   +---------------+
       |             |             |
       |             |             |
-------+-------------+-------------+---------------------------------------------------
       |             |             |
       |             |             |                        debugger-provided backend
       |             |             |
       |             |             |
    +-----+      +------+      +------+
    | gdb |      | lldb |      | pykd |
    +-----+      +------+      +------+

---------------------------------------------------------------------------------------
도구 다운로드