It turned out IDA sends first sends vCont;c
and then vCont;s:1
for some weird reason in that particular instance. I fixed my mitm :
const net=require("net")
const process = require('process');
net.createServer(server => {
const client = new net.Socket()
let lastcommand, response, lastterm
client.connect(50505, "localhost")
/**
* @param {Buffer} string
*/
function createResponse(string)
{
string = string.slice(0, string.length - 1)
let checksum = 0
for(const a of string) checksum += a
checksum %= 256
return "$"+string.toString()+"#"+checksum.toString(0x10)
}
client.on("data", handler = data => {
let string = data.toString()
if(string.search(/^\$T\d\d/) != -1) lastterm = string
console.log(string),
server.write(string)
})
server.on("data", handlerserver = async data => {
let string = data.toString()
console.log(string)
let cmd
if((cmd = string.replace(/^\$qRcmd,([a-f0-9]+)#/, (_, substring) => substring)) != string){
lastcommand = string = createResponse(Buffer.from(cmd, "hex"))
const innerresponse = createResponse(Buffer.from("OK\n"))
console.log(innerresponse)
server.write(innerresponse)
response = lastcommand
return
}
else if(string.search(/^\$vCont;c#a8/) != -1) return console.log(response),
client.write(response)//, response = undefined
else if(string.search(/^\$vCont;s:1#23/) != -1) return console.log(lastterm), server.write(lastterm)
client.write(string)
})
}).listen(23946, "localhost")
I basically capture the last received signal and resend it the second time.
Now I have to figure out how to add forward stepping.