Repository navigation
Description
Context
Windows PE (Portable Executable) binaries contain a .rsrc section with a hierarchical resource directory structure that holds rich metadata and embedded strings. These resources are currently not being extracted by Stringy, resulting in missed opportunities to identify:
- Version Information: Product names, company names, file descriptions, copyright strings
- Manifest Files: Embedded XML manifests with assembly information and dependencies
- String Tables: Localized strings stored in
STRINGTABLEresources - Dialog Boxes: Control text, window titles, and UI strings
- Menu Definitions: Menu item text and tooltips
The PE resource directory follows a three-level tree structure:
- Type: Resource type (RT_VERSION, RT_MANIFEST, RT_STRING, RT_DIALOG, etc.)
- Name: Resource identifier (numeric ID or string name)
- Language: Language/locale identifier (LCID)
Resources commonly use UTF-16LE encoding, requiring proper string decoding beyond ASCII/UTF-8 extraction.
Proposed Solution
Implementation Approach
Extend the PE container parser (src/container/pe.rs) to parse the resource directory structure and extract strings from high-value resource types:
1. Resource Directory Parsing
- Locate the
.rsrcsection using existing section enumeration - Parse the three-level resource directory tree (Type → Name → Language)
- Navigate resource data entries to locate actual resource data
- Handle both numeric and string resource identifiers
2. Resource Type Handlers
Implement extraction for the following Win32 resource types:
RT_VERSION (Type 16) - Version Information
- Parse
VS_VERSIONINFOstructure - Extract
StringFileInfofields:FileDescriptionProductNameCompanyNameLegalCopyrightFileVersionProductVersionInternalNameOriginalFilename
- Tag with
VersionandResourcetags - Assign high relevance scores (8-10)
RT_MANIFEST (Type 24) - Application Manifest
- Extract embedded XML manifest
- Parse manifest for assembly names, dependencies, and configuration strings
- Tag with
ManifestandResourcetags - Assign high relevance scores (7-9)
RT_STRING (Type 6) - String Tables
- Parse
STRINGTABLEblocks (16 strings per block) - Extract null-terminated UTF-16LE strings
- Tag with
Resourcetag - Assign medium-high relevance scores (6-8)
RT_DIALOG (Type 5) - Dialog Box Templates
- Parse
DLGTEMPLATEorDLGITEMTEMPLATEstructures - Extract window titles, control text, and tooltips
- Handle both
DIALOGandDIALOGEXformats - Tag with
Resourcetag - Assign medium relevance scores (5-7)
RT_MENU (Type 4) - Menu Resources
- Parse
MENUITEMTEMPLATEstructures - Extract menu item text strings
- Tag with
Resourcetag - Assign medium relevance scores (5-7)
3. String Encoding
- Implement UTF-16LE decoding (resources typically use UTF-16)
- Handle null-terminated wide strings
- Convert to UTF-8 for storage in
ExtractedString - Integrate with existing encoding detection if mixed encodings exist
4. Integration Points
- Add resource extraction method to
PeParserimplementation - Call during container parsing in
parse()method - Store extracted strings with
StringSource::ResourceString - Apply semantic tags:
Resource,Version,Manifest - Integrate into existing section weighting/scoring system
5. Library Consideration
Option A: Use pelite crate (specialized PE parser with resource support)
- Pros: Handles resource parsing complexity, well-tested
- Cons: Adds dependency, may need integration work
Option B: Extend current goblin-based parser manually
- Pros: No new dependencies, full control
- Cons: More complex implementation, need to handle edge cases
Recommendation: Start with Option B (manual parsing) leveraging existing goblin::pe::PE structures, add pelite later if complexity warrants.
Acceptance Criteria
- Parse PE resource directory three-level tree structure (Type → Name → Language)
- Extract version info fields (
FileDescription,ProductName,CompanyName, etc.) - Extract manifest XML strings from embedded manifests
- Handle
STRINGTABLEresources with UTF-16LE decoding - Extract dialog box template strings (window titles, control text)
- Extract menu definition strings
- Apply appropriate semantic tags (
Resource,Version,Manifest) - Include resource strings in scoring/ranking system with appropriate weights
- Add unit tests for resource directory parsing
- Add integration tests using real PE binaries with resources
- Handle edge cases: missing resources, malformed structures, mixed encodings
- Document resource extraction in
docs/src/binary-formats.md
Implementation Notes
- Resource extraction should be optional/non-blocking (gracefully handle parse failures)
- Maintain performance: avoid deep recursion, limit resource tree depth
- Consider adding CLI flag
--resourcesto enable/disable resource extraction - Test with real-world Windows binaries (e.g.,
notepad.exe,calc.exe)
Related Issues
- Add pelite dependency for PE resource extraction (VERSIONINFO, STRINGTABLE) #4 - Add pelite dependency for PE resource extraction
- Implement PE Resource String Extraction (VERSIONINFO, STRINGTABLE, Manifests) #5 - Implement PE Resource String Extraction (VERSIONINFO, STRINGTABLE, Manifests)
- Extract Strings from PE Resource Directory (Version Info, Manifests, String Tables, Dialogs) #56 - Extract Strings from PE Resource Directory
Note: This issue consolidates and supersedes #5 and #56 with a more comprehensive approach.
Activity
traycerai commentedon Nov 10, 2025
Warning
Rate limit exceeded. Please try after 265 seconds.
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.
[-]Advanced PE Resources Extraction[/-][+]Extract Strings from PE Resource Directory (Version Info, Manifests, String Tables, Dialogs, Menus)[/+]coderabbitai commentedon Nov 10, 2025
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 7330
🏁 Script executed:
Length of output: 14093
🏁 Script executed:
Length of output: 197
@unclesp1d3r I've successfully enhanced issue #57 with comprehensive technical details and proper metadata. Here's what was improved:
Changes Made
🏷️ Title Update
New: "Extract Strings from PE Resource Directory (Version Info, Manifests, String Tables, Dialogs, Menus)"
📋 Enhanced Body Content
1. Expanded Context
2. Detailed Implementation Approach
PeParser3. Expanded Acceptance Criteria
4. Implementation Notes
--resources)5. Cross-References
🏷️ Labels Added
area:analyzer- Binary analyzer functionalitylang:rust- Rust implementationneeds:tests- Test coverage requiredpriority:medium- Appropriate priority levelThe issue now provides a comprehensive blueprint for implementation with technical specifications, architectural decisions, and clear success criteria. It's ready for development! 🚀
unclesp1d3r commentedon Jul 4, 2026
Implemented: PE resource extraction in src/extraction/pe_resources/ (version_info, string_tables, manifests, dialogs/menus via pelite). Closing as completed.