Repository navigation
Description
Summary
Implement structured extraction of PE resources, specifically VERSIONINFO and STRINGTABLE data, which contain rich metadata and user-facing strings often crucial for malware analysis, software identification, and reverse engineering workflows.
Background & Context
Windows PE (Portable Executable) binaries embed structured resources in the .rsrc section containing valuable string data:
- VERSIONINFO: File metadata including ProductName, FileDescription, CompanyName, LegalCopyright, FileVersion, and ProductVersion
- STRINGTABLE: Localized UI strings, error messages, and application text
- Other resources: Dialog templates, menus, and accelerator tables (future work)
While the current implementation uses goblin for PE parsing, its resource section support is limited to raw byte access. The pelite crate provides a pure Rust PE parser with comprehensive resource parsing capabilities, making structured extraction straightforward.
Implementation Plan
Phase 1: Foundation (This Issue)
-
Add pelite dependency to
Cargo.toml- Version: Latest stable (0.10.x recommended)
- Evaluate if pelite should replace or complement goblin
-
Create resource extraction module at
src/extraction/pe_resources.rs- Define resource types enum (VersionInfo, StringTable, etc.)
- Implement resource enumeration using pelite's resource directory walker
- Add error handling for malformed resource sections
-
Extend existing types in
src/types.rs- Add
ResourceMetadatastruct for VERSIONINFO fields - Add
ResourceStringTablestruct for STRINGTABLE entries - Extend
FoundStringto include resource context
- Add
-
Integration with PE parser (
src/container/pe.rs)- Add resource section parsing to
PeParser::parse() - Populate
ContainerInfowith resource metadata - Ensure existing section classification still works
- Add resource section parsing to
Phase 2: Resource Extraction (Follow-up)
- Implement VERSIONINFO extraction with key-value pair parsing
- Implement STRINGTABLE extraction with locale handling
- Add Unicode and ANSI string decoding for resource data
- Map extracted strings to
FoundStringwithStringSource::ResourceString
Phase 3: Testing & Documentation (Follow-up)
- Unit tests with sample PE resource data
- Integration tests with real-world PE binaries
- Document resource extraction architecture
- Add examples to README
Technical Considerations
- Dual parser strategy: Consider using pelite specifically for resource extraction while keeping goblin for section/import/export parsing
- Performance: Resource parsing should be optional via CLI flag (e.g.,
--extract-resources) - Malformed binaries: Gracefully handle corrupted resource directories (common in packed/obfuscated malware)
- Memory safety: pelite operates on byte slices; ensure proper bounds checking
Success Criteria
- pelite dependency added and compiling
- Basic resource enumeration working for .rsrc section
- Framework for VERSIONINFO and STRINGTABLE extraction in place
- No regressions in existing PE parsing functionality
- Unit tests covering resource enumeration edge cases
References
- pelite documentation: https://docs.rs/pelite/
- PE resource format: https://learn.microsoft.com/en-us/windows/win32/menurc/resource-file-formats
- Existing resource section classification:
src/container/pe.rs:50(SectionType::Resources)
Related Work
- Milestone: v0.1 (MVP)
- Depends on: Existing PE parser infrastructure
- Enables: Future work on dialog/menu resource parsing, icon extraction
@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 Resource Extraction Foundation[/-][+]Add pelite dependency for PE resource extraction (VERSIONINFO, STRINGTABLE)[/+]coderabbitai commentedon Sep 30, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 1306
🏁 Script executed:
Length of output: 30820
🏁 Script executed:
Length of output: 87
@unclesp1d3r I've successfully enhanced issue #4 with the following improvements:
✅ Changes Made
Title Updated:
Enhanced Body Includes:
Metadata:
priority:mediumlabelThe issue now provides clear context for contributors about why
peliteis needed overgoblinfor resource extraction, and offers a concrete implementation roadmap that integrates with your existing architecture insrc/container/pe.rs.( o.o )
> ^ < thoughtful rabbit
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 codebase uses goblin for PE parsing with basic section classification including resources. The types module has structures for ContainerInfo, FoundString, and StringSource but lacks resource-specific metadata. The extraction module is minimal. Tests include PE integration but no resource-specific tests. Fixtures have a basic PE binary without resources. Pelite 0.10.0 provides excellent resource parsing APIs for VERSIONINFO and STRINGTABLE extraction. Dual-parser approach (goblin for structure, pelite for resources) is optimal to avoid regressions.
Approach
Focus on Phase 1 foundation: Add pelite dependency, create pe_resources extraction module with enumeration framework, extend types for resource metadata, integrate into PE parser with graceful error handling, and add basic tests. This sets up the structure for Phase 2 extraction without breaking existing functionality. Use dual-parser strategy: goblin for sections/imports/exports, pelite only for resources to minimize changes and risks.
Reasoning
Explored the repository structure using list_dir on root and src directories. Read key files like Cargo.toml, src/types.rs, src/container/pe.rs, src/extraction/mod.rs, and tests/integration_pe.rs to understand the PE parsing flow and type system. Searched for pelite documentation and examples to confirm API for resource enumeration and extraction. Verified that .rsrc sections are already classified but not parsed deeply.
Proposed File Changes
📄 Cargo.toml (MODIFY) 🔗
📄 src/types.rs (MODIFY) 🔗
📄 src/extraction/pe_resources.rs (MODIFY) 🔗
📄 src/extraction/mod.rs (MODIFY) 🔗
📄 src/container/pe.rs (MODIFY) 🔗
📄 src/lib.rs (MODIFY) 🔗
📄 tests/integration_pe.rs (MODIFY) 🔗
📄 README.md (MODIFY) 🔗
Diagram
sequenceDiagram participant App as Application participant Parser as PeParser participant Goblin as goblin::PE participant Pelite as pelite::PeFile participant Extractor as extract_pe_resources participant Info as ContainerInfo App->>Parser: parse(data) Parser->>Goblin: PE::parse(data) Goblin-->>Parser: PE structure (sections, imports, exports) Note over Parser,Pelite: Dual Parser for Resources Parser->>Pelite: PeFile::from_bytes(data) Pelite-->>Parser: PE file handle Parser->>Extractor: extract_pe_resources(&pe_file) Extractor->>Pelite: resources(), types(), names(), etc. Pelite-->>Extractor: Resource directory tree Extractor-->>Parser: Vec<ResourceMetadata> Parser->>Info: ContainerInfo { sections, imports, exports, resources } Info-->>App: Parsed info with resourcesImport 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.