Skip to content

Commit a07671f

Browse files
authored
Merge pull request #146 from acomerlatto/main
feat(native-connect-hook): enhance support for system connection hooks
2 parents 426bd4e + 09cd59b commit a07671f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

native-connect-hook.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
? 4
3030
: 2048; // Linux/Android
3131

32-
let systemModule, fcntl, send, recv;
32+
let fcntl, send, recv, conn;
3333
try {
34-
systemModule = Process.findModuleByName('libc.so') ?? // Android
34+
const systemModule = Process.findModuleByName('libc.so') ?? // Android
3535
Process.findModuleByName('libc.so.6') ?? // Linux
3636
Process.findModuleByName('libsystem_kernel.dylib'); // iOS
3737

@@ -40,13 +40,15 @@
4040
fcntl = new NativeFunction(systemModule.getExportByName('fcntl'), 'int', ['int', 'int', 'int']);
4141
send = new NativeFunction(systemModule.getExportByName('send'), 'ssize_t', ['int', 'pointer', 'size_t', 'int']);
4242
recv = new NativeFunction(systemModule.getExportByName('recv'), 'ssize_t', ['int', 'pointer', 'size_t', 'int']);
43+
44+
conn = systemModule.getExportByName('connect')
4345
} catch (e) {
4446
console.error("Failed to set up native hooks:", e.message);
4547
console.warn('Could not initialize system functions to to hook raw traffic');
4648
return;
4749
}
4850

49-
Interceptor.attach(systemModule.getExportByName('connect'), {
51+
Interceptor.attach(conn, {
5052
onEnter(args) {
5153
const fd = this.sockFd = args[0].toInt32();
5254
const sockType = Socket.type(fd);

0 commit comments

Comments
 (0)