public
class
fbyd
extends
AbstractJni {
private
AndroidEmulator emulator;
private
VM vm;
private
final
Module module;
public
fbyd() {
emulator = AndroidEmulatorBuilder.for64Bit()
.setProcessName(
"com.byd.aeri.caranywhere"
)
.build();
final
Memory memory = emulator.getMemory();
memory.setLibraryResolver(
new
AndroidResolver(
23
));
vm = emulator.createDalvikVM(
new
File(
"unidbg-android/src/test/java/com/byd/aeri/caranywhere/byd770.apk"
));
vm.setJni(
this
);
vm.setVerbose(
true
);
new
AndroidModule(emulator, vm).register(memory);
DalvikModule dm = vm.loadLibrary(
new
File(
"unidbg-android/src/test/java/com/byd/aeri/caranywhere/libencrypt.so_0x7026013000_0x1d9000_fix.so"
),
true
);
module = dm.getModule();
dm.callJNI_OnLoad(emulator);
}
@Override
public
DvmObject<?> callStaticObjectMethod(BaseVM vm, DvmClass dvmClass, String signature, VarArg varArg) {
switch
(signature) {
case
"android/app/ActivityThread->currentActivityThread()Landroid/app/ActivityThread;"
:
return
vm.resolveClass(
"android/app/ActivityThread"
).newObject(
null
);
case
"android/os/SystemProperties->get(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"
:
String arg = varArg.getObjectArg(
0
).getValue().toString();
System.out.println(
"SystemProperties get arg===>"
+ arg);
if
(arg.equals(
"ro.serialno"
)) {
return
new
StringObject(vm,
"9B131FFBA001Y5"
);
}
}
return
super
.callStaticObjectMethod(vm, dvmClass, signature, varArg);
}
@Override
public
DvmObject<?> callObjectMethod(BaseVM vm, DvmObject<?> dvmObject, String signature, VarArg varArg) {
switch
(signature){
case
"android/app/ActivityThread->getSystemContext()Landroid/app/ContextImpl;"
:
return
vm.resolveClass(
"android/app/ContextImpl"
).newObject(
null
);
case
"android/app/ContextImpl->getPackageManager()Landroid/content/pm/PackageManager;"
:
return
vm.resolveClass(
"android/content/pm/PackageManager"
).newObject(
null
);
case
"android/app/ContextImpl->getSystemService(Ljava/lang/String;)Ljava/lang/Object;"
:
String arg = varArg.getObjectArg(
0
).getValue().toString();
System.out.println(
"getSystemService arg ===> "
+arg);
return
vm.resolveClass(
"android.net.wifi"
).newObject(signature);
case
"android/net/wifi->getConnectionInfo()Landroid/net/wifi/WifiInfo;"
:
return
vm.resolveClass(
"android/net/wifi/WifiInfo"
).newObject(
null
);
case
"android/net/wifi/WifiInfo->getMacAddress()Ljava/lang/String;"
:
return
new
StringObject(vm,
"02:00:00:00:00:00"
);
}
return
super
.callObjectMethod(vm, dvmObject, signature, varArg);
}
public
static
void
main(String[] args) {
fbyd b =
new
fbyd();
}
}