Repository navigation
Description
Summary
Enhance the PE (Portable Executable) parser to intelligently classify sections based on string likelihood and implement import/export table parsing to extract meaningful symbols and metadata from Windows executables.
Context
PE binaries structure data differently than ELF or Mach-O formats. Windows executables typically store:
- Read-only strings in
.rdata(read-only data) sections - high value for string extraction - Initialized data in
.datasections - lower priority, often contains runtime state - Import tables listing DLL dependencies and function names - valuable for understanding program behavior
- Export tables defining public API surfaces - critical for DLL analysis
Currently, StringyMcStringFace lacks PE-specific intelligence to prioritize these sections appropriately, which means:
- We treat all sections equally, missing optimization opportunities
- We don't extract import/export symbols that provide high-signal strings
- UTF-16LE strings common in PE binaries aren't prioritized correctly
- Section scoring doesn't account for PE-specific characteristics
Proposed Solution
1. Section Classification Enhancement
Implement section weight assignment based on PE characteristics:
// Proposed section scoring for PE
fn classify_pe_section(section: &PESection) -> SectionWeight {
match section.name.as_str() {
".rdata" | ".text" => SectionWeight::High, // Read-only, likely strings
".rsrc" => SectionWeight::Medium, // Resources, may contain strings
".data" => SectionWeight::Low, // Writable, runtime state
".bss" | ".reloc" => SectionWeight::VeryLow, // Unlikely to contain strings
_ => SectionWeight::Medium // Default for unknown sections
}
}2. Import/Export Table Parsing
Extract symbol names from PE import and export directories:
- Parse import directory to extract DLL names and imported function names
- Parse export directory to extract exported function names (for DLL analysis)
- Tag extracted symbols with appropriate metadata (
source: ImportTable,source: ExportTable) - Assign high scores to these strings as they represent high-confidence identifiers
3. Integration Points
- Update
PEParserincrates/stringy-analyzer/src/parsers/pe.rs - Extend
SectionInfoto include PE-specific weight heuristics - Add import/export extraction to the symbol extraction pipeline
- Ensure UTF-16LE detection prioritizes
.rdatasections
Technical Requirements
Requirement 1.2: Section classification by string likelihood
Requirement 1.4: Import/export table parsing
Dependencies
goblinPE parser capabilities- Existing
SectionWeightenum may need extension StringSourceenum needsImportTableandExportTablevariants
Performance Considerations
- Import/export parsing is typically fast (small tables)
- Section classification is O(n) where n = number of sections (usually < 10)
- No significant performance impact expected
Acceptance Criteria
- Implement section weight classification for PE-specific sections (
.rdata,.data,.rsrc,.text,.bss,.reloc) - Parse PE import directory and extract DLL names and imported function names
- Parse PE export directory and extract exported function names
- Add
ImportTableandExportTablevariants toStringSourceenum - Assign appropriate scores to import/export strings (high priority)
- Add unit tests for section classification logic
- Add integration tests using sample PE binaries (e.g., a simple DLL with exports)
-
cargo clippy -- -D warningspasses without errors - Add benchmarks with criterion for PE parsing performance
- Use insta for snapshot testing of import/export extraction results
- Update justfile recipes for PE-specific test cases
- Ensure CI pipeline passes all checks
- Document PE-specific behavior in module-level docs
Test Cases
Unit Tests
- Section weight assignment for known PE section names
- Section weight for unknown/custom section names
- Empty import/export table handling
Integration Tests
- Parse a PE binary with imports (e.g.,
kernel32.dllfunctions) - Parse a DLL with exports
- Verify UTF-16LE strings from
.rdatascore higher than.data
Snapshot Tests (insta)
- Import table extraction output
- Export table extraction output
- Section classification results
Related Work
- Builds on existing
goblinPE parser foundation - Complements ELF/Mach-O section classification (issues Implement Intelligent ELF Section Classification for Targeted String Extraction #1, Enhance ELF Dynamic Symbol Extraction with Library Mapping and Comprehensive Symbol Classification #2)
- Feeds into ranking system (Requirement 2.1)
- Enables better YARA rule generation for PE binaries
References
Task-ID: stringy-analyzer/pe-section-classification
Requirements: 1.2, 1.4
Milestone: v0.1
@traycerai branch:3-implement-pe-section-classification-and-importexport-table-parsing
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.
[-]PE Section Classification[/-][+]Implement PE Section Classification and Import/Export Table Parsing[/+]coderabbitai commentedon Sep 30, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 7747
🏁 Script executed:
Length of output: 93
@unclesp1d3r I've successfully enhanced issue #3 with comprehensive improvements:
What Was Updated
✅ Title Enhanced
Before: "PE Section Classification"
After: "Implement PE Section Classification and Import/Export Table Parsing"
✅ Body Enhanced With
Additional Context:
.rdata,.data, import/export tablesProposed Solution:
Enhanced Acceptance Criteria:
New Sections Added:
✅ Metadata
The existing labels and metadata were already well-configured:
area:analyzer,type:enhancement,status:backlog,lang:rust,needs:testsThe enhanced issue now provides clear technical direction for implementation and serves as comprehensive documentation for anyone working on PE parser enhancements. You can view the updated issue at: #3
unclesp1d3r commentedon Nov 10, 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.
coderabbitai commentedon Nov 10, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 4538
@unclesp1d3r Issue #3 has already been fully enhanced!
The issue currently has:
✅ Enhanced Title: "Implement PE Section Classification and Import/Export Table Parsing"
✅ Comprehensive Body including:
✅ Metadata properly configured:
area:analyzer,type:enhancement,status:backlog,lang:rust,needs:testsThe issue is ready for development work. Is there something specific you'd like me to modify or improve further?
unclesp1d3r commentedon Nov 10, 2025
@traycerai generate
traycerai commentedon Nov 10, 2025
Hi @unclesp1d3r, I have updated the Implementation Plan to reflect the recent changes in the ticket.
traycerai commentedon Nov 10, 2025
Plan
Observations
The PE parser in
src/container/pe.rsalready implements comprehensive section classification (.rdataas StringData weight 10.0,.rsrcResources 9.0, etc.), import extraction frompe.imports(with DLL, RVA, ordinal handling), and export extraction frompe.exports(with base ordinal calculation, forwarded exports). Unit tests cover classification and weights. Integration tests intests/integration_pe.rsverify parsing, sections, and include an insta snapshot for symbols.StringSourceusesImportName/ExportName(needs rename toImportTable/ExportTable). Missing: PE benchmarks, fixture build recipe,Cargo.tomlbench config, task update, expanded docs inbinary-formats.md.Approach
Complete PE implementation per acceptance criteria:\n\n1. Rename
ImportName/ExportNametoImportTable/ExportTableintypes.rsfor exact match.\n2. Addbenches/pe.rswith criterion benchmarks for parsing, imports, exports mirroring ELF.\n3. Add[[bench]]for PE inCargo.toml.\n4. Enhancejustfilewithbuild-fixtures-perecipe using zig/mingw fortest_binary_pe.exefromtest_binary.c.\n5. Expand PE docs indocs/src/binary-formats.mdwith weights table, import/export details.\n6. Update.kiro/specs/.../tasks.mdmarking task 4 complete.\n7. Ensure high scores for import/export strings via weights (already integrated).\n\nMaintain existing tests/docs; run clippy/CI post-changes.Reasoning
I examined the repository structure to locate key files, read
src/container/pe.rsto assess existing PE parser features including classification, weights, and symbol extraction, reviewedsrc/types.rsforStringSourcevariants, inspectedtests/integration_pe.rsfor current tests and snapshots, listed benches directory to confirm missing PE benchmarks, and checked for documentation and task files to identify completion gaps.Proposed File Changes
📄 src/types.rs (MODIFY) 🔗
📄 benches/pe.rs (MODIFY) 🔗
📄 Cargo.toml (MODIFY) 🔗
📄 justfile (MODIFY) 🔗
📄 docs/src/binary-formats.md (MODIFY) 🔗
📄 .kiro/specs/stringy-binary-analyzer/tasks.md (MODIFY) 🔗
Import In IDE
🤖 Prompt for AI Agents
Developer Humor
Execution Information
Branch: 3-implement-pe-section-classification-and-importexport-table-parsing
Commit: 5ac6f0c
💡 Tips
Supported Commands (Inside Comments)
@traycerai generateto iterate on the previous version of the implementation plan.Supported Commands (Inside Description)
@traycerai ignoreanywhere in the ticket description to prevent this ticket from being processed.@traycerai branch:<branch-name>anywhere in the ticket description to specify the target branch for the implementation plan.Community
traycerai commentedon Nov 10, 2025
I have updated the Implementation Plan to reflect the recent changes in the ticket.
traycerai commentedon Nov 10, 2025
I have updated the Implementation Plan to reflect the recent changes in the ticket.