Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Fastest possible bank PIN solver.


    Computor

    Recommended Posts

    Sup,

    I wanted a faster bank pin solving method, since the client's current one isn't too good (slow, messes up easily). So, I created one in attempts to replace the current one, however I've been informed that the devs don't want/need it, and will just fix the current bank pin solver. So, to not let my code/time go to waste, I'll simply release it to the public, in the case that someone wants it.

     

    This also proves to be a fairly good example of using widgets.

     

    Method currently only has two public methods, one to check for bank pin visibility (are we trying to solve the pin), and a pin solver:

    mhK1xiZ.png

     

    Bank pins can be solved in as little as 3 seconds:

    https://dl.dropboxusercontent.com/s/d8grb6l0lguvvlx/2015-10-02_21-26-06.mp4?dl=0

     

     

    So, here's the source code, one test file, and then the actual BankPin class:

    package Test;
    
    import org.dreambot.api.randoms.RandomEvent;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    
    import java.awt.*;
    
    /**
     * Created by Computor on 9/29/2015.
     */
    @ScriptManifest(category = Category.MISC, name = "Bank Pin Test", author = "Computor", version = 1.0)
    public class BankPinTest extends AbstractScript{
    
        private BankPin bankPin;
    
        @Override
        public void onStart() {
            bankPin = new BankPin(this);
            getRandomManager().disableSolver(RandomEvent.BANK_PIN);
            getRandomManager().disableSolver(RandomEvent.BANK_PIN_CONFIRM);
        }
    
        @Override
        public int onLoop() {
            if(getBankPin().isPinVisible()){
                getBankPin().solveBankPin(new int[]{0,0,0,0}); //Enter your pin numbers here.
            }
            return 300;
        }
    
        @Override
        public void onPaint(Graphics g) {
            g.setColor(Color.black);
            g.fillRect(3, 341, 514, 138);
    
            g.setColor(Color.green);
            g.drawString("Bank is open: " + getBank().isOpen(), 7, 355);
            g.drawString("Pin visible: " + getBankPin().isPinVisible(), 7, 370);
        }
    
        public BankPin getBankPin() {
            return bankPin;
        }
    }
    

    BankPin class:

    package Test;
    
    import org.dreambot.api.methods.MethodContext;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.widgets.WidgetChild;
    
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     * Created by Computor on 10/2/2015.
     */
    public class BankPin {
        private MethodContext ctx;
        private Timer timer;
    
        public BankPin(MethodContext ctx) {
            this.ctx = ctx;
        }
    
    
        /**
         * Checks to see if the pin screen is visible.
         *
         * @[member='return zez'] True if the bank PIN screen is open.
         */
        public boolean isPinVisible() {
            return ctx.getWidgets().getChildWidget(213, 1) != null;
        }
    
    
        /**
         * Solves the user's bank pin, which is stored in the sequence array.
         *
         * @param sequence
         * @[member='return zez']
         */
        public boolean solveBankPin(int[] sequence) {
            timer = new Timer();
            List<Integer> windowsCompleted = new ArrayList<>();
            int failSafeCount = 0;
            while (isPinVisible() && ctx.getClient().getInstance().getScriptManager().isRunning() && failSafeCount < 7) {
                failSafeCount++;
                int currentWindow = whatWindow();
                switch (currentWindow) {
                    case 1:
                        clickAndSleep(windowsCompleted, sequence, currentWindow, 0, 1);
                        break;
    
                    case 2:
                        clickAndSleep(windowsCompleted, sequence, currentWindow, 1, 2);
                        break;
    
                    case 3:
                        clickAndSleep(windowsCompleted, sequence, currentWindow, 2, 3);
                        break;
    
                    case 4:
                        clickAndSleep(windowsCompleted, sequence, currentWindow, 3, 4);
                        break;
                }
            }
    
            if((windowsCompleted.contains(4) || ctx.getBank().isOpen()) && failSafeCount < 7){
                MethodContext.log("Done.");
                MethodContext.log("Solved PIN in " + timer.formatTime() + " seconds.");
                return true;
            }
            return false;
        }
    
    
        /**
         * Gets a HashMap of all of the bank's pin numbers according to each widget (red bank pin button).
         *
         * @[member='return zez'] HashMap of the WidgetChild and it's pin number.
         */
        private List<Integer> getPinList() {
            List<Integer> pinList = new ArrayList<>(); //HashMap<Widget child number, pin number>
    
            while(isPinVisible() && pinList.size() != 10 && ctx.getClient().getInstance().getScriptManager().isRunning()) {
                for (int i = 16; i < 35; i += 2) {
                    if (ctx.getWidgets().getChildWidget(213, i) != null) {
                        WidgetChild gc = ctx.getWidgets().getChildWidget(213, i).getChild(1);
                        if (gc != null && !gc.getText().equals("")) {
                            int number = Integer.parseInt(gc.getText());
                            pinList.add(number);
                        } else {
                            pinList.add(-1);
                        }
                    } else {
                        pinList.add(-1);
                    }
                }
    
                /**
                 * We're missing a pin number, the mouse was probably over a widget. Time to find it, and fill it in.
                 */
                if (pinList.contains(-1)) {
                    int missingNumber = findMissingNumbers(pinList);
    
                    pinList.add(pinList.indexOf(-1), missingNumber);
                    pinList.remove(new Integer(-1));
                }
            }
            return pinList;
        }
    
    
        /**
         * Finds the missing number between 0-9 in the array list. Example: List: "0,1,2,3,4,6,7" would return 5.
         *
         * @param integerList The list we're checking for a missing integer.
         * @[member='return zez'] The missing integer.
         */
        private int findMissingNumbers(List<Integer> integerList) {
            int missingNumber = -1;
            List<Integer> numberList = new ArrayList<Integer>(){{
                add(0); add(1); add(2); add(3); add(4);add(5); add(6); add(7); add(8); add(9);
            }};
    
            for(int num : numberList){ //Cycle through complete number list.
                if(!integerList.contains(num)){ //If we don't have the complete number in our integerList, it's obviously missing.
                    missingNumber = num; //So set the missing number equal to the missing number.
                }
            }
    
            return missingNumber;
        }
    
    
        /**
         * Gets the button's location (number) based off of the pinNumber.
         *
         * @param pinNumber the pin we're searching for.
         * @[member='return zez'] the button's location in an (imaginary) array:
         *
         * [9][3][5][2]
         * [1][7][4]
         * [6][0][8]
         *
         * 9 would be button 0
         * 3 would be button 1
         * 5 would be button 2
         * 2 would be button 3
         * 1 would be button 4, etc.
         */
        private int getButtonNumber(int pinNumber) {
            List<Integer> pinList = getPinList();
            for (int i = 0; i < pinList.size(); i++) {
                if (pinNumber == pinList.get(i)) {
                    return i;
                }
            }
            return -1;
        }
    
    
        /**
         * Clicks on the widget whose pin number equals the pinNumber
         *
         * @param pinNumber searching for a widget with this pin number
         * @[member='return zez'] true if successfully interacted with the widget.
         */
        private boolean clickPinNumber(int pinNumber) {
            int childID = (16 + getButtonNumber(pinNumber) * 2);
            WidgetChild bankPinSquare = ctx.getWidgets().getChildWidget(213, childID);
            return bankPinSquare != null && bankPinSquare.interact();
        }
    
    
        /**
         * Gets what bank pin window the user is currently in.
         *
         * @[member='return zez'] The number of the order in which the screen appears in the pin sequence. First screen = 1, second = 2, etc.
         */
        private int whatWindow() {
            if (isPinVisible() && ctx.getWidgets().getChildWidget(213, 10) != null) {
                switch (ctx.getWidgets().getChildWidget(213, 10).getText()) {
                    case "First click the FIRST digit.":
                        return 1;
                    case "Now click the SECOND digit.":
                        return 2;
                    case "Time for the THIRD digit.":
                        return 3;
                    case "Finally, the FOURTH digit.":
                        return 4;
                }
            }
            return 0;
        }
    
    
        /**
         * Created this method just because of the repetition of code. Technically there is no reason for this, other
         * than to eliminate repetitive code lines.
         *
         * @param windowsCompleted windowsCompleted list from solveBankPin
         * @param sequence the sequence array from solveBankPin
         * @param currentWindow the currentWindow  from solveBankPin
         * @param sequenceNum the position in the sequence array  from solveBankPin
         * @param comp the number of completion to add to the windowsCompleted array from solveBankPin
         */
        private void clickAndSleep(List<Integer> windowsCompleted, int[] sequence, int currentWindow, int sequenceNum, int comp){
            if (!windowsCompleted.contains(comp) && clickPinNumber(sequence[sequenceNum])) {
                MethodContext.sleep(80,150); //Little extra sleep, the whatWindow loads faster than the actual pin numbers.
                MethodContext.sleepUntil(() -> {
                    int window = whatWindow();
                    return (!isPinVisible() || ctx.getBank().isOpen()) || (window != currentWindow && window != 0);
                },2000); //Sleep till the next window is available
                windowsCompleted.add(comp); //We completed it, don't want to do this window ever again. Failsafe.
            }
        }
    }
    
    Link to comment
    Share on other sites

    :L I'd rather the Dreambot client not be the one used to crack bank pins..

     

    Oh well I suppose Jamflex did fix it :3

    It doesn't crack your pin XD it just solves it.

    Link to comment
    Share on other sites

    It doesn't crack your pin XD it just solves it.

     

    I believe he is referring to the fact that you can use this and a dictionary of #s to crack bank PINs, you'd just have to make an (easy) custom script for it.

     

    regardless, this is helpful if it is faster than the clients, and possibly can be used to further the speed of the client's solver.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.