function
hook_pthread() {
var
pthread_create_addr = Module.findExportByName(
'libc.so'
,
'pthread_create'
);
console.log(
"pthread_create_addr,"
, pthread_create_addr);
var
pthread_create =
new
NativeFunction(pthread_create_addr,
"int"
, [
"pointer"
,
"pointer"
,
"pointer"
,
"pointer"
]);
Interceptor.replace(pthread_create_addr,
new
NativeCallback(
function
(a,b,c,d) {
var
m = Process.getModuleByName(
"libexec.so"
);
var
base = m.base;
var
so_name = Process.getModuleByAddress(c).name;
var
so_path = Process.getModuleByAddress(c).path;
var
offset = c.sub(base);
console.log(
"so_name"
, so_name,
"offset"
, offset,
"path"
, so_path,
"parg2"
, c);
var
PC = 0;
if
((so_name.indexOf(
"libexec.so"
) > -1) || (so_name.indexOf(
"xxxx"
) > -1)) {
console.log(
"find thread func offset"
, so_name, offset);
if
((0x4400c === offset)) {
console.log(
"anti bypass"
);
}
else
if
(0x44060 === offset) {
console.log(
"anti bypass"
);
}
else
{
PC = pthread_create(a,b,c,d);
console.log(
"ordinary sequence"
, PC)
}
}
else
{
PC = pthread_create(a,b,c,d);
}
return
PC;
},
"int"
, [
"pointer"
,
"pointer"
,
"pointer"
,
"pointer"
]))
}