yes
This commit is contained in:
commit
9c3189cac2
3219 files changed
+1984040
No files matched your search
@@ -0,0 +1,131 @@
|
||||
// sniff_gameserver.js - Frida hook to intercept game server traffic (port 11001)
|
||||
// Also hooks EOS_P2P_SendPacket/ReceivePacket for the room replication layer
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var TARGET_PORT = 11001;
|
||||
var knownGameFds = {};
|
||||
var pktCount = 0;
|
||||
|
||||
// ---- ws2_32 exports ----
|
||||
var ws2 = Process.getModuleByName('ws2_32.dll');
|
||||
var ws2exp = {};
|
||||
ws2.enumerateExports().forEach(function(e) { ws2exp[e.name] = e.address; });
|
||||
|
||||
// NativeFunction wrappers (x64 uses default calling convention)
|
||||
var getpeername_fn = new NativeFunction(ws2exp['getpeername'], 'int', ['uint', 'pointer', 'pointer']);
|
||||
|
||||
function getPeerPort(fd) {
|
||||
var buf = Memory.alloc(32);
|
||||
var lenp = Memory.alloc(4);
|
||||
lenp.writeU32(32);
|
||||
if (getpeername_fn(fd, buf, lenp) === 0 && buf.readU16() === 2) {
|
||||
return (buf.add(2).readU8() << 8) | buf.add(3).readU8();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getPeerInfo(fd) {
|
||||
var buf = Memory.alloc(32);
|
||||
var lenp = Memory.alloc(4);
|
||||
lenp.writeU32(32);
|
||||
if (getpeername_fn(fd, buf, lenp) === 0 && buf.readU16() === 2) {
|
||||
var port = (buf.add(2).readU8() << 8) | buf.add(3).readU8();
|
||||
var ip = buf.add(4).readU8() + '.' + buf.add(5).readU8() + '.' +
|
||||
buf.add(6).readU8() + '.' + buf.add(7).readU8();
|
||||
return { ip: ip, port: port };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function isGameSocket(fd) {
|
||||
if (knownGameFds[fd] !== undefined) return knownGameFds[fd];
|
||||
var port = getPeerPort(fd);
|
||||
knownGameFds[fd] = (port === TARGET_PORT);
|
||||
if (knownGameFds[fd]) {
|
||||
var info = getPeerInfo(fd);
|
||||
send({ t: 'found', fd: fd, ip: info.ip, port: info.port });
|
||||
}
|
||||
return knownGameFds[fd];
|
||||
}
|
||||
|
||||
function hexBytes(ptr, n) {
|
||||
var s = '';
|
||||
for (var i = 0; i < n; i++) {
|
||||
var b = ptr.add(i).readU8();
|
||||
s += ('0' + b.toString(16)).slice(-2);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// ---- Hook recv ----
|
||||
Interceptor.attach(ws2exp['recv'], {
|
||||
onEnter: function(args) {
|
||||
this.fd = args[0].toInt32();
|
||||
this.buf = args[1];
|
||||
},
|
||||
onLeave: function(retval) {
|
||||
var n = retval.toInt32();
|
||||
if (n > 0 && isGameSocket(this.fd)) {
|
||||
pktCount++;
|
||||
var data = this.buf.readByteArray(n);
|
||||
send({ t: 'r', n: pktCount, sz: n }, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ---- Hook send ----
|
||||
Interceptor.attach(ws2exp['send'], {
|
||||
onEnter: function(args) {
|
||||
this.fd = args[0].toInt32();
|
||||
this.buf = args[1];
|
||||
this.len = args[2].toInt32();
|
||||
},
|
||||
onLeave: function(retval) {
|
||||
var n = retval.toInt32();
|
||||
if (n > 0 && isGameSocket(this.fd)) {
|
||||
pktCount++;
|
||||
var data = this.buf.readByteArray(n);
|
||||
send({ t: 's', n: pktCount, sz: n }, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ---- Hook EOS P2P ----
|
||||
var eos = Process.getModuleByName('EOSSDK-Win64-Shipping.dll');
|
||||
var eosexp = {};
|
||||
eos.enumerateExports().forEach(function(e) { eosexp[e.name] = e.address; });
|
||||
|
||||
if (eosexp['EOS_P2P_SendPacket']) {
|
||||
Interceptor.attach(eosexp['EOS_P2P_SendPacket'], {
|
||||
onEnter: function(args) {
|
||||
// EOS_P2P_SendPacket(handle, options)
|
||||
// options->DataLengthBytes at offset, options->Data at offset
|
||||
// We just log that it was called for now
|
||||
pktCount++;
|
||||
send({ t: 'eos_send', n: pktCount });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (eosexp['EOS_P2P_ReceivePacket']) {
|
||||
Interceptor.attach(eosexp['EOS_P2P_ReceivePacket'], {
|
||||
onEnter: function(args) {
|
||||
this.outData = args[4]; // void* OutData
|
||||
this.outBytesWritten = args[5]; // uint32_t* OutBytesWritten
|
||||
},
|
||||
onLeave: function(retval) {
|
||||
if (retval.toInt32() === 0 && this.outBytesWritten) { // EOS_Success = 0
|
||||
var written = this.outBytesWritten.readU32();
|
||||
if (written > 0) {
|
||||
pktCount++;
|
||||
var data = this.outData.readByteArray(written);
|
||||
send({ t: 'eos_recv', n: pktCount, sz: written }, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
send({ t: 'ready', msg: 'Hooks installed. Watching port ' + TARGET_PORT + '. Pkt hooks: recv/send + EOS P2P.' });
|
||||
})();
|
||||
Reference in new issue
Block a user