-
Notifications
You must be signed in to change notification settings - Fork 89
/
wpspin.html
1927 lines (1799 loc) · 46.1 KB
/
wpspin.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
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<title>%l10n_title_wpspin%</title>
<head>
<script type="text/javascript">
function zeroFill(number, width)
{
width -= number.toString().length;
if (width > 0)
{
return new Array(width + (/\./.test( number ) ? 2 : 1)).join('0') + number;
}
return number + ""; // always return a string
}
function reverse(s)
{
return s.split("").reverse().join("");
}
function insert(a, b, position)
{
return [a.slice(0, position), b, a.slice(position)].join('');
}
function pinChecksum(pin)
{
pin %= 10000000;
var a = 0, t = pin;
while (t)
{
a += 3 * (t % 10);
t = Math.floor(t / 10);
a += t % 10;
t = Math.floor(t / 10);
}
return (pin * 10) + ((10 - (a % 10)) % 10);
}
function genPin(mac, sn, i)
{
return (algos[i].mode == ALGO_MACSN ? algos[i].func(mac, sn) : algos[i].func(mac));
}
function pinSuggestAPI(getAll, bssid, sn)
{
var result = [];
var mac = bssid.replace(/:/g, '').replace(/-/g, '').replace(/\./g, '').replace(/ /g, '');
mac = parseInt(mac, 16);
if (isNaN(mac) || mac > 0xFFFFFFFFFFFF) return result;
for (var i = 0; i < algos.length; i++)
{
var match = getAll;
if (!getAll)
{
var info = document.getElementById(algos[i].id).value.split("\n");
for (var k = 0; k < info.length; k++)
{
if (info[k].indexOf(' ') == 0 && info[k].lastIndexOf(':xx') == 16)
{
info[k] = info[k].substr(2);
info[k] = info[k].substr(0, info[k].indexOf('x'));
match = bssid.indexOf(info[k]) == 0;
if (match) break;
}
}
}
if (match)
{
var pin = genPin(mac, sn, i);
if (typeof pin != 'string')
{
pin = pinChecksum(pin);
pin = zeroFill(pin.toString(10), 8);
}
result.push({pin: pin, algo: i});
}
}
return result;
}
function pinSuggest()
{
$('#result').empty();
var ln = $('#bssids').val().replace(/^\s+|\s+$/g, '').split("\n");
for (var j = 0; j < ln.length; j++)
{
var m = ln[j];
var z = m.split('|');
m = z[0];
m = m.replace(/:/g, '').replace(/-/g, '').replace(/\./g, '').replace(/ /g, '');
m = parseInt(m, 16);
if (isNaN(m) || m > 0xFFFFFFFFFFFF) continue;
var mt = zeroFill(m.toString(16).toUpperCase(), 12);
mt = insert(mt, ':', 10);
mt = insert(mt, ':', 8);
mt = insert(mt, ':', 6);
mt = insert(mt, ':', 4);
mt = insert(mt, ':', 2);
$('#suggpin').text("%l10n_wpspin_suggested% "+mt+"\n\n");
var sugg = pinSuggestAPI(false, mt, z[1]);
for (var i = 0; i < sugg.length; i++)
{
var pin = sugg[i].pin;
if (pin == '')
pin = '<empty>';
pin = pin.padEnd(8);
if (algos[sugg[i].algo].mode == ALGO_STATIC)
{
$('#suggpin').append(encodeHTML(pin, true) + ' | %l10n_wpspin_static% - ' + algos[sugg[i].algo].name + "\n");
} else {
$('#suggpin').append(encodeHTML(pin, true) + ' | ' + algos[sugg[i].algo].name + "\n");
}
}
if (sugg.length > 0) $('#result').append(encodeHTML($('#suggpin').val()) + "\n");
}
$('#algosel').val('algonone');
}
function getAll()
{
var m = $('#bssids').val().replace(/^\s+|\s+$/g, '').split("\n");
if (m.length > 1)
return alert('%l10n_wpspin_one_bssid%.');
var bss = m[0].replace(/ /g, '').toUpperCase();
var z = m[0].split('|');
m[0] = z[0];
m = m[0].replace(/:/g, '').replace(/-/g, '').replace(/\./g, '').replace(/ /g, '');
m = parseInt(m, 16);
if (isNaN(m) || m > 0xFFFFFFFFFFFF)
return alert('%l10n_wpspin_bssid_wrong%.');
$('#result').text("%l10n_wpspin_all_pins% "+bss+"\n\n");
var res = pinSuggestAPI(true, bss, z[1]);
for (var i = 0; i < res.length; i++)
{
var pin = res[i].pin;
if (pin == '')
pin = '<empty>';
pin = pin.padEnd(8);
if (algos[res[i].algo].mode == ALGO_STATIC)
{
$('#result').append(encodeHTML(pin, true) + ' | %l10n_wpspin_static% - ' + algos[res[i].algo].name + "\n");
} else {
$('#result').append(encodeHTML(pin, true) + ' | ' + algos[res[i].algo].name + "\n");
}
}
$('#algosel').val('algonone');
}
function showAlgo()
{
var algo = $('#algosel').val();
$('#result').empty();
for (var i = 0; i < algos.length; i++)
{
if (algos[i].id == algo)
{
switch (algos[i].mode)
{
case ALGO_MAC:
case ALGO_MACSN:
$('#result').append(algos[i].name + " %l10n_wpspin_algo%,\n");
break;
case ALGO_STATIC:
$('#result').append(algos[i].name + " %l10n_wpspin_stat%,\n");
break;
case ALGO_EMPTY:
$('#result').append(algos[i].name + ",\n");
break;
}
$('#result').append("%l10n_wpspin_used_by%\n\n");
$('#result').append($('#' + algos[i].id).val());
break;
}
}
}
function checkDSLkeys(keys)
{
if (keys.length > 0)
{
if (keys.length == 1)
{
keys = keys[0];
var amb = false;
for (var i = 0; i < keys.length; i++)
if (keys[i].length > 1)
{
amb = true;
break;
}
if (amb)
{
$('#result').append("[*] %l10n_wpspin_dsl_key_ambig%, %l10n_wpspin_dsl_more_data%.\n");
return false;
}
else
{
$('#result').append("[+] %l10n_wpspin_dsl_key_found% "+keys.reverse().join(', ')+"\n");
return true;
}
}
else
{
$('#result').append("[*] %l10n_wpspin_dsl_many_keys% (" + keys.length + "), %l10n_wpspin_dsl_more_data%.\n");
return false;
}
}
else
{
$('#result').append("[-] %l10n_wpspin_dsl_key_not_found%.\n");
return false;
}
}
function runDSLcrack(data, bss_offset, sn_offset)
{
if (bss_offset == 0 && sn_offset == 0)
{
$('#result').append("[*] %l10n_wpspin_dsl_mode_straight%...\n");
}
else
{
var a = [];
if (bss_offset > 0)
a.push("BSSID + " + bss_offset);
if (bss_offset < 0)
a.push("BSSID - " + (-bss_offset));
if (sn_offset > 0)
a.push("SN[-" + sn_offset + "]");
if (sn_offset == -1)
a.push("derived SN (dec)");
if (sn_offset == -2)
a.push("derived SN (hex)");
$('#result').append("[*] %l10n_wpspin_dsl_mode_custom% " + a.join(', ') + "...\n");
for (var i = 0; i < data.length; i++)
{
if (bss_offset != 0)
data[i][1] += bss_offset;
if (sn_offset > 0)
data[i][2] = data[i][2].substr(0, data[i][2].length - sn_offset);
if (sn_offset == -1)
data[i][2] = (data[i][1] & 0xFFFF).toString(10);
if (sn_offset == -2)
data[i][2] = (data[i][1] & 0xFFFF).toString(16);
}
}
var DSL_keys = intersect_pairs(data);
return checkDSLkeys(DSL_keys);
}
function unreference(obj)
{
return JSON.parse(JSON.stringify(obj));
}
function crackAlgo()
{
$('#result').empty();
var ln = $('#bssids').val().replace(/^\s+|\s+$/g, '').split("\n");
var pairs = [];
for (var j = 0; j < ln.length; j++)
{
var m = ln[j];
var z = m.split('|');
m = z[0];
m = m.replace(/:/g, '').replace(/-/g, '').replace(/\./g, '').replace(/ /g, '');
m = parseInt(m, 16);
if (isNaN(m) || m > 0xFFFFFFFFFFFF) continue;
pairs.push([Math.floor(parseInt(z[1]) / 10), m, (z[2] == null ? '' : z[2])]);
if (z[1] == '')
z[1] = '<empty>';
var mt = zeroFill(m.toString(16).toUpperCase(), 12);
mt = insert(mt, ':', 10);
mt = insert(mt, ':', 8);
mt = insert(mt, ':', 6);
mt = insert(mt, ':', 4);
mt = insert(mt, ':', 2);
var sugg = false;
$('#suggpin').empty();
for (var i = 0; i < algos.length; i++)
{
var pin = genPin(m, z[2], i);
if (typeof pin == 'string')
{
if (pin == '')
pin = '<empty>';
} else {
pin = pinChecksum(pin);
pin = zeroFill(pin.toString(10), 8);
}
if (z[1] == pin)
{
$('#suggpin').append(mt+" - "+z[1].padEnd(8)+" - "+algos[i].name);
sugg = true;
}
}
if (sugg) $('#result').append(encodeHTML($('#suggpin').val()) + "\n");
}
if (pairs.length > 1)
{
$('#result').append("\n%l10n_wpspin_dsl_crack%\n");
var result = runDSLcrack(unreference(pairs), 0, 0); // try without offset
if (!result)
result = runDSLcrack(unreference(pairs), 0, -1); // try derived S/N (decimal)
if (!result)
result = runDSLcrack(unreference(pairs), 0, -2); // try derived S/N (hexadecimal)
if (!result)
result = runDSLcrack(unreference(pairs), 0, 1); // cut last S/N char
if (!result)
result = runDSLcrack(unreference(pairs), 0, 2); // cut 2 last S/N chars
if (!result)
{
// try offset BSSID -1..-4
for (var i = 0; i < 4; i++)
{
result = runDSLcrack(unreference(pairs), - i - 1, 0);
if (result) break;
}
}
if (!result)
{
// try offset BSSID +1..+4
for (var i = 0; i < 4; i++)
{
result = runDSLcrack(unreference(pairs), i + 1, 0);
if (result) break;
}
}
if (!result)
{
// mixed BSSID & S/N offset
for (var i = 0; i < 4; i++)
for (var j = 0; j < 4; j++)
{
result = runDSLcrack(unreference(pairs), - i - 1, (j < 2 ? - j - 1 : j - 1));
if (result) break;
}
}
if (!result)
{
// mixed BSSID & S/N offset
for (var i = 0; i < 4; i++)
for (var j = 0; j < 4; j++)
{
result = runDSLcrack(unreference(pairs), i + 1, (j < 2 ? - j - 1 : j - 1));
if (result) break;
}
}
}
$('#algosel').val('algonone');
}
function detect()
{
var formdata = $($('form')[0]).serialize();
$('input').prop('disabled', true);
$('button').prop('disabled', true);
$('#fdata').empty();
$('#fhead').empty();
$('#fhead').append('<tr><th>%l10n_tbl_algorithm%</th><th>%l10n_tbl_wpspin%</th><th>%l10n_tbl_notes%</th><th>%l10n_tbl_probability%</th></tr>');
$('#fdata').append('<tr><td colspan=4><img src="img/loading.gif"></td></tr>');
$.post('3wifi.php?a=wpspin', formdata, function(d)
{
$('input').prop('disabled', false);
$('button').prop('disabled', false);
if (!d.result)
{
if (d.error == 'unauthorized')
{
$('#fdata > tr:first-child > :first-child').html(loginRequireMsg());
}
else if (d.error == 'bssid')
{
$('#fdata > tr:first-child > :first-child').text('%l10n_wpspin_bssid_wrong%.');
}
else
{
$('#fdata > tr:first-child > :first-child').text(errorStr(d.error));
}
return;
}
if (d.scores.length > 0)
{
$('#fdata').empty();
for (var i = 0; i < d.scores.length; i++)
{
var info = '';
var pin = d.scores[i].value;
if (d.scores[i].fromdb)
info += '<img src="img/ok.png" title="%l10n_wpspin_fromdb%"/>';
if (pinChecksum(Math.floor(pin / 10)) != pin)
info += ' <img src="img/icon-warning.png" title="%l10n_wpspin_chksum%"/>';
$('#fdata').append('<tr><td>'+d.scores[i].name+'</td><td>'+pin+'</td><td>'+info+'</td><td style="text-align: left"><span class=perc></span><b> '+Math.round(d.scores[i].score * 100)+'%</b></td></tr>');
var perc = $('.perc:last');
var wid = 180;
perc.css('width', wid + 'px');
var chld = $('<span class=perc-data>');
chld.css('width', Math.round(d.scores[i].score * 100) + '%');
perc.html(chld);
}
} else {
$('#fdata > tr:first-child > :first-child').text('%l10n_wpspin_not_found%.');
}
}).fail(function(jqXHR, textStatus, errorThrown) {
$('#fdata > tr:first-child > :first-child').text('%l10n_err_data%.');
$('input').prop('disabled', false);
$('button').prop('disabled', false);
});
}
function algoDLink(mac)
{
mac &= 0xFFFFFF;
mac ^= 0x55AA55;
mac ^= ((mac & 0xF) << 4)
| ((mac & 0xF) << 8)
| ((mac & 0xF) << 12)
| ((mac & 0xF) << 16)
| ((mac & 0xF) << 20);
mac %= 10000000;
if (mac < 1000000) mac += ((mac % 9) * 1000000) + 1000000;
return mac;
}
function algoDSL_MAC_SN(mac, ser, init)
{
/*
universal algorithm, returns pin derived from MAC and S/N
used by: Belkin, DSL-EasyBox, Arcadyan, and possibly other manufacturers
reverse-engineered by Stas'M
*/
if (ser == null)
ser = '';
if (ser.length < 4)
ser = zeroFill(ser, 4);
if (ser.length > 4)
ser = ser.substr(-4);
var sn = [];
for (var i = 0; i < ser.length; i++)
{
x = parseInt(ser[i], 16);
if (isNaN(x)) x = 0;
sn.push(x);
}
var nic = [(mac & 0xFFFF) >> 12, (mac & 0xFFF) >> 8, (mac & 0xFF) >> 4, mac & 0xF];
/*
init vector:
bk1 - k1 sum composite bits (0~255)
bk2 - k2 sum composite bits (0~255)
bx[] - xor composite bits (array of 0~255)
k1 - k1 init nibble (0~15)
k2 - k2 init nibble (0~15)
pin - pin init value (0~9999999)
xor - xor init nibble (0~15)
sub - substraction mode (0 - no sub, 1 - substraction, 2 - addition)
sk - substraction multiple coefficient (0 - skv value, 1 - k1, 2 - k2)
skv - substraction multiple value
*/
if (init.bk1 == null) init.bk1 = 60;
if (init.bk2 == null) init.bk2 = 195;
if (init.k1 == null) init.k1 = 0;
if (init.k2 == null) init.k2 = 0;
if (init.pin == null) init.pin = 0;
if (init.xor == null) init.xor = 0;
if (init.sub == null) init.sub = 0;
if (init.sk == null) init.sk = 0;
if (init.skv == null) init.skv = 0;
var k1 = init.k1 & 0xF;
var i = 0;
while (init.bk1)
{
// 0 1 2 3 4 5 6 7
// nic[0] nic[1] nic[2] nic[3] sn[0] sn[1] sn[2] sn[3]
if (init.bk1 & 1)
{
k1 += (i < 4 ? nic[i] : sn[i - 4]);
k1 &= 0xF;
}
init.bk1 >>= 1;
i++;
}
var k2 = init.k2 & 0xF;
i = 0;
while (init.bk2)
{
// 0 1 2 3 4 5 6 7
// nic[0] nic[1] nic[2] nic[3] sn[0] sn[1] sn[2] sn[3]
if (init.bk2 & 1)
{
k2 += (i < 4 ? nic[i] : sn[i - 4]);
k2 &= 0xF;
}
init.bk2 >>= 1;
i++;
}
var pin = init.pin;
for (var j = 0; j < init.bx.length; j++)
{
var xor = init.xor & 0xF;
i = 0;
while (init.bx[j])
{
// 0 1 2 3 4 5 6 7
// k1, k2, nic[1], nic[2], nic[3], sn[1], sn[2], sn[3]
if (init.bx[j] & 1)
{
xor ^= (i > 4 ? sn[i - 4] : (i > 1 ? nic[i - 1] : (i > 0 ? k2 : k1)));
}
init.bx[j] >>= 1;
i++;
}
pin <<= 4;
pin |= xor;
}
switch (init.sub)
{
case 0: // by default
return pin % 10000000;
case 1: // spoiled from Belkin's reversed algo
return (pin % 10000000) - (Math.floor(pin / 10000000) * (init.sk > 1 ? k2 : (init.sk > 0 ? k1 : init.skv)));
case 2:
return (pin % 10000000) + (Math.floor(pin / 10000000) * (init.sk > 1 ? k2 : (init.sk > 0 ? k1 : init.skv)));
}
}
function get_combs(nibs, nic, sn)
{
/*
part of key cracking algorithm for universal DSL algorithm (that derives pin from MAC and S/N)
programmed by Stas'M in 2017-10-23
*/
var combs = [];
// loop through 7 nibbles
for (var i = 0; i < 7; i++)
{
combs[i] = [];
// get nibble
var nib = nibs & 0xF;
// brute-force xor combinations
for (var j = 0; j < 256; j++)
{
if (algoDSL_MAC_SN(nic, sn, {bx: [0, 0, 0, 0, 0, 0, j]}) == nib)
combs[i].push(j); // match
}
if (combs[i].length == 0)
return false; // some of nibbles is not affected by algorithm
nibs >>= 4;
}
return combs;
}
function get_all_combs(pin, nic, sn)
{
/*
part of key cracking algorithm for universal DSL algorithm (that derives pin from MAC and S/N)
programmed by Stas'M in 2017-10-23
*/
// get all possible xor combinations
var pns = [];
// pin should contain 7 nibbles
while (pin < 0x10000000)
{
// get all possible xor combinations
var x = get_combs(pin, nic, sn);
if (x != false)
pns.push(x);
// actual pin is modulus of 10000000
pin += 10000000;
}
// only one of combination tables is correct
return pns;
}
function intersect(a, b)
{
return a.filter((n) => b.includes(n));
}
function intersect_combs(a, b)
{
var c = [];
for (var i = 0; i < 7; i++)
{
var x = intersect(a[i], b[i]);
if (x.length == 0)
return false;
c[i] = x;
}
return c;
}
function intersect_pairs(pairs)
{
/*
part of key cracking algorithm for universal DSL algorithm (that derives pin from MAC and S/N)
programmed by Stas'M in 2017-10-23
*/
// assuming first pair is correct (have a key)
var c0 = get_all_combs(pairs[0][0], pairs[0][1], pairs[0][2]);
for (var i = 1; i < pairs.length; i++)
{
var c1 = get_all_combs(pairs[i][0], pairs[i][1], pairs[i][2]);
var c2 = [];
// collide combs with each other
for (var j = 0; j < c0.length; j++)
for (var k = 0; k < c1.length; k++)
{
var x = intersect_combs(c0[j], c1[k]);
if (x == false)
continue;
c2.push(x);
}
c0 = c2;
}
return c0;
}
function initAlgos()
{
ALGO_MAC = 0;
ALGO_MACSN = 1;
ALGO_EMPTY = 2;
ALGO_STATIC = 3;
algos = [];
algos.push({id: "pin24", name: "24-bit PIN", mode: ALGO_MAC, func: function (mac) {return mac & 0xFFFFFF;}});
algos.push({id: "pin28", name: "28-bit PIN", mode: ALGO_MAC, func: function (mac) {return mac & 0xFFFFFFF;}});
algos.push({id: "pin32", name: "32-bit PIN", mode: ALGO_MAC, func: function (mac) {return mac % 0x100000000;}});
algos.push({id: "pin36", name: "36-bit PIN", mode: ALGO_MAC, func: function (mac) {return mac % 0x1000000000;}});
algos.push({id: "pin40", name: "40-bit PIN", mode: ALGO_MAC, func: function (mac) {return mac % 0x10000000000;}});
algos.push({id: "pin44", name: "44-bit PIN", mode: ALGO_MAC, func: function (mac) {return mac % 0x100000000000;}});
algos.push({id: "pin48", name: "48-bit PIN", mode: ALGO_MAC, func: function (mac) {return mac;}});
algos.push({id: "pin24rh", name: "Reverse byte 24-bit", mode: ALGO_MAC, func: function (mac)
{
mac &= 0xFFFFFF;
mac = zeroFill(mac.toString(16), 6);
mac = mac.substr(4,2)
+ mac.substr(2,2)
+ mac.substr(0,2);
return parseInt(mac, 16);
}});
algos.push({id: "pin32rh", name: "Reverse byte 32-bit", mode: ALGO_MAC, func: function (mac)
{
mac %= 0x100000000;
mac = zeroFill(mac.toString(16), 8);
mac = mac.substr(6,2)
+ mac.substr(4,2)
+ mac.substr(2,2)
+ mac.substr(0,2);
return parseInt(mac, 16);
}});
algos.push({id: "pin48rh", name: "Reverse byte 48-bit", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(16), 12);
mac = mac.substr(10,2)
+ mac.substr(8,2)
+ mac.substr(6,2)
+ mac.substr(4,2)
+ mac.substr(2,2)
+ mac.substr(0,2);
return parseInt(mac, 16);
}});
algos.push({id: "pin24rn", name: "Reverse nibble 24-bit", mode: ALGO_MAC, func: function (mac)
{
mac &= 0xFFFFFF;
mac = zeroFill(mac.toString(16), 6);
return parseInt(reverse(mac), 16);
}});
algos.push({id: "pin32rn", name: "Reverse nibble 32-bit", mode: ALGO_MAC, func: function (mac)
{
mac %= 0x100000000;
mac = zeroFill(mac.toString(16), 8);
return parseInt(reverse(mac), 16);
}});
algos.push({id: "pin48rn", name: "Reverse nibble 48-bit", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(16), 12);
return parseInt(reverse(mac), 16);
}});
algos.push({id: "pin24rb", name: "Reverse bits 24-bit", mode: ALGO_MAC, func: function (mac)
{
mac &= 0xFFFFFF;
mac = zeroFill(mac.toString(2), 24);
return parseInt(reverse(mac), 2);
}});
algos.push({id: "pin32rb", name: "Reverse bits 32-bit", mode: ALGO_MAC, func: function (mac)
{
mac %= 0x100000000;
mac = zeroFill(mac.toString(2), 32);
return parseInt(reverse(mac), 2);
}});
algos.push({id: "pin48rb", name: "Reverse bits 48-bit", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(2), 48);
return parseInt(reverse(mac), 2);
}});
algos.push({id: "pinDLink", name: "D-Link PIN", mode: ALGO_MAC, func: algoDLink});
algos.push({id: "pinDLink1", name: "D-Link PIN +1", mode: ALGO_MAC, func: function (mac)
{
return algoDLink(mac + 1);
}});
algos.push({id: "pinBelkin", name: "Belkin PIN", mode: ALGO_MACSN, func: function (mac, ser)
{
return algoDSL_MAC_SN(mac, ser, {bx: [66, 129, 209, 10, 24, 3, 39]});
}});
algos.push({id: "pinEasyBox", name: "Vodafone EasyBox", mode: ALGO_MACSN, func: function (mac, ser)
{
if (ser == null)
ser = (mac & 0xFFFF).toString(10);
return algoDSL_MAC_SN(mac, ser, {bx: [129, 65, 6, 10, 136, 80, 33]});
}});
algos.push({id: "pinLivebox", name: "Livebox Arcadyan", mode: ALGO_MACSN, func: function (mac, ser)
{
return algoDSL_MAC_SN(mac - 2, ser, {bx: [129, 65, 6, 10, 136, 80, 33]});
}});
algos.push({id: "pinASUS", name: "ASUS PIN", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(16), 12);
var b = [];
b[0] = parseInt(mac.substr(0, 2), 16);
b[1] = parseInt(mac.substr(2, 2), 16);
b[2] = parseInt(mac.substr(4, 2), 16);
b[3] = parseInt(mac.substr(6, 2), 16);
b[4] = parseInt(mac.substr(8, 2), 16);
b[5] = parseInt(mac.substr(10, 2), 16);
var pin = [];
for (var i = 0; i < 7; i++)
{
pin[i] = (b[i % 6] + b[5]) % (10 - ((i + b[1] + b[2] + b[3] + b[4] + b[5]) % 7));
}
return parseInt(pin.join(''), 10);
}});
algos.push({id: "pinAirocon", name: "Airocon Realtek", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(16), 12);
var b = [];
b[0] = parseInt(mac.substr(0, 2), 16);
b[1] = parseInt(mac.substr(2, 2), 16);
b[2] = parseInt(mac.substr(4, 2), 16);
b[3] = parseInt(mac.substr(6, 2), 16);
b[4] = parseInt(mac.substr(8, 2), 16);
b[5] = parseInt(mac.substr(10, 2), 16);
return ((b[0] + b[1]) % 10)
+ (((b[5] + b[0]) % 10) * 10)
+ (((b[4] + b[5]) % 10) * 100)
+ (((b[3] + b[4]) % 10) * 1000)
+ (((b[2] + b[3]) % 10) * 10000)
+ (((b[1] + b[2]) % 10) * 100000)
+ (((b[0] + b[1]) % 10) * 1000000);
}});
algos.push({id: "pinInvNIC", name: "Inv NIC to PIN", mode: ALGO_MAC, func: function (mac)
{
mac &= 0xFFFFFF;
return ~mac & 0xFFFFFF;
}});
algos.push({id: "pinNIC2", name: "NIC * 2", mode: ALGO_MAC, func: function (mac) {return (mac & 0xFFFFFF) * 2;}});
algos.push({id: "pinNIC3", name: "NIC * 3", mode: ALGO_MAC, func: function (mac) {return (mac & 0xFFFFFF) * 3;}});
algos.push({id: "pinOUIaddNIC", name: "OUI + NIC", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(16), 12);
var oui = parseInt(mac.substr(0, 6), 16);
var nic = parseInt(mac.substr(6, 6), 16);
return (oui + nic) % 0x1000000;
}});
algos.push({id: "pinOUIsubNIC", name: "OUI - NIC", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(16), 12);
var oui = parseInt(mac.substr(0, 6), 16);
var nic = parseInt(mac.substr(6, 6), 16);
if (nic < oui)
{
return oui - nic;
} else {
return (oui + 0x1000000 - nic) & 0xFFFFFF;
}
}});
algos.push({id: "pinOUIxorNIC", name: "OUI ^ NIC", mode: ALGO_MAC, func: function (mac)
{
mac = zeroFill(mac.toString(16), 12);
var oui = parseInt(mac.substr(0, 6), 16);
var nic = parseInt(mac.substr(6, 6), 16);
return oui ^ nic;
}});
algos.push({id: "pinEmpty", name: "%l10n_wpspin_empty%", mode: ALGO_EMPTY, func: function (mac) {return '';}});
algos.push({id: "pinCisco", name: "Cisco", mode: ALGO_STATIC, func: function (mac) {return 1234567;}});
algos.push({id: "pinBrcm1", name: "Broadcom 1", mode: ALGO_STATIC, func: function (mac) {return 2017252;}});
algos.push({id: "pinBrcm2", name: "Broadcom 2", mode: ALGO_STATIC, func: function (mac) {return 4626484;}});
algos.push({id: "pinBrcm3", name: "Broadcom 3", mode: ALGO_STATIC, func: function (mac) {return 7622990;}});
algos.push({id: "pinBrcm4", name: "Broadcom 4", mode: ALGO_STATIC, func: function (mac) {return 6232714;}});
algos.push({id: "pinBrcm5", name: "Broadcom 5", mode: ALGO_STATIC, func: function (mac) {return 1086411;}});
algos.push({id: "pinBrcm6", name: "Broadcom 6", mode: ALGO_STATIC, func: function (mac) {return 3195719;}});
algos.push({id: "pinAirc1", name: "Airocon 1", mode: ALGO_STATIC, func: function (mac) {return 3043203;}});
algos.push({id: "pinAirc2", name: "Airocon 2", mode: ALGO_STATIC, func: function (mac) {return 7141225;}});
algos.push({id: "pinDSL2740R", name: "DSL-2740R", mode: ALGO_STATIC, func: function (mac) {return 6817554;}});
algos.push({id: "pinRealtek1", name: "Realtek 1", mode: ALGO_STATIC, func: function (mac) {return 9566146;}});
algos.push({id: "pinRealtek2", name: "Realtek 2", mode: ALGO_STATIC, func: function (mac) {return 9571911;}});
algos.push({id: "pinRealtek3", name: "Realtek 3", mode: ALGO_STATIC, func: function (mac) {return 4856371;}});
algos.push({id: "pinUpvel", name: "Upvel", mode: ALGO_STATIC, func: function (mac) {return 2085483;}});
algos.push({id: "pinUR814AC", name: "UR-814AC", mode: ALGO_STATIC, func: function (mac) {return 4397768;}});
algos.push({id: "pinUR825AC", name: "UR-825AC", mode: ALGO_STATIC, func: function (mac) {return 0529417;}});
algos.push({id: "pinOnlime", name: "Onlime", mode: ALGO_STATIC, func: function (mac) {return 9995604;}});
algos.push({id: "pinEdimax", name: "Edimax", mode: ALGO_STATIC, func: function (mac) {return 3561153;}});
algos.push({id: "pinThomson", name: "Thomson", mode: ALGO_STATIC, func: function (mac) {return 6795814;}});
algos.push({id: "pinHG532x", name: "HG532x", mode: ALGO_STATIC, func: function (mac) {return 3425928;}});
algos.push({id: "pinH108L", name: "H108L", mode: ALGO_STATIC, func: function (mac) {return 9422988;}});
algos.push({id: "pinONO", name: "CBN ONO", mode: ALGO_STATIC, func: function (mac) {return 9575521;}});
}
function initpage()
{
initAlgos();
for (var i = 0; i < algos.length; i++)
{
if (algos[i].mode == ALGO_STATIC)
{
$('#algosel').append($('<option>').val(algos[i].id).text('Static PIN - ' + algos[i].name));
} else {
$('#algosel').append($('<option>').val(algos[i].id).text(algos[i].name));
}
}
}
</script>
</head>
<body>
<table width=100%>
<tr><td width=50% style="vertical-align: top">
<p>%l10n_msg_wpspin%</p>
<p>%l10n_msg_wpspin_info%</p>
<table>
<tr><td>
<textarea id=bssids rows=3 cols=32 autofocus>12:34:56:78:9A:BC</textarea>
</td><td>
<button onclick="pinSuggest()">%l10n_btn_suggest%</button> <button onclick="getAll()">%l10n_btn_getall%</button>
</td></tr>
<tr><td colspan=2>
<textarea id=result readonly rows=14 cols=52></textarea>
</td></tr>
</table>
<div>%l10n_wpspin_algos%</div>
<select id=algosel onchange="showAlgo()"><option value=algonone>%l10n_wpspin_not_selected%</option></select>
<button onclick="crackAlgo()">%l10n_wpspin_check_algo%</button>
</td><td width=50% style="vertical-align: top">
<p>%l10n_msg_wpspin_db%</p>
<p>%l10n_msg_wpspin_db_info%</p>
<form id=fdeviceform enctype="multipart/form-data" method="POST" onsubmit="detect(); return false">
<table>
<tbody>
<tr>
<td><nobr>%l10n_str_bssid%</nobr></td>
<td><input name="bssid" type="text" value="" pattern="([0-9A-Fa-f]{2}[:-]?){5}[0-9A-Fa-f]{2}" /></td>
<td><nobr> (%l10n_bssid_format%)</nobr></td>
</tr>
</tbody>
<tbody>
<tr><td><input type=submit value="%l10n_btn_detect%" /></td><td></td></tr>
</tbody>
</table>
</form>
<br>
<table class=st1>
<tbody id=fhead></tbody>
<tbody id=fdata></tbody>
</table>
</td></tr>
</table>
<div style="display: none">
<textarea id=suggpin rows=14 cols=38></textarea>
<textarea id=pin24>ZyXEL NDMS
04:BF:6D:xx:xx:xx
0E:5D:4E:xx:xx:xx
10:7B:EF:xx:xx:xx
14:A9:E3:xx:xx:xx
28:28:5D:xx:xx:xx
2A:28:5D:xx:xx:xx
32:B2:DC:xx:xx:xx
38:17:66:xx:xx:xx
40:4A:03:xx:xx:xx
4E:5D:4E:xx:xx:xx
50:67:F0:xx:xx:xx
5C:F4:AB:xx:xx:xx
6A:28:5D:xx:xx:xx
8E:5D:4E:xx:xx:xx
AA:28:5D:xx:xx:xx
B0:B2:DC:xx:xx:xx
C8:6C:87:xx:xx:xx
CC:5D:4E:xx:xx:xx
CE:5D:4E:xx:xx:xx
EA:28:5D:xx:xx:xx
E2:43:F6:xx:xx:xx
EC:43:F6:xx:xx:xx
EE:43:F6:xx:xx:xx
F2:B2:DC:xx:xx:xx
FC:F5:28:xx:xx:xx
FE:F5:28:xx:xx:xx
%l10n_wpspin_wsc%
ZyXEL Internet Center
Keenetic Giga II
Keenetic Lite III
Keenetic Ultra
RalinkAPS
ZyXEL DEL1201-T10A
4C:9E:FF:xx:xx:xx
TRENDnet (%l10n_wpspin_some_fw%)
TRENDnet TEW-651BR
00:14:D1:xx:xx:xx
TRENDnet TEW-735AP
D8:EB:97:xx:xx:xx
%l10n_wpspin_wsc%
Wireless-N Multi-function AP
D-Link DIR-300NRU B5
1C:7E:E5:xx:xx:xx
84:C9:B2:xx:xx:xx
FC:75:16:xx:xx:xx
%l10n_wpspin_wsc%
RalinkAPS
D-Link DIR-620
14:D6:4D:xx:xx:xx
90:94:E4:xx:xx:xx
BC:F6:85:xx:xx:xx
%l10n_wpspin_wsc%
RalinkAPS
D-Link DSL-2600U
C4:A8:1D:xx:xx:xx
Huawei HG532e
00:66:4B:xx:xx:xx
08:7A:4C:xx:xx:xx
14:B9:68:xx:xx:xx
20:08:ED:xx:xx:xx
34:6B:D3:xx:xx:xx
4C:ED:DE:xx:xx:xx
78:6A:89:xx:xx:xx
88:E3:AB:xx:xx:xx
D4:6E:5C:xx:xx:xx
E8:CD:2D:xx:xx:xx
EC:23:3D:xx:xx:xx
EC:CB:30:xx:xx:xx
F4:9F:F3:xx:xx:xx
%l10n_wpspin_wsc%
RalinkAPS
ASUS RT-G32
ASUS RT-N13U
ASUS RT-N13U Rev.B1
20:CF:30:xx:xx:xx
90:E6:BA:xx:xx:xx
E0:CB:4E:xx:xx:xx
Upvel UR-309BN
Upvel UR-309NB
D4:BF:7F:4x:xx:xx
Upvel (%l10n_wpspin_some_fw%)
F8:C0:91:xx:xx:xx
Belkin F5D8231-4v5000
00:1C:DF:xx:xx:xx
Belkin F5D8235-4v1000
00:22:75:xx:xx:xx
Belkin F9K1104v1
08:86:3B:xx:xx:xx
Tenda W309R
00:B0:0C:xx:xx:xx
08:10:75:xx:xx:xx
C8:3A:35:xx:xx:xx
Conceptronic c300brs4a v2_v1.0.0
00:22:F7:xx:xx:xx
Edimax 3G-6210n
Edimax 3G-6220n
00:1F:1F:xx:xx:xx
Hitron CDE-30364
00:26:5B:xx:xx:xx
68:B6:CF:xx:xx:xx
78:8D:F7:xx:xx:xx
BC:14:01:xx:xx:xx
Huawei HG566a
20:2B:C1:xx:xx:xx
30:87:30:xx:xx:xx
5C:4C:A9:xx:xx:xx
62:23:3D:xx:xx:xx
62:3C:E4:xx:xx:xx
62:3D:FF:xx:xx:xx
62:53:D4:xx:xx:xx
62:55:9C:xx:xx:xx
62:6B:D3:xx:xx:xx
62:7D:5E:xx:xx:xx
62:96:BF:xx:xx:xx
62:A8:E4:xx:xx:xx
62:B6:86:xx:xx:xx
62:C0:6F:xx:xx:xx
62:C6:1F:xx:xx:xx
62:C7:14:xx:xx:xx
62:CB:A8:xx:xx:xx
62:CD:BE:xx:xx:xx
62:E8:7B:xx:xx:xx
64:16:F0:xx:xx:xx
6A:1D:67:xx:xx:xx
6A:23:3D:xx:xx:xx
6A:3D:FF:xx:xx:xx
6A:53:D4:xx:xx:xx
6A:55:9C:xx:xx:xx
6A:6B:D3:xx:xx:xx
6A:96:BF:xx:xx:xx
6A:7D:5E:xx:xx:xx