AyrA icon

nodeJS Password cracker

AyrA | PRO | 04/07/16 07:42:44 PM UTC | 0 ⭐ | 415 👁️ | Never ⏰ | []
JavaScript |

2.09 KB

|

None

|

0 👍

/

0 👎

//This is a very specific password cracker for bcrypt.
//It cracks from 0A0 to 99z999 and thus is probably useless for you.
//Made for https://redd.it/4dqeyz
var util=require("util");
var bcrypt=require("bcrypt");
var cluster=require("cluster");
var numCPUs=require("os").cpus().length;;
 
var charset="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
var hash="$2a$10$Cv/hHXntAbMoFbZ9.fFNbeNdi26sc15eo04ruHTfk8xhuza88.xq6";
var id=0;
var last=null;
 
charset=charset.reverse().join("");
 
//The master process needs to do different stuff
if(cluster.isMaster)
{
    var childs=[];
    var hashes=[];
    var count=0;
    var total=0;
    var start=Date.now();
    //spawn one slave for each CPU code in our system.
    for (var i = 0; i < numCPUs; i++)
    {
        childs.push(cluster.fork());
    }
    //display stats once a second
    setInterval(function(){
        //clears screen and moves cursor to top left
        util.print("\u001b[2J\u001b[0;0H");
        console.log("H/s",count);
        console.log("Total",total);
        console.log("Runtime:",((Date.now()-start)/1000)|0,"sec");
        hashes.forEach(function(v,i){
            console.log(i,v);
        });
        count=0;
    },1000);
    //hook to message events from children
    childs.forEach(function(v,i){
        v.on("message",function(m)
        {
            if(m.msg==="count")
            {
                ++count;
                ++total;
            }
            hashes[i]=m.hash;
        });
    });
}
else if(cluster.isWorker)
{
    id=cluster.worker.id;
    console.log(id,"started");
    //counts down from 99 to 0 (1st part of password)
    for(var i=99;i>=0;i--)
    {
        //counts down all possible letters (2nd part of password)
        for(var k=0;k<charset.length;k++)
        {
            //counts down from 999 to 0 (3rd part of password)
            //here we don't subtract only one and we have different starting values.
            //Each slave will thus have a different password to test
            for(var j=999-id;j>=0;j-=numCPUs)
            {
                //if the password is correct, print it and then exit
                if(bcrypt.compareSync(i+charset[k]+j,hash))
                {
                    console.log("DONE! Password:",i+charset[k]+j);
                    process.exit();
                }
                process.send({msg:"count",hash:i+charset[k]+j});
            }
        }
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎