AI-assisted development tracking for the ROP Tools Suite.
-
NO GIT OPERATIONS: Never execute git commands (add, commit, push, etc.)
- Only print summaries of changes when requested
- User handles all version control operations
-
DOCUMENTATION REQUIREMENTS: Always update when making major changes:
README.md- User-facing documentationCLAUDE.md- Development notes and technical details- Tool-specific docs in respective directories
-
CONSISTENCY: Follow existing patterns, naming conventions, code style
- Language: Python 3.8+
- Dependencies:
rich(terminal formatting),pefile(PE parsing) - Testing:
unittest(stdlib) - Linting: flake8, black, isort, mypy (config in root
.flake8/pyproject.toml)
# Gadget analyzer (requires ROPgadget output file)
./rop/get_rop_gadgets.py <gadget_file> [options]
# PE base address extractor (requires PE file)
./rop/get_base_address.py <pe_file> [options]
# Interactive ROP worksheet
./rop/rop_worksheet.py# All rop tests
python3 -m unittest discover -s rop/tests
# Specific test file
python3 -m unittest rop/tests/test_operations_asm.py
# Shared lib tests
python3 -m unittest discover -s lib/testsflake8 rop/ lib/
black --check rop/ lib/
isort --check-only rop/ lib/rop_tools/
├── lib/ # Shared across all tools
│ └── color_printer.py # Terminal color abstraction
└── rop/
├── get_rop_gadgets.py # Gadget analyzer (~350 lines)
├── get_base_address.py # PE base address extractor
├── rop_worksheet.py # Interactive ROP builder
├── core/ # Business logic (no terminal deps)
│ ├── gadget.py # Gadget dataclass + analysis
│ ├── parser.py # ROPGadgetParser
│ ├── categories.py # GadgetCategory enum
│ └── pe_info.py # PEAnalyzer, PEInfo, PESection
└── display/ # Output formatting
└── formatters.py # Uses lib/color_printer
Benefits: Separation of concerns, testable modules, shared ColorPrinter, library independence
- Added
--generate-completion {bash,zsh}to bothget_rop_gadgets.pyandget_base_address.py - Extracted
target_builder/src/completions.pyinto sharedlib/completions.pywith parameterized tool names.target_builder/src/completions.pyis now a thin wrapper delegating to the shared module. lib/completions.pyprovides:generate_completion(shell, parser, tool_names),handle_completion(argv, parser_builder, tool_names)for early-exit beforeparse_args(), and_extract_flags(parser)for argparse introspection.- Refactored
get_base_address.pyto extract_build_parser()from inline parser construction inmain(). - 522 rop tests (was 501), 65 lib tests (was 40)
--iatnow shows a DEP Bypass Candidates section after the full IAT- Scans for 8 DEP bypass APIs: VirtualProtect, VirtualAlloc, WriteProcessMemory, HeapCreate, SetProcessDEPPolicy, NtAllocateVirtualMemory, VirtualProtectEx, NtProtectVirtualMemory
- Shows API, DLL, IAT address, bypass technique, and argument reference
- Only shown when matching APIs are found and not filtering by
--dll
nextcommand (aliases:n): Pops EIP from the stack — equivalent topop EIP. Simulates stepping to the next gadget in the ROP chain. If auto-gadget is enabled, the gadget at the new EIP is automatically executed.- Ctrl+N keybinding: Triggers
nextwithout typing. Works on both GNU readline and macOS libedit. - Added to tab completion, full help text, and compact help bar.
- Phase 1 — Sub-register support: AL/AH/AX, BL/BH/BX, CL/CH/CX, DL/DH/DX, SI, DI, BP, SP. Read via masking, write via merge into parent 32-bit register. Gadgets with sub-register operands are now auto-executed instead of skipped.
- Phase 2 — Bitwise/shift ops:
and,or,shl,shr,ror,rol - Phase 3 — Bitwise complement:
not - Phase 4 — Zero-operand:
cdq(sign-extend EAX→EDX),lodsd(EAX=[ESI]; ESI+=4),stosd([EDI]=EAX; EDI+=4),nop - Phase 5 — Data movement:
movzx(zero-extend),movsxd(sign-extend) - Phase 6 — LEA:
lea dst, [reg+reg*scale+offset]with full bracket expression parser supporting all x86 addressing modes - Refactored dispatch table, added zero-operand dispatch category in REPL
- Added
sub dst, srcoperation - Refactored
_execute_instruction()from if/elif chain to dispatch table lookup - Refactored
cmd_moveand arithmetic ops to use shared_write_to_targethelper
- Auto-filters 44 harmful instructions (privileged, I/O, control flow, interrupts)
--keep-bad-instructionsflag to disable filtering- Filtered: clts, hlt, mov cr/dr, in/out, cli/sti, call, jmp, conditional jumps, etc.
--iatflag shows Import Address Table--dll <name>filters by specific DLL- Displays: function names, RVAs, absolute addresses
- Grouped by DLL for organized output
- Created
core/pe_info.pymodule (PESection, PEInfo, PEAnalyzer) - Rewrote with argparse + ColorPrinter
- Added verbose (
-v), quiet (-q),--no-colormodes
- 18 Gadget Categories: Stack (pivot/pop/push), register (load/move/xchg), memory (read/write), arithmetic, logic, control flow, syscall, string ops
- Auto Encoding Detection: UTF-8/UTF-16 with BOM detection
- Register Analysis: Affected vs modified registers (32/64/16/8-bit)
- Multi-level Grouping: By instruction/category/register, category→register drill-down
- Instruction (
-i), category (-c), register (--register), dereferenced (--deref) - Regex (
-r) with highlighting (--highlight), exclusion (-e), bad chars (-b) - Max instruction count (
-m)
- Instruction/category display, smart sorting (count/address)
- Offset calculation (
--offset), colored output with--no-colorfallback - Statistics: totals, top 10 instructions, category distribution
- Register Tracking: All x86 32-bit regs (EAX-ESP, EIP) plus 8/16-bit sub-registers (AL/AH/AX, etc.), named value matching
- Stack Management: ESP-relative offsets, absolute addresses, register-based addressing
- ASM Operations: mov, add, sub, xor, xchg, and, or, shl, shr, ror, rol, inc, dec, neg, not, cdq, lodsd, stosd, nop, movzx, movsxd, lea, push/pop, next (pop EIP shortcut, Ctrl+N keybind) (auto ESP tracking)
- WinDbg Integration:
importregs,importstack(multi-line paste) - ROP Chains: Add gadgets, delete entries, visual display
- Workflow: Save/load JSON, command history, tab completion
- Fixed push/pop to use ESP-relative offsets
- Fixed value resolution in
stack/setcommands - Added EIP tracking (previously missing)
- Added
xchg, stack address column, named value matching
from core import ROPGadgetParser, GadgetCategory
parser = ROPGadgetParser(gadget_file)
gadgets = parser.parse()
filtered = parser.filter_by_instruction("pop", gadgets)
filtered = parser.filter_by_category(GadgetCategory.STACK_POP, gadgets)
grouped = parser.group_by_register(gadgets)from core import PEAnalyzer
base = PEAnalyzer.get_base_address("kernel32.dll")
pe_info = PEAnalyzer.analyze_file("kernel32.dll")
print(f"ImageBase: 0x{pe_info.image_base:x}")from lib.color_printer import ColorPrinter
printer = ColorPrinter()
printer.print_header("Header", "bold green")
printer.print_labeled("Label", "Value", label_style="cyan")
printer.disable() # No colors- Secondary sorting, gadget complexity scoring
- JSON/CSV export, interactive re-filtering
- Auto-suggest gadget chains
- 64-bit support (RSI, RDI, R8-R15)
- Export to Python exploit code
- Chain simulation, constraint checking, disassembly
- Runtime base detection, import/export tables
- Security features display (ASLR, DEP, CFG)
- Unit Tests: Core modules independently (parser, categorizer)
- Integration Tests: CLI with various command combinations
- Edge Cases: Empty/large files, invalid input, encoding issues
- Cross-platform: Windows, Linux, macOS
- core/: Business logic (no terminal deps, testable, importable)
- display/: Output formatting (uses lib/color_printer)
- lib/: Shared across all pentest tools (color_printer)
Authorized defensive purposes only:
- Understanding ROP attack techniques
- Analyzing binaries and malware
- Developing exploit mitigations
- Security research and education
- Writing detection rules
Maintained alongside codebase to track AI-assisted development.
