-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Convert .r2 scripts to Python with r2pipe for generic binary analysis #3373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: cpholguera <[email protected]>
…scripts completed Co-authored-by: cpholguera <[email protected]>
…ASTG-DEMO-0019 isExcludedFromBackup Co-authored-by: cpholguera <[email protected]>
… 5 scripts completed Co-authored-by: cpholguera <[email protected]>
There's still a lot of repetition that can be avoided. Let's make this even more generic by creating a shared module in utils/radare2/ with all common functions and importing it into these scripts which will become minimal thanks to that. |
…ode duplication Co-authored-by: cpholguera <[email protected]>
I've implemented the shared utility module as requested. Created |
This is very good, but you can do it even better. If you look at the scripts they still share a lot of similarities so you can try this:
The scripts in each demo must be as minimal as it gets, e.g. just a config first indicating what to look for (pattern/flag, functions, strings, etc.) and then the corresponding calls to the shared utility module and prints (which can be also parametrized). |
This PR addresses the issue where .r2 scripts in MASTG-DEMO-xxxx folders were hardcoded to work only with specific binaries using fixed memory addresses. The scripts have been rewritten to use Python with r2pipe for dynamic symbol resolution, making them work with any generic binary.
Changes Made
Successfully converted 6 out of 12 .r2 scripts to Python equivalents:
Completed Conversions
cryptokit_hash.r2
→cryptokit_hash.py
): CryptoKit.Insecure function analysiscchash.r2
→cchash.py
): CommonCrypto hash function analysissecurity_keysize.r2
→security_keysize.py
): SecKeyCreateRandomKey analysisisExcludedFromBackup.r2
→isExcludedFromBackup.py
): File backup exclusion analysiscccrypt.r2
→cccrypt.py
): CCCrypt function analysisjailbreak_detection.py
): Jailbreak detection string analysisKey Improvements
Before:
After:
Updated run.sh Scripts
All converted scripts now have updated
run.sh
files that:r2 -i script.r2
./run.sh [binary_path]
Example Usage
Template for Remaining Scripts
Created a reusable template pattern that can be quickly adapted for the remaining 6 scripts:
afl
andii
commandsaxt
pd--
andpdf
The remaining scripts follow similar patterns and can be converted using the established template approach.
Fixes #3069.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
/usr/lib/apt/methods/https
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.