NimGuard is a dynamic binary patching and instrumentation tool for legacy systems.
It enables runtime analysis, patch injection, and behavior monitoring—all without requiring source code modifications.
This tool is designed to help security researchers, DevSecOps engineers, and reverse engineers analyze, patch, and protect legacy binaries that are otherwise difficult to modify due to missing source code or vendor lock-in.
✅ Binary Analysis: Disassemble and analyze binaries using Capstone.
✅ Dynamic Patching: Assemble and inject patches at runtime using Keystone.
✅ Instrumentation Hooks: Insert monitoring hooks for logging, runtime protection, and anomaly detection.
✅ Rule-Based Engine: Define patching rules via a custom DSL for flexible, scenario-based modifications.
✅ Live Debugging: Emulate patched code before applying it using Unicorn.
✅ Cross-Platform Support: Works on Windows, Linux, and macOS with proper dependencies installed.
Use choosenim to install Nim:
curl https://nim-lang.org/choosenim/init.sh -sSf | shVerify installation:
nim -vEnsure you have the required dependencies installed:
nimble install capstone
nimble install keystone
nimble install unicorn(If these libraries are not available in Nimble, you may need to install system-level bindings.)
git clone https://github.com/will-bates11/nimguard.git
cd nimguardCompile the project:
nimble buildTo verify functionality, run:
nim c -r tests/test_patcher.nimRun NimGuard to analyze and patch a binary:
./nimguard target_binary.exeIf target_binary.exe contains a function with a known buffer overflow, NimGuard will:
-
Disassemble the function using Capstone.
-
Identify the overflow vulnerability.
-
Inject a runtime patch using Keystone (e.g., replacing a vulnerable instruction with a safer one).
-
Insert instrumentation hooks for logging and monitoring.
NimGuard supports a rule-based engine where you define patching rules:
rules:
- identifier: "auth_bypass"
description: "Bypass authentication in login function"
condition: "if function login() is called"
patch: "mov eax, 1; ret"Load a custom rule set:
./nimguard target_binary.exe --rules my_rules.yamlTo enable live monitoring and logging:
./nimguard target_binary.exe --monitorThis mode will attach runtime hooks to the binary and provide insights into function calls, arguments, and memory access.
✅ Implement binary analysis with Capstone.
✅ Develop basic runtime patching with Keystone.
✅ Set up instrumentation hooks for logging.
✅ Create rule-based patching system.
⏳ Add interactive shell for manual patching.
⏳ Implement a rollback mechanism for safe patching.
⏳ Support for ELF, PE, and Mach-O binaries.
⏳ Create a Web UI for real-time patching and monitoring.
⏳ Add stealth mode to evade anti-tampering mechanisms.
We welcome contributions! Follow these steps to contribute:
-
Fork the repository
-
Create a feature branch:
git checkout -b my-new-feature -
Commit your changes:
git commit -m "Add my feature" -
Push to the branch:
git push origin my-new-feature -
Submit a pull request
For major changes, please open an issue first to discuss your proposal.
⚠ Use this tool only in a controlled and legal environment. NimGuard is designed for research, security analysis, and ethical hacking purposes. Misuse of this software in unauthorized systems may violate laws and regulations.