import frida, time, subprocess
ADB="/opt/android-sdk/platform-tools/adb"
JS=r"""
function cls(p){try{var gc=Module.findExportByName("libil2cpp.so","il2cpp_object_get_class");var gn=Module.findExportByName("libil2cpp.so","il2cpp_class_get_name");var gns=Module.findExportByName("libil2cpp.so","il2cpp_class_get_namespace");if(!gc)return "?";var k=new NativeFunction(gc,'pointer',['pointer'])(p);var n=new NativeFunction(gn,'pointer',['pointer'])(k).readUtf8String();var ns=new NativeFunction(gns,'pointer',['pointer'])(k).readUtf8String();return (ns?ns+".":"")+n;}catch(e){return "clserr";}}
function tname(k){try{var gn=Module.findExportByName("libil2cpp.so","il2cpp_class_get_name");return new NativeFunction(gn,'pointer',['pointer'])(k).readUtf8String();}catch(e){return "?";}}
function ins(){var m=Process.findModuleByName("libil2cpp.so");if(!m)return false;var b=m.base;
 Interceptor.attach(b.add(0xea27d3),{onEnter:function(){send({info:"OnSelectSniperMode"});}});
 Interceptor.attach(b.add(0xd31a4f),{onEnter:function(){send({info:"Matchmaking.Initiate"});}});
 Interceptor.attach(b.add(0xd34fb9),{onEnter:function(a){ try{ send({info:"recv(a2) class = "+(a[2].isNull()?"null":cls(a[2]))}); }catch(e){} }});
 Interceptor.attach(b.add(0x13a1ff6),{onEnter:function(a){var ra=this.returnAddress;var lo=b.add(0xd34fb9),hi=b.add(0xd358f2); if(ra.compare(lo)>=0&&ra.compare(hi)<0){ try{send({info:"  extract(idx="+a[2].toInt32()+", type="+tname(a[3])+")"});}catch(e){} } }});
 var ab=Process.findModuleByName("libc.so").findExportByName("abort");Interceptor.attach(ab,{onEnter:function(){send({info:"ABORT"});}});
 send({info:"__ready"});return true;}
if(!ins()){var iv=setInterval(function(){if(ins())clearInterval(iv);},120);}
"""
subprocess.run([ADB,"shell","am","force-stop","se.foglo.svt"]); time.sleep(3)
subprocess.run([ADB,"shell","monkey","-p","se.foglo.svt","-c","android.intent.category.LAUNCHER","1"],stdout=-3,stderr=-3)
time.sleep(44)
dev=frida.get_usb_device(timeout=10)
pid=int(subprocess.run([ADB,"shell","pidof","se.foglo.svt"],capture_output=True,text=True).stdout.split()[0])
s=dev.attach(pid); sc=s.create_script(JS)
got={"sel":False}
def om(mm,d):
    p=mm.get("payload",mm); 
    if isinstance(p,dict) and "OnSelectSniperMode" in str(p.get("info","")): got["sel"]=True
    print(p,flush=True)
sc.on("message",om); sc.load(); time.sleep(1)
for _ in range(4):
    if got["sel"]: break
    subprocess.run([ADB,"shell","input","tap","690","730"]); time.sleep(3)
time.sleep(2)
subprocess.run([ADB,"shell","input","tap","1350","960"]); time.sleep(10)
