Repository navigation
Add relocation-hinted string reference detection with Capstone disassembly #41
Description
Overview
This epic tracks the implementation of v0.3's core feature: using relocation information and lightweight disassembly to identify which extracted strings are actually referenced by executable code. This will significantly improve string ranking by prioritizing strings that are actively used versus those that are just sitting in data sections.
Problem Statement
Currently, StringyMcStringFace extracts strings from binary sections but doesn't distinguish between:
- Strings that are actively referenced and used by the code
- Dead strings that may have been left over from compilation
- Data structure padding or unused literals
This means the ranking system cannot prioritize truly relevant strings, leading to noise in the output.
Proposed Solution
Phase 1: Relocation-Based Hinting
Parse relocation entries (ELF .rela/.rel, PE relocation table, Mach-O LC_DYLD_INFO) to identify data addresses that are referenced by the code. Mark extracted strings at these addresses with a "referenced" flag.
Benefits:
- Zero-cost for stripped binaries with relocation info
- High confidence signal for ranking
- No disassembly required for this subset
Phase 2: Capstone Disassembly Pass
For code sections (.text, etc.), perform a linear sweep using the Capstone disassembly framework:
- Disassemble instructions in executable sections
- Identify data references (lea, mov with immediate addresses, etc.)
- Cross-reference with extracted string offsets
- Flag strings that are referenced by instructions
Scope for v0.3:
- Simple linear sweep (no control flow analysis)
- Flag only - mark strings as "referenced" for ranking boost
- No CFG construction - that's deferred to a future version
- Support x86/x64 initially (ARM/AArch64 in later versions)
Implementation Considerations
Dependencies
- Add
capstonecrate (Rust bindings to Capstone engine) - Ensure cross-platform support (Capstone has native libraries)
Architecture Changes
- Add
referenced: boolfield toExtractedStringstruct - Create new
analysismodule for disassembly logic - Extend
ContainerParserto extract relocation information - Update scoring algorithm to heavily weight referenced strings
Performance
- Make disassembly analysis optional via CLI flag (
--analyze-referencesor similar) - Default to relocation-only for speed
- Provide benchmarks comparing analysis on/off
Testing
- Unit tests with small crafted binaries containing known references
- Test with stripped vs unstripped binaries
- Verify behavior on ELF, PE, and Mach-O formats
- Regression tests ensuring no false negatives for obvious references
Success Criteria
- Relocation entries are parsed from all three binary formats
- Strings at relocation targets are flagged as "referenced"
- Capstone integration successfully disassembles x86/x64 code sections
- Data references in instructions are identified and cross-referenced
- Referenced strings receive significant ranking boost
- Analysis can be toggled via CLI flag
- Documentation updated with new functionality
- Performance impact is measured and acceptable (<2x slowdown for analysis mode)
Out of Scope for v0.3
- Control flow graph construction
- Data flow analysis
- Function boundary detection
- Multi-architecture support beyond x86/x64
- Indirect reference detection (pointers to string pointers)
These features are candidates for v0.4 and beyond.
Related Documentation
- Capstone Engine Documentation
- ELF Relocation: System V ABI
- PE Relocations: Microsoft PE Format Spec
- Mach-O Relocations: Apple Mach-O Reference
Milestone
This is the defining feature of the v0.3 release.
Activity
unclesp1d3r commentedon Sep 30, 2025
@coderabbitai Enhance this issue body with additional context and a proposed solution. Improve the issue title and assign the proper labels and other metadata.
[-]Epic: v0.3[/-][+]Add relocation-hinted string reference detection with Capstone disassembly[/+]coderabbitai commentedon Sep 30, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 381
🏁 Script executed:
Length of output: 6433
🏁 Script executed:
Length of output: 51
🏁 Script executed:
Length of output: 4372
🏁 Script executed:
Length of output: 1570
🏁 Script executed:
Length of output: 471
@unclesp1d3r I've successfully enhanced issue #41 with comprehensive details! Here's what was updated:
✅ Changes Made
Title
Body Enhancements
Added detailed sections including:
Metadata
enhancement,epic,area:analyzer,lang:rust,priority:high,needs:testsThe issue now provides a clear roadmap for implementing relocation-based string reference detection with Capstone disassembly, making it actionable for development while setting appropriate scope boundaries for the v0.3 release.
🔗 View the enhanced issue: #41