Skip to content

Instantly share code, notes, and snippets.

@vay3t
Last active May 10, 2019 16:17
Show Gist options
  • Save vay3t/9621512cd52039507894829c1dcc180a to your computer and use it in GitHub Desktop.
Save vay3t/9621512cd52039507894829c1dcc180a to your computer and use it in GitHub Desktop.
cracker calculator
<script>
function doit()
{
var n = parseInt(document.all.item("len").value);
if(n<1 || n>20)
{
alert("Invalid value for password length. Valid range is 1..20");
return;
}
var speedS = document.all.item("speed").value;
speedS = speedS.replace(",", "");
var speed = parseFloat(speedS);
if(speed<=0 || speed>100000000)
{
alert("Invalid value for speed");
return;
}
var pcn = parseInt(document.all.item("pcn").value);
if(pcn<1 || pcn>1000000)
{
alert("Invalid value for the number of computers");
return;
}
var cslen=0;
if(document.all.item("cslwr").checked)
cslen += 26;
if(document.all.item("csuppr").checked)
cslen += 26;
if(document.all.item("csdigits").checked)
cslen += 10;
if(document.all.item("cssymb").checked)
cslen += 12;
if(document.all.item("csascii").checked)
cslen = 96;
var t = Math.pow(cslen,n) / (speed*pcn);
var s;
if (t<60)
s=" a minute";
else
{
t /= 60;
if (t<180)
s = Math.ceil(t).toString() + " minutes";
else
{
t /= 60;
if (t<72)
s = Math.ceil(t).toString() + " hours";
else
{ t /= 24;
if (t<90)
s = Math.ceil(t).toString() + " days";
else
{ t /= 30;
if (t<36)
s = Math.ceil(t).toString() + " months";
else
{ t /= 12;
s = Math.ceil(t).toString() + " years";
}
}
}
}
}
document.all.item("result2").innerHTML = s;
}
</script>
<form method="POST">
<table width="500" border="0" align="center" cellpadding="3" cellspacing="0">
<tr bgcolor="#FFFFCC">
<td align="right">Password length:</td>
<td>
<input type="text" id="len" size="6" value="5"></td>
</tr>
<tr bgcolor="#FFFFCC">
<td align="right">Speed:</td>
<td>
<input type="text" id="speed" size="11" value="224000" name="T1"> passwords per second</td>
</tr>
<tr bgcolor="#FFFFCC">
<td height="25" align="right">Number of computers: </td>
<td>
<input type="text" id="pcn" size="6" value="1" name="T2"></td>
</tr>
<tr align="center" bgcolor="#FFFFCC">
<td height="12" colspan="2">
<table width="400" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="25"> <input type="checkbox" name="cslwr" value="ON" checked></td>
<td>chars in lower case&nbsp;</td>
<td width="25"> <input type="checkbox" name="cssymb" value="ON"></td>
<td>common punctuation&nbsp;</td>
</tr>
<tr>
<td width="25"> <input type="checkbox" name="csuppr" value="ON"></td>
<td>chars in upper case</td>
<td width="25"> <input type="checkbox" name="csascii" value="ON"></td>
<td>full ASCII</td>
</tr>
<tr>
<td width="25" height="25">
<input type="checkbox" name="csdigits" value="ON"></td>
<td colspan="3">digits&nbsp;</td>
</tr>
</table></td>
</tr>
<tr align="center" bgcolor="#FFFFCC">
<td height="5" colspan="2">
<input type="button" value="Calculate!" onclick=doit();></td>
</tr>
<tr align="center" bgcolor="#FFFF99">
<td height="6" colspan="2">Brute Force Attack
will take up to <strong><span id="result2"></span></strong></td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment