From 1cf11939f1bf64cf2bdb225d60a86e9817d2288e Mon Sep 17 00:00:00 2001 From: noobpk Date: Tue, 21 Jun 2022 22:25:56 +0700 Subject: [PATCH] bump to version 1.3 --- .vscode/settings.json | 5 ++- CHANGELOG.md | 12 ++++++ README.md | 44 ++++++++++++++++++-- frida-android-hook/core/hook.json | 2 +- frida-android-hook/core/hook.py | 45 +++++++++++++++++---- frida-android-hook/core/utils/config.py | 18 ++++----- frida-android-hook/core/utils/suggestion.py | 19 +++++++++ 7 files changed, 124 insertions(+), 21 deletions(-) create mode 100644 frida-android-hook/core/utils/suggestion.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 697a0f6..600b314 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,9 @@ { "cSpell.words": [ "androidhook", - "Frida" + "findclass", + "Frida", + "logcat", + "lowlevel" ] } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cadd344..a3c88ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Frida Android Hook ChangeLog +## [Release 1.3] - 2022-06-21 + +### Added +- Add setup.py for build executable +- Add suggestion script for option -s (--script) +### Changed +- Update readme, changelog +- Update frida-script +- Update hook.py +### Fixed +- Fix syntax in hook.json + ## [Unrelease] - 2022-04-18 ### Add diff --git a/README.md b/README.md index f19e6a3..18f095e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ image # Frida Android hook + +[![CodeQL](https://github.com/noobpk/frida-android-hook/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/noobpk/frida-android-hook/actions/workflows/codeql-analysis.yml) +![python](https://img.shields.io/badge/python-3.x-blue) +![frida](https://img.shields.io/badge/frida-15.x-orange) + 📍 A tool that helps you can easy using frida. It support script for trace classes, functions, and modify the return values of methods on iOS platform. 👉 For iOS platform: [frida-ios-hook](https://github.com/noobpk/frida-ios-hook) @@ -33,7 +38,7 @@ Support both spawn & attach script to process. -c(--check-version) Check for the newest version -u(--update) Update to the newest version - [*] Dump memory aplication: + [*] Dump memory application: --dump-memory Dump memory of application @@ -60,12 +65,45 @@ Support both spawn & attach script to process. ## ChangeLog +Version: 1.3 +``` + [+] Add: + + [-] Add setup.py for build executable + + [-] Add suggestion script for option `-s (--script)` + + + [+] Change: + + [-] Update readme, changelog + + [-] Update frida-script + + [-] Update hook.py + + [+] Fix + + [-] Fix syntax in hook.json + +``` [See Full ChangeLog](https://github.com/noobpk/frida-android-hook/blob/master/CHANGELOG.md) -## Install & Build +## Install + +``` + [+] Latest version + + https://github.com/noobpk/frida-android-hook/releases + + [+] Develop version + + git clone -b dev https://github.com/noobpk/frida-android-hook.git +``` + +## Build ``` -1. git clone https://github.com/noobpk/frida-android-hook 2. cd frida-android-hook/ 3. pip3 install -r requirements.txt 4. python3 setup.py diff --git a/frida-android-hook/core/hook.json b/frida-android-hook/core/hook.json index c17a234..3b8db84 100644 --- a/frida-android-hook/core/hook.json +++ b/frida-android-hook/core/hook.json @@ -5,7 +5,7 @@ "author": "noobpk", "license": "LICENSE", "requirements": "requirements.txt", - "fristRun": true, + "firstRun": true, "packages": { "windows": { "Android Debug Bridge": "https://dl.google.com/android/repository/platform-tools-latest-windows.zip" diff --git a/frida-android-hook/core/hook.py b/frida-android-hook/core/hook.py index cb13ec6..c6c7e9b 100644 --- a/frida-android-hook/core/hook.py +++ b/frida-android-hook/core/hook.py @@ -14,6 +14,7 @@ from utils.log import * from utils.config import * from utils.cli import * +from utils.suggestion import * GLOBAL_CONFIG = config.loadConfig() @@ -35,7 +36,7 @@ def start_frida_server(param_1): else: logger.info("[*] Start Frida Server...") os.system('adb shell chmod +x ' + fs) - os.system('adb shell ' + fs + ' &') + os.system('adb shell ' + 'su -c ' + fs + ' &') time.sleep(2) isProc = os.popen('adb shell ps |' + param_1).read() if (isProc): @@ -49,7 +50,7 @@ def stop_frida_server(param): if (isProc): logger.info("[*] Found Process Frida Server:" + isProc) logger.info("[*] Stop Frida Server...") - os.system('adb shell pkill -f ' + fs) + os.system('adb shell ' + 'su -c ' + 'pkill -f ' + fs) time.sleep(2) logger.info("[*] Stop Frida Server Success!!") else: @@ -196,6 +197,21 @@ def main(): #Attaching script to application elif options.name and options.script: + if not os.path.isfile(options.script): + logger.warning('[!] Script '+options.script+' not found. Try suggestion in frida-script!') + findingScript = suggestion_script(options.script) + if (findingScript == False): + logger.error('[x_x] No matching suggestions!') + sys.exit(0) + logger.info('[*] iOSHook suggestion use '+findingScript) + answer = input('[?] Do you want continue? (y/n): ') or "y" + if answer == "y": + options.script = APP_FRIDA_SCRIPTS + findingScript + elif answer == "n": + sys.exit(0) + else: + logger.error('[x_x] Nothing done. Please try again!') + sys.exit(0) if os.path.isfile(options.script): logger.info('[*] Attaching: ' + options.name) logger.info('[*] Script: ' + options.script) @@ -210,6 +226,21 @@ def main(): #Spawning application and load script elif options.package and options.script: + if not os.path.isfile(options.script): + logger.warning('[!] Script '+options.script+' not found. Try suggestion in frida-script!') + findingScript = suggestion_script(options.script) + if (findingScript == False): + logger.error('[x_x] No matching suggestions!') + sys.exit(0) + logger.info('[*] iOSHook suggestion use '+findingScript) + answer = input('[?] Do you want continue? (y/n): ') or "y" + if answer == "y": + options.script = APP_FRIDA_SCRIPTS + findingScript + elif answer == "n": + sys.exit(0) + else: + logger.error('[x_x] Nothing done. Please try again!') + sys.exit(0) if os.path.isfile(options.script): logger.info('[*] Spawning: ' + options.package) logger.info('[*] Script: ' + options.script) @@ -240,7 +271,7 @@ def main(): frida.get_usb_device().resume(pid) sys.stdin.read() else: - logger.error('[?] Script for method not found!') + logger.error('[x_x] Script for method not found!') #Bypass SSL Pinning elif options.package and options.method == "bypass-ssl": @@ -256,7 +287,7 @@ def main(): script.load() sys.stdin.read() else: - logger.error('[?] Script for method not found!') + logger.error('[x_x] Script for method not found!') #Intercept url request in app elif options.name and options.method == "i-nw-req": @@ -272,7 +303,7 @@ def main(): script.load() sys.stdin.read() else: - logger.error('[?] Script for method not found!') + logger.error('[x_x] Script for method not found!') #Intercept Crypto Operations elif options.package and options.method == "i-crypto": @@ -285,7 +316,7 @@ def main(): os.system('frida -U -f '+ options.package + ' -l ' + method + ' --no-pause') #sys.stdin.read() else: - logger.error('[?] Script for method not found!') + logger.error('[x_x] Script for method not found!') #check newversion elif options.checkversion: @@ -328,7 +359,7 @@ def main(): #EXCEPTION FOR FRIDA except frida.ServerNotRunningError: - logger.error("Frida server is not running.") + logger.error("[x_x] Frida server is not running.") except frida.TimedOutError: logger.error("Timed out while waiting for device to appear.") except frida.TransportError: diff --git a/frida-android-hook/core/utils/config.py b/frida-android-hook/core/utils/config.py index 06b233a..b71993a 100644 --- a/frida-android-hook/core/utils/config.py +++ b/frida-android-hook/core/utils/config.py @@ -8,7 +8,7 @@ APP_AUTHOR = '' APP_VERSION = '' -APP_PLATFORM_SUPORT = '' +APP_PLATFORM_SUPPORT = '' APP_FIRST_RUN = '' APP_PACKAGES = '' APP_CONFIG = 'core/hook.json' @@ -17,7 +17,7 @@ class config(): def loadConfig(): - global APP_VERSION, APP_AUTHOR, APP_PLATFORM_SUPORT, APP_FIRST_RUN, APP_PACKAGES + global APP_VERSION, APP_AUTHOR, APP_PLATFORM_SUPPORT, APP_FIRST_RUN, APP_PACKAGES try: if os.path.isfile(APP_CONFIG): @@ -31,8 +31,8 @@ def loadConfig(): APP_CLI_VERSION = obj['cliVersion'] APP_METHODS = obj['methods'] APP_UTILS = obj['utils'] - APP_PLATFORM_SUPORT = obj['platformSupport'] - APP_FIRST_RUN = obj['fristRun'] + APP_PLATFORM_SUPPORT = obj['platformSupport'] + APP_FIRST_RUN = obj['firstRun'] APP_PACKAGES = obj['packages'] APP_FRIDA_SCRIPTS = obj['fridaScripts'] return { @@ -41,7 +41,7 @@ def loadConfig(): "author": APP_AUTHOR, "methods": APP_METHODS, "utils": APP_UTILS, - "platformSupport": APP_PLATFORM_SUPORT, + "platformSupport": APP_PLATFORM_SUPPORT, "firstRun": APP_FIRST_RUN, "packages": APP_PACKAGES, "fridaScripts": APP_FRIDA_SCRIPTS @@ -76,7 +76,7 @@ def initLoad(): try: if APP_FIRST_RUN == True: logger.info("[*] This is the first time you are running AndroidHook. We are need install some package.") - if sys.platform == 'darwin12321': + if sys.platform == 'darwin': for name, cmd in APP_PACKAGES['darwin'].items(): logger.info("[*] Install " + name) cmd = shlex.split("brew install " + cmd) @@ -86,13 +86,13 @@ def initLoad(): logger.info("[*] Install " + name) cmd = shlex.split("sudo apt-get install " + cmd) subprocess.call(cmd) - elif sys.platform == 'darwin': + elif sys.platform == 'windows': for name, cmd in APP_PACKAGES['windows'].items(): logger.warning("[*] You are running AndroidHook on Windows. Please download " + name + " at " + cmd + " then set system variable.!!") with open(APP_CONFIG, "r") as f: data = json.load(f) - data['fristRun'] = False + data['firstRun'] = False with open(APP_CONFIG, "w") as f: f.write(json.dumps(data, sort_keys=False, indent=4)) @@ -102,7 +102,7 @@ def initLoad(): def platform(): try: - if sys.platform not in APP_PLATFORM_SUPORT: + if sys.platform not in APP_PLATFORM_SUPPORT: sys.exit(logger.error("[x_x] Your platform currently does not support.")) except Exception as e: logger.error("[x_x] Something went wrong, please check your error message.\n Message - {0}".format(e)) diff --git a/frida-android-hook/core/utils/suggestion.py b/frida-android-hook/core/utils/suggestion.py new file mode 100644 index 0000000..53bc3ab --- /dev/null +++ b/frida-android-hook/core/utils/suggestion.py @@ -0,0 +1,19 @@ +import os +from utils.config import * + +GLOBAL_CONFIG = config.loadConfig() +APP_FRIDA_SCRIPTS = GLOBAL_CONFIG['fridaScripts'] + +list_Script = os.listdir(APP_FRIDA_SCRIPTS) + +def suggestion_script(word): + i = 0 + while i < len(list_Script): + if word[0] == list_Script[i][0] and word[1] == list_Script[i][1]: + return list_Script[i] + i += 1 + else: + return False + +# if __name__ == '__main__': +# suggestion_script() \ No newline at end of file