import frida, time, subprocess, sys
sys.path.insert(0,"/root/ants"); import emu
JS=r"""
function sstr(p){try{if(p.isNull()||p.compare(ptr(0x10000))<0)return "n/a"; var n=p.add(8).readS32();if(n<0||n>200)return "notstr"; return "'"+p.add(0xc).readUtf16String(n)+"'";}catch(e){return "e";}}
function ins(){var m=Process.findModuleByName("libil2cpp.so");if(!m)return false;var b=m.base;
 [0x794653,0x79468d,0x794761,0x794795,0x7947d4].forEach(function(a){
   try{Interceptor.attach(b.add(a),{onEnter:function(){var sp=this.context.esp;
     var bt=Thread.backtrace(this.context,Backtracer.ACCURATE).slice(0,4).map(function(x){var mm=Process.findModuleByAddress(x);return mm&&mm.name=="libil2cpp.so"?"il+0x"+x.sub(mm.base).toString(16):""+x;}).join(" ");
     send({g:"LS@"+a.toString(16)+" a0="+sstr(sp.add(4).readPointer())+" i0="+sp.add(4).readS32()+" bt="+bt});}});}catch(e){}});
 try{Interceptor.attach(b.add(0xe47cab),{onEnter:function(){send({g:"GC.Awake"});}});}catch(e){}
 send({g:"__ready"});return true;}
if(!ins()){var iv=setInterval(function(){if(ins())clearInterval(iv);},100);}
"""
t=emu.launch_to_menu(); print("menu",int(t) if t else "FAIL",flush=True)
dev=frida.get_usb_device(timeout=10)
pid=int(subprocess.run([emu.ADB,"shell","pidof","se.foglo.svt"],capture_output=True,text=True).stdout.split()[0])
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 None)
sc.load(); time.sleep(0.5)
emu.tap(700,730); time.sleep(6)
print("[GO]",flush=True); emu.tap(1355,960); time.sleep(30)
print("done",flush=True)
