New Agma.io Bot

dog sora

// ==UserScript==
// @name         New Agma.io Bot
// @namespace    http://tampermonkey.net/
// @version      2024-03-25
// @description  dog sora
// @author       You
// @match        *://agma.io/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        unsafeWindow
// ==/UserScript==
unsafeWindow.bots =[];
unsafeWindow.create = (amount)=>{for(let i=0;i<amount;i++){
unsafeWindow.bots.push(new Bot(url,i))
}}
class Writer {
    constructor(n) {
      this.buffer = new DataView(new ArrayBuffer(n));
      this.position = 0;
      this.littleEndian = true;
    }
    ["setString"](n) {
      for (let r = 0;r<n.length; r++) {
        this.setUint16(n.charCodeAt(r));
      }
      return this;
    }
    ["setInt8"](n) {
      this.buffer.setInt8(this.position++, n);
      return this;
    }
    ["setUint8"](n) {
      this.buffer.setUint8(this.position++, n);
      return this;
    }
    ["setInt16"](n) {
      this.buffer.setInt16(((this.position += 2)-2), n, this.littleEndian);
      return this;
    }
    ["setUint16"](n) {
      this.buffer.setUint16(((this.position += 2)- 2), n, this.littleEndian);
      return this;
    }
    ["setInt32"](n) {
      this.buffer.setInt32(((this.position += 4)- 4), n, this.littleEndian);
      return this;
    }
    ["setUint32"](n) {
      if (((n%1) != 0) && (88==n.toString().slice(-2))) {
        n += 4;
      }
      this.buffer.setUint32(((this.position += 4)-4), n, this.littleEndian);
      return this;
    }
    ["setFloat32"](n) {
      this.buffer.setFloat32(((this.position += 4)-4), n, this.littleEndian);
      return this;
    }
    ["setFloat64"](n) {
      this.buffer.setFloat64(((this.position += 8)-8), n, this.littleEndian);
      return this;
    }
  }
  class Reader {
    constructor(n, t) {
      this.buffer = new DataView(n.data);
      this.position = t || 0;
      this.littleEndian = true;
    }
    ["getString"]() {
      let i = "";
      for (;;) {
        var o = this.getUint16();
        if (!o) {
          break;
        }
        i += String.fromCharCode(o);
      }
      return i;
    }
    ["getInt8"]() {
      return this.buffer.getInt8(this.position++);
    }
    ["getUint8"]() {
      return this.buffer.getUint8(this.position++);
    }
    ["getInt16"]() {
      return this.buffer.getInt16(((this.position += 2)- 2), this.littleEndian);
    }
    ["getUint16"]() {
      return this.buffer.getUint16(((this.position += 2)- 2), this.littleEndian);
    }
    ["getInt32"]() {
      return this.buffer.getInt32(((this.position += 4)- 4), this.littleEndian);
    }
    ["getUint32"]() {
      return this.buffer.getUint32(((this.position += 4)- 4), this.littleEndian);
    }
    ["getFloat32"]() {
      return this.buffer.getFloat32(((this.position += 4)- 4), this.littleEndian);
    }
    ["getFloat64"]() {
      return this.buffer.getFloat64(((this.position += 8)- 8), this.littleEndian);
    }
  }
class Bot{
    socket = null;
    random = 1 + ~~(53550+(6e5*Math.random()));
    j9=50;
    M_ = -1;
    ag219 = "";
    ag219_2 = ""
    rq219done = false;
    sentFirstTime;
    verifykey ="Co+kQI2/U7Fto3imGgDcp9qAhFyQqE047lMrIoJkj4yKGzNjC+R4ZX";
   constructor (ws,index){
        this.index = index;
        this.ws = ws;
       this.postag218()
       //this.postclient(ws)
    }
    async postag218(){
      await grecaptcha.execute('6LfOcVMhAAAAAIzR2aCZX5fTjD8HUYYnntFzKqcA',{action: "homepage"}).then((_)=>{this.ag218_key=_})
      console.log(this.ag218_key);
      await $.post("ag218.php", {cvcb: JSON.stringify({cvcb: this.ag218_key})},(_)=>{
        if (_) {
          this.verifykey = _
        }
      }, 'text')
      this.postclient(this.ws);
    }
    connect(ws){
        this.postag219()
        this.j9 = 60;
        this.socket = new WebSocket(ws,['WebSocket'])
        this.socket.binaryType = 'arraybuffer'
        this.socket.onopen = this.open.bind(this)
        this.socket.onmessage = this.message.bind(this)
        this.socket.onerror = this.error.bind(this)
        this.socket.onclose = this.close.bind(this)
    }
    open(){
        const o = new Writer(13);
       this.send(o.setUint8(245).setUint16(57).setUint16(153).setUint32(this.random).setUint32(this.Va(o.buffer, 0, 9, 245)))
    }
    message(message){
        const l = new Reader(message, 0);
        if (240 === l.buffer.getUint8(0)) {
          l.position += 5;
        }
        switch (l.getUint8()) {
            case 64:
                for(let i=0;i<4;i++){l.getUint32()}
                l.getInt16()
                let num1 = l.getUint32(),
                    num2 = l.getUint32()
                l.getUint8()
                l.getUint32()
                l.getUint32()
                l.getUint16()
                l.getUint16()
                if(num1==num2){
                    if(this.j9<70){
                        this.j9 += 40;
                        this.M_ = num1;
                        this.M_ += 1;
                        this.try64(0)
                    }
                }
                break;
            case 244:
                console.log(244)
                this.try244()
                break;
            case 112:
                console.log('captcha')
                break;
            case 104:
                console.log('ag219')
                this.postag219(0)
                break;
        }
    }
    error(err){

    }
    close(event){
      console.log('closed')
      this.setPingInterval(false)
      this.setFpsInterval(false)
      this.setMouseInterval(false)
      this.setSpawnInterval(false)
      if(this.socket){
        this.socket.onopen=this.socket.onmessage=this.socket.onclose=this.socket.onerror=null;
        try{
          this.socket.close()
          this.socket=null;
        }
        catch(e){}
      }
    }
    feed(){
      this.send1byte(21)
      this.send1byte(36)
    }
    split(){
      this.send1byte(17)
    }
    sendMouse(x,y){
      const packet = new DataView(new ArrayBuffer(9));
      packet.setUint8(0, 0)
      packet.setInt32(1, x, true);
      packet.setInt32(5, y, true);
      this.send(packet);
    }
    spawn(name){
      var spawnBuf = new DataView(new ArrayBuffer(4 + 2 * 1 + 2 * name.length));
      spawnBuf.setUint8(0, 1);
      for (var b = 4, x = 0; x < 1; x++) spawnBuf.setUint16(b, 0, true);
      for (x = 0; x < name.length; ++x) spawnBuf.setUint16(b + 2 * x, name.charCodeAt(x), true);
      this.send1byte(34);
      this.send(spawnBuf);
    }
    sendChat(msg){

    }
    sendPw(id,x,y){

    }
    send(data){
      if (this.getstate())this.socket.send(data.buffer)
    }
    Va(n, t, i, o) {
      var f = ["2","0","3","4","1"]
      for (var a = 0;;) {
        switch (f[a++]) {
          case "0":
            if ((t+i)> n.byteLength) {
              i = 0;
            }
            continue;
          case "1":
            Math.floor(10*Math.random());
            o = Math.floor(10*Math.random());
            return l+3
          case "2":
            continue;
          case "3":
            var l = 12354678+o;
            for (var m = 0; m<i; m++) {
              l += n.getUint8(t+m)*(m+1);
            }
            continue;
          case "4":
            for (var d = 1; d<1; d++) {
              d++;
            }
            continue;
        }
        break;
      }
    }
    Zu(n) {
      n.setUint32(this.Va(n.buffer, 0, 9, 255));
    }
    Qu(n, t, i) {
      this.Yu(2)
      n.setUint32(((1+~~(((this.M_/1.4)+(this.j9/2))- (2* t ? 0.5 : 1)))+ ~~((~~(22.29* ((~~((this.M_+(4.81*this.random))+ 550)% --i)- 36360))/ 4.2)+ 0.4)));
    }
    Yu(n, t) {
      return (2==n) && this.Yu(typeof Event) ? (this.Qu = function () {}, ((2*n)+ ((this.M_/ this.M_)* 1.88))) : (2==n) && (162== this.M_) ? ((2* n)+ ((this.M_/ this.M_)* 0.48)) : (2==t) ? (((2*n)+ (t/2))+ ((this.M_/this.M_)* 0.68)) : ((2*n)+ ((this.M_/this.M_)*0.88));
    }
    getstate(){
      if(this.socket && this.socket.readyState === this.socket.OPEN){
        return true
      } else {
        return false
      }
    }
    try64(n) {
      var Wi = [126, 57, 139, 92, 346, 36];
      var Xi = 162;
     if (this.getstate() && (-1!=this.M_) && !n) {
        let c;
        let r = this.verifykey;
        let f = new Writer(1+2*r.length);
        f.setUint8(244);
        f.setString(r);
        this.send(f);
        if (c = 0<this.ag219_2.length) {
          c = (2*this.ag219_2.length);
        }
        const a = new Writer(14+c);
        a.setUint8(((2*(this.j9+30))- ((this.M_-5)% 10))- 5);
        this.Qu(a, n, this.key);
        a.setUint32((this.Yu(2)+(()=>{
          var r = 0;
          for (var u = 0; (u<Wi.length); u++) {
            r += ~~((this.M_/Wi[u])+(Wi[u]% Xi));
          }
          return r;
        })())+Xi+10);
        this.Zu(a);
        if ((0<this.ag219_2.length)) {
          a.setString(this.ag219_2);
        }
        this.send(a)
     }
    }
      async postclient(ws){
      var ksksksv = 'letsplayTictactoe?'
      ksksksv = 'cHMOT3JYYm94Pw==';
      ksksksv = 'C9K9BFB1CI4M19D3LT4'
      var vkx = 'K9BF'
      var U = 'cHMOT3JYYm94Pw=='
      var B = 119
      var O = 159
      vkx.charCodeAt(1);
      var F = this.random-2;
      await $.post("client.php", {data: JSON.stringify({cv: (4*this.random), ch: this.j9, ccv: F, vv: 153})}, (n) => {
        this.key =function (n){
           var i = 0;
           if (n && !isNaN(n)) {
             if ((7< (n = n.toString()).length)) {
               var o = n.substr(0, 7);
               var c = n.substr(7);
               if (!isNaN(o) && !isNaN(c)) {
                 var f = 0;
                 for (var a = 0; (a<o.length); a++) {
                   f += (((((parseInt(o.substr(a, 1))+ 20)+ vkx.charCodeAt(0))+ B)- O)* (a+1));
                 }
                 if (f==parseInt(c)) {
                   i = Math.max((parseInt(o)- 1e6), 0);
                 }
               }
             } else {
               i = parseInt(n);
             }
           }
           return i;
         }(n)
       }, "text")
       .then(()=>{
        console.log(this.key);
        this.connect(ws)
       });
    }
     async postag219(n){
      await $.post('ag219.php', {data: JSON.stringify({cv: (2*this.random), ch: this.j9, ccv2: (this.random-2), abl: 129, cp: 57, vv: 153})}, (r) => {
        if (r) {
          this.rq219done = true;
          this.ag219 = r;
          if (this.sentFirstTime&&!n) {
            this.ml();
          }
        }
      }, "text");
     }
     ml() {
      if (this.getstate()) {
        if (0 < this.ag219.length) {
          this.send(new Writer((3+ (2*this.ag219.length))).setUint8(101).setUint16(this.ag219.length).setString(this.ag219))
          this.rq219done = false;
          this.sentFirstTime = true;
        } else if (!this.rq219done) {
          setTimeout (()=> {
            this.ml();
          }, 3e3);
        }
      }
    }
    try244(){
      this.ml()
      this.ul(7,1)
      this.ul(8,0)
      this.ul(3,1)
      this.fps()
      this.sendlastthing()
      this.setPingInterval(true)
      this.setFpsInterval(true)
      this.setMouseInterval(true)
      this.setSpawnInterval(true)
      console.log('finished handshake')
    }
    ul(n, t) {
      if (this.getstate()) {
        this.send(new Writer(3).setUint8(4).setUint8(n).setUint8(t))
      }
    }
    send1byte(e){
      this.send(new Writer(1).setUint8(e))
    }
    sendlastthing(){
      this.send(new Writer(2).setUint8(160).setUint8(0))
    }
    ping(){
      this.send1byte(95)
    }
    fps(){
      this.send1byte(130)
    }
    setPingInterval(e){
      if (e){
        this.pingInt = setInterval(this.ping,18e3)
      } else {
        if (this.pingInt){
        clearInterval(this.pingInt)
        this.pingInt = null;
      }
      }
    }
    setFpsInterval(e){
      if (e){
        this.fpsInt = setInterval(this.fps,1e4)
      } else {
        if (this.fpsInt){
        clearInterval(this.fpsInt)
        this.fpsInt = null;
      }
      }
    }
    setMouseInterval(e){
      if (e){
        this.mouseInt = setInterval(()=>{this.sendMouse(position.x,position.y)},50)
      } else {
        if (this.mouseInt){
        clearInterval(this.mouseInt)
        this.mouseInt = null;
      }
      }
    }
    setSpawnInterval(e){
      if (e){
        this.spawnInt = setInterval(()=>{this.spawn('hi')},2500)
      } else {
        if (this.spawnInt){
        clearInterval(this.spawnInt)
        this.spawnInt = null;
      }
      }
    }
}
let position = {
  x:0,
  y:0
},
url;
WebSocket.prototype.send = new Proxy(WebSocket.prototype.send,{
apply(target,thisArg,argArray){
	let pkt = argArray[0];
		pkt = (pkt instanceof ArrayBuffer) ? new DataView(pkt) : (pkt instanceof DataView) ? pkt : new DataView(pkt.buffer);
		if (!pkt.getUint8(0, true) && pkt.byteLength == 9) {position.x = pkt.getInt32(1, true);position.y= pkt.getInt32(5, true)}
        url = thisArg.url;
		target.apply(thisArg, argArray);
}
})