❓ BTC Minefield Crack
I'm trying to crack the random string that the game BTC Minefield generates for the user to see which is hidden and somehow decrypts to tell the locations of the mines and a SHA256 hash. I pulled the main JavaScript code from the site but please go here: minefield[.]bitcoinlab[.]org to understand and inspect the HTML. Here's the JS code that I cleaned up a bit:
Code:
$(document).ready(function () {
function j(F, E) {
E = E || "\\s";
return F.replace(new RegExp("^[" + E + "]+", "g"), "")
}
function a(F, E) {
E = E || "\\s";
return F.replace(new RegExp("[" + E + "]+$", "g"), "")
}
function y(F, E) {
return j(a(F, E), E)
}
function h(E) {
return E[Math.floor(Math.random() * E.length)]
}
var o = 0;
function D() {
this.subscriptions = {};
this.remoteobjects = {};
this.callback = {}
}
D.prototype.subscribe = function (F, G, H) {
var E = this;
if (!E.subscriptions[F]) {
E.subscriptions[F] = {}
}
if (!E.subscriptions[F][G]) {
E.subscriptions[F][G] = []
}
E.subscriptions[F][G].push(H)
};
D.prototype.event = function (G, I, H, J) {
var F = this;
var E = G.objectname;
if (F.subscriptions["*"]["*"]) {
F.subscriptions["*"]["*"].forEach(function (K) {
K(H, J, I, G)
})
}
if (F.subscriptions["*"][I]) {
F.subscriptions["*"][I].forEach(function (K) {
K(H, J, I, G)
})
}
if (F.subscriptions[E]["*"]) {
F.subscriptions[E]["*"].forEach(function (K) {
K(H, J, I, G)
})
}
if (!F.subscriptions[E]) {
return
}
if (!F.subscriptions[E][I]) {
return
}
F.subscriptions[E][I].forEach(function (K) {
K(H, J, I, G)
})
};
router = new D();
user = undefined;
function r(E, F) {
this.objectname = E;
if (E == "user") {
user = this
}
router.remoteobjects[E] = this;
if (!router.subscriptions[E]) {
router.subscriptions[E] = {}
}
this.update(F)
}
r.prototype.update = function (G) {
var E = this;
for (var F in G) {
function H(J, I) {
if (I == "function") {
E[J] = function () {
var N = {};
N.object = E.objectname;
N["function"] = J;
var L = Array.prototype.slice.call(arguments);
if (typeof (L[L.length - 1]) == "function") {
var M = J + new Date().getTime();
N.answerid = M;
router.callback[M] = L.pop();
setTimeout(function () {
delete router[M]
}, 10000)
}
N["arguments"] = L;
m.emit("call", JSON.stringify(N))
};
router.event(E, J);
return
}
if (!E["_" + J]) {
E.__defineSetter__(J, function (M) {
var L = {
objects: {},
secret: b
};
L.objects[E.objectname] = {};
L.objects[E.objectname][J] = M;
m.emit("objectsync", JSON.stringify(L))
});
E.__defineGetter__(J, function () {
return E["_" + J]
})
} else {
if (E["_" + J] == I) {
return
}
}
var K = E["_" + J];
E["_" + J] = I;
if (K != I) {
router.event(E, J, I, K)
}
}
H(F, G[F])
}
};
var b = "y4KBFwqTMFvsgVZq";
var f = "5356dfb4cf6eb62409003e78";
var c = {};
var A = {};
$("#bla").html("js ok");
$("#message").hide();
$(".mon").hide();
$(".editable").click(function (H) {
var G = $(H.currentTarget);
var I = G.html();
if (I.search("<input") != -1) {
return
}
var F = $("<input size='" + (I.length + 1) + "' type='text' value='" + I + "'>");
function E() {
F.trigger("edited", [G, F.val(), I]);
G.html(F.val())
}
F.blur(E);
F.keypress(function (J) {
if (J.which == 13) {
E()
}
});
G.html(F);
F.focus();
F.trigger("editstart", [G, I])
});
$(".sync_user_name").bind("edited", function (H, F, G, E) {
user.name = G
});
$("#user_withdrawal_amount").bind("edited", function (H, F, G) {
var E = parseFloat(G);
if (!E) {
n("invalid amount");
return
}
});
$("#user_withdrawal_address").bind("edited", function (G, E, F) {
F = y(F);
if ((F.length > 34) || (F.length < 27)) {
n("invalid address");
return
} else {
d("user", "address_withdrawal", F)
}
});
function q() {
$("#minefieldslider").slider({
value: 10,
min: 3,
max: 24,
step: 1,
slide: function (F, G) {
var E = 100 - (G.value / (25 / 100));
var H = (90 / E);
H = Math****und(H * 100) / 100;
x(v(G.value, o));
$("#minenum").html(G.value);
$("#sync_minefield_multi").html(H)
},
stop: function (E, F) {
$("#suggestion").html("Choose your bet to start a new game.")
}
});
C();
$("#minefield_ammount_radio").buttonset()
}
function C() {
x([
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
])
}
q();
function z() {
m.emit("initminefield", {
mines: 3
})
}
function v(N) {
function O() {
return (Math.random() > 0.5)
}
function K(P) {
return Math.floor(Math.random() * P)
}
function J(P, R) {
var Q = [];
for (var S = 0; S < P; S++) {
Q.push(R())
}
return Q
}
function M(P, Q) {
return J(P, function () {
return J(P, Q)
})
}
var F = -1;
function E() {
F++;
return F
}
var I = J(25, E);
var L = J(25, function () {
return 0
});
for (var G = 0; G < N; G++) {
var H = K(I.length);
L[I[H]] = 1;
I.splice(H, 1)
}
return M(5, function () {
var P = L.pop();
return P
})
}
function x(I) {
var H = $("<table></table>");
for (var G in I) {
row = I[G];
var F = $("<tr></tr>");
for (var E in row) {
function J(L, K) {
entry = row[K];
var N = $("<td></td>");
if (entry == 3) {
var O = $("<span class='mine mine_step_yes'></span>");
O.click(function () {
user.newminefield($("#minefieldslider").slider("value"), o)
});
N.append(O)
}
if (entry == 2) {
N.append($("<span class='mine mine_step_no'>"))
}
if (entry == 1) {
var O = $("<span class='mine mine_yes'></span>");
N.append(O)
}
if (entry == 0) {
var O = $("<span class='mine mine_no'></span>");
N.append(O)
}
if (entry == -1) {
var M = $("<span class='mine mine_undefined'></span>");
M.click(function () {
M.unbind("click");
router.remoteobjects.minefield.step([L, K])
});
N.append(M)
}
$(".mine").mousedown(function (P) {
P.preventDefault()
});
return N
}
F.append(J(G, E))
}
H.append(F)
}
$("#minefield").html(H)
}
function n(E) {
var F = $("#message");
F.html(E);
F.fadeIn(500);
setTimeout(function () {
F.fadeOut()
}, 1000)
}
function l(E) {
return Math.floor(E * 100000000)
}
function w(E) {
return Math.floor(E / 100000) / 1000
}
function k(E) {
E = String(E);
while (E.length < 9) {
E = "0" + E
}
cutpoint = E.length - 8;
E = E.substr(0, cutpoint) + "." + E.substr(cutpoint);
while (E[E.length - 1] == "0") {
E = E.substr(0, E.length - 1)
}
if (E[E.length - 1] == ".") {
E = E.substr(0, E.length - 1)
}
return E
}
function g(E) {
user.listTransactions(function (H) {
if (H.length == 0) {
var G = "no transactions"
} else {
var G = "<table cellspacing=0 cellpadding=13>";
G += "<thead>";
G += "<tr>";
G += "<th>time</th>";
G += "<th>from/to</th>";
G += "<th></th>";
G += "<th>amount</th>";
G += "<th>confirmations</th>";
G += "<th></th>";
G += "</tr>";
G += "</thead>";
G += "<tbody class='transactionhistory'>";
var F = true;
H.forEach(function (K) {
var J = new Date(parseInt(K.time));
var I = J.getDate() + "." + (J.getMonth() + 1) + "." + J.getFullYear() + ", " + J.getHours() + ":" + J.getMinutes() + ":" + J.getSeconds();
if (F) {
G += "<tr bgcolor='#ddd'>";
F = false
} else {
G += "<tr>";
F = true
}
G += "<td class='transactionhistory'>" + I + "</td>";
G += "<td class='transactionhistory'>" + K.address + "</td>";
if (K.amount > 0) {
G += "<td class='transactionhistory plus'><font color='green' size='2em'><b>+</b></font></td>"
} else {
K.amount *= -1;
G += "<td class='transactionhistory minus'><font color='red' size='2em'><b>-</b></font></td>"
}
G += "<td class='transactionhistory'>" + k(K.amount) + "</td>";
if (K.confirmed) {
K.confirmations = "<font color='green'>confirmed</font>"
}
G += "<td class='transactionhistory'>" + K.confirmations + "</td>";
G += "<td class='transactionhistory'><a href='https://blockchain.info/tx/" + K.txid + "'><img width='20px' src='/img/info.png'></a></td>";
G += "</tr>"
});
G += "</tbody></table>"
}
$("#transaction_history").html(G)
})
}
function e() {
if (router.remoteobjects.user.transaction_history.length == 0) {
var F = "no transactions"
} else {
var F = "<table cellspacing=0 cellpadding=13>";
F += "<thead>";
F += "<tr>";
F += "<th>time</th>";
F += "<th>address</th>";
F += "<th></th>";
F += "<th>amount</th>";
F += "<th>balance</th>";
F += "</tr>";
F += "</thead>";
F += "<tbody class='transactionhistory'>";
var E = true;
router.remoteobjects.user.transaction_history.forEach(function (I) {
var H = new Date(parseInt(I.time));
var G = H.getDate() + "." + H.getMonth() + "." + H.getFullYear() + ", " + H.getHours() + ":" + H.getMinutes() + ":" + H.getSeconds();
if (E) {
F += "<tr bgcolor='#ddd'>";
E = false
} else {
F += "<tr>";
E = true
}
F += "<td class='transactionhistory'>" + G + "</td>";
F += "<td class='transactionhistory'>" + I.other_party + "</td>";
if (I.deposit) {
F += "<td class='transactionhistory plus'><font color='green' size='2em'><b>+</b></font></td>"
} else {
F += "<td class='transactionhistory minus'><font color='red' size='2em'><b>-</b></font></td>"
}
F += "<td class='transactionhistory'>" + w(I.amount) + "</td>";
F += "<td class='transactionhistory'>" + w(I.balance) + "</td>";
F += "</tr>"
});
F += "</tbody></table>"
}
$("#transaction_history").html(F)
}
var m = io.connect("minefield.bitcoinlab.org:45284");
m.emit("hello", {
uid: f,
secret: b
});
m.on("answer", function (E) {
if (router.callback[E.answerid]) {
router.callback[E.answerid](JSON.parse(E.data));
delete router.callback[E.answerid]
}
});
m.on("msg", function (E) {
E = JSON.parse(E);
n(E.message)
});
m.on("objectsync", function (F) {
F = JSON.parse(F);
for (var E in F) {
p(E, F[E])
}
});
m.on("disconnect", function (E) {
location.reload(true)
});
$("#btnwithdraw").click(function () {
var E = l($("#user_withdrawal_amount").html());
if ((!E) || (E == 0)) {
n("invalid amount<br>edit the [ ammount ] field")
} else {
user.sendMoney($("#user_withdrawal_address").html(), E)
}
});
$("#btn_deposit_generate").click(function () {
user.generatedepositaddr(function (E) {})
});
$("#logout").click(function () {});
function p(E, F) {
if (!router.remoteobjects[E]) {
var G = new r(E, F);
router.remoteobjects[E] = G;
router.event(G, "created", G)
} else {
router.remoteobjects[E].update(F)
}
}
function d(E, G, F) {
router.remoteobjects[E][G] = F
}
function u(G, E) {
if (!E) {
return false
}
if ((typeof (G) != "object") || (typeof (E) != "object")) {
return (G == E)
}
if (G.length != E.length) {
return false
}
for (var F in G) {
if (G[F] != E[F]) {
return false
}
}
return true
}
router.subscribe("*", "*", function (G, H, F, E) {
if ((E[F] != undefined) && (E[F] != null)) {
$("#sync_" + E.objectname + "_" + F).html(E[F]);
$(".sync_" + E.objectname + "_" + F).html(E[F])
}
});
router.subscribe("user", "cash", function (E) {
$("#user_cash").html(k(E));
$("#user_cash_small").html(k(E))
});
router.subscribe("user", "created", function (F, G, E) {
g();
router.subscribe("user", "lasttransaction", function (I, J, H) {
g()
})
});
router.subscribe("user", "address_deposit", function (H, I, G, E) {
if (H.length == 0) {
$("#address_deposit").html("no addresses (click generate)");
$("#paybelow").hide();
return
}
var F = $("<span></span>");
H.forEach(function (J) {
F.append($("<b>" + J + "<b><br>"))
});
$("#paybelow").show();
if (H.length == 3) {
$("#btn_deposit_generate").hide()
} else {
$("#btn_deposit_generate").show()
}
$("#address_deposit").html(F)
});
router.subscribe("minefield", "done", function (G, H, F, E) {
if (G) {
$(".mon").fadeOut(200, function () {
$(".moff").fadeIn(200)
})
} else {
$(".moff").fadeOut(200, function () {
$(".mon").fadeIn(200)
})
}
});
router.subscribe("globalobject", "availiablebets", function (G, H, F, E) {
t(G)
});
$("#sync_minefield_win").click(function () {
router.remoteobjects.minefield.payout()
});
router.subscribe("minefield", "crypted", function (H, I, G, E) {
if (H != "hidden") {
var F = $("<span>" + E.hash + "</span>");
F.click(function () {
$("#minefield_crypted").fadeIn()
});
$(".sync_minefield_hash").html(F)
} else {
$("#minefield_crypted").hide()
}
});
router.subscribe("minefield", "minefield", function (G, H, F, E) {
x(G)
});
router.subscribe("user", "address_withdrawal", function (G, H, F, E) {
if (E.address_withdrawal) {
$("#user_address_withdrawal").html(E.address_withdrawal);
return
}
});
var B = [$("#tab_minefield"), $("#tab_balance"), $("#tab_referals"), $("#tab_faq")];
B.forEach(function (E) {
E.hide()
});
var i = undefined;
function s(E) {
if (i != undefined) {
B[i].trigger("tabhide");
B[i].hide()
}
B[E].trigger("tabshow");
B[E].show();
i = E
}
$("#tabbalance").bind("tabshow", function () {
$("#small_balance").hide()
});
$("#tab_balance").bind("tabhide", function () {
$("#small_balance").show()
});
$("#btnminefield").click(function () {
s(0)
});
$("#btnballance").click(function () {
s(1)
});
$("#btnreferals").click(function () {
s(2)
});
$("#btnfaq").click(function () {
s(3)
});
$("#btnminefield").click();
function t(F) {
var E = $("#betbuttons");
E.fadeOut(30, function () {
E.html("");
F.forEach(function (G) {
var H = $("<button>" + G + "</button>").button();
H.click(function () {
user.newminefield($("#minefieldslider").slider("value"), G)
});
E.append(H)
});
E.fadeIn()
})
}
});