Parte 3

Interceptor arguments:

onEnter: function(args);

⇒ args: son un tipo de Puntero nativo.

1
2
3
4
5
6
7
8
9
10
11
var sleep = Module.getExportByName(null, "sleep");

Interceptor.attach(sleep, {
onEnter: function(args) {
console.log("[*] Argument for sleep() => " + parseInt(args[0]));
console.log("[*] Sleep from Frida!");
},
onLeave: function(retval) {
console.log("[*] Done sleeping from Frida!");
}
});
1
./pew
1
frida pew -l interceptor-attach.js

• Ahora modificaremos el argumento de sleep() con Integers:

args[0] = ptr(“0x01”);

Ó

args[0] = new NativePointer(“0x01”);

1
2
3
4
5
6
7
8
9
10
11
12
var sleep = Module.getExportByName(null, "sleep");

Interceptor.attach(sleep, {
onEnter: function(args) {
console.log("[*] Argument for sleep() => " + parseInt(args[0]));
args[0] = ptr("0x01");
console.log("[*] Sleep from Frida!");
},
onLeave: function(retval) {
console.log("[*] Done sleeping from Frida!");
}
});
1
2
3
4
5
6
7
var printf = Module.getExportByName(null, "printf");

Interceptor.attach(printf, {
onEnter: function(args) {
console.log(JSON.stringify(this.context, null, 4));
}
});

*(Va guardando los valores en el registro rsi).*

1
2
3
4
5
6
7
var rand_range = DebugSymbol.getFunctionByName("rand_range");

Interceptor.attach(rand_range, {
onLeave: function(retval) {
console.log(retval);
}
});
1
2
3
4
5
6
7
8
9
onEnter: ftunction(a) {
this.value = ptr("0x01");
},

#this is in scope

onLeave: function(r) {
r.replace(this.value);
}

→ Nos saldrá uno en el sleeping debido a que arg1 siempre valdrá uno por que adquiere el valor del primer argumento.