Skip to content

Commit 3b1de87

Browse files
committed
fixes in identifying if friTap is running on MacOS or iOS; MacOS hooking for BoringSSL improved
1 parent 5f12a09 commit 3b1de87

File tree

6 files changed

+101
-35
lines changed

6 files changed

+101
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</p>
44

55
# friTap
6-
![version](https://img.shields.io/badge/version-1.2.6.8-blue) [![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&r=r&ts=1683906897&type=6e&v=1.2.6.8&x2=0)](https://badge.fury.io/py/friTap)
6+
![version](https://img.shields.io/badge/version-1.2.7.0-blue) [![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&r=r&ts=1683906897&type=6e&v=1.2.7.0&x2=0)](https://badge.fury.io/py/friTap)
77

88
friTap is a powerful tool designed to assist researchers in analyzing network traffic encapsulated in SSL/TLS. With its ability to automate key extraction, friTap is especially valuable when dealing with malware analysis or investigating privacy issues in applications. By simplifying the process of decrypting and inspecting encrypted traffic, friTap empowers researchers to uncover critical insights with ease.
99

agent/macos/openssl_boringssl_macos.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,33 @@ import { devlog, log } from "../util/log.js";
77
export class OpenSSL_BoringSSL_MacOS extends OpenSSL_BoringSSL {
88

99
install_tls_keys_callback_hook(){
10-
console.log(this.addresses) // currently only for debugging purposes will be removed in future releases
10+
//console.log(this.addresses) // currently only for debugging purposes will be removed in future releases
1111
if (ObjC.available) { // inspired from https://codeshare.frida.re/@andydavies/ios-tls-keylogger/
1212
var CALLBACK_OFFSET = 0x2A8;
1313

1414
var foundationNumber = Module.findExportByName('CoreFoundation', 'kCFCoreFoundationVersionNumber')?.readDouble();
15+
devlog("[*] Calculating offset to keylog callback based on the FoundationVersionNumber: "+foundationNumber)
1516
if(foundationNumber == undefined){
16-
devlog("Installing callback for iOS < 14");
1717
CALLBACK_OFFSET = 0x2A8;
18+
devlog("Installing callback for MacOS < 14 using callback offset: "+CALLBACK_OFFSET);
1819
} else if (foundationNumber >= 1751.108 && foundationNumber < 1854) {
19-
devlog("Installing callback for iOS >= 14");
2020
CALLBACK_OFFSET = 0x2B8; // >= iOS 14.x
21+
devlog("Installing callback for MacOS >= 14 using callback offset: "+CALLBACK_OFFSET);
2122
} else if (foundationNumber >= 1854 && foundationNumber < 1946.102) {
22-
devlog("Installing callback for iOS >= 15");
2323
CALLBACK_OFFSET = 0x2F8; // >= iOS 15.x
24+
devlog("Installing callback for MacOS >= 15 using callback offset: "+CALLBACK_OFFSET);
2425
} else if (foundationNumber >= 1946.102 && foundationNumber <= 1979.1) {
25-
devlog("Installing callback for iOS >= 16");
2626
CALLBACK_OFFSET = 0x300; // >= iOS 16.x
27+
devlog("Installing callback for MacOS >= 16 using callback offset: "+CALLBACK_OFFSET);
2728
} else if (foundationNumber > 1979.1) {
28-
devlog("Installing callback for iOS >= 17");
29-
CALLBACK_OFFSET = 0x308; // >= iOS 17.x
29+
CALLBACK_OFFSET = 0x2F8; // >= iOS 17.x
30+
devlog("Installing callback for MacOS >= 17 using callback offset: "+CALLBACK_OFFSET);
3031
}
3132
Interceptor.attach(this.addresses[this.module_name]["SSL_CTX_set_info_callback"], {
3233
onEnter: function (args : any) {
33-
ptr(args[0]).add(CALLBACK_OFFSET).writePointer(this.keylog_callback);
34+
var ssl_str_ptr = new NativePointer(args[0]);
35+
var callback = new NativePointer(ssl_str_ptr).add(CALLBACK_OFFSET)
36+
callback.writePointer(this.keylog_callback);
3437
}
3538
});
3639

@@ -42,7 +45,7 @@ export class OpenSSL_BoringSSL_MacOS extends OpenSSL_BoringSSL {
4245

4346
var library_method_mapping: { [key: string]: Array<string> } = {}
4447

45-
// the iOS implementation needs some further improvements - currently we are not able to get the sockfd from an SSL_read/write invocation
48+
// the MacOS implementation needs some further improvements - currently we are not able to get the sockfd from an SSL_read/write invocation
4649
library_method_mapping[`*${moduleName}*`] = ["SSL_read", "SSL_write", "BIO_get_fd", "SSL_get_session", "SSL_SESSION_get_id", "SSL_new", "SSL_CTX_set_info_callback"]
4750
library_method_mapping[`*${socket_library}*`] = ["getpeername*", "getsockname*", "ntohs*", "ntohl*"] // currently those functions gets only identified if we at an asterisk at the end
4851

agent/util/process_infos.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,38 @@ export function isAndroid(): boolean{
1717
}
1818
}
1919

20+
function is_macos_based_version_string(): boolean{
21+
// Check if NSProcessInfo is available (indicating macOS or iOS)
22+
if (ObjC.classes.NSProcessInfo !== undefined) {
23+
try {
24+
// Get the operating system version string
25+
const NSProcessInfo = ObjC.classes.NSProcessInfo;
26+
const version = NSProcessInfo.processInfo()
27+
.operatingSystemVersionString()
28+
.toString();
29+
30+
if (version.includes("iOS")) {
31+
return false;
32+
} else if (version.includes("macOS") || version.includes("OS X")) {
33+
return true;
34+
}
35+
} catch (error) {
36+
}
37+
}
38+
39+
return false;
40+
41+
}
42+
2043

2144
export function isiOS(): boolean{
2245
if(get_process_architecture() === "arm64" && Process.platform == "darwin"){
2346
try{
24-
// check if iOS or MacOS (currently we handle MacOS with ARM Processor as an iOS device)
25-
// maybe Kernel.available could be used for that or a file which is unique
26-
return true
47+
if(is_macos_based_version_string()){
48+
return false;
49+
}else{
50+
return true;
51+
}
2752
}catch(error){
2853
return false
2954
}
@@ -33,11 +58,17 @@ export function isiOS(): boolean{
3358
}
3459

3560

61+
62+
3663
export function isMacOS(): boolean{
3764
if(get_process_architecture() === "x64" && Process.platform == "darwin"){
3865
return true
3966
}else{
40-
return false
67+
if(is_macos_based_version_string()){
68+
return false;
69+
}else{
70+
return true;
71+
}
4172
}
4273
}
4374

0 commit comments

Comments
 (0)