Skip to content

Commit

Permalink
Merge pull request #29 from noobpk/dev
Browse files Browse the repository at this point in the history
bump to version 1.3
  • Loading branch information
noobpk authored Jun 21, 2022
2 parents 06c9963 + 1cf1193 commit 9a7300f
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"cSpell.words": [
"androidhook",
"Frida"
"findclass",
"Frida",
"logcat",
"lowlevel"
]
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<img width="544" alt="image" src="https://user-images.githubusercontent.com/31820707/108661418-60d4b500-74fe-11eb-81ed-c164df9ef4a5.png">

# 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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frida-android-hook/core/hook.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
45 changes: 38 additions & 7 deletions frida-android-hook/core/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from utils.log import *
from utils.config import *
from utils.cli import *
from utils.suggestion import *

GLOBAL_CONFIG = config.loadConfig()

Expand All @@ -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):
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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":
Expand All @@ -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":
Expand All @@ -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":
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
18 changes: 9 additions & 9 deletions frida-android-hook/core/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

APP_AUTHOR = ''
APP_VERSION = ''
APP_PLATFORM_SUPORT = ''
APP_PLATFORM_SUPPORT = ''
APP_FIRST_RUN = ''
APP_PACKAGES = ''
APP_CONFIG = 'core/hook.json'
Expand All @@ -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):
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand All @@ -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))
Expand Down
19 changes: 19 additions & 0 deletions frida-android-hook/core/utils/suggestion.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 9a7300f

Please sign in to comment.