You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: INTEGRATION.md
+149-3Lines changed: 149 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,9 @@ The following example demonstrates how to use `friTap` to hook into an applicati
11
11
### **Code Example**
12
12
13
13
```python
14
+
#!/usr/bin/env python3
15
+
# -*- coding: utf-8 -*-
16
+
14
17
from friTap importSSL_Logger
15
18
import sys
16
19
@@ -26,7 +29,7 @@ try:
26
29
app_package,
27
30
verbose=True, # Enable verbose output
28
31
mobile=True, # Indicate that the target app is running on a mobile device
29
-
keylog="keylogtest3.log", # Path to save SSL key log
32
+
keylog="keylogtest.log", # Path to save SSL key log
30
33
debug_output=True# Enable debug output
31
34
)
32
35
@@ -68,17 +71,160 @@ except KeyboardInterrupt:
68
71
|`payload_modification`|`bool`|`False`| Enable payload modification during traffic capture. |
69
72
|`enable_default_fd`|`bool`|`False`| Enable default file descriptor handling. |
70
73
|`patterns`|`list`|`None`| List of patterns to match during traffic capture. |
71
-
|`custom_hook_script`|`str`|`None`| Path to a custom Frida hook script to be executed during the session. |
74
+
|`custom_hook_script`|`str`|`None`| Path to a custom Frida hook script to be executed during the session. These hooks are installed prior to the installation of friTap hooks.|
72
75
73
76
---
74
77
78
+
## Advanced Usage: Integrating friTap with Custom Handler
79
+
80
+
If you'd like to integrate friTap into your project but prefer to manage Frida yourself, friTap offers advanced flexibility. With this approach, you can either:
81
+
82
+
- Retrieve the friTap script Path: Use `ssl_log.get_fritap_frida_script_path()` to obtain the path to the friTap Frida script. You can then manually load the script into your target process.
83
+
- Use the Advanced API: Utilize the `start_fritap_session_instrumentation(own_message_handler, process)` API to integrate friTap while managing Frida yourself.
84
+
-`on_message_handler`: Your custom handler function to process messages between the script and your Python code.
85
+
-`process`: The Frida process object you manage, which can be created by spawning or attaching to the target application.
86
+
87
+
This API gives you full control over when the friTap script is loaded into the target process. It returns the script object, allowing you to load the script at your preferred time. Below is an example of how to use this API:
# Manually load the friTap script into the target process
160
+
script.load()
161
+
162
+
# Wait for the user to interrupt
163
+
sys.stdin.read()
164
+
165
+
exceptKeyboardInterrupt:
166
+
# Detach the process when interrupted
167
+
process.detach()
168
+
print("friTap logging stopped.")
169
+
170
+
```
171
+
172
+
Key Notes about this approach:
173
+
174
+
- Script Loading: The `start_fritap_session_instrumentation` API provides the script object but does not automatically load it. This gives you full control over when the friTap hooks are injected.
175
+
- Custom Message Handler: Your on_message_handler function allows you to handle Frida messages and data flexibly. When managing the handler yourself, it is mandatory to ensure that certain internal friTap variables are correctly communicated with the Frida script. Failing to do so will halt the installation of the friTap hooks, as they depend on values from the Python environment to determine how certain hooks should be applied.
176
+
- Full Control: This approach is ideal for advanced use cases where you want precise management of Frida processes and script lifecycle.
177
+
178
+
### Understanding Frida Messages in friTap
179
+
180
+
In friTap, the `on_fritap_message(self, job, message, data)` handler processes messages sent from the Frida script. These messages contain important information about the operation of friTap. The key fields in the message are:
181
+
182
+
-**`payload`**: This field contains a structured dictionary with a `contentType` key that determines the type of the message. The specific `contentType` dictates how the remaining fields in the `payload` are interpreted. The structure looks like this `'payload': {'contentType': '<content type>', '<content key>': <content value>}`
183
+
-**`data`**: This field contains the decrypted TLS payload when the `contentType` is `datalog`. In other cases, the `data` field is typically unused and the focus remains on the `payload` field.
184
+
185
+
Here are the different `contentType` values and their meanings:
|`datalog`| Contains decrypted TLS payload data and associated socket information. Useful for analyzing TLS traffic. |`datalog`|
190
+
|`console_dev`| Debug output intended for development and troubleshooting, such as scanning logs or fallback patterns. |`console_dev`|
191
+
|`console_error`| Error messages encountered during the operation of friTap. |`console_error`|
192
+
|`console`| Standard output messages visible to the user when running friTap. |`console`|
193
+
|`keylog`| Extracted TLS key material from the target application. |`keylog`|
194
+
195
+
**Key Details**:
196
+
197
+
1.**Decrypted TLS Data**:
198
+
- When `contentType` is `datalog`, the `data` field contains the decrypted TLS payload (if available), along with associated socket information.
199
+
200
+
2.**Development Logs**:
201
+
-`console_dev` messages provide insights into debug operations, which are helpful during development or when fixing bugs.
202
+
203
+
3.**Error Handling**:
204
+
- Error messages (`console_error`) help identify problems within friTap’s execution.
205
+
206
+
4.**User Output**:
207
+
-`console` messages are meant for the user and reflect key operational statuses.
208
+
209
+
5.**TLS Key Extraction**:
210
+
-`keylog` messages provide extracted key material for analyzing the cryptographic state of the target application.
211
+
212
+
By using the `contentType` as the key, you can access specific fields in the `payload` to analyze the messages accordingly.
213
+
214
+
215
+
216
+
By using this API, you can seamlessly integrate friTap while maintaining complete control over Frida's operation in your application.
217
+
75
218
## Advanced Usage: Using friTap as a Job in AndroidFridaManager
76
219
77
220
friTap can also be used as a job within the `AndroidFridaManager` framework. This allows you to manage friTap sessions as part of a larger job workflow.
78
221
79
222
### **Code Example**
80
223
81
224
```python
225
+
#!/usr/bin/env python3
226
+
# -*- coding: utf-8 -*-
227
+
82
228
from friTap importSSL_Logger
83
229
from AndroidFridaManager import JobManager
84
230
import sys
@@ -97,7 +243,7 @@ try:
97
243
ssl_log = SSL_Logger(
98
244
app_package,
99
245
verbose=True, # Enable verbose output
100
-
keylog="keylogtest3.log", # Path to save SSL key log
246
+
keylog="keylogjobtest.log", # Path to save SSL key log
print("[*] YOU ARE TRYING TO WRITE A PCAP AND HAVING A LIVE VIEW\nTHIS IS NOT SUPPORTED!\nWHEN YOU DO A LIVE VIEW YOU CAN SAFE YOUR CAPUTRE WITH WIRESHARK.")
431
-
fifo_file = self.temp_fifo()
432
-
print(f'[*] friTap live view on Wireshark')
433
-
print(f'[*] Created named pipe for Wireshark live view to {fifo_file}')
434
-
print(
435
-
f'[*] Now open this named pipe with Wireshark in another terminal: sudo wireshark -k -i {fifo_file}')
436
-
print(f'[*] friTap will continue after the named pipe is ready....\n')
0 commit comments