PE32 signature finder | Anti-virus signature removal | Malware analysis tool | ClamAV signature detection | Domain-Driven Design | Clean Architecture
SignFinder is a powerful tool for PE32 file analysis and anti-virus signature localization. It helps security researchers and malware analysts identify where anti-virus signatures are located in PE executables by systematically zeroing out different parts of the file or by directly searching for ClamAV signature patterns.
The tool has been completely refactored following Domain-Driven Design (DDD) and Clean Architecture principles.
- π Fast Mode: Quickly identify signature location (emulator, import directory, sections)
- π Header Mode: Test PE headers by zeroing each field individually
- π¦ Section Mode: Divide sections into parts for granular analysis
- π― Manual Mode: Test specific byte ranges with custom part counts
- π Sliding Window Mode: Advanced analysis with byte-by-byte sliding window
- π¦ ClamAV Signature Mode: Search for specific ClamAV signatures in PE files
- β Duplicate Detection: Automatically prevents creating identical files
- π RVA Information: Includes Relative Virtual Address for each section
- π§Ή Zero Mode: Remove detected signatures from files
pip install -r requirements.txtDisplay detailed PE file section information:
python main.py path_to_exe infoOutput: Section names, offsets, sizes, RVAs, and characteristics.
Quickly identify signature type (emulator, import, sections):
python main.py path_to_exe fastHow it works:
- Tests DOS stub (emulator signatures)
- Tests import directory
- Tests each section individually
- Reports which component triggers AV detection
Use case: First step in signature analysis to narrow down search area.
Test PE headers by zeroing each field:
python main.py path_to_exe headHow it works:
- Systematically zeros out each PE header field
- Creates test files for each field
- Identifies which header fields contain AV signatures
Use case: Detect signatures in PE headers (rare but possible).
Test a specific section by dividing it into parts:
python main.py path_to_exe sect section_number [-p part_count]Parameters:
section_number: Section index (0-based)-p part_count: Number of parts to divide section into (default: 10)
How it works:
- Divides the specified section into N equal parts
- Creates test files with each part zeroed out
- Identifies which part contains the signature
Use case: Narrow down signature location within a specific section.
Test a specific byte range:
python main.py path_to_exe man offset size part_numberParameters:
offset: Starting byte offsetsize: Number of bytes to analyzepart_number: How many parts to divide the range into
How it works:
- Divides the specified byte range into parts
- Creates test files with each part zeroed
- Pinpoints exact signature location
Use case: Final precision targeting after narrowing down with other modes.
Advanced byte-by-byte sliding window testing:
python main.py path_to_exe man2 offset size window_sizeParameters:
offset: Starting byte offsetsize: Total range sizewindow_size: Size of sliding window in bytes
How it works:
- Slides a window of specified size byte-by-byte through the range
- Creates test files with each window position zeroed
- Provides byte-level precision
Use case: Ultra-precise signature localization when exact byte position is needed.
Search for specific ClamAV signatures in PE files:
python main.py path_to_exe sig clamav_db_path [-n signature_name] [-z]Parameters:
clamav_db_path: Path to ClamAV LDB database file (e.g.,clamav/daily.ldb)-n signature_name: Optional signature name to search for (partial match)-z: Optional flag to zero out found signatures and save cleaned file
How it works:
ClamAV LDB signatures follow this format:
SignatureName;Engine:version,Target:type;conditions;pattern1;pattern2;...
Example:
Win.Spyware.Zbot-9841872-0;Engine:81-255,Target:1;0&1&2&3&4;496e74...;4d6f7a...;677261...;536372...;556e6b...
Components:
- SignatureName: Malware family identifier
- Engine:81-255: ClamAV engine version range
- Target:1: Target type (1 = PE files)
- Conditions:
0&1&2&3&4means patterns 0, 1, 2, 3, and 4 must ALL be found - Patterns: Hex-encoded byte patterns to search for
- Plain hex:
496e7465726e616cβ searches for exact bytes - Wide strings (
::w):677261625f...::wβ ASCII hex converted to UTF-16LE - Wildcards:
??β matches any byte (treated as00in current implementation)
- Parse signature: Extract name, target type, conditions, and patterns
- Decode patterns: Convert hex strings to bytes, handle wide strings
- Search entire file: Find all occurrences of each pattern
- Check conditions: Verify all required patterns are present
- Report results: Show offset, section, RVA, hex dump, and disassembly
Search for specific Zbot signature:
python main.py tests/samples_pass_infected/zeus sig clamav/daily.ldb -n "Win.Spyware.Zbot-9841872-0"Output:
DEBUG: Partial match 'Win.Spyware.Zbot-9841872-0'
DEBUG: Found 'Win.Spyware.Zbot-9841872-0', 5 patterns: [34, 55, 50, 24, 27]
[-] Found 5 signature location(s):
Signature Name Pattern Offset Section RVA
Win.Spyware.Zbot-9841872-0 1 0x00001D50 [0].text 0x00002950
Pattern (34 bytes): 496e7465726e616c20636f6d6d616e64206572726f72...
As string: "Internal command error at line %u."
Win.Spyware.Zbot-9841872-0 2 0x0000379C [0].text 0x0000439C
Pattern (55 bytes): 4d6f7a696c6c612f342e302028636f6d70617469626c65...
As string: "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
...
Search and remove signatures (zero mode):
python main.py tests/samples_pass_infected/zeus sig clamav/daily.ldb -n "Zbot" -zOutput:
[+] Zeroing signatures...
Zeroed 0x0000379C-0x000037D3 (55 bytes)
Zeroed 0x00003664-0x00003696 (50 bytes)
Zeroed 0x00001D50-0x00001D72 (34 bytes)
Zeroed 0x00001D34-0x00001D4C (24 bytes)
Zeroed 0x00001CFC-0x00001D17 (27 bytes)
[+] Saved: tests/samples_pass_infected/zeus_zeros_clean
Conditions specify which patterns must be found:
0&1&2&3&4: All patterns 0, 1, 2, 3, 4 must be present0&1: Only patterns 0 and 1 must be present0-4: Range notation, patterns 0 through 4 must be present- No conditions: Any pattern match is reported
Important: Conditions indicate which patterns are required, NOT which PE sections to search. All patterns are searched across the entire file.
# Step 1: Get file info
python main.py malware.exe info
# Step 2: Quick scan to identify area
python main.py malware.exe fast
# Step 3: If signature is in section 0, divide it into parts
python main.py malware.exe sect 0 -p 20
# Step 4: Narrow down to specific byte range
python main.py malware.exe man 0x1000 0x500 10
# Step 5: Precise location with sliding window
python main.py malware.exe man2 0x1200 0x100 32# Search for all Zbot signatures
python main.py malware.exe sig clamav/daily.ldb -n "Zbot"
# Search for specific signature and remove it
python main.py malware.exe sig clamav/daily.ldb -n "Win.Spyware.Zbot-9841872-0" -zThe codebase is organized into four main layers:
- Domain Layer (
signfinder/domain/): Core business logic, entities, value objects, and domain services - Application Layer (
signfinder/application/): Use cases that orchestrate domain objects - Infrastructure Layer (
signfinder/infrastructure/): Adapters for external concerns (file I/O, PE parsing, ClamAV parsing) - Presentation Layer (
signfinder/presentation/): CLI interface
See ARCHITECTURE.md for detailed documentation.
signfinder/
βββ domain/ # Business logic (entities, value objects, services)
βββ application/ # Use cases
β βββ use_cases/
β βββ fast_mode_use_case.py
β βββ header_mode_use_case.py
β βββ section_mode_use_case.py
β βββ manual_mode_use_case.py
β βββ signature_mode_use_case.py # ClamAV signature search
β βββ info_use_case.py
βββ infrastructure/ # Adapters (file I/O, PE parsing)
β βββ adapters/
β βββ clamav_parser.py # ClamAV LDB parser
β βββ pe_parser.py
β βββ file_io.py
β βββ disassembler.py
βββ presentation/ # CLI interface
βββ di/ # Dependency injection
main.py # Entry point
requirements.txt # Dependencies
- Create a new use case in
signfinder/application/use_cases/ - Add CLI handler in
signfinder/presentation/cli.py - Register in
signfinder/di/__init__.py
- Malware Analysis: Identify AV signature locations in PE files
- Security Research: Understand how anti-virus engines detect malware
- ClamAV Signature Testing: Verify ClamAV signatures against samples
- Reverse Engineering: Analyze PE file structure and modifications
- Educational: Learn about PE32 format and signature detection techniques
- Python 3.8+: Core language
- pefile: PE32 file parsing library
- capstone: Disassembly engine for x86/x64
- Domain-Driven Design: Business logic organization
- Clean Architecture: Layer separation and dependency inversion
PE32 PE file malware analysis anti-virus signature detection ClamAV reverse engineering security research file modification Domain-Driven Design Clean Architecture Python pefile binary analysis executable analysis signature localization AV bypass malware research LDB signaturesSignatureName;Engine:version
Same as original project.
Tags: pe32 malware-analysis security-research reverse-engineering anti-virus clamav signature-detection domain-driven-design clean-architecture python pefile binary-analysis file-modification