Refactor: Symmetric architecture — shared function discovery for CFF and Junk modes - #22
Merged
Merged
Conversation
Extract shared function discovery layer so both obfuscation modes follow the same pipeline: validate → discover → engine → save. New common/ module: - function_info.h: shared FunctionInfo struct (name, pdb_offset, rva, size) - function_discovery.h/.cpp: single PE+PDB load, returns function list - function_filter.h/.cpp: blacklist filtering, size filtering, interactive selection — moved from JunkCodeManager private methods Architecture changes: - Both modes use FunctionDiscovery for function discovery (1 PE load each) - CFF: FunctionDiscovery → convert to sym_func → pe64 → obfuscatecff → save - Junk: FunctionDiscovery → filter → LIEF → TrampolineInjector → save - Junk mode no longer loads PE 2-4 times (was: pe64 via RVAResolver + LIEF) - JunkCodeManager::run_auto/manual_injection_mode now accept pre-discovered function list instead of creating internal RVAResolver instances - main.cpp orchestrates both modes at the same abstraction level DbgHelp singleton safety: - FunctionDiscovery (which owns pdbparser) is scoped in a block and destroyed before CFF creates its own pe64 for the VA-mapped buffer - Neither engine creates a second pdbparser after receiving the function list Files changed: 5 modified, 5 new (common/ module) Files unchanged: pe64, pdbparser, obfuscatecff, cfflattening, func2rva
sondt99
added a commit
that referenced
this pull request
Aug 10, 2026
Refactor: Symmetric architecture — shared function discovery for CFF and Junk modes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both obfuscation modes now follow the same pipeline pattern, eliminating the asymmetric architecture where Junk mode loaded the PE 2-4 times redundantly.
Before
After
New
common/Module (5 files)function_info.hFunctionInfostruct used by both modesfunction_discovery.h/.cppfunction_filter.h/.cppKey Changes
Checklist
common/function_info.h— shared structcommon/function_discovery.h/.cpp— single load, testedcommon/function_filter.h/.cpp— blacklist + size filter + interactive selectionJunkCodeManager::run_auto_injection_modeusesObfuGuard::filter_functionsJunkCodeManager::run_manual_injection_modeusesObfuGuard::select_functions_interactivemain.cppCFF mode usesFunctionDiscoveryin scoped blockmain.cppJunk mode usesFunctionDiscoveryin scoped blockParser::parsecalled exactly once (inside TrampolineInjector)Test plan
match_check.pyon full 60-binary test suite