Skip to content

Commit 584c047

Browse files
author
daniel baier
committed
update the standalone version
1 parent 54825cb commit 584c047

File tree

2 files changed

+58
-14
lines changed

2 files changed

+58
-14
lines changed

create_standalone_release/createRelease.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
def create_tmp_release_folder():
1515
os.mkdir(tmp_folder_name)
16-
shutil.copy("android.py", tmp_folder_name)
17-
shutil.copy("pcap.py", tmp_folder_name)
18-
shutil.copy("__init__.py", tmp_folder_name)
16+
shutil.copy("../friTap/android.py", tmp_folder_name)
17+
shutil.copy("../friTap/pcap.py", tmp_folder_name)
18+
shutil.copy("../friTap/__init__.py", tmp_folder_name)
1919
shutil.copy("__main__.py", tmp_folder_name)
2020

2121

@@ -30,7 +30,7 @@ def create_executable_archive():
3030
zipapp.create_archive(tmp_folder_name,target=release_string,interpreter="/usr/bin/env python3")
3131

3232
def main():
33-
with open('../_ssl_log.js') as js_File:
33+
with open('../friTap/_ssl_log.js') as js_File:
3434
frida_js_code = js_File.readlines()
3535

3636
with open("./friTap_release_template.py", "r") as f:

create_standalone_release/friTap_release_template.py

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
import sys
1313
import tempfile
1414
import json
15-
import pcap
15+
import pcap as pcap
16+
from __init__ import __version__
17+
from __init__ import __author__
18+
from __init__ import debug
1619

1720
try:
1821
import hexdump # pylint: disable=g-import-not-at-top
1922
except ImportError:
2023
print("Unable to import hexdump module!")
2124
pass
2225

23-
__author__ = "Daniel Baier, Francois Egner, Max Ufer"
24-
__version__ = "1.0.3"
25-
2626

2727

2828

@@ -46,6 +46,9 @@
4646
# Names of all supported write functions:
4747
SSL_WRITE = ["SSL_write", "wolfSSL_write", "writeApplicationData", "NSS_write","Full_write"]
4848

49+
# here - where we are.
50+
here = os.path.abspath(os.path.dirname(__file__))
51+
4952

5053

5154
def cleanup(live=False, socket_trace=False, full_capture=False, debug_output=False):
@@ -96,7 +99,9 @@ def temp_fifo():
9699
print(f'Failed to create FIFO: {e}')
97100

98101

99-
def ssl_log(app, pcap_name=None, verbose=False, spawn=False, keylog=False, enable_spawn_gating=False, mobile=False, live=False, environment_file=None, debug_output=False,full_capture=False, socket_trace=False, host=False):
102+
def ssl_log(app, pcap_name=None, verbose=False, spawn=False, keylog=False, enable_spawn_gating=False, mobile=False, live=False, environment_file=None, debug_output=False,full_capture=False, socket_trace=False, host=False, offsets=None):
103+
global debug
104+
debug = debug_output
100105

101106

102107
def on_message(message, data):
@@ -191,20 +196,54 @@ def on_spawn_added(spawn):
191196
device.resume(spawn.pid)
192197

193198
def instrument(process):
194-
with open("_ssl_log.js") as f:
195-
script = process.create_script(f.read())
199+
runtime="qjs"
200+
if debug:
201+
if frida.__version__ < "16":
202+
process.enable_debugger(1337)
203+
print("\n[!] running in debug mode")
204+
print("[!] Chrome Inspector server listening on port 1337\n")
205+
runtime="v8"
206+
207+
with open(os.path.join(here, '_ssl_log.js')) as f:
208+
script_string = f.read()
209+
210+
if offsets_data is not None:
211+
print(offsets_data)
212+
script_string = script_string.replace('"{OFFSETS}"', offsets_data)
213+
214+
script = process.create_script(script_string, runtime=runtime)
215+
216+
if debug and frida.__version__ >= "16":
217+
script.enable_debugger(1337)
196218
script.on("message", on_message)
197219
script.load()
198220

199221
# Main code
200222
global pcap_obj
223+
global offsets_data
224+
201225
if mobile:
202226
device = frida.get_usb_device()
203227
elif host:
204228
device = frida.get_device_manager().add_remote_device(host)
205229
else:
206230
device = frida.get_local_device()
207231

232+
233+
if offsets is not None:
234+
if os.path.exists(offsets):
235+
file = open(offsets, "r")
236+
offsets_data = file.read()
237+
file.close()
238+
else:
239+
try:
240+
json.load(offsets)
241+
offsets_data = offsets
242+
except ValueError as e:
243+
print("Log error, defaulting to auto-detection?")
244+
else:
245+
offsets_data = None
246+
208247
device.on("child_added", on_child_added)
209248
if enable_spawn_gating:
210249
device.enable_spawn_gating()
@@ -279,7 +318,7 @@ def error(self, message):
279318
self.exit(0)
280319

281320

282-
if __name__ == "__main__":
321+
def main():
283322

284323
parser = ArgParser(
285324
add_help=False,
@@ -322,6 +361,8 @@ def error(self, message):
322361
help="Catch newly spawned processes. ATTENTION: These could be unrelated to the current process!")
323362
args.add_argument("exec", metavar="<executable/app name/pid>",
324363
help="executable/app whose SSL calls to log")
364+
args.add_argument("--offsets", required=False, metavar="<offsets.json>",
365+
help="Provide custom offsets for all hooked functions inside a JSON file or a json string containing all offsets. For more details see our example json (offsets_example.json)")
325366
parsed = parser.parse_args()
326367

327368
if parsed.full_capture and parsed.pcap is None:
@@ -331,7 +372,7 @@ def error(self, message):
331372
try:
332373
print("Start logging")
333374
ssl_log(parsed.exec, parsed.pcap, parsed.verbose,
334-
parsed.spawn, parsed.keylog, parsed.enable_spawn_gating, parsed.mobile, parsed.live, parsed.environment, parsed.debug, parsed.full_capture, parsed.socket_tracing,parsed.host)
375+
parsed.spawn, parsed.keylog, parsed.enable_spawn_gating, parsed.mobile, parsed.live, parsed.environment, parsed.debug, parsed.full_capture, parsed.socket_tracing, parsed.host, parsed.offsets)
335376

336377
except Exception as ar:
337378
print(ar)
@@ -349,6 +390,9 @@ def error(self, message):
349390
pcap_obj.android_Instance.pull_pcap_from_device()
350391
print(f"[*] full {capture_type} capture safed to _{parsed.pcap}")
351392

352-
393+
353394
cleanup(parsed.live,parsed.socket_tracing,parsed.full_capture,parsed.debug)
354395

396+
397+
if __name__ == "__main__":
398+
main()

0 commit comments

Comments
 (0)