Overview
Patching in angr Management lets you:Modify Code
Change assembly instructions, replace with NOPs, or rewrite logic
Edit Data
Modify strings, constants, and data structures
Test Changes
Verify patches with debugging before exporting
Export Binary
Save patched binary for deployment
Patch Types
angr Management supports several patching approaches:Assembly Patching
Replace instructions with new assembly code:
Examples:
Hex Patching
Directly modify bytes in the hex view:Edit Bytes
- Click on hex bytes section
- Type new hex values (e.g.,
90for NOP) - Or click ASCII section to edit as text
Programmatic Patching
Use the Python console for complex patches:Patch Management
Viewing Patches
Open the Patches View (View → Patches) to see all patches:| Column | Description |
|---|---|
| Address | Location of patch in hex |
| Size | Number of bytes modified |
| Original | Original byte values |
| Patched | New byte values |
| Comment | Optional description |
Patch Highlighting
Patches are visually marked throughout the interface:- Disassembly View: Yellow background on patched instructions
- Hex View: Yellow highlight on patched bytes
- Patches View: Complete list with details
Editing Patches
Modify existing patches:- In Patches View
- In Hex View
- Re-patch
- Double-click patch in Patches view
- Modify bytes or comment
- Click OK to save
Reverting Patches
Single Patch
Single Patch
In Patches View:
- Right-click patch
- Select “Revert Patch”
- Confirm reversion
- Right-click yellow highlight
- Select “Revert”
- Patch is removed
All Patches
All Patches
Via Console:
Patch Comments
Document your patches:- Right-click patch (in Hex View or Patches View)
- Select “Set Comment”
- Enter description (e.g., “Bypass license check”)
- Comment appears in Patches view
Common Patching Patterns
NOPing Instructions
Remove unwanted instructions:- Right-click
callinstruction - Patch Instruction →
nop - Repeat for
testandjz - Or use multi-byte NOP for efficiency
Changing Conditionals
Flip conditional logic:Forcing Return Values
Change function results:Redirecting Calls
Change call targets:Ensure the new target has a compatible calling convention and signature.
Patching Data
Modify strings and constants:- Strings
- Constants
In Hex View:
- Navigate to string address
- Click in ASCII column
- Type new text
- Null terminator handled automatically
Advanced Patching
Multi-Instruction Patches
Replace multiple instructions:Conditional Patching
Apply patches based on conditions:Patch Merging
Combine adjacent patches:- Apply patch at address A
- Apply patch at address A+N (adjacent)
- In Hex View, right-click first patch
- Select “Merge with next”
- Patches combine into single patch
Patch Splitting
Split large patches:- Navigate to middle of patch in Hex View
- Right-click on patch highlight
- Select “Split”
- Two independent patches created
Testing Patches
Debug Patched Code
Decompile Patched Code
View patches in pseudocode:- Apply patches in disassembly
- Press
Tabto switch to pseudocode - Decompiler shows patched code
- Verify logic changes
Decompiler uses patched bytes, so you see the modified logic in C code.
Exporting Patched Binaries
Save Patched Binary
What Gets Saved:
- All applied patches
- Preserved file structure
- Updated checksums (where applicable)
- Original file format maintained
Patch Persistence
Patches are stored in:- angr database (.adb): When you save the database
- Patched binary: When you export
- Memory only: Until you save (lost on exit)
Patch Limitations
Size Constraints
Size Constraints
Patches cannot exceed original instruction sizeIf your new code is longer:
- Use a jump to a code cave
- Place new code in unused space
- Jump back when done
Relocation Issues
Relocation Issues
Some binaries have relocations:
- PIE executables
- DLLs/shared libraries
- Position-independent code
- Patched addresses may change at runtime
- Use relative addressing when possible
- Test at expected load address
Code Signing
Code Signing
Signed binaries:
- Patches invalidate signatures
- Binary won’t verify after patching
- May need to re-sign (platform-dependent)
Best Practices
Document Patches
- Add comments to every patch
- Explain why the patch was needed
- Note any side effects
- Keep a patch log
Test Thoroughly
- Use debugger to verify patches
- Test edge cases
- Check for unintended effects
- Validate with decompiler
Backup First
- Save original binary
- Save angr database frequently
- Version your patches
- Test on copies, not originals
Minimal Changes
- Patch only what’s necessary
- Preserve original behavior where possible
- Avoid cascading changes
- Keep patches simple
Troubleshooting
Patch Not Applied
Patch Not Applied
Patch doesn’t appear in binary:Solutions:
- Check Patches view for the patch
- Verify address is correct
- Ensure you exported after patching
- Check file permissions
Crash After Patch
Crash After Patch
Patched binary crashes:Causes:
- Incorrect instruction encoding
- Changed stack alignment
- Broken calling convention
- Invalid jump target
- Revert patches one by one
- Use debugger to find crash location
- Verify instruction bytes are correct
Wrong Instruction Encoding
Wrong Instruction Encoding
Patch assembles incorrectly:Solutions:
- Check architecture (x86 vs x64, ARM mode)
- Verify syntax (AT&T vs Intel)
- Use hex bytes directly if needed
- Consult instruction reference
Next Steps
Debugging
Test patches with the debugger
Scripting
Automate patching workflows
Advanced Topics
Advanced binary modification techniques
Disassembly
Return to disassembly guide