import frida, time, subprocess
ADB="/opt/android-sdk/platform-tools/adb"
JS=r"""
function ins(){ var m=Process.findModuleByName("libil2cpp.so"); if(!m) return false;
 var b=m.base; var t0=Date.now();
 function H(a,n){ Interceptor.attach(b.add(a),{onEnter:function(){ send(((Date.now()-t0))+" "+n); }}); }
 H(0xd8c232,"LoadInventoryItem");
 H(0x10287c6,"  OwnedRifle.ctor");
 H(0x10282a5,"  OwnedBag.ctor");
 H(0xd9086e,"LinkInventory");
 H(0xd8b417,"LoadProfile");
 Interceptor.attach(b.add(0xd99193),{onEnter:function(){send("SetEquippedRifle");}});
 var ab=Process.findModuleByName("libc.so").findExportByName("abort");
 Interceptor.attach(ab,{onEnter:function(){send("*** ABORT ***");}});
 send("__ready"); return true; }
if(!ins()){ var iv=setInterval(function(){ if(ins()) clearInterval(iv); },120); }
"""
subprocess.run([ADB,"shell","am","force-stop","se.foglo.svt"])
dev=frida.get_usb_device(timeout=10); pid=dev.spawn(["se.foglo.svt"])
s=dev.attach(pid); sc=s.create_script(JS); t0=time.time()
s.on("detached", lambda r,c=None: print("DETACH %s"%r,flush=True))
sc.on("message",lambda m,d: print(m.get("payload",m),flush=True))
sc.load(); dev.resume(pid); time.sleep(40)
