-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathminiminer.html
610 lines (548 loc) · 19.4 KB
/
miniminer.html
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
<!DOCTYPE html>
<html>
<head>
<title>Duino-Coin Mini Miner 3.2.1</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.includes%2CNumber.parseFloat%2CNumber.parseInt%2CString.prototype.includes%2CDate.now%2CURLSearchParams%2CURL"></script>
<link rel="icon" type="image/x-icon" href="/assets/miniminer.ico">
<link rel="shortcut icon" type="image/x-icon" href="/assets/miniminer.ico">
<style>
body {
background-color: #FFFFCC;
text-align: center;
color: #330000;
max-width: 360px;
}
.heading {
margin-top: 0;
margin-bottom: 0;
}
.success {
color: #00CC00;
}
.info {
color: #0099FF;
}
.error {
color: #CC0000;
}
h6 {
margin-bottom: 0
}
button {
margin-top: 5px;
margin-bottom: 10px;
background-color: #00CC00;
color: #fff;
border: none;
font-size: 16px;
padding: 5px;
}
li {
margin-bottom: 5px;
}
ul {
text-align: left;
}
</style>
</head>
<body>
<h1 class="heading">Duino-Coin</h1>
<h2 class="heading">Mini Miner <small>3.2</small></h2>
<p class="heading">
A web miner for devices with limited functionality<br>
<small>(HTML 4.0, only basic JavaScript and styling)</small><br>
<small class="info">
Made in 2022 by
<a href="https://piotrowsky.dev" target="_blank">revox</a>
from
<a href="https://duinocoin.com/team" target="_blank">the Duino Team</a>
•
<a href="https://github.com/revoxhere/duco-webservices" target="_blank">GitHub</a>
</small>
</p>
<h4 class="error">
<b>Warning:</b> please be careful when starting this miner if you're on a PC or a modern smartphone. Your browser <b>may</b> freeze.<br>
<b>Use the
<a href="https://server.duinocoin.com/webminer.html">full web miner</a>
on modern devices</b>.
</h4>
<h4 class="info">
<b>Info:</b> for now this miner only supports one miner per username.
</h4>
<br>
<label for="username">Username</label><br>
<input id="username" placeholder="Username">
<br>
<label for="key">Mining key (if any)</label><br>
<input id="key" show="*" type="password" placeholder="Mining key (if any)">
<br>
<button id="button" onclick="startMining()">Start mining</button><br>
Accepted: <span id="accepted">0</span><br>
Rejected: <span id="rejected">0</span><br>
Hashrate: <span id="hashrate">0 H/s</span><br>
Last share: <span id="sharetime">0</span>s<br>
Difficulty <small>(Kolka 3)</small>: <span id="difficulty">0</span><br>
<br>
<h3 class='heading'>Tested devices (and browsers)</h3>
<ul align="left">
<li>
Samsung SGH-L700 (2008) -
(NetFront 3.4) -
<span class="success">works with ocassional freezes</span>,
<b>2.7 H/s</b> (credit: <b>Techcrafter</b>)
</li>
<li>
Nintendo DSi XL (2009) -
<span class="success">works perfectly</span>,
<b>9.3 H/s</b> (credit: <b>lsadf</b>)
</li>
<li>
Motorola Symbol (2009) -
<span class="success">works perfectly</span>,
<b>3.88 H/s</b> (credit: <b>Dark_Hunter</b>)
</li>
<li>
Samsung GT-S3350 (2010) -
(NetFront 3.5) -
<span class="success">works perfectly</span>,
<b>3.5 H/s</b> (credit: <b>revox</b>)
</li>
<li>
Samsung GT-S3350 (2010) -
(Opera Mini) -
<span class="info">works for a limited time (Opera limitation)</span>,
<b>5 kH/s</b> (credit: <b>revox</b>)
</li>
<li>
Nokia X2-00 (2010) -
<span class="error">not working (XMLHttpRequest error)</span>,
(credit: <b>ACoTam2</b>)
</li>
<li>
Android 2.3.6 (2010) -
<span class="success">works perfectly</span>,
<b>940 H/s</b> (credit: <b>JustKenux</b>)
</li>
<li>
Huawei U8110 (2010) -
<span class="success">works perfectly</span>,
<b>83.5 H/s</b> (credit: <b>Torpeda</b>)
</li>
<li>
Ipad 1st gen v5.1.1 (2010)
<span class="success">works perfectly</span>
(credit: <b>farfadet46</b>)
<li>
HTC Explorer A310e (2011) -
<span class="success">works perfectly</span>,
<b>920 H/s</b> (credit: <b>Olim</b>)
</li>
<li>
Nokia Lumia 610 (2012) -
(IE Mobile 9.0) -
<span class="success">works with ocassional freezes</span>,
<b>400 H/s</b> (credit: <b>revox</b>)
</li>
<li>
Nokia Lumia 920 (2012) -
(IE Mobile 11.0) -
<span class="success">works perfectly</span>,
<b>7 kH/s</b> (credit: <b>revox</b>)
</li>
<li>
Nintendo 2DS (2013) -
<span class="info">possibly working, script message pops up</span>,
(credit: <b>lsadf</b>)
</li>
<li>
Apple Watch SE (2020) -
<span class="success">works perfectly</span>,
<b>3.4 kH/s</b> (credit: <b>JustinKopf</b>)
</li>
</ul>
</body>
<script>
document.write("<h3 class='heading'>Init log</h3>")
document.write("<span class='success'>JavaScript init successful</span><br>");
document.write("<span class='info'>Running on " + window.location.href + "</span><br>")
if (window.location.href.indexOf("https") > -1) document.write("<span class='info'>HTTPS enabled</span><br>");
else document.write("<span class='info'>HTTPS disabled</span><br>");
window.sha1 = (function() {
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS 180-1
* Version 2.2 Copyright Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
// Convert a raw string to a hex string
function rawToHex(raw) {
var hex = "";
var hexChars = "0123456789abcdef";
for (var i = 0; i < raw.length; i++) {
var c = raw.charCodeAt(i);
hex += (
hexChars.charAt((c >>> 4) & 0x0f) +
hexChars.charAt(c & 0x0f));
}
return hex;
}
// Calculate the SHA1 of a raw string
function sha1Raw(raw) {
return binaryToRaw(sha1Binary(rawToBinary(raw), raw.length * 8));
}
/*
* Convert an array of big-endian words to a string
*/
function binaryToRaw(bin) {
var raw = "";
for (var i = 0, il = bin.length * 32; i < il; i += 8) {
raw += String.fromCharCode((bin[i >> 5] >>> (24 - i % 32)) & 0xff);
}
return raw;
}
/*
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function sha1Binary(bin, len) {
// append padding
bin[len >> 5] |= 0x80 << (24 - len % 32);
bin[((len + 64 >> 9) << 4) + 15] = len;
var w = new Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
for (var i = 0, il = bin.length; i < il; i += 16) {
var _a = a;
var _b = b;
var _c = c;
var _d = d;
var _e = e;
for (var j = 0; j < 80; j++) {
if (j < 16) {
w[j] = bin[i + j];
} else {
w[j] = _rotateLeft(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
}
var t = _add(_add(_rotateLeft(a, 5), _ft(j, b, c, d)),
_add(_add(e, w[j]), _kt(j)));
e = d;
d = c;
c = _rotateLeft(b, 30);
b = a;
a = t;
}
a = _add(a, _a);
b = _add(b, _b);
c = _add(c, _c);
d = _add(d, _d);
e = _add(e, _e);
}
return [a, b, c, d, e];
}
// Add integers, wrapping at 2^32. This uses 16-bit operations internally
// to work around bugs in some JS interpreters.
function _add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function _rotateLeft(n, count) {
return (n << count) | (n >>> (32 - count));
}
/*
* Perform the appropriate triplet combination function for the current
* iteration
*/
function _ft(t, b, c, d) {
if (t < 20) {
return (b & c) | ((~b) & d);
} else if (t < 40) {
return b ^ c ^ d;
} else if (t < 60) {
return (b & c) | (b & d) | (c & d);
} else {
return b ^ c ^ d;
}
}
/*
* DeterMine the appropriate additive constant for the current iteration
*/
function _kt(t) {
if (t < 20) {
return 1518500249;
} else if (t < 40) {
return 1859775393;
} else if (t < 60) {
return -1894007588;
} else {
return -899497514;
}
}
// Convert a raw string to an array of big-endian words.
// Characters >255 have their high-byte silently ignored.
function rawToBinary(raw) {
var binary = new Array(raw.length >> 2);
for (var i = 0, il = binary.length; i < il; i++) {
binary[i] = 0;
}
for (i = 0, il = raw.length * 8; i < il; i += 8) {
binary[i >> 5] |= (raw.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
}
return binary;
}
// Encode a string as UTF-8.
// For efficiency, this assumes the input is valid UTF-16.
function stringToRaw(string) {
var raw = "",
x, y;
var i = -1;
var il = string.length;
while (++i < il) {
// decode UTF-16 surrogate pairs
x = string.charCodeAt(i);
y = i + 1 < il ? string.charCodeAt(i + 1) : 0;
if (0xd800 <= x && x <= 0xdbff && 0xdc00 <= y && y <= 0xdfff) {
x = 0x10000 + ((x & 0x03ff) << 10) + (y & 0x03ff);
++i;
}
// encode output as UTF-8
if (x <= 0x7f) {
raw += String.fromCharCode(x);
} else if (x <= 0x7ff) {
raw += String.fromCharCode(0xc0 | ((x >>> 6) & 0x1f),
0x80 | (x & 0x3f));
} else if (x <= 0xffff) {
raw += String.fromCharCode(0xe0 | ((x >>> 12) & 0x0f),
0x80 | ((x >>> 6) & 0x3f),
0x80 | (x & 0x3f));
} else if (x <= 0x1fffff) {
raw += String.fromCharCode(0xf0 | ((x >>> 18) & 0x07),
0x80 | ((x >>> 12) & 0x3f),
0x80 | ((x >>> 6) & 0x3f),
0x80 | (x & 0x3f));
}
}
return raw;
}
// Calculate the HMAC-SHA1 of a key and some data (raw strings)
function hmacRaw(key, data) {
var binaryKey = rawToBinary(key);
if (binaryKey.length > 16) {
binaryKey = sha1Binary(binaryKey, key.length * 8);
}
var ipad = new Array(16);
var opad = new Array(16);
for (var i = 0; i < 16; i++) {
ipad[i] = binaryKey[i] ^ 0x36363636;
opad[i] = binaryKey[i] ^ 0x5c5c5c5c;
}
var hash = sha1Binary(ipad.concat(rawToBinary(data)), 512 + data.length * 8);
return binaryToRaw(sha1Binary(opad.concat(hash), 512 + 160));
}
return {
sha1: function(s) {
return rawToHex(sha1Raw(stringToRaw(s)));
},
sha1Hex: function(value) {
return rawToHex(sha1Raw(this.hexToString(value)));
},
hmac: function(k, d) {
return rawToHex(hmacRaw(stringToRaw(k), stringToRaw(d)));
},
hexToString: function(hex) {
var str = '';
for (var i = 0, il = hex.length; i < il; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return str;
},
};
})();
let XMLHttpFactories = [
function () {return new XMLHttpRequest()}, // Default Api
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
function () {return new ActiveXObject("Msxml2.XMLHTTP.6.0")},
function () {return new ActiveXObject("Msxml2.XMLHTTP.3.0")},
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];
let requestApi = false;
for (let i = 0; i < XMLHttpFactories.length; i++) {
try {
requestApi = XMLHttpFactories[i]();
}
catch (e) {
continue;
}
break;
}
if(!requestApi)
{
document.write("<span class='error'> We can't make an http request.</span><br><br>");
document.write("<span class='info'>Try searching for help on our official Discord server (<a href='https://discord.gg/kvBkccy' target='_blank'>discord.gg/kvBkccy</a>) or GitHub (<a href='https://github.com/revoxhere/duino-coin'>github.com/revoxhere/duino-coin</a>)</span><br><b>You can also open the troubleshooting page</b> (<a href='/webtest.html' target='_blank'>webtest.html</a>)");
document.getElementById("button").innerHTML = "Error";
}
function httpGet(theUrl) {
requestApi.open("GET", theUrl, false);
requestApi.send(null);
return requestApi.responseText;
}
function httpPost(theUrl) {
requestApi.open("POST", theUrl, false);
requestApi.send(null);
return requestApi.responseText;
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
function roundTo(precision, value) {
power_of_ten = 10 * (precision * precision);
return Math.round(value * power_of_ten) / power_of_ten;
}
function getPrefix(value) {
value = parseFloat(value);
if (value / 1000000 > 0.5)
value = roundTo(4, value / 1000000) + " M";
else if (value / 1000 > 0.5)
value = roundTo(3, value / 1000) + " k";
else
value = roundTo(2, value) + " ";
return value;
}
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
accepted = 0;
rejected = 0;
hashrate = 0;
sharetime = 0;
difficulty = 0;
function Mine() {
username = document.getElementById("username").value;
key = document.getElementById("key").value;
//if (!username) {
// alert("Please enter your username");
// return;
//}
setCookie("username", username, 14);
setCookie("key", key, 14);
document.getElementById("hashrate").innerHTML = getPrefix(hashrate) + " H/s";
document.getElementById("accepted").innerHTML = accepted;
document.getElementById("rejected").innerHTML = rejected;
document.getElementById("sharetime").innerHTML = sharetime;
document.getElementById("difficulty").innerHTML = difficulty;
base_url = "http://51.15.127.80";
if (window.location.href.indexOf("https") > -1) {
base_url = "https://server.duinocoin.com";
}
try {
job = httpGet(base_url +
"/legacy_job?u=" + username +
"&i=" + navigator.userAgent +
"&nocache=" + new Date().getTime());
last_block_hash = job.split(",")[0];
expected_hash = job.split(",")[1];
difficulty = job.split(",")[2];
timeStart = new Date().getTime();
for (result = 0; result < difficulty * 100; result++) {
current_hash = sha1.sha1(last_block_hash + result)
if (current_hash == expected_hash) {
break;
}
}
timeStop = new Date().getTime();
timeDiff = (timeStop - timeStart) / 1000;
sharetime = roundTo(2, timeDiff);
hashrate = (result / timeDiff);
feedback = httpPost(base_url +
"/legacy_job?u=" + username +
"&r=" + result +
"&k=" + key +
"&s=Official Mini Miner 3.2" +
"&j=" + expected_hash +
"&i=" + navigator.userAgent +
"&h=" + hashrate +
"&b=" + sharetime +
"&nocache=" + new Date().getTime());
if (feedback == "GOOD") {
accepted++;
} else {
rejected++;
}
setTimeout(Mine(username), 500);
} catch (err) {
document.write("<span class='error'>" + err + "</span><br><br>");
document.write("<span class='info'>Try searching for help on our official Discord server (<a href='https://discord.gg/kvBkccy' target='_blank'>discord.gg/kvBkccy</a>) or GitHub (<a href='https://github.com/revoxhere/duino-coin'>github.com/revoxhere/duino-coin</a>)</span><br><b>You can also open the troubleshooting page</b> (<a href='/webtest.html' target='_blank'>webtest.html</a>)");
document.getElementById("button").innerHTML = "Error";
}
}
if (getCookie("username")) {
document.getElementById("username").value = getCookie("username");
document.write("<span class='info'>Filled username from cookie</span><br>");
}
if (getCookie("key")) {
document.getElementById("key").value = getCookie("key");
document.write("<span class='info'>Filled key from cookie</span><br>");
}
function Refresh() {
window.location.href = window.location.pathname + window.location.search + window.location.hash;
}
function startMining() {
document.getElementById("button").innerHTML = "Mining started";
setTimeout(function() { Refresh() }, restart_min * 60 * 1000);
Mine();
}
try {
var url = new URL(window.location.href);
var username = url.searchParams.get("u");
var restart_min = url.searchParams.get("r");
var key = url.searchParams.get("k");
if (!restart_min) restart_min = 20;
if (key) {
document.getElementById("key").value = key;
document.write("<span class='info'>Fetched mining key from URL parameters</span><br>");
}
if (username) {
document.getElementById("username").value = username;
document.write("<span class='info'>Fetched username from URL parameters</span><br>");
}
} catch (err) {
document.write("<span class='error'>URL parameters unsupported, use input boxes (" + err + ")</span><br>");
}
document.write("<span class='success'>JavaScript fully loaded. Miner should work!</span><br>");
if (username) {
document.write("<span class='info'>Starting mining from URL parameters</span><br>");
setTimeout(function() { startMining() }, 1000);
} else {
if (document.getElementById("username").value) {
document.write("<span class='info'>Starting mining in 5s from pre-filled input boxes</span><br>");
setTimeout(function() { startMining() }, 5000);
}
}
</script>
</html>