@@ -40,8 +40,8 @@ const TARGET_LIBS = [
40
40
] ;
41
41
42
42
TARGET_LIBS . forEach ( ( targetLib ) => {
43
- waitForModule ( targetLib . name , ( moduleName ) => {
44
- patchTargetLib ( moduleName ) ;
43
+ waitForModule ( targetLib . name , ( targetModule ) => {
44
+ patchTargetLib ( targetModule , targetLib . name ) ;
45
45
targetLib . hooked = true ;
46
46
} ) ;
47
47
@@ -56,36 +56,36 @@ TARGET_LIBS.forEach((targetLib) => {
56
56
}
57
57
} ) ;
58
58
59
- function patchTargetLib ( targetLib ) {
59
+ function patchTargetLib ( targetModule , targetName ) {
60
60
// Get the peer certificates from an SSL pointer. Returns a pointer to a STACK_OF(CRYPTO_BUFFER)
61
61
// which requires use of the next few methods below to actually access.
62
62
// https://commondatastorage.googleapis.com/chromium-boringssl-docs/ssl.h.html#SSL_get0_peer_certificates
63
63
const SSL_get0_peer_certificates = new NativeFunction (
64
- Module . findExportByName ( targetLib , 'SSL_get0_peer_certificates' ) ,
64
+ targetModule . getExportByName ( 'SSL_get0_peer_certificates' ) ,
65
65
'pointer' , [ 'pointer' ]
66
66
) ;
67
67
68
68
// Stack methods:
69
69
// https://commondatastorage.googleapis.com/chromium-boringssl-docs/stack.h.html
70
70
const sk_num = new NativeFunction (
71
- Module . findExportByName ( targetLib , 'sk_num' ) ,
71
+ targetModule . getExportByName ( 'sk_num' ) ,
72
72
'size_t' , [ 'pointer' ]
73
73
) ;
74
74
75
75
const sk_value = new NativeFunction (
76
- Module . findExportByName ( targetLib , 'sk_value' ) ,
76
+ targetModule . getExportByName ( 'sk_value' ) ,
77
77
'pointer' , [ 'pointer' , 'int' ]
78
78
) ;
79
79
80
80
// Crypto buffer methods:
81
81
// https://commondatastorage.googleapis.com/chromium-boringssl-docs/pool.h.html
82
82
const crypto_buffer_len = new NativeFunction (
83
- Module . findExportByName ( targetLib , 'CRYPTO_BUFFER_len' ) ,
83
+ targetModule . getExportByName ( 'CRYPTO_BUFFER_len' ) ,
84
84
'size_t' , [ 'pointer' ]
85
85
) ;
86
86
87
87
const crypto_buffer_data = new NativeFunction (
88
- Module . findExportByName ( targetLib , 'CRYPTO_BUFFER_data' ) ,
88
+ targetModule . getExportByName ( 'CRYPTO_BUFFER_data' ) ,
89
89
'pointer' , [ 'pointer' ]
90
90
) ;
91
91
@@ -118,7 +118,7 @@ function patchTargetLib(targetLib) {
118
118
}
119
119
pendingCheckThreads . add ( threadId ) ;
120
120
121
- if ( targetLib !== 'libboringssl.dylib' ) {
121
+ if ( targetName !== 'libboringssl.dylib' ) {
122
122
// Cronet assumes its callback is always called, and crashes if not. iOS's BoringSSL
123
123
// meanwhile seems to use some negative checks in its callback, and rejects the
124
124
// connection independently of the return value here if it's called with a bad cert.
@@ -171,8 +171,8 @@ function patchTargetLib(targetLib) {
171
171
} ;
172
172
173
173
const customVerifyAddrs = [
174
- Module . findExportByName ( targetLib , "SSL_set_custom_verify" ) ,
175
- Module . findExportByName ( targetLib , "SSL_CTX_set_custom_verify" )
174
+ targetModule . findExportByName ( "SSL_set_custom_verify" ) ,
175
+ targetModule . findExportByName ( "SSL_CTX_set_custom_verify" )
176
176
] . filter ( Boolean ) ;
177
177
178
178
customVerifyAddrs . forEach ( ( set_custom_verify_addr ) => {
@@ -190,14 +190,14 @@ function patchTargetLib(targetLib) {
190
190
191
191
if ( customVerifyAddrs . length ) {
192
192
if ( DEBUG_MODE ) {
193
- console . log ( `[+] Patched ${ customVerifyAddrs . length } ${ targetLib } verification methods` ) ;
193
+ console . log ( `[+] Patched ${ customVerifyAddrs . length } ${ targetName } verification methods` ) ;
194
194
}
195
- console . log ( `== Hooked native TLS lib ${ targetLib } ==` ) ;
195
+ console . log ( `== Hooked native TLS lib ${ targetName } ==` ) ;
196
196
} else {
197
- console . log ( `\n !!! Hooking native TLS lib ${ targetLib } failed - no verification methods found` ) ;
197
+ console . log ( `\n !!! Hooking native TLS lib ${ targetName } failed - no verification methods found` ) ;
198
198
}
199
199
200
- const get_psk_identity_addr = Module . findExportByName ( targetLib , "SSL_get_psk_identity" ) ;
200
+ const get_psk_identity_addr = targetModule . findExportByName ( "SSL_get_psk_identity" ) ;
201
201
if ( get_psk_identity_addr ) {
202
202
// Hooking this is apparently required for some verification paths which check the
203
203
// result is not 0x0. Any return value should work fine though.
0 commit comments