How hackerl/pangolin works
Project type and purpose
• Pangolin is an open‑source, native C/C++ “ELF injector” tool.
• It provides a command‑line interface (CLI) that uses ptrace to inject an arbitrary ELF payload into a remote process (the “target”).
File structure
• Top‑level:
• CMakeLists.txt / shellcode/Makefile – build orchestrators.
• main.cpp – entry point parsing CLI args.
• inject/
• injector.cpp/.h – high‑level injection logic (parses options, drives ptrace calls).
• ptrace/
• executor.cpp/.h – abstraction for performing remote syscalls over ptrace (attach, poke, call).
• tracee.cpp/.h – helper routines that run inside the target to bootstrap shellcode execution.
• shellcode/
• alloc/entry.c – code to allocate remote memory (mmap).
• free/entry.c – code to free memory.
• c‑runtime/ – runtime support for shellcode (e.g., minimal libc).
• linker.ld – custom linker script to layout shellcode sections.
• loader/elf_loader.c/.h – in‑process ELF‐loading routine.
• loader/payload.h – placeholder for the user payload.
• loader/entry.c / quit.c/.h – entry points for loader thread and cleanup.
README for additional insights
• Built with GCC, Make, CMake.
• Usage: pangolin [options] pid inject‑path argv…
• Supports static & dynamic targets, daemon mode for long‑lived threads, environment injection.
Elements
– Host‑side vs. Target‑side
– Build‑time modules vs. Run‑time modules
– Ptrace syscalls vs. In‑process code