Bitcoin Forum
May 06, 2024, 04:06:55 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 4 »  All
  Print  
Author Topic: [Bounty - 0.5 BTC ($500)] Javascript / Password Recovery issue (CLAIMED)  (Read 2565 times)
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 07:22:47 AM
Last edit: November 30, 2013, 03:53:01 AM by Cyberdyne
 #1

Update 2013-11-30: Bounty claimed. Thanks everyone.


Another day, another lost password.

The code I've pasted below is my (very crude) attempt at modifying bitaddress.org (v 2.4) to help me recover a password in a particular way.

In my particular case, I know the exact length of my password, and pretty much know what every letter is, however I'm stuck on the case of some of the letters.

Example: I don't know if my password is appLe or aPple or ApplE.

In this case, there are 2^X possible combinations, where X is the number of characters whose case I'm unsure of.

If you save the below code as .html and check out the brainwallet tab, you'll see I've modified this page to take each character as a separate input.

Example:

a
p
p
l
e


I've set it up so that for each character, I can type all the different possible combinations for that character, and then the script will check all the possible combinations of the password.

Example, I input:

a
pP
pP
l
e

And it will check:

apple
apPle
aPple
aPPle

What it's checking against, is the 'target' address. I paste in that target address input box the bitcoin address that I'm trying to find the key for. When the script finds a match, it will output the passphrase that resulted in the address, and output the private key for it too.

Now the part I'm stuck on, and what the bounty is for:

Any more than about 20 combinations makes my browser hang, because of the horrible way I've done all this in nested while loops. What I need is for this whole thing to be modified so that the browser doesn't hang, and constantly outputs where it's up to.

Example:
Checking combination 75 out of 8192

I'd like it to kind of act like how the 'bulk wallet' generator tab works, when you generate a huge amount of addresses (say 1000). You can see it working, and doesn't hang the browser.

Code:
http://pastebin.com/ijxcd4qk
(Sorry it was too big to paste here directly)


Edit: Here are the 2 parts I've modified:

My modified 'brainarea' div:
Code:
			<div id="brainarea" class="walletarea">
<div id="braincommands" class="commands">
<div class="row">
<span id="brainlabelenterpassphrase1" class="label">Char 1: </span><input tabindex="1" type="text" id="passphrasechar_1" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase2" class="label">Char 2: </span><input tabindex="2" type="text" id="passphrasechar_2" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase3" class="label">Char 3: </span><input tabindex="3" type="text" id="passphrasechar_3" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase4" class="label">Char 4: </span><input tabindex="4" type="text" id="passphrasechar_4" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase5" class="label">Char 5: </span><input tabindex="5" type="text" id="passphrasechar_5" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase6" class="label">Char 6: </span><input tabindex="6" type="text" id="passphrasechar_6" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase7" class="label">Char 7: </span><input tabindex="7" type="text" id="passphrasechar_7" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase8" class="label">Char 8: </span><input tabindex="8" type="text" id="passphrasechar_8" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase9" class="label">Char 9: </span><input tabindex="9" type="text" id="passphrasechar_9" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase10" class="label">Char 10: </span><input tabindex="10" type="text" id="passphrasechar_10" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase11" class="label">Char 11: </span><input tabindex="11" type="text" id="passphrasechar_11" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase12" class="label">Char 12: </span><input tabindex="12" type="text" id="passphrasechar_12" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase13" class="label">Char 13: </span><input tabindex="13" type="text" id="passphrasechar_13" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase14" class="label">Char 14: </span><input tabindex="14" type="text" id="passphrasechar_14" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase15" class="label">Char 15: </span><input tabindex="15" type="text" id="passphrasechar_15" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase16" class="label">Char 16: </span><input tabindex="16" type="text" id="passphrasechar_16" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase17" class="label">Char 17: </span><input tabindex="17" type="text" id="passphrasechar_17" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase18" class="label">Char 18: </span><input tabindex="18" type="text" id="passphrasechar_18" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase19" class="label">Char 19: </span><input tabindex="19" type="text" id="passphrasechar_19" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase20" class="label">Char 20: </span><input tabindex="20" type="text" id="passphrasechar_20" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase21" class="label">Char 21: </span><input tabindex="21" type="text" id="passphrasechar_21" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase22" class="label">Char 22: </span><input tabindex="22" type="text" id="passphrasechar_22" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase23" class="label">Char 23: </span><input tabindex="23" type="text" id="passphrasechar_23" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase24" class="label">Char 24: </span><input tabindex="24" type="text" id="passphrasechar_24" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase25" class="label">Char 25: </span><input tabindex="25" type="text" id="passphrasechar_25" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase26" class="label">Char 26: </span><input tabindex="26" type="text" id="passphrasechar_26" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase27" class="label">Char 27: </span><input tabindex="27" type="text" id="passphrasechar_27" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase28" class="label">Char 28: </span><input tabindex="28" type="text" id="passphrasechar_28" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase29" class="label">Char 29: </span><input tabindex="29" type="text" id="passphrasechar_29" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase30" class="label">Char 30: </span><input tabindex="30" type="text" id="passphrasechar_30" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase31" class="label">Char 31: </span><input tabindex="31" type="text" id="passphrasechar_31" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase32" class="label">Char 32: </span><input tabindex="32" type="text" id="passphrasechar_32" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase33" class="label">Char 33: </span><input tabindex="33" type="text" id="passphrasechar_33" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase34" class="label">Char 34: </span><input tabindex="34" type="text" id="passphrasechar_34" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase35" class="label">Char 35: </span><input tabindex="35" type="text" id="passphrasechar_35" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase36" class="label">Char 36: </span><input tabindex="36" type="text" id="passphrasechar_36" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase37" class="label">Char 37: </span><input tabindex="37" type="text" id="passphrasechar_37" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase38" class="label">Char 38: </span><input tabindex="38" type="text" id="passphrasechar_38" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase39" class="label">Char 39: </span><input tabindex="39" type="text" id="passphrasechar_39" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase40" class="label">Char 40: </span><input tabindex="40" type="text" id="passphrasechar_40" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase41" class="label">Char 41: </span><input tabindex="41" type="text" id="passphrasechar_41" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase42" class="label">Char 42: </span><input tabindex="42" type="text" id="passphrasechar_42" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase43" class="label">Char 43: </span><input tabindex="43" type="text" id="passphrasechar_43" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase44" class="label">Char 44: </span><input tabindex="44" type="text" id="passphrasechar_44" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase45" class="label">Char 45: </span><input tabindex="45" type="text" id="passphrasechar_45" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase46" class="label">Char 46: </span><input tabindex="46" type="text" id="passphrasechar_46" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase47" class="label">Char 47: </span><input tabindex="47" type="text" id="passphrasechar_47" value="" onfocus="this.select();"/><br/>
<span id="brainlabelenterpassphrase48" class="label">Char 48: </span><input tabindex="48" type="text" id="passphrasechar_48" value="" onfocus="this.select();"/><br/>
</div>
<div class="row extra">
<span class="label" id="brainlabelconfirm">Target Address: </span>
<input tabindex="54" type="text" id="targetaddress" value="" onfocus="this.select();" />
<span><input tabindex="55" type="button" id="brainview" value="View" onclick="ninja.wallets.brainwallet.view();" /></span>
</div>
</div>
<div class="body">
<span class="label" id="bulklabelcsv">Comma Separated Values:</span> <span class="format" id="bulklabelformat">Index,Address,Private Key (WIF)</span>
<textarea rows="20" cols="88" id="bulktextarea2"></textarea>
</div>                
<div id="brainkeyarea" class="keyarea">
<div class="public">
<div id="brainqrcodepublic" class="qrcode_public"></div>
<div class="pubaddress">
<span class="label" id="brainlabelbitcoinaddress">Bitcoin Address:</span>
<span class="output" id="brainbtcaddress"></span>
</div>
</div>
<div class="private">
<div id="brainqrcodeprivate" class="qrcode_private"></div>
<div class="privwif">
<span class="label" id="brainlabelprivatekey">Private Key (Wallet Import Format):</span>
<span class="output" id="brainbtcprivwif"></span>
</div>
</div>
</div>
</div>


My modified 'brainwallet' function:
Code:
	<script type="text/javascript">
ninja.wallets.brainwallet = {
open: function () {
document.getElementById("brainarea").style.display = "block";
document.getElementById("passphrasechar_1").focus();
},

close: function () {
document.getElementById("brainarea").style.display = "none";
},

view: function () {
var passphrasechar_1 = document.getElementById("passphrasechar_1").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_2 = document.getElementById("passphrasechar_2").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_3 = document.getElementById("passphrasechar_3").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_4 = document.getElementById("passphrasechar_4").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_5 = document.getElementById("passphrasechar_5").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_6 = document.getElementById("passphrasechar_6").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_7 = document.getElementById("passphrasechar_7").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_8 = document.getElementById("passphrasechar_8").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_9 = document.getElementById("passphrasechar_9").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_10 = document.getElementById("passphrasechar_10").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_11 = document.getElementById("passphrasechar_11").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_12 = document.getElementById("passphrasechar_12").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_13 = document.getElementById("passphrasechar_13").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_14 = document.getElementById("passphrasechar_14").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_15 = document.getElementById("passphrasechar_15").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_16 = document.getElementById("passphrasechar_16").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_17 = document.getElementById("passphrasechar_17").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_18 = document.getElementById("passphrasechar_18").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_19 = document.getElementById("passphrasechar_19").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_20 = document.getElementById("passphrasechar_20").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_21 = document.getElementById("passphrasechar_21").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_22 = document.getElementById("passphrasechar_22").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_23 = document.getElementById("passphrasechar_23").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_24 = document.getElementById("passphrasechar_24").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_25 = document.getElementById("passphrasechar_25").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_26 = document.getElementById("passphrasechar_26").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_27 = document.getElementById("passphrasechar_27").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_28 = document.getElementById("passphrasechar_28").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_29 = document.getElementById("passphrasechar_29").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_30 = document.getElementById("passphrasechar_30").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_31 = document.getElementById("passphrasechar_31").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_32 = document.getElementById("passphrasechar_32").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_33 = document.getElementById("passphrasechar_33").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_34 = document.getElementById("passphrasechar_34").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_35 = document.getElementById("passphrasechar_35").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_36 = document.getElementById("passphrasechar_36").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_37 = document.getElementById("passphrasechar_37").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_38 = document.getElementById("passphrasechar_38").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_39 = document.getElementById("passphrasechar_39").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_40 = document.getElementById("passphrasechar_40").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_41 = document.getElementById("passphrasechar_41").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_42 = document.getElementById("passphrasechar_42").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_43 = document.getElementById("passphrasechar_43").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_44 = document.getElementById("passphrasechar_44").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_45 = document.getElementById("passphrasechar_45").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_46 = document.getElementById("passphrasechar_46").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_47 = document.getElementById("passphrasechar_47").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var passphrasechar_48 = document.getElementById("passphrasechar_48").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
var target = document.getElementById("targetaddress").value.toString().replace(/^\s+|\s+$/g, ""); // trim white space
                
                var checkphrase = "";
//     var combos = [];
                var bytes;
                var btcKey;
                var bitcoinAddress;                
                var attempts = 0;
                
                var len_1 = passphrasechar_1.length;
                var len_2 = passphrasechar_2.length;
                var len_3 = passphrasechar_3.length;
                var len_4 = passphrasechar_4.length;
                var len_5 = passphrasechar_5.length;
                var len_6 = passphrasechar_6.length;
                var len_7 = passphrasechar_7.length;
                var len_8 = passphrasechar_8.length;
                var len_9 = passphrasechar_9.length;
                var len_10 = passphrasechar_10.length;
                var len_11 = passphrasechar_11.length;
                var len_12 = passphrasechar_12.length;
                var len_13 = passphrasechar_13.length;
                var len_14 = passphrasechar_14.length;
                var len_15 = passphrasechar_15.length;
                var len_16 = passphrasechar_16.length;
                var len_17 = passphrasechar_17.length;
                var len_18 = passphrasechar_18.length;
                var len_19 = passphrasechar_19.length;
                var len_20 = passphrasechar_20.length;
                var len_21 = passphrasechar_21.length;
                var len_22 = passphrasechar_22.length;
                var len_23 = passphrasechar_23.length;
                var len_24 = passphrasechar_24.length;
                var len_25 = passphrasechar_25.length;
                var len_26 = passphrasechar_26.length;
                var len_27 = passphrasechar_27.length;
                var len_28 = passphrasechar_28.length;
                var len_29 = passphrasechar_29.length;
                var len_30 = passphrasechar_30.length;
                var len_31 = passphrasechar_31.length;
                var len_32 = passphrasechar_32.length;
                var len_33 = passphrasechar_33.length;
                var len_34 = passphrasechar_34.length;
                var len_35 = passphrasechar_35.length;
                var len_36 = passphrasechar_36.length;
                var len_37 = passphrasechar_37.length;
                var len_38 = passphrasechar_38.length;
                var len_39 = passphrasechar_39.length;
                var len_40 = passphrasechar_40.length;
                var len_41 = passphrasechar_41.length;
                var len_42 = passphrasechar_42.length;
                var len_43 = passphrasechar_43.length;
                var len_44 = passphrasechar_44.length;
                var len_45 = passphrasechar_45.length;
                var len_46 = passphrasechar_46.length;
                var len_47 = passphrasechar_47.length;
                var len_48 = passphrasechar_48.length;
                    
                var totalcombinations =
                    len_1*len_2*len_3*len_4*len_5*len_6*len_7*len_8*len_9*len_10*
                    len_11*len_12*len_13*len_14*len_15*len_16*len_17*len_18*len_19*len_20*
                    len_21*len_22*len_23*len_24*len_25*len_26*len_27*len_28*len_29*len_30*
                    len_31*len_32*len_33*len_34*len_35*len_36*len_37*len_38*len_39*len_40*
                    len_41*len_42*len_43*len_44*len_45*len_46*len_47*len_48  
                    ;
                    
                //var attemptedpercent = 0;
                
                var i_1 = 0; while ((i_1 < len_1) && (bitcoinAddress != target)) {
                var i_2 = 0; while ((i_2 < len_2) && (bitcoinAddress != target)) {
                var i_3 = 0; while ((i_3 < len_3) && (bitcoinAddress != target)) {
                var i_4 = 0; while ((i_4 < len_4) && (bitcoinAddress != target)) {
                var i_5 = 0; while ((i_5 < len_5) && (bitcoinAddress != target)) {
                var i_6 = 0; while ((i_6 < len_6) && (bitcoinAddress != target)) {
                var i_7 = 0; while ((i_7 < len_7) && (bitcoinAddress != target)) {
                var i_8 = 0; while ((i_8 < len_8) && (bitcoinAddress != target)) {
                var i_9 = 0; while ((i_9 < len_9) && (bitcoinAddress != target)) {
                var i_10 = 0; while ((i_10 < len_10) && (bitcoinAddress != target)) {
                var i_11 = 0; while ((i_11 < len_11) && (bitcoinAddress != target)) {
                var i_12 = 0; while ((i_12 < len_12) && (bitcoinAddress != target)) {
                var i_13 = 0; while ((i_13 < len_13) && (bitcoinAddress != target)) {
                var i_14 = 0; while ((i_14 < len_14) && (bitcoinAddress != target)) {
                var i_15 = 0; while ((i_15 < len_15) && (bitcoinAddress != target)) {
                var i_16 = 0; while ((i_16 < len_16) && (bitcoinAddress != target)) {
                var i_17 = 0; while ((i_17 < len_17) && (bitcoinAddress != target)) {
                var i_18 = 0; while ((i_18 < len_18) && (bitcoinAddress != target)) {
                var i_19 = 0; while ((i_19 < len_19) && (bitcoinAddress != target)) {
                var i_20 = 0; while ((i_20 < len_20) && (bitcoinAddress != target)) {
                var i_21 = 0; while ((i_21 < len_21) && (bitcoinAddress != target)) {
                var i_22 = 0; while ((i_22 < len_22) && (bitcoinAddress != target)) {
                var i_23 = 0; while ((i_23 < len_23) && (bitcoinAddress != target)) {
                var i_24 = 0; while ((i_24 < len_24) && (bitcoinAddress != target)) {
                var i_25 = 0; while ((i_25 < len_25) && (bitcoinAddress != target)) {
                var i_26 = 0; while ((i_26 < len_26) && (bitcoinAddress != target)) {
                var i_27 = 0; while ((i_27 < len_27) && (bitcoinAddress != target)) {
                var i_28 = 0; while ((i_28 < len_28) && (bitcoinAddress != target)) {
                var i_29 = 0; while ((i_29 < len_29) && (bitcoinAddress != target)) {
                var i_30 = 0; while ((i_30 < len_30) && (bitcoinAddress != target)) {
                var i_31 = 0; while ((i_31 < len_31) && (bitcoinAddress != target)) {
                var i_32 = 0; while ((i_32 < len_32) && (bitcoinAddress != target)) {
                var i_33 = 0; while ((i_33 < len_33) && (bitcoinAddress != target)) {
                var i_34 = 0; while ((i_34 < len_34) && (bitcoinAddress != target)) {
                var i_35 = 0; while ((i_35 < len_35) && (bitcoinAddress != target)) {
                var i_36 = 0; while ((i_36 < len_36) && (bitcoinAddress != target)) {
                var i_37 = 0; while ((i_37 < len_37) && (bitcoinAddress != target)) {
                var i_38 = 0; while ((i_38 < len_38) && (bitcoinAddress != target)) {
                var i_39 = 0; while ((i_39 < len_39) && (bitcoinAddress != target)) {
                var i_40 = 0; while ((i_40 < len_40) && (bitcoinAddress != target)) {
                var i_41 = 0; while ((i_41 < len_41) && (bitcoinAddress != target)) {
                var i_42 = 0; while ((i_42 < len_42) && (bitcoinAddress != target)) {
                var i_43 = 0; while ((i_43 < len_43) && (bitcoinAddress != target)) {
                var i_44 = 0; while ((i_44 < len_44) && (bitcoinAddress != target)) {
                var i_45 = 0; while ((i_45 < len_45) && (bitcoinAddress != target)) {
                var i_46 = 0; while ((i_46 < len_46) && (bitcoinAddress != target)) {
                var i_47 = 0; while ((i_47 < len_47) && (bitcoinAddress != target)) {
                var i_48 = 0; while ((i_48 < len_48) && (bitcoinAddress != target)) {
                    checkphrase =
                        passphrasechar_1[i_1] +
                        passphrasechar_2[i_2] +
                        passphrasechar_3[i_3] +
                        passphrasechar_4[i_4] +
                        passphrasechar_5[i_5] +
                        passphrasechar_6[i_6] +
                        passphrasechar_7[i_7] +
                        passphrasechar_8[i_8] +
                        passphrasechar_9[i_9] +
                        passphrasechar_10[i_10] +
                        passphrasechar_11[i_11] +
                        passphrasechar_12[i_12] +
                        passphrasechar_13[i_13] +
                        passphrasechar_14[i_14] +
                        passphrasechar_15[i_15] +
                        passphrasechar_16[i_16] +
                        passphrasechar_17[i_17] +
                        passphrasechar_18[i_18] +
                        passphrasechar_19[i_19] +
                        passphrasechar_20[i_20] +
                        passphrasechar_21[i_21] +
                        passphrasechar_22[i_22] +
                        passphrasechar_23[i_23] +
                        passphrasechar_24[i_24] +
                        passphrasechar_25[i_25] +
                        passphrasechar_26[i_26] +
                        passphrasechar_27[i_27] +
                        passphrasechar_28[i_28] +
                        passphrasechar_29[i_29] +
                        passphrasechar_30[i_30] +
                        passphrasechar_31[i_31] +
                        passphrasechar_32[i_32] +
                        passphrasechar_33[i_33] +
                        passphrasechar_34[i_34] +
                        passphrasechar_35[i_35] +
                        passphrasechar_36[i_36] +
                        passphrasechar_37[i_37] +
                        passphrasechar_38[i_38] +
                        passphrasechar_39[i_39] +
                        passphrasechar_40[i_40] +
                        passphrasechar_41[i_41] +
                        passphrasechar_42[i_42] +
                        passphrasechar_43[i_43] +
                        passphrasechar_44[i_44] +
                        passphrasechar_45[i_45] +
                        passphrasechar_46[i_46] +
                        passphrasechar_47[i_47] +
                        passphrasechar_48[i_48]
                    ;
                    
                    bytes = Crypto.SHA256(checkphrase, { asBytes: true });
                    btcKey = new Bitcoin.ECKey(bytes);
                    bitcoinAddress = btcKey.getBitcoinAddress();
                    
//combos.push(checkphrase + ", " + bitcoinAddress);
                    attempts++;
                    
                    //attemptedpercent = attempts / totalcombinations * 100;
                    document.getElementById("bulktextarea2").value = "Combinations tried: " + attempts + " out of " + totalcombinations; // + " (" + attemptedpercent.toFixed(2) + "%)";
                    
                    
                    i_48++;}
                    i_47++;}
                    i_46++;}
                    i_45++;}                
                    i_44++;}
                    i_43++;}
                    i_42++;}
                    i_41++;}                
                    i_40++;}
                    i_39++;}                
                    i_38++;}
                    i_37++;}
                    i_36++;}
                    i_35++;}                
                    i_34++;}
                    i_33++;}
                    i_32++;}
                    i_31++;}                
                    i_30++;}
                    i_29++;}                
                    i_28++;}
                    i_27++;}
                    i_26++;}
                    i_25++;}                
                    i_24++;}
                    i_23++;}
                    i_22++;}
                    i_21++;}                
                    i_20++;}
                    i_19++;}                
                    i_18++;}
                    i_17++;}
                    i_16++;}
                    i_15++;}                
                    i_14++;}
                    i_13++;}
                    i_12++;}
                    i_11++;}                
                    i_10++;}
                    i_9++;}                
                    i_8++;}
                    i_7++;}
                    i_6++;}
                    i_5++;}                
                    i_4++;}
                    i_3++;}
                    i_2++;}
                    i_1++;
                }                

                if (bitcoinAddress == target)
                {
                    var privWif = btcKey.getBitcoinWalletImportFormat();
                    document.getElementById("brainbtcaddress").innerHTML = bitcoinAddress;
                    document.getElementById("brainbtcprivwif").innerHTML = privWif;
                    ninja.qrCode.showQrCode({
                        "brainqrcodepublic": bitcoinAddress,
                        "brainqrcodeprivate": privWif
                    });
                    document.getElementById("brainkeyarea").style.visibility = "visible";
                }

},

clear: function () {
document.getElementById("brainkeyarea").style.visibility = "hidden";
},

showToggle: function (element) {
if (element.checked) {
document.getElementById("brainpassphrase").setAttribute("type", "text");
document.getElementById("brainpassphraseconfirm").style.visibility = "hidden";
document.getElementById("brainlabelconfirm").style.visibility = "hidden";
}
else {
document.getElementById("brainpassphrase").setAttribute("type", "password");
document.getElementById("brainpassphraseconfirm").style.visibility = "visible";
document.getElementById("brainlabelconfirm").style.visibility = "visible";
}
}
};
</script>
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714968415
Hero Member
*
Offline Offline

Posts: 1714968415

View Profile Personal Message (Offline)

Ignore
1714968415
Reply with quote  #2

1714968415
Report to moderator
1714968415
Hero Member
*
Offline Offline

Posts: 1714968415

View Profile Personal Message (Offline)

Ignore
1714968415
Reply with quote  #2

1714968415
Report to moderator
1714968415
Hero Member
*
Offline Offline

Posts: 1714968415

View Profile Personal Message (Offline)

Ignore
1714968415
Reply with quote  #2

1714968415
Report to moderator
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
November 29, 2013, 07:34:49 AM
 #2

Your link isn't much help as it's thousands of lines of code (why don't you just paste your relevant function rather than the whole of the bitaddress.org webpage that presumably includes your code "somewhere" inside) - but basically you will want to use a timer function for your looping.

Here is a simple timer example:
Code:
var auto_refresh_seconds = 30;

function auto_refresh( )
{
   if( auto_refresh_seconds == 1 )
      window.location.replace( window.location );
   else if( auto_refresh_seconds > 0 )
   {
      auto_refresh_seconds -= 1;
      setTimeout( "auto_refresh( )", 1000 );
   }
}

function load( )
{
   auto_refresh( );
}

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 07:40:48 AM
Last edit: November 29, 2013, 08:06:52 AM by Cyberdyne
 #3

Your link isn't much help as it's thousands of lines of code (why don't you just paste your relevant function rather than the whole of the bitaddress.org webpage that presumably includes your code "somewhere" inside) - but basically you will want to use a timer function for your looping.


Good idea, although I'm so embarrassed by my lack of array usage Smiley

OP updated.

As far as timer usage goes, you're very likely correct that it needs some kind of setTimeout(), however I can't get my own head around how to do it yet. Willing to pay some Javascript guru for the help.
schalk
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
November 29, 2013, 08:08:34 AM
 #4

I think the main issue is that you are using iteration instead of recursion. If I have time I'll post up a sample that'll help you fix it.
KieranJones1
Member
**
Offline Offline

Activity: 126
Merit: 10


View Profile
November 29, 2013, 08:15:58 AM
 #5

As schalk said, your main issue is using iteration instead of recursion. Here's a much better approach.

First, you'll need some understanding of what is meant by a "graph" in CS. A graph is an organization of nodes and edges. The nodes contain data or represent state, and the edges represent connections between pieces of data or transitions between states. (Apologies if you knew this already, but I figured you were looking for a full explanation.)

For our purposes, think of each letter in the word as a node, and the edges connect in the obvious way, from the first letter to the second, etc. We're going to search the graph for the correct sequence.

For simplicity, let's say that our starting node is empty. Let's pretend your password is some upper/lower combo of abcde, in that order.

So our blank node has two edges, leading to a and A.
a has two edges, leading to b and B
A has two edges, leading to b and B

We'll be using a concept known as depth first search. Essentially, we're going to dive down to the bottom of the graph, because those are the only valid solutions in our case. Assuming you're familiar with how recursion works, you'd have a function that takes a string and a position, where the position refers to the index of the next character to be appended to the string.

When the index is past the end of the string, you have a possible password and you should try it. If not, you return from the function and it unwinds up the stack.

A third parameter would be helpful - a boolean representing whether it should be upper or lower. So you call your search function from the implicit blank node, pass in an empty string, 0, and true - then call it again with an empty string, 0, and false. That will search the entire graph of upper and lower combinations.

Let me know if this is the kind of advice you were looking for! Smiley
schalk
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
November 29, 2013, 08:20:36 AM
 #6

Here is some code that will allow you too check using recursion:

Code:

function test(target, current, characters, index)
{
if (index == characters.length)
{
if (current == target)
{
console.log("found");
}
return;
}

var currentLetters = characters[index];
for(var i = 0; i < currentLetters.length; i++)
{

test(target, current + currentLetters[i], characters, index + 1);
}
}

// get pass character elements
var characters = [];
var index = 1;
while ($("input[type=text][tabindex='" + index + "']") !== null) {
var value = $("input[type=text][tabindex='" + index + "']").value.toString().replace(/^\s+|\s+$/g, "");
if (value != "") {
characters.push(value);
}
index++;
}

console.log(characters);

var target = document.getElementById("targetaddress").value.toString().replace(/^\s+|\s+$/g, "");
var current = "";

console.log(target);

test(target, current, characters, 0);
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 08:21:47 AM
 #7

I think the main issue is that you are using iteration instead of recursion. If I have time I'll post up a sample that'll help you fix it.

Thank you for your reply schalk and KieranJones1.

Yes, the above was a quick and dirty copy/paste job. I'm familiar with recursion but just feel like paying someone else to do this at the moment rather than spend time on it. As the issue involves my own personal money, I feel too emotionally involved to want to code this myself right now.

I've tried 2048 combinations with no luck, but need a more solid solution that will help me test about 8 or 16m.

Again, anyone able to provide me with a complete solution (rather than just coding help) will be well rewarded.
schalk
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
November 29, 2013, 08:25:03 AM
 #8

Can you please leave this bounty for me. I'm closish to having a solution.
KieranJones1
Member
**
Offline Offline

Activity: 126
Merit: 10


View Profile
November 29, 2013, 08:26:00 AM
 #9

You never explicitly asked for code, just "help" Tongue No problem, though, I hope my explanation helped rather than confused things.
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 08:32:58 AM
 #10

You never explicitly asked for code, just "help" Tongue

Quote
What I need is for this whole thing to be modified

I do appreciate your input Kieran, PM me your address for a tip.
schalk
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
November 29, 2013, 08:38:34 AM
 #11

http://pastebin.com/P2ghHZrg# full solution

Please tip 18xavJxp7Wxs3vjQvLAsfpTyt9RDBin4RB if you are satisfied with the solution

EDIT: Sorry just read your previous post about it needing to have the ability to do 16million combinations. I'm unsure if my solution is capable of that.

I think you'd be better off with a desktop application solution as opposed to a javascript one if you're planning on generating upto 16 million bitcoin addresses.
KieranJones1
Member
**
Offline Offline

Activity: 126
Merit: 10


View Profile
November 29, 2013, 08:49:02 AM
 #12

Just received my tip, thank you very much OP. I hope you get the solution you're after!
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 08:53:59 AM
 #13

http://pastebin.com/P2ghHZrg# full solution

Please tip 18xavJxp7Wxs3vjQvLAsfpTyt9RDBin4RB if you are satisfied with the solution

EDIT: Sorry just read your previous post about it needing to have the ability to do 16million combinations. I'm unsure if my solution is capable of that.

I think you'd be better off with a desktop application solution as opposed to a javascript one if you're planning on generating upto 16 million bitcoin addresses.

Why would it be incapable of a particular number? The main point is that I should be able to see it's progress without the browser hanging.

If I have no success with 16m, I may even have to go back and try doing a 64m or 128m run... depending on how things go.

I'll take a look at your code now anyway, thank you so much for your efforts.
tubbyjr
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
November 29, 2013, 08:55:26 AM
 #14

Here's my solution

http://pastebin.com/NWc2rWWr

Does what you asked for, it does not cause the browser to hang. Updates the combinations, it won't show every increase in text area, due to the code seemingly going to fast for JS to actually constantly update the text area value, but i added code so the progress shows up in your console, in real time. So if you go to web developer tools, and console, you'll see realtime data.
tubbyjr
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
November 29, 2013, 08:57:52 AM
 #15

I'm doing 6M combos at the moment, note, it will take about 30 seconds for it to start up, when doing this many combos. More for 16M ofc.

EDIT: Something odd happened lol, once I passed 5000, the textarea actually updates in realtime now, and console is lagging lol. So you might even wanna consider commenting out the console.log code I added.

EDIT2: What happened was my console window actually got too full, once i closed and reopened it, it was showing realtime too. Browser does not hang Smiley.
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 09:01:33 AM
 #16


Hi schalk,

The only thing yours is doing for me, is posting a javascript alert() saying 'done', at the end of it's run. It is not updating me on the progress of how many have been checked as they're being checked. Did you take a look at how the 'bulk wallet' generate tab works, as suggested in the OP?

I will now take a look at tubbyjr's solution.

Thanks.
tubbyjr
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
November 29, 2013, 09:08:30 AM
 #17

If you wish to tip or pay, please do it to the following address: 1KU8RFgfVqaqUNTB8uA7MLzbZJTuEwQCQ3
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 09:10:19 AM
 #18


Hi Tubby,

Your progress alert is working how I'd expect, however your code doesn't seem to be actually checking each address against the target. Once the target address is found, it should stop processing and show what phrase generated that address.

I tried your code with the following phrase:

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv

The real bitaddress.org says the address for that is 1KVGuANp3HyH4m6xQYhUV9EWhq6tUVypAG

So, in your html, I input:

a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
abcdefghijklmnopqrstuvwxyz
1KVGuANp3HyH4m6xQYhUV9EWhq6tUVypAG

There are 26 combinations in the above, but your code tries all 26 of them with no 'success', whereas it should have found success on the 23rd 22nd attempt.

My originally supplied code in the OP does properly check the target address and stop processing at that point, so this is functionality that you have broken or removed in your version. If you can put that functionality back in, the bounty would be yours.

Thanks very much.
tubbyjr
Full Member
***
Offline Offline

Activity: 182
Merit: 100


View Profile
November 29, 2013, 09:24:08 AM
 #19

Ugh, yes unfortunately I just noticed that :S. I'm trying some workarounds right now to fix it, it's 4:30 am here :p, may be going to sleep soon, but if it's still up for tomorrow, I'll definitely jump on it.
Cyberdyne (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
November 29, 2013, 09:44:27 AM
 #20

EDIT2: What happened was my console window actually got too full, once i closed and reopened it, it was showing realtime too. Browser does not hang Smiley.

I can reproduce that experience Smiley It would be cool if this console (on Chrome at least) could be set to only display a certain number of lines and discard the earlier lines! Limiting the console window to 1000 lines or something would be handy.

p.s. On my i7 2600k, doing 8m in Javascript should take about 39 hours. Not great, but at least it's not 39 years. If it turns out I need to check more than 8m, I'll probably start hunting for a c++ (and gpu) solution.

Pages: [1] 2 3 4 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!