Skip to content

Commit 37d0121

Browse files
authored
Bump to v1.4 (#50)
* update for option bypass-ssl * refactor code * update new script for intercept crypto * update .gitignore * add new script for crypto * add new option --proxy and fix bug * update README & CHANGELOG * update to version 1.4 * update requirements * update requirements --------- Co-authored-by: Lê Thành Phúc <>
1 parent 2e05378 commit 37d0121

13 files changed

+1829
-75
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
py-env/
131+
frida_server_tmp/
132+
tmp/

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Frida Android Hook ChangeLog
22

3+
## [Release 1.4] - 2024-09-05
4+
5+
### Added
6+
- Add new frida scripts
7+
- Add option --proxy
8+
### Changed
9+
- Update readme, changelog
10+
- Update frida-script
11+
- Update hook.py
12+
### Fixed
13+
- Fix bug
14+
315
## [Release 1.3] - 2022-06-21
416

517
### Added

README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
| ------------- | ---------| ----------------- |
2323
| 8.0 - Api 26 | 14.2.13 | :white_check_mark:|
2424
| 8.0 - Api 26 | 15.0.18 | :white_check_mark:|
25+
| 13.0 - Api 33 | 16.4.9 | :white_check_mark:|
2526

2627
## Feature
2728

@@ -52,26 +53,26 @@ Support both spawn & attach script to process.
5253
--list-scripts List All Scripts
5354
--logcat Show system log of device
5455
--shell Get the shell of connect device
56+
--proxy Config global proxy ::3128 and reverse tcp 3128:8080
5557
5658
[*] Quick method:
5759
5860
-m(--method) Support commonly used methods
59-
app-static(-n)
60-
bypass-jb(-p)
61+
bypass-root(-p)
6162
bypass-ssl(-p)
62-
i-url-req(-p)
63-
i-crypto(-n)
63+
i-nw-req(-p)
64+
i-crypto(-p)
6465
```
6566

6667
## ChangeLog
6768

68-
Version: 1.3
69+
Version: 1.4
6970
```
7071
[+] Add:
7172
72-
[-] Add setup.py for build executable
73+
[-] Add new frida scrips
7374
74-
[-] Add suggestion script for option `-s (--script)`
75+
[-] Add option `--proxy` for config global proxy on device
7576
7677
7778
[+] Change:
@@ -84,7 +85,7 @@ Version: 1.3
8485
8586
[+] Fix
8687
87-
[-] Fix syntax in hook.json
88+
[-] Fix bug
8889
8990
```
9091
[See Full ChangeLog](https://github.com/noobpk/frida-android-hook/blob/master/CHANGELOG.md)

frida-android-hook/androidhook

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ from shutil import which
88

99
try:
1010
if(which('python3') is not None):
11-
command = shlex.split("python3 " +"core/hook.py")
11+
command = shlex.split("python3 " + "core/hook.py")
1212
else:
13-
command = shlex.split("python " +"core/hook.py")
13+
command = shlex.split("python " + "core/hook.py")
1414

1515
command.extend(sys.argv[1:])
1616
subprocess.call(command, cwd=os.path.dirname(__file__))

frida-android-hook/core/hook.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frida-android-hook",
3-
"version": "1.3",
3+
"version": "1.4",
44
"cliVersion": "1.0",
55
"author": "noobpk",
66
"license": "LICENSE",

frida-android-hook/core/hook.py

+58-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import re
88
import fnmatch
99
import shlex
10-
import subprocess
1110

1211
from utils.listapp import *
1312
from utils.checkversion import *
@@ -46,15 +45,32 @@ def start_frida_server(param_1):
4645

4746
def stop_frida_server(param):
4847
fs = "/data/local/tmp/frida-server*"
49-
isProc = os.popen('adb shell ps |' + param).read()
50-
if (isProc):
51-
logger.info("[*] Found Process Frida Server:" + isProc)
48+
49+
# Check if the Frida server process is running
50+
isProc = subprocess.getoutput(f'adb shell ps | {param}')
51+
52+
if isProc:
53+
logger.info("[*] Found Process Frida Server: " + isProc)
5254
logger.info("[*] Stop Frida Server...")
53-
os.system('adb shell ' + 'su -c ' + 'pkill -f ' + fs)
55+
56+
# Try to stop the Frida server with su privilege
57+
result = subprocess.run(f'adb shell su -c "pkill -f {fs}"', shell=True)
58+
59+
# Check if the su command was successful
60+
if result.returncode != 0:
61+
logger.error("[!] Failed to stop Frida Server with su -c")
62+
# Retry without su
63+
logger.info("[*] Try to stop Frida Server withou su...")
64+
result = subprocess.run(f'adb shell pkill -f {fs}', shell=True)
65+
66+
if result.returncode != 0:
67+
logger.error("[!] Failed to stop Frida Server")
68+
return
69+
5470
time.sleep(2)
5571
logger.info("[*] Stop Frida Server Success!!")
5672
else:
57-
logger.warning("[!] Frida Server Not Start")
73+
logger.warning("[!] Frida Server Not Started")
5874

5975
def check_frida_server_run(param):
6076
isProc = os.popen('adb shell ps |' + param).read()
@@ -127,6 +143,7 @@ def main():
127143
action="store_true", help="List All Scripts", dest="listscripts")
128144
info.add_option("--logcat", action="store_true", help="Show system log of device", dest="logcat")
129145
info.add_option("--shell", action="store_true", help="Get the shell of connect device", dest="shell")
146+
info.add_option("--proxy", action="store_true", help="Config global proxy ::3128 and reverse tcp 3128:8080", dest="proxy")
130147

131148
parser.add_option_group(info)
132149
parser.add_option_group(quick)
@@ -158,9 +175,9 @@ def main():
158175
if re.search(description_pattern, line):
159176
description = re.sub(r'\n', '', line[16:])
160177
if re.search(mode_pattern, line):
161-
mode = re.sub('\s+', '', line[9:])
178+
mode = re.sub(r'\s+', '', line[9:])
162179
if re.search(version_pattern, line):
163-
version = re.sub('\s+', '', line[12:])
180+
version = re.sub(r'\s+', '', line[12:])
164181
print('|%d|%s|%s|%s|%s|' % (i, mode, file_name, description, version))
165182
else:
166183
logger.error('[?] Path frida-script not exists!')
@@ -203,7 +220,7 @@ def main():
203220
if (findingScript == False):
204221
logger.error('[x_x] No matching suggestions!')
205222
sys.exit(0)
206-
logger.info('[*] iOSHook suggestion use '+findingScript)
223+
logger.info('[*] androidhook suggestion use '+findingScript)
207224
answer = input('[?] Do you want continue? (y/n): ') or "y"
208225
if answer == "y":
209226
options.script = APP_FRIDA_SCRIPTS + findingScript
@@ -232,7 +249,7 @@ def main():
232249
if (findingScript == False):
233250
logger.error('[x_x] No matching suggestions!')
234251
sys.exit(0)
235-
logger.info('[*] iOSHook suggestion use '+findingScript)
252+
logger.info('[*] androidhook suggestion use '+findingScript)
236253
answer = input('[?] Do you want continue? (y/n): ') or "y"
237254
if answer == "y":
238255
options.script = APP_FRIDA_SCRIPTS + findingScript
@@ -281,10 +298,12 @@ def main():
281298
logger.info('[*] Spawning: ' + options.package)
282299
logger.info('[*] Script: ' + method)
283300
time.sleep(2)
284-
process = frida.get_usb_device().attach(options.package)
285-
method = open(method, 'r')
286-
script = process.create_script(method.read())
301+
pid = frida.get_usb_device().spawn(options.package)
302+
session = frida.get_usb_device().attach(pid)
303+
hook = open(method, 'r')
304+
script = session.create_script(hook.read())
287305
script.load()
306+
frida.get_usb_device().resume(pid)
288307
sys.stdin.read()
289308
else:
290309
logger.error('[x_x] Script for method not found!')
@@ -296,7 +315,6 @@ def main():
296315
logger.info('[*] Intercept NetWork Request: ')
297316
logger.info('[*] Attaching: ' + options.name)
298317
logger.info('[*] Script: ' + method)
299-
time.sleep(2)
300318
process = frida.get_usb_device().attach(options.name)
301319
method = open(method, 'r')
302320
script = process.create_script(method.read())
@@ -308,13 +326,18 @@ def main():
308326
#Intercept Crypto Operations
309327
elif options.package and options.method == "i-crypto":
310328
method = APP_METHODS['Intercept Crypto Operations']
311-
check_frida_server_run()
312329
if os.path.isfile(method):
313330
logger.info('[*] Intercept Crypto Operations: ')
314331
logger.info('[*] Spawning: ' + options.package)
315332
logger.info('[*] Script: ' + method)
316-
os.system('frida -U -f '+ options.package + ' -l ' + method + ' --no-pause')
317-
#sys.stdin.read()
333+
time.sleep(2)
334+
pid = frida.get_usb_device().spawn(options.package)
335+
session = frida.get_usb_device().attach(pid)
336+
hook = open(method, 'r')
337+
script = session.create_script(hook.read())
338+
script.load()
339+
frida.get_usb_device().resume(pid)
340+
sys.stdin.read()
318341
else:
319342
logger.error('[x_x] Script for method not found!')
320343

@@ -323,7 +346,7 @@ def main():
323346
logger.info('[*] Checking for updates...')
324347
is_newest = check_version(speak=True)
325348
# if not is_newest:
326-
# logger.info('[*] There is an update available for iOS hook')
349+
# logger.info('[*] There is an update available for androidhook')
327350

328351
#update newversion
329352
elif options.update:
@@ -336,23 +359,37 @@ def main():
336359
elif options.package and options.dumpmemory:
337360
dump_memory(options.dumpmemory, options.package)
338361

339-
#ios system log
362+
#android system log
340363
elif options.logcat:
341364
cmd = shlex.split('adb logcat')
342365
subprocess.call(cmd)
343366
sys.exit(0)
344367

345-
#ios get the shell
368+
#android get the shell
346369
elif options.shell:
347370
cmd = shlex.split('adb shell')
348371
subprocess.call(cmd)
349372
sys.exit(0)
350373

351-
#ioshook cli
374+
#androidhook cli
352375
elif options.cli:
353376
logger.info("Welcome to AndroidHook CLI! Type ? to list commands")
354377
AndroidHook_CLI().cmdloop()
355378

379+
#androidhook proxy
380+
elif options.proxy:
381+
cmd1 = shlex.split('adb shell settings put global http_proxy 127.0.0.1:3128')
382+
cmd2 = shlex.split('adb reverse tcp:3128 tcp:8080')
383+
384+
logger.info("[*] Config device global proxy to ::3128")
385+
subprocess.call(cmd1)
386+
387+
logger.info("[*] Config reverse tcp from device to machine 3128:8080")
388+
subprocess.call(cmd2)
389+
390+
logger.info("[*] Config success - Using proxy 127.0.0.1:8080")
391+
sys.exit(0)
392+
356393
else:
357394
logger.warning("[!] Specify the options. use (-h) for more help!")
358395
# sys.exit(0)

0 commit comments

Comments
 (0)