import frida, time, subprocess, re
ADB="/opt/android-sdk/platform-tools/adb"
JS=r"""
function il2str(p){ try{ if(p.isNull())return null; var l=p.add(8).readS32(); if(l<0||l>200)return null; return p.add(0xc).readUtf16String(l);}catch(e){return "<e>";} }
function ins(){ var m=Process.findModuleByName("libil2cpp.so"); if(!m) return false;
  var b=m.base;
  var EBX=b.add(0x1df6b7c);
  var slots={ "profile[0x64bb8]":0x64bb8, "tutorials?[0x687a8]":0x687a8, "sec[0x687ac]":0x687ac,
              "del?[0x687c4]=INV-parent":0x687c4, "affil[0x687c8]":0x687c8, "prog[0x687cc]":0x687cc,
              "msg[0x6275c]":0x6275c, "clan[0x64bb8b]?":0x64bb8 };
  var out=[];
  for(var k in slots){ var slotva=EBX.add(slots[k]); var p=slotva.readPointer(); out.push(k+" -> "+il2str(p)); }
  send(out.join("\n")); return true; }
if(!ins()){ var iv=setInterval(function(){ if(ins()) clearInterval(iv); },150); }
"""
dev=frida.get_usb_device(timeout=10)
# attach to running game
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)
sc.on("message",lambda m,d: print(m.get("payload",m),flush=True))
sc.load(); time.sleep(2)
