import frida, time, subprocess
ADB="/opt/android-sdk/platform-tools/adb"
JS=r"""
function rd(p){ try{if(p.isNull())return null;var l=p.add(8).readS32();if(l<0||l>128)return null;return p.add(0xc).readUtf16String(l);}catch(e){return null;} }
function ins(){ var m=Process.findModuleByName("libil2cpp.so"); if(!m) return false;
 var b=m.base; var seen={};
 // FetchCommodity(id) — log every id requested + whether found
 Interceptor.attach(b.add(0x22ba97),{onEnter:function(a){this.id=rd(a[0])||rd(a[1]);},onLeave:function(rv){ var k=this.id+" "+(rv.isNull()?"MISS":"OK"); if(this.id && !seen[k]){seen[k]=1; send("FetchCommodity "+k);} }});
 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 @%.1f %s"%(time.time()-t0,r),flush=True))
out=[]
def om(m,d):
    p=m.get("payload",m)
    print("[%5.1f] %s"%(time.time()-t0,p),flush=True)
sc.on("message",om); sc.load(); dev.resume(pid)
time.sleep(30)
