import frida, subprocess, time
ADB="/opt/android-sdk/platform-tools/adb"
pid=int(subprocess.run([ADB,"shell","pidof","se.foglo.svt"],capture_output=True,text=True).stdout.split()[0])
print("attaching to running pid",pid,flush=True)
JS=r"""
var B=Process.findModuleByName("libil2cpp.so").base;
var sp=0, sniper=0, thief=0, mc=0, mcTrue=0;
Interceptor.attach(B.add(0xe4bd6a),{onEnter:function(){sp++;}});
Interceptor.attach(B.add(0xe4bfd8),{onEnter:function(){sniper++;send({g:"SpawnSniper CALLED"});}});
Interceptor.attach(B.add(0xe4c511),{onEnter:function(){thief++;send({g:"SpawnThief CALLED"});}});
Interceptor.attach(B.add(0xd6fede),{onLeave:function(r){mc++; if(r.toInt32())mcTrue++;}});
Interceptor.attach(B.add(0xdf9152),{onEnter:function(){send({g:"Thief.Awake!"});}});
Interceptor.attach(B.add(0xe47cab),{onEnter:function(){send({g:"GameController.Awake (new match?)"});}});
setTimeout(function(){ send({g:"5s: SpawnPlayers="+sp+" SpawnSniper="+sniper+" SpawnThief="+thief+" isMasterClient calls="+mc+" returnedTrue="+mcTrue}); }, 5000);
send({g:"probe live"});
"""
dev=frida.get_usb_device(timeout=10)
s=dev.attach(pid); sc=s.create_script(JS)
sc.on("message",lambda m,d: print(m.get("payload",{}).get("g",""),flush=True) if isinstance(m.get("payload"),dict) else print("MSG",m,flush=True))
sc.load(); time.sleep(7)
print("done",flush=True)
