var frida = require('frida'); var spawn = require('child_process').spawn; var injectScript = fs.readFileSync('injectScript.js', "utf8"); var workingDir = 'C:/SLRR/'; // // process.chdir(workingDir); var gameProcess = spawn( workingDir + 'StreetLegal_Redline.exe', [], { stdio: 'inherit' }); // id « » AttachHook(gameProcess.pid);
function AttachHook(pid) { frida.attach(pid) .then(function (session) { return session.createScript(injectScript); }) .then(function (script) { script.events.listen('message',function (message, data) { handleMessage(script, message.payload.name, message.payload.data); }); script.load() .then(function () { console.log('Hook script injected.'); }) .catch(function(error) { console.log('Hook Error:', error.message); }); }) }
// var pos = {x: 0.0, y: 0.0, z: 0.0, sy: 0.0, sp: 0.0, sr: 0.0, angle: 0.0}; function handleMessage(script, type, data) { if (type == "POS") { var tmp = data.split(';'); pos.x=tmp[0]; pos.y=tmp[1]; pos.z=tmp[2]; } }
// ( ) var dummy = Memory.allocAnsiString("\\\\nothing\\dev\\null"); var message=""; // CreateFileA. Hook Interceptor.attach(Module.findExportByName('kernel32.dll','CreateFileA'), { onEnter: function onEnter(args) { // message = Memory.readUtf8String(args[0]); // DTM^ ( ) // DTM^payloadname^data if (message.indexOf('DTM^') != -1) { //, , «» message = message.split('^'); send({name: message[1], data:message[2]}); } }, onLeave: function onLeave(retval) { } });
public class MultiplayerSocket { int connected = 0; // File dtm; public void MultiplayerSocket(){ dtm = new File(); } public int send(String type, String msg) { // «» , dtm = new File("&nofolder\\DTM^" + type + "^" + msg); dtm.open(File.MODE_READ); // ( error.log) dtm.close(); //. - return 0; // } } // MultiplayerSocket MP; …. public void enter(GameState prev_state ){ // MP = new MultiplayerSocket(); …. } …. // public void sendPositionDatagram() { if (MP) { if (player.car && player.car.chassis) { Vector3 pos = player.car.getPos(); // MP.send("POS", pos.x + ";" + pos.y + ";" + pos.z); // } } } // ( 30 fps) public void frame(){ sendPositionDatagram(); }
Source: https://habr.com/ru/post/275235/
All Articles