Results 1 to 12 of 12

Thread: accidentally made a scriptable bot

  1. #1
    Join Date
    Aug 2017
    Posts
    23
    Mentioned
    1 Post(s)
    Quoted
    4 Post(s)

    Default accidentally made a scriptable bot

    I went poking around in the source code to look at the possibility of making a packet reader to feed info to Simba, ended up with a scriptable java bot a week later

    scriptengine.jpg

  2. #2
    Join Date
    Oct 2007
    Posts
    187
    Mentioned
    7 Post(s)
    Quoted
    61 Post(s)

    Default

    what game is that? looks interesting

  3. #3
    Join Date
    Jan 2013
    Posts
    86
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Quote Originally Posted by klamor View Post
    what game is that? looks interesting
    That's Rucoy Online I believe.

  4. #4
    Join Date
    Aug 2017
    Posts
    23
    Mentioned
    1 Post(s)
    Quoted
    4 Post(s)

    Default

    Rucoy online, I'm using Xposed framework for reflection/code injection(the game is Android only)

  5. #5
    Join Date
    Aug 2016
    Location
    Kentucky
    Posts
    254
    Mentioned
    3 Post(s)
    Quoted
    96 Post(s)

  6. #6
    Join Date
    Aug 2017
    Posts
    23
    Mentioned
    1 Post(s)
    Quoted
    4 Post(s)

    Default

    Yes, its all Java, Xposed framework does some magic with (to my knowledge) replacing android's bootloader, and the 'modules' are loaded while the app is loaded, you can hook a method then call your own code before/after specific method calls in an app.

    Heres an example of how I get my players coordinates

    Code:
                findAndHookMethod("com.beQneGwBEZpUkAYsbTtP", lpparam.classLoader, "TceSSUw3xCrzGptgaf2", new XC_MethodHook() {
    
                    @Override
                    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                        Float f = (Float) param.getResult();
                        myX = f;
                    }
                });
    
                findAndHookMethod("com.beQneGwBEZpUkAYsbTtP", lpparam.classLoader, "tXNQ3fnzWpRGFpzRPqYH", new XC_MethodHook() {
    
                    @Override
                    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                        Float f = (Float) param.getResult();
                        myY = f;
                    }
                });
    TceSSUw3xCrzGptgaf2 is the game client's getX method(obfuscated obviously) which is called about 5 times a second, as soon as it is called, I update a value myX in my bot with whatever TceSSUw3xCrzGptgaf2 returned.

    another example

    Code:
                findAndHookMethod("com.AqNZfj9bSwW2BcTx6k", lpparam.classLoader, "cq9McHfjjYvSxMgGmBnX", byte.class,String.class,String.class, new XC_MethodHook() {
    
                    @Override
                    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                        XposedBridge.log("method cq9McHfjjYvSxMgGmBnX 10.(something(b,s,s))" + param.args[0] +"," +param.args[1] +"," +param.args[2]);
                        String s = (String)param.args[2];
                        if(s.contains(".stop") || s.contains(".start") || s.contains(".attack") || s.contains(".")) {
    
    
    
                            if (s.contains(".start")) {
                                if (se == null)
                                    se = new ScriptEngine();
                                se.startScript(s);
                            } else if (s.contains(".stop")) {
                                se.stopScript(s);
                            } else if(s.contains(".attack")) {
                                se.startScript(s);
                            }
                            param.setResult(null);
    
                        }
                    }
                });
    cq9McHfjjYvSxMgGmBnX is the method name, and with arguments its cq9McHfjjYvSxMgGmBnX(Byte,String,String)

    This is the code I use for starting scripts, cq9McHfjjYvSxMgGmBnX is the method to send chat messages, if the string you are sending contains .stop,.start,or .attack(i used this for testing invoked methods) then it will start/stop the script, and then stop cq9McHfjjYvSxMgGmBnX from actually executing with param.setResult(null) (so you don't end up saying ".start autofighter" in game, which will probably get you ban lol)
    Last edited by JimmyJay; 10-25-2017 at 04:52 PM.

  7. #7
    Join Date
    Aug 2017
    Posts
    23
    Mentioned
    1 Post(s)
    Quoted
    4 Post(s)

    Default

    Small update on the progress, I've been pretty busy with work and I really was only working on this to kill free time which I had way too much of.

    Finally found a way to handle the inventory, get Z coordinates, and implement A-Star into the bot, loading config files for the maps for A-Star gave me a pretty good run around. Anyways, my script to fight ninja assassins... It's working pretty good, still need to implement potion usage which won't be a problem now that I can handle inventory items.

    Fights assassins/ninja assassins, path walking complete... walks to them if they're not on screen.

    Code:
    package lesroberts.bridge;
    
    import AStar.AStar;
    import AStar.Node;
    import de.robv.android.xposed.XposedBridge;
    
    /**
     * Created by Leslie on 10/18/2017.
     */
    
    public class AssassinFighter extends ScriptEngine implements Runnable {
        boolean running = true;
        Node center = new Node((byte)-1,37,118);
        int fdist = 20;
        Thing t = null;
        public AssassinFighter() {
    
        }
        public void stop() {
            running = false;
        }
    
        public void run() {
            while(running) {
                System.out.println("loop");
                while(getInteractingID() != 0 || isMoving()) {
                    if(inCombat()) {
                        System.out.println("in combat");
                        for(int i = 0;i < getSurroundingItemCount();i++) {
                            takeNearItem();
                            sleep(random(300,900));
                        }
                    }
                    if(isMoving()) {
                        System.out.println("walking");
                    }
                    sleep(random(100,400));
    
                }
                t = closest();
                System.out.println("getnpc");
                if(t != null) {
                    System.out.println("npc not null");
                    if(isThingOnScreen(t)) {
                        System.out.println("attack npc");
                        attack(t.ThingID);
                        sleep(random(800,2000));
                    } else {
                        System.out.println("npc not on screen");
                        Node[] path = AStar.findPath(getX(),getY(),t.xcoord,t.ycoord,getZ());
                        if(walkPath(path)) {
                            System.out.println("walk");
                            sleep(random(800,1400));
                        } else { System.out.println("can't walk path"); }
                    }
                }
                sleep(random(50,200));
            }
        }
    
        boolean walkPath(Node[] n) {
            for(int i = 0;i < n.length;i++) {
                if(coordOnScreen(n[i].x,n[i].y)) {
                    System.out.println("walking" +n[i].x +"," + n[i].y +"mypos "+getX()+","+getY());
                    walk((short)n[i].x,(short)n[i].y);
                    return true;
                }
            }
            return false;
        }
    
        Thing closest() {
            Thing[] things = getNpcArray();
            int myx = getX();
            int myy = getY();
            int distance = Integer.MAX_VALUE;
            Thing close = null;
            int[] types = new int[] {10,11,46};
            for(Thing t : things) {
                if(t != null) {
                    System.out.println("thing not null 1");
                    for(int i : types) {
                        if(t == null)
                            continue;
                        t = getNpcInfo(t.ThingID);
                        if(t != null) {
                            if(t.npcid == i) {
                                System.out.println("found matching npc");
                                //t = getNpcInfo(t.ThingID);
                                if(dist(center.x,center.y,t.xcoord,t.ycoord) < fdist) {
                                    System.out.println("npc in fight area");
                                    Node[] path = AStar.findPath(myx,myy,t.xcoord,t.ycoord,getZ());
                                    if(path == null)
                                        continue;
                                    int dist = path.length;
                                    System.out.println("thing " + t.ThingID + "astar dist "+dist);
                                    if(dist == 2)
                                        return t;
                                    if (dist < distance) {
                                        distance = dist;
                                        close = t;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return close;
        }
    
        public void sleep(int i) {
            try {
                Thread.sleep(i);
            } catch (Exception e) {
            }
        }
    }

  8. #8
    Join Date
    Aug 2016
    Location
    Kentucky
    Posts
    254
    Mentioned
    3 Post(s)
    Quoted
    96 Post(s)

    Default

    Quote Originally Posted by JimmyJay View Post
    Small update on the progress, I've been pretty busy with work and I really was only working on this to kill free time which I had way too much of.

    Finally found a way to handle the inventory, get Z coordinates, and implement A-Star into the bot, loading config files for the maps for A-Star gave me a pretty good run around. Anyways, my script to fight ninja assassins... It's working pretty good, still need to implement potion usage which won't be a problem now that I can handle inventory items.

    Fights assassins/ninja assassins, path walking complete... walks to them if they're not on screen.

    Code:
    package lesroberts.bridge;
    
    import AStar.AStar;
    import AStar.Node;
    import de.robv.android.xposed.XposedBridge;
    
    /**
     * Created by Leslie on 10/18/2017.
     */
    
    public class AssassinFighter extends ScriptEngine implements Runnable {
        boolean running = true;
        Node center = new Node((byte)-1,37,118);
        int fdist = 20;
        Thing t = null;
        public AssassinFighter() {
    
        }
        public void stop() {
            running = false;
        }
    
        public void run() {
            while(running) {
                System.out.println("loop");
                while(getInteractingID() != 0 || isMoving()) {
                    if(inCombat()) {
                        System.out.println("in combat");
                        for(int i = 0;i < getSurroundingItemCount();i++) {
                            takeNearItem();
                            sleep(random(300,900));
                        }
                    }
                    if(isMoving()) {
                        System.out.println("walking");
                    }
                    sleep(random(100,400));
    
                }
                t = closest();
                System.out.println("getnpc");
                if(t != null) {
                    System.out.println("npc not null");
                    if(isThingOnScreen(t)) {
                        System.out.println("attack npc");
                        attack(t.ThingID);
                        sleep(random(800,2000));
                    } else {
                        System.out.println("npc not on screen");
                        Node[] path = AStar.findPath(getX(),getY(),t.xcoord,t.ycoord,getZ());
                        if(walkPath(path)) {
                            System.out.println("walk");
                            sleep(random(800,1400));
                        } else { System.out.println("can't walk path"); }
                    }
                }
                sleep(random(50,200));
            }
        }
    
        boolean walkPath(Node[] n) {
            for(int i = 0;i < n.length;i++) {
                if(coordOnScreen(n[i].x,n[i].y)) {
                    System.out.println("walking" +n[i].x +"," + n[i].y +"mypos "+getX()+","+getY());
                    walk((short)n[i].x,(short)n[i].y);
                    return true;
                }
            }
            return false;
        }
    
        Thing closest() {
            Thing[] things = getNpcArray();
            int myx = getX();
            int myy = getY();
            int distance = Integer.MAX_VALUE;
            Thing close = null;
            int[] types = new int[] {10,11,46};
            for(Thing t : things) {
                if(t != null) {
                    System.out.println("thing not null 1");
                    for(int i : types) {
                        if(t == null)
                            continue;
                        t = getNpcInfo(t.ThingID);
                        if(t != null) {
                            if(t.npcid == i) {
                                System.out.println("found matching npc");
                                //t = getNpcInfo(t.ThingID);
                                if(dist(center.x,center.y,t.xcoord,t.ycoord) < fdist) {
                                    System.out.println("npc in fight area");
                                    Node[] path = AStar.findPath(myx,myy,t.xcoord,t.ycoord,getZ());
                                    if(path == null)
                                        continue;
                                    int dist = path.length;
                                    System.out.println("thing " + t.ThingID + "astar dist "+dist);
                                    if(dist == 2)
                                        return t;
                                    if (dist < distance) {
                                        distance = dist;
                                        close = t;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return close;
        }
    
        public void sleep(int i) {
            try {
                Thread.sleep(i);
            } catch (Exception e) {
            }
        }
    }
    You have me super interested. I would love to see a tutorial series on this basic script. Or if possible, a learning path to where you have learned to do this? I have Xposed on my phone, but I assume you're using it on an emulator? I wanted to get into reflection/injection os badly, but the emulator scrambles the data to much for a basic memory reader.

  9. #9
    Join Date
    Aug 2017
    Posts
    23
    Mentioned
    1 Post(s)
    Quoted
    4 Post(s)

    Default

    How I started was I wanted to make a packet reader to send data to Simba. I read the basic 'this is where you start with Xposed' tutorial and went from there. I stripped down Rucoy's packet handling class, hooked the byte buffer and passed that onto the packet handler that I stripped down. I finally realized it would just be easier to do it all with reflection instead of passing data to Simba and it went on from there. I'm probably going to release the whole module source today or tomorrow as I have no plans to keep this going after I get home in about a week(currently deployed, hence too much free time)

    edit: I tried to upload it earlier, apparently a 5MB zip is too much for the forums to handle, and as usual, nobody on IRC had a suggestion on where to upload it.
    Last edited by JimmyJay; 11-23-2017 at 05:56 AM.

  10. #10
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Quote Originally Posted by JimmyJay View Post
    edit: I tried to upload it earlier, apparently a 5MB zip is too much for the forums to handle, and as usual, nobody on IRC had a suggestion on where to upload it.
    i guess you could use any file hosting site
    https://uploadfiles.io/
    Well done with this ive often started out on something simple which has later fruited into something much more than i imagined well done.
    @Aspect +1
    Previously Known or not Known as CRU1Z1N.
    If you want to succeed you should strike out on new paths, rather than travel the worn paths of accepted success.(John D. Rockefeller)

  11. #11
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    @JimmyJay, can you make a video?
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  12. #12
    Join Date
    Aug 2017
    Posts
    23
    Mentioned
    1 Post(s)
    Quoted
    4 Post(s)

    Default

    On what? The bot running, setup, installing Xposed Framework?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •