Last active
October 18, 2018 17:55
-
-
Save virtualminds/49de0e4a4530c0dfbe7a61dc1edc69c1 to your computer and use it in GitHub Desktop.
frida libmono ssl read
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
onEnter: function (log, args, state) { | |
soname = Memory.readUtf8String(args[0]); | |
if(soname.includes('libmono-btls-shared.so')) { | |
log("libmono-btls-shared.so cargada!"); | |
this.dlopen = true; | |
this.dlopenMonitor = false; | |
} | |
}, | |
onLeave: function (log, retval, state) { | |
if(this.dlopen && !this.dlopenMonitor) { | |
// Obtenemos la dirección de los syms mono_btls_ssl_read y mono_btls_ssl_write | |
symSSLRead = Module.findExportByName("libmono-btls-shared.so", "mono_btls_ssl_read"); | |
symSSLWrite = Module.findExportByName("libmono-btls-shared.so", "mono_btls_ssl_write"); | |
// De paso pillamos dlsym, es gratis. | |
symdlsym = Module.findExportByName(null, "dlsym"); | |
/* Descomentar si quereis ver cuando carga los simbolos de mono | |
if(symdlsym) { | |
Interceptor.attach(symdlsym, { | |
onEnter: function (args) { | |
symbol = Memory.readUtf8String(args[1]); | |
if(symbol.includes("mono_")) { | |
console.log("Simbolo: " + symbol); | |
} | |
}, | |
onLeave: function (retval) { | |
} | |
}); | |
} | |
*/ | |
if(symSSLRead && symSSLWrite) { | |
log("Interceptando SSL_Read"); | |
// Interceptamos las llamada a ssl_read | |
log(Interceptor.attach(symSSLRead, { | |
onEnter: function (args) { | |
// Estos valores los necesitamos para luego. bp == buffer | count == numero de bytes leidos/escritos | |
this.bp = args[1] | |
this.count = args[2].toInt32(); | |
}, | |
onLeave: function (retval) { | |
// Printamos el buffer despues de la ejecucion | |
numBytes = retval.toInt32(); | |
if (numBytes > 0) { | |
console.log("mono_btls_ssl_read"); | |
console.log(hexdump(this.bp, { length: numBytes, ansi: true })); | |
} | |
} | |
})); | |
log("Interceptando SSL_Write"); | |
// same shit pero con write | |
log(Interceptor.attach(symSSLWrite, { | |
onEnter: function (args) { | |
this.bp = args[1] | |
this.count = args[2].toInt32(); | |
}, | |
onLeave: function (retval) { | |
numBytes = retval.toInt32(); | |
if (numBytes > 0) { | |
console.log("mono_btls_ssl_write"); | |
console.log(hexdump(this.bp, { length: numBytes, ansi: true })); | |
} | |
} | |
} | |
)); | |
// y lo marcamos como interceptado para no repetir el proceso | |
this.dlopenMonitor = true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment