Compare commits

...

121 Commits

Author SHA1 Message Date
33ee88c0e8 okhttp3.Interceptor
okhttp3.Interceptor注入

Signed-off-by: heibai2006 <heibai2006@noreply.localhost>
2022-08-21 06:05:48 +00:00
iddoeldor
88fbef19f5
refactor SSL 🔑 log 2021-12-22 18:51:52 +02:00
iddoeldor
afe0e9dd9f
refactor SSL 🔑 log 2021-12-22 18:50:30 +02:00
iddoeldor
c0d4f48b28
Merge pull request #26 from coofee/master
fix hookOverloads
2021-12-05 13:40:26 +02:00
coofee
9baa12b04f
fix hookOverloads
`overloads[i].hasOwnProperty('argumentTypes')` will return false even if it has argumentTypes property on android device.
2021-11-25 11:27:54 +08:00
iddoeldor
03a26f73ca
Merge pull request #23 from adiantek/patch-1
fix toast
2021-11-12 13:20:04 +02:00
Adrian Antkowiak
e88989f182
fix toast
`Use` is undefined, should be `use`.
2021-11-06 10:55:02 +01:00
iddoeldor
e627f950c1
fetch ssl keys 2021-06-19 18:43:37 +03:00
iddoeldor
f7e291649a
[Android] Increase step count 2021-02-10 14:59:11 +02:00
iddoeldor
01867e4796
Merge pull request #21 from wizche/patch-1
Update README.md
2021-01-31 10:27:26 +02:00
Sergio Paganoni
6b5e839335
Update README.md
Also intercept tcp6
2021-01-28 12:21:00 +01:00
iddoeldor
ea8b909747
Merge pull request #19 from iGio90/patch-1
Squash a double change
2020-12-24 18:02:03 +02:00
iGio90
653ce0b613
Squash a double change
* Make early hook consistent for arm32 and x86
* Remove detachAll(), this was there because of my needed, I think it shouldn't be there
2020-12-24 15:05:59 +01:00
iddoeldor
e5468a4f6a
hook before init_array 2020-12-21 21:53:18 +02:00
iddoeldor
716e8236c5
disable java hook 2020-11-15 13:32:02 +02:00
iddoeldor
f533235530
improv get iOS version 2020-11-05 17:43:26 +02:00
iddoeldor
6fe08f607c
JEB Java method hook generator #formatting 2020-11-04 11:10:19 +02:00
iddoeldor
0102391670
Create FridaCodeGenerator.py 2020-11-04 11:04:58 +02:00
iddoeldor
780ee12c9f
JEB Java method hook generator #formatting-2 2020-11-04 01:08:36 +02:00
iddoeldor
31584e46ef
JEB Java method hook generator #formatting 2020-11-04 01:07:18 +02:00
iddoeldor
50ae9a92d6
JEB Java method hook generation 2020-11-04 01:00:04 +02:00
iddoeldor
a6eaabc7fb
c++ demangler 2020-10-14 18:37:28 +03:00
iddoeldor
7257797be2
log binder transactions 2020-09-04 14:15:38 +03:00
iddoeldor
d115483d32
ios log ssh cmds 2020-08-11 12:22:26 +03:00
iddoeldor
c106d2aa81
Merge pull request #16 from wiwii/master
update RevealNativeMethods
2020-06-30 11:55:45 +03:00
wiwii
d87440906c
update RevealNativeMethods
RevealNativeMethods output method name is not right
2020-06-30 16:17:07 +08:00
iddoeldor
0804545271
load c module example 2020-06-21 18:32:49 +03:00
iddoeldor
b3e40c2b57
load c module with log 2020-06-21 17:31:36 +03:00
iddoeldor
64b54be7da
update android toast; issue #13 2020-05-20 17:14:51 +03:00
iddoeldor
88d288a327
Load CPP module refactoring 2020-04-22 13:17:01 +03:00
iddoeldor
95e06f5c7b
compile & load cpp module, link fix 2020-04-22 12:57:47 +03:00
iddoeldor
306fc5eb85
compile and load c++ module 2020-04-22 12:56:34 +03:00
iddoeldor
36a223dbc0
Register broadcast receiver 2020-01-16 11:09:17 +02:00
iddoeldor
9f6e7f9504
memscn for duk 2019-11-28 15:18:24 +02:00
iddoeldor
6b4702ac86
memory scan refactor 2019-10-28 13:16:01 +02:00
iddoeldor
b077347938
refactor&fix dump memory ranges 2019-10-16 14:28:16 +03:00
iddoeldor
0e473c1e95
Merge pull request #10 from gergesh/add-proxy
Add proxy setting script
2019-10-16 14:10:16 +03:00
iddoeldor
b9a5789d5c
hook android get sys prop 2019-10-16 14:06:41 +03:00
Yoav Shai
249202f9ab Add proxy setting script 2019-10-12 17:59:28 +03:00
iddoeldor
d2c52a1dbd
unpack dex 64bit version 2019-09-12 13:07:45 +03:00
iddoeldor
dbef1c1a78
intercept read from fd 2019-09-02 17:13:11 +03:00
iddoeldor
26b85c3e4a
intercept read/pread/readv from file descriptors 2019-09-02 16:47:58 +03:00
iddoeldor
e151ca90fb
intercept read/pread/readv from file descriptor 2019-09-02 16:46:58 +03:00
iddoeldor
0fc76eafb3
Merge pull request #8 from sekkr1/master
Removed typo
2019-09-02 16:34:50 +03:00
iddoeldor
d29c03d36a
intercept read from file descriptor 2019-09-02 16:33:07 +03:00
sekkr1
48d0499ae6
Removed typo 2019-08-27 17:30:33 +03:00
iddoeldor
e7104f2205
onetimewatchpoint comment fix 2019-08-18 12:23:38 +03:00
iddoeldor
d847c76187
python invoke rpc via cli 2019-08-18 12:18:38 +03:00
iddoeldor
b6ecd41421
stalker log modified registers values 2019-08-18 12:14:24 +03:00
iddoeldor
cc9e3d9fb7
stalker 2019-08-18 12:05:00 +03:00
iddoeldor
a850707367
scan memory for pattern 2019-07-23 15:36:27 +03:00
iddoeldor
2ea7288186
ios screenshot refactoring 2019-07-18 13:57:32 +03:00
iddoeldor
a6f994deae
ios take screenshot 2019-07-18 13:01:33 +03:00
iddoeldor
677037b450
change gps android 2019-07-18 12:05:39 +03:00
iddoeldor
3cff0e9346
dump memory segment 2019-07-17 18:10:52 +03:00
iddoeldor
5b7c2d794d
add watchpoint current & return debug symbols 2019-07-09 15:36:20 +03:00
iddoeldor
eaaffe7014
Merge pull request #5 from QuestionGuy/master
Sublime snippets
2019-06-10 12:14:49 +03:00
Guy Ishay
e25e3aaa8d
Update README.md 2019-06-05 14:53:07 +03:00
iddoeldor
743dfe086e
socket activity refactoring 2019-05-26 18:00:15 +03:00
iddoeldor
29fbbdd281
object props snippet #vim 2019-05-26 12:54:19 +03:00
iddoeldor
fe0021a176
vim abbreviations update 2019-05-26 12:50:20 +03:00
iddoeldor
ec018a5171
backtrace snippet #vim 2019-05-26 12:46:36 +03:00
iddoeldor
94e0fd3b07
enable remote debugging WIP 2019-05-23 16:24:33 +03:00
iddoeldor
4f18af7edd
interceptor #vim-snippet 2019-05-23 16:20:32 +03:00
iddoeldor
b984306ea3
interceptor #vimsnippet 2019-05-23 16:14:57 +03:00
iddoeldor
d8583ccf28
OTW explicit description 2019-05-21 22:07:20 +03:00
iddoeldor
ff6fbe14c7
watchpoint refactoring 2019-05-21 19:15:49 +03:00
iddoeldor
c61a477a7c
watchpoint fix 2019-05-21 18:24:01 +03:00
iddoeldor
9c2b7e8f7f
watchpoint fix 2019-05-21 18:22:50 +03:00
iddoeldor
d9da5e5c99
watchpoint + iOS example 2019-05-21 18:21:52 +03:00
iddoeldor
d00d54e1dc
stalker onCallSummary 2019-05-16 20:34:59 +03:00
iddoeldor
08200a5d73
stalker #refactoring 2019-05-16 19:54:27 +03:00
iddoeldor
25bdd40c69
add log to stalker 2019-05-16 19:52:37 +03:00
iddoeldor
fbe4908f23
stalker example 2019-05-16 19:37:24 +03:00
iddoeldor
0eb81236c6
hook ios os_log 2019-05-08 17:04:28 +03:00
iddoeldor
c009b66efa
hook ios os_log 2019-05-08 17:03:24 +03:00
iddoeldor
bbe7ab5be3
ios executable path 2019-05-05 14:30:16 +03:00
iddoeldor
29643058cc
hook java overloads 2019-05-02 13:59:48 +03:00
iddoeldor
2067de23a4
hook all java method overloads 2019-05-02 12:46:03 +03:00
iddoeldor
2a210509c6
reveal native methods android split package&class 2019-05-01 14:44:08 +03:00
iddoeldor
357a9e3e1c
add moduleName to RevealNativeMethods 2019-04-30 16:28:36 +03:00
iddoeldor
8aeb1d9c90
android file access hook (log contents) 2019-04-30 15:54:32 +03:00
iddoeldor
39d3f75251
Reveal JNI methods update #2 2019-04-29 23:27:56 +03:00
iddoeldor
4f8595d90a
Reveal JNI methods update 2019-04-29 21:04:30 +03:00
iddoeldor
52a7557c72
add get_frontmost_application example 2019-04-29 14:09:54 +03:00
iddoeldor
372a7bacc8
Update README.md 2019-04-23 15:01:09 +03:00
iddoeldor
0dd0f51bf2
socket activity #fix 2019-04-17 15:34:08 +03:00
iddoeldor
2b87e7e6bc
socket activity #refactoring 2019-04-17 15:14:14 +03:00
iddoeldor
11fce7c847
socket activity 2019-04-17 14:55:55 +03:00
iddoeldor
f0c0a8c898
add pass (& read) error pointer example #ios 2019-04-01 17:09:57 +03:00
iddoeldor
5d120c0834
get app info 2019-03-25 15:42:57 +02:00
iddoeldor
08a4df5b51
Create WIP_ios_app_info.js 2019-03-25 14:52:35 +02:00
iddoeldor
1e92708ee1
iOS UIDevice properties example 2019-03-21 15:47:41 +02:00
iddoeldor
df2f75f3be
iOS UIDevice properties 2019-03-21 15:45:36 +02:00
iddoeldor
d6db57ae2f
add android intercept open gif example 2019-03-20 14:54:48 +02:00
iddoeldor
8658889847
android intercept libc#open example 2019-03-20 14:52:45 +02:00
iddoeldor
7208fc7793
Add files via upload 2019-03-20 14:50:15 +02:00
iddoeldor
be8fdd13f5
Create README.md 2019-03-20 14:50:01 +02:00
iddoeldor
3fb941dced
android IPC 2019-03-18 20:08:59 +02:00
iddoeldor
3e67a68b54
android log SharedPreference update 2019-03-17 16:53:56 +02:00
iddoeldor
7e3bde9518
bypass android screenshot prevention 2019-03-04 19:21:34 +02:00
iddoeldor
85d02960d3
get android id 2019-02-22 02:18:28 +02:00
iddoeldor
53ba7ccf93
hooking unity3d #ShamelessAdvertising 2019-02-17 12:52:58 +02:00
iddoeldor
e917f166bd
ios cookie jar 2019-02-07 16:01:45 +02:00
iddoeldor
889f6030c4
ios cookiejar json stringify 2019-02-03 16:28:03 +02:00
iddoeldor
7fe8eedcd1
add post about fuzzing universal links (intent link) 2019-01-29 15:23:31 +02:00
iddoeldor
9bbc7c1344
intercept entire module +excludeList 2019-01-23 19:00:22 +02:00
iddoeldor
c1687cd3b3
Create extact_ipa.sh 2019-01-23 12:56:19 +02:00
iddoeldor
87a46b133e
hooking objc_msgSend 2019-01-20 21:18:35 +02:00
iddoeldor
47d2fdd08b
Create ios_ssl_unpin.js 2019-01-06 17:49:50 +02:00
iddoeldor
3302d093ee
typo fix 2018-12-01 16:18:38 +02:00
iddoeldor
b6b63e2dd4
Create WIP_dump_dynamically_created_files.js 2018-11-26 21:17:15 +02:00
iddoeldor
3aadf1c18c
add iOS pull binary shell usage example 2018-11-26 16:05:44 +02:00
iddoeldor
00dfdf717d
Create android_proxy.js 2018-11-21 16:03:41 +02:00
iddoeldor
906b713fc9
android wifi update 2018-11-21 15:21:07 +02:00
iddoeldor
e0e93e2a57
add windows section 2018-11-21 13:31:02 +02:00
iddoeldor
be8c289bbe
pr & output examples are welcome 2018-11-21 13:21:28 +02:00
iddoeldor
bd9cacda50
PRs welcome badge 2018-11-21 13:20:32 +02:00
iddoeldor
5aa3bc3933
universal TLS unpinning ref 2018-11-18 15:16:05 +02:00
iddoeldor
952c0f8ea8
update toString hook 2018-10-17 17:23:00 +03:00
iddoeldor
6fd5ea6984
Merge pull request #3 from iddoeldor/style-refactor
Style refactor
2018-10-13 16:16:56 +03:00
14 changed files with 2001 additions and 59 deletions

1461
README.md

File diff suppressed because it is too large Load Diff

1
gif/README.md Normal file
View File

@ -0,0 +1 @@
.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 MiB

View File

@ -0,0 +1,148 @@
#?shortcut=Mod1+Shift+Z
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from com.pnfsoftware.jeb.client.api import IScript
from com.pnfsoftware.jeb.core import RuntimeProjectUtil
from com.pnfsoftware.jeb.core.units.code.android import IDexUnit
from subprocess import Popen, PIPE
def arg_format(i):
return 'arg_%d' % i
def generate_body_code(types, retval, method_name, orig_method_name, class_name):
body_code = "\n\tconsole.log('[{}#{}] ' + JSON.strigify({{\n\t".format(
FridaCodeGenerator.to_canonical_name(class_name), method_name)
for i, typ in enumerate(types):
body_code += '\t{}: {}, // {}\n\t'.format('a%d' % i, arg_format(i), typ)
if retval != 'void':
body_code = '\n\tvar retval = this.{}.apply(this, arguments);{}\tretv: retval\n\t}});'.format(
orig_method_name, body_code)
else:
body_code += '}});\n\tthis.{}.apply(this, arguments);'.format(method_name)
return body_code + '\n'
class JavaMethod(object):
def __init__(self):
self.class_name = None
self.class_orig_name = None
self.name = None
self.orig_name = None
self.arg = []
self.retType = None
def get_parameters(self):
return self.arg
def get_return_type(self):
return self.retType
def get_name(self):
return self.name
def get_orig_name(self):
return self.orig_name
def get_class_orig_name(self):
return self.class_orig_name
def get_class_name(self):
return self.class_name
def __str__(self):
return 'JavaMethod[name: %s, orig_name: %s, args: %s, return type: %s]' % (
self.name, self.orig_name, self.arg, self.retType)
class FridaCodeGenerator(IScript):
@staticmethod
def to_canonical_name(mname):
mname = mname.replace('/', '.')
return {
'C': 'char',
'I': 'int',
'B': 'byte',
'Z': 'boolean',
'F': 'float',
'D': 'double',
'S': 'short',
'J': 'long',
'V': 'void',
'L': mname[1:-1],
'[': mname
}[mname[0]]
def run(self, ctx):
project = ctx.getEnginesContext().getProjects()[0] # Get current project(IRuntimeProject)
self.dexunit = RuntimeProjectUtil.findUnitsByType(project, IDexUnit, False)[0] # Get dex context, needs >=V2.2.1
try:
self.current_unit = ctx.getFocusedView().getActiveFragment().getUnit() # Get current Source Tab in Focus
java_class = self.current_unit.getClassElement().getName()
current_addr = ctx.getFocusedView().getActiveFragment().getActiveAddress()
m = FridaCodeGenerator.get_decompiled_method(self.dexunit, current_addr, java_class)
method_name = m.get_name()
class_name = FridaCodeGenerator.to_canonical_name(m.get_class_orig_name())
return_type = FridaCodeGenerator.to_canonical_name(str(m.get_return_type()))
if method_name == '<clinit>':
raise Exception('Class initializer')
args_code = ', '.join([arg_format(i) for i in range(len(m.get_parameters()))])
if method_name == '<init>': method_name = '$init'
types = [FridaCodeGenerator.to_canonical_name(param) for param in m.get_parameters()]
# TODO get original type class names
type_code = ', '.join(["'{0}'".format(t) for t in types])
body_code = generate_body_code(types, return_type, method_name, m.get_orig_name(), m.get_class_name())
hook = "Java.use('{class_name}').{method}.overload({sig}).implementation = function({args}) {{{body}}}".format(
class_name=class_name,
method=m.get_orig_name() if method_name != '$init' else method_name,
sig=type_code,
args=args_code,
body=body_code
)
print(hook)
# copy to system's clipboard
Popen(['xclip', '-sel', 'c', '-i'], stdin=PIPE).communicate(input=(hook.encode()))
except Exception as e:
print(e)
ctx.displayMessageBox(None, 'Place the cursor in the function you want to generate the Frida code', None, None)
@staticmethod
def get_decompiled_method(dex, addr, class_orig_name):
method_info = JavaMethod()
method_info.orig_name = dex.getMethod(addr).getName(False)
msig = addr.split('+')[0]
infos = str(msig).split('->')
if len(infos) == 2:
method_info.class_name = infos[0]
method_info.class_orig_name = class_orig_name
if len(infos[1].split('(')) == 2:
method_info.name = infos[1].split('(')[0]
if len(infos[1].split(')')) == 2:
method_info.retType = infos[1].split(')')[1]
if len(infos[1].split('(')) == 2 and len(infos[1].split(')')) == 2:
args = infos[1].split('(')[-1].split(')')[0]
while args:
if args[0] in ['C', 'I', 'B', 'Z', 'F', 'D', 'S', 'J', 'V']:
method_info.arg.append(str(args[0]))
args = args[1:]
elif args[0] == '[':
if args[1] == 'L':
offset = args.find(';')
method_info.arg.append(str(args[0:offset + 1]))
args = args[offset + 1:]
else:
method_info.arg.append(str(args[0:2]))
args = args[2:]
elif args[0] == 'L':
offset = args.find(";")
method_info.arg.append(str(args[0:offset + 1]))
args = args[offset + 1:]
print(method_info)
return method_info

View File

@ -0,0 +1,28 @@
var ContextWrapper = Java.use("android.content.ContextWrapper");
ContextWrapper.sendBroadcast.overload("android.content.Intent").implementation = function(intent) {
send(JSON.stringify({
_intent: intent.toString(),
extras: intent.getExtras() ? intent.getExtras().toString() : 'null',
flags: intent.getFlags().toString()
}));
return this.sendBroadcast.overload("android.content.Intent").apply(this, arguments);
}
ContextWrapper.sendBroadcast.overload("android.content.Intent", "java.lang.String").implementation = function(intent, receiverPermission) {
send(JSON.stringify({
});
return this.sendBroadcast.overload("android.content.Intent", "java.lang.String").apply(this, arguments);
}
ContextWrapper.sendStickyBroadcast.overload("android.content.Intent").implementation = function(intent) {
return this.sendStickyBroadcast.overload("android.content.Intent").apply(this, arguments);
}
ContextWrapper.startActivity.overload("android.content.Intent").implementation = function(intent) {
return this.startActivity.overload("android.content.Intent").apply(this, arguments);
}

View File

@ -0,0 +1,134 @@
#!/usr/bin/env node
// Work in progress
// TBD how to show diff.. use git or just git style
const fs = require('fs');
const frida = require('frida');
const APP_ID = process.argv[2];
const source = `
Java.perform(function() {
var openedfile = "";
var data = {
"file": "",
"content": []
};
var isOpen = false;
var index = 0;
var fos = Java.use('java.io.FileOutputStream');
var fos_construct_2 = fos.$init.overload('java.lang.String');
var fos_construct_3 = fos.$init.overload('java.io.File');
var fos_construct_4 = fos.$init.overload('java.lang.String', 'boolean');
var fos_construct_5 = fos.$init.overload('java.io.File', 'boolean');
var fos_write_1 = fos.write.overload('[B', 'int', 'int');
var fos_close = fos.close;
function dump(data) {
console.log("Got " + data["content"].length + " bytes!");
var tmp_name = openedfile.split("/");
tmp_name = tmp_name[tmp_name.length - 1];
data["file"] = tmp_name;
send(data);
data["content"] = [];
index = 0;
}
fos_construct_2.implementation = function(file) {
var filename = file;
if (openedfile != filename) {
openedfile = filename;
console.log("File opened for write " + filename);
isOpen = true;
}
return fos_construct_2.call(this, file);
}
fos_construct_3.implementation = function(file) {
var filename = file.getAbsolutePath();
if (openedfile != filename) {
openedfile = filename;
console.log("File opened for write " + filename);
isOpen = true;
}
return fos_construct_3.call(this, file);
}
fos_construct_4.implementation = function(file, true_false) {
var filename = file;
if (openedfile != filename) {
openedfile = filename;
console.log("File opened for write " + filename);
isOpen = true;
}
return fos_construct_4.call(this, file, true_false);
}
fos_construct_5.implementation = function(file, true_false) {
var filename = file.getAbsolutePath();
if (openedfile != filename) {
openedfile = filename;
console.log("File opened for write " + filename);
isOpen = true;
}
return fos_construct_5.call(this, file, true_false);
}
fos_write_1.implementation = function(arr, offset, length) {
var i = 0;
for (i = offset; i < length; i = i + 1) {
data["content"][index] = arr[i];
index = index + 1;
}
return fos_write_1.call(this, arr, offset, length);
}
fos_close.implementation = function() {
dump(data);
return fos_close.call(this);
}
});
`;
function stop() { // cleanup, TODO add session.detach ?
if (script !== null) {
script.unload().then(() => {
script = null;
console.log('[!] Script unloaded');
}).catch(console.error);
}
}
async function Main() {
let device = await frida.getUsbDevice();
let pid = await device.spawn([APP_ID]);
let session = await device.attach(pid);
let script = await session.createScript(source);
script.message.connect(msg => {
if (msg['type'] === 'send') {
let payload = msg['payload'];
if (typeof payload === 'object') {
console.log('[D]', payload['file'], '\n\n', payload['content']);
}
} else {
console.error('[!]', msg, '\n', msg['stack']);
}
});
await script.load();
await device.resume(pid);
process.stdin.resume(); // keep process running
process.on('SIGTERM', stop);
process.on('SIGINT', stop);
console.log('...');
}
Main().catch(console.error);

View File

@ -0,0 +1,57 @@
function dictFromNSDictionary(nsDict) {
var jsDict = {};
var keys = nsDict.allKeys();
var count = keys.count();
for (var i = 0; i < count; i++) {
var key = keys.objectAtIndex_(i);
var value = nsDict.objectForKey_(key);
jsDict[key.toString()] = value.toString();
}
return jsDict;
}
function arrayFromNSArray(nsArray) {
var jsArray = [];
var count = nsArray.count();
for (var i = 0; i < count; i++) {
jsArray[i] = nsArray.objectAtIndex_(i).toString();
}
return jsArray;
}
function infoDictionary() {
if (ObjC.available && "NSBundle" in ObjC.classes) {
var info = ObjC.classes.NSBundle.mainBundle().infoDictionary();
return dictFromNSDictionary(info);
}
return null;
}
function infoLookup(key) {
if (ObjC.available && "NSBundle" in ObjC.classes) {
var info = ObjC.classes.NSBundle.mainBundle().infoDictionary();
var value = info.objectForKey_(key);
if (value === null) {
return value;
} else if (value.class().toString() === "__NSCFArray") {
return arrayFromNSArray(value);
} else if (value.class().toString() === "__NSCFDictionary") {
return dictFromNSDictionary(value);
} else {
return value.toString();
}
}
return null;
}
console.warn(JSON.stringify({
name: infoLookup("CFBundleName"),
bundleId: ObjC.classes.NSBundle.mainBundle().bundleIdentifier().toString(),
version: infoLookup("CFBundleVersion"),
path: {
bundle: ObjC.classes.NSBundle.mainBundle().bundlePath().toString(),
data: ObjC.classes.NSProcessInfo.processInfo().environment().objectForKey_("HOME").toString(),
binary: ObjC.classes.NSBundle.mainBundle().executablePath().toString()
},
info: infoDictionary()
}, null, 2))

21
scripts/WIP_unpack_64.js Normal file
View File

@ -0,0 +1,21 @@
var art_DexFile_OpenMemory = Module.findExportByName('libart.so','_ZN3art7DexFile10OpenMemoryEPKhmRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEjPNS_6MemMapEPKNS_10OatDexFileEPS9_'); // art::DexFile::OpenMemory > 64bit version
console.log(art_DexFile_OpenMemory);
Interceptor.attach(art_DexFile_OpenMemory, {
onEnter: function (_args) {
var begin = this.context.x0;
this.o = {};
this.o.begin = begin;
this.o.magic = Memory.readUtf8String(begin);
var address = parseInt(begin, 16) + 0x20;
var dexSize = Memory.readInt(ptr(address));
this.o.dexSize = dexSize;
var file = new File('/sdcard/unpack/' + dexSize + '.dex', 'wb');
file.write(Memory.readByteArray(begin, dexSize));
file.flush();
file.close();
},
onLeave: function (retval) {
this.o.retval = retval;
console.log(JSON.stringify(this.o, null, 2));
}
});

4
scripts/android_proxy.js Normal file
View File

@ -0,0 +1,4 @@
// open proxy (not working)
Java.perform(function() {
Java.use('android.net.Proxy').setHttpProxySystemProperty(Java.use('android.net.ProxyInfo').buildDirectProxy('1.0.0.1', 8081));
});

View File

@ -0,0 +1,29 @@
/*
Enable remote debugging of Android WebViews at Runtime using Frida
run "adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'" to get the current activity
*/
Java.perform(function() {
Java.deoptimizeEverything();
var injected = false;
Java.choose('com.app.SomeActivity', {
'onMatch': function(o) {
var Runnable = Java.use('java.lang.Runnable');
var MyRunnable = Java.registerClass({
name: 'com.example.MyRunnable',
implements: [Runnable],
methods: {
'run': function() {
Java.use('android.webkit.WebView').setWebContentsDebuggingEnabled(true);
}
}
});
var runnable = MyRunnable.$new();
o.runOnUiThread(runnable);
console.log('\nWebview debug enabled......');
},
'onComplete': function() {
console.log('completed');
}
})
});

17
scripts/extact_ipa.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# Extracting IPA from Jailbroken +Frida device
# The IPA will be @ /tmp/ios_ssh/iphonessh/python-client/frida-ios-dump/AppName.ipa
mkdir /tmp/ios_ssh
cd "$_"
sudo apt-get install libgcrypt20-doc gnutls-doc gnutls-bin usbmuxd libimobiledevice*
git clone https://github.com/rcg4u/iphonessh
cd iphonessh/python-client/
chmod +x *
python2.7 tcprelay.py -t 22:2222 &
TCP_RELAY_PID=$!
git clone https://github.com/AloneMonkey/frida-ios-dump.git
cd frida-ios-dump
git checkout origin/3.x
sudo -H pip3 install -r requirements.txt --upgrade
sudo python3.6 dump.py $1 # com.app.bundle.id
kill $TCP_RELAY_PID

8
scripts/ios_ssl_unpin.js Normal file
View File

@ -0,0 +1,8 @@
var SecTrustEvaluate_prt = Module.findExportByName("Security", "SecTrustEvaluate");
var SecTrustEvaluate = new NativeFunction(SecTrustEvaluate_prt, "int", ["pointer", "pointer"]);
Interceptor.replace(SecTrustEvaluate_prt, new NativeCallback(function(trust, result) {
console.log("[*] SecTrustEvaluate(...) hit!");
SecTrustEvaluate(trust, result); // call original method
Memory.writeU8(result, 1);
return 0;
}, "int", ["pointer", "pointer"]));

View File

@ -0,0 +1,109 @@
function hook_okhttp3(classLoader) {
Java.perform(function () {
var ByteString = classLoader.use("com.android.okhttp.okio.ByteString");
var Buffer = classLoader.use("com.android.okhttp.okio.Buffer");
var Interceptor = classLoader.use("okhttp3.Interceptor");
var MyInterceptor = Java.registerClass({
name: "okhttp3.MyInterceptor",
implements: [Interceptor],
methods: {
intercept: function (chain) {
var request = chain.request();
try {
console.log("MyInterceptor.intercept onEnter:", request, "\nrequest headers:\n", request.headers());
var requestBody = request.body();
var contentLength = requestBody ? requestBody.contentLength() : 0;
if (contentLength > 0) {
var BufferObj = Buffer.$new();
requestBody.writeTo(BufferObj);
try {
console.log("\nrequest body String:\n", BufferObj.readString(), "\n");
} catch (error) {
try {
console.log("\nrequest body ByteString:\n", ByteString.of(BufferObj.readByteArray()).hex(), "\n");
} catch (error) {
console.log("error 1:", error);
}
}
}
} catch (error) {
console.log("error 2:", error);
}
var response = chain.proceed(request);
try {
console.log("MyInterceptor.intercept onLeave:", response, "\nresponse headers:\n", response.headers());
var responseBody = response.body();
var contentLength = responseBody ? responseBody.contentLength() : 0;
if (contentLength > 0) {
console.log("\nresponsecontentLength:", contentLength, "responseBody:", responseBody, "\n");
var ContentType = response.headers().get("Content-Type");
console.log("ContentType:", ContentType);
if (ContentType.indexOf("video") == -1) {
if (ContentType.indexOf("application") == 0) {
var source = responseBody.source();
if (ContentType.indexOf("application/zip") != 0) {
try {
console.log("\nresponse.body StringClass\n", source.readUtf8(), "\n");
} catch (error) {
try {
console.log("\nresponse.body ByteString\n", source.readByteString().hex(), "\n");
} catch (error) {
console.log("error 4:", error);
}
}
}
}
}
}
} catch (error) {
console.log("error 3:", error);
}
return response;
}
}
});
var ArrayList = classLoader.use("java.util.ArrayList");
var OkHttpClient = classLoader.use("okhttp3.OkHttpClient");
console.log(OkHttpClient);
OkHttpClient.$init.overload('okhttp3.OkHttpClient$Builder').implementation = function (Builder) {
console.log("OkHttpClient.$init:", this, Java.cast(Builder.interceptors(), ArrayList));
this.$init(Builder);
};
var MyInterceptorObj = MyInterceptor.$new();
var Builder = classLoader.use("okhttp3.OkHttpClient$Builder");
console.log(Builder);
Builder.build.implementation = function () {
this.interceptors().clear();
//var MyInterceptorObj = MyInterceptor.$new();
this.interceptors().add(MyInterceptorObj);
var result = this.build();
return result;
};
Builder.addInterceptor.implementation = function (interceptor) {
this.interceptors().clear();
//var MyInterceptorObj = MyInterceptor.$new();
this.interceptors().add(MyInterceptorObj);
return this;
//return this.addInterceptor(interceptor);
};
console.log("hook_okhttp3...");
});
}
Java.perform(function() {
var application = Java.use("android.app.Application");
application.attach.overload('android.content.Context').implementation = function(context) {
var result = this.attach(context); // 先执行原来的attach方法
var classloader = context.getClassLoader(); // 获取classloader
Java.classFactory.loader = classloader;
hook_okhttp3(Java.classFactory);
}
});

43
scripts/stalker.js Normal file
View File

@ -0,0 +1,43 @@
Interceptor.attach(ObjC.classes.MyClass['- myMethod:param1'].implementation, {
onEnter: function (args) {
console.warn(JSON.stringify({
fname: args[1].readCString(),
text: new ObjC.Object(args[2]).toString(),
backtrace: Thread.backtrace(this.context, Backtracer.ACCURATE).map(DebugSymbol.fromAddress).map(m => m.moduleName+'!'+m.name),
ctx: this.context
}, null, 2));
var tid = Process.getCurrentThreadId();
this.tid = tid;
Stalker.follow(tid, {
events: {
call: true
},
/*
onCallSummary: function (summary) {
Object.keys(summary).forEach(s => {
var sym = DebugSymbol.fromAddress(ptr(s));
if (sym.moduleName == 'Viber')
console.log(summary[s], sym.name);
})
}
*/
transform: function (iterator) {
var instruction;
while ((instruction = iterator.next()) !== null) {
iterator.keep();
if (instruction.mnemonic.startsWith('bl')) {
try {
console.log('#' + tid + ':' + DebugSymbol.fromAddress(ptr(instruction.operands[0].value)));
} catch (e) {
// ignoring branch&link to register
}
}
}
}
});
},
onLeave: function (retval) {
Stalker.unfollow(this.tid);
Stalker.garbageCollect();
}
})