-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
preload.js
2430 lines (2220 loc) · 100 KB
/
preload.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
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
// Preload JS
const { contextBridge, ipcRenderer, powerMonitor } = require('electron')
const electron = require('electron');
const { exec } = require("child_process");
const Store = require('electron-store');
const os = require('os')
const net = require('net');
const crypto = require('crypto')
const { Resolver } = require('dns');
const punycode = require('punycode/');
const { isNull } = require('util');
var util = require('util')
const { exit } = require('process');
var ESAPI = require('node-esapi');
// configDefaults.: Is how the default config.json file is to look if no file found
// configScheme...: Is the validation on what happens if we dont know the value, ie.
// user has older config.json file and new changes have been introduced.
// But it can also be used for validating whats accepted via the set()
// function and what type it holds.
const configDefaults = require('./assets/js/config-defaults.js');
const configScheme = require('./assets/js/config-scheme.js');
const store = new Store({defaults: configDefaults, schema: configScheme});
// Not sure if i want to use this yet, trying settings out for now
//const storage = require('electron-json-storage')
//const defaultDataPath = storage.getDefaultDataPath()
//const dataPath = storage.getDataPath();
//console.log(defaultDataPath);
const sysUserInfo = os.userInfo();
// Our DNS resolver
const resolver = new Resolver();
// Handle custom NS server for our resolver !!
// We support
// - System (default)
// - Multiple NS (as array)
// - Single NS (as string)
var nsresolver = store.get('info.itemDefaults.dnsresolver');
if ( nsresolver ) {
if ( nsresolver == "system" ) resolver.setServers(resolver.getServers()); // Yes set get blooper! But config might change on fly
else if ( Array.isArray(nsresolver) ) resolver.setServers(nsresolver);
else resolver.setServers([nsresolver]);
}
// Redjoust vars
var myDebug = store.get('settings.debug')
var myTheme = store.get('settings.theme')
var myTarget = store.get('info.target')
var myMode = store.get('info.mode')
var privacyMode = store.get('settings.privacymode')
var showExternals = store.get('menuitems.externaltools.show')
var myStatusbarMessage = "";
var myStatusbarIcon = "";
var statusbarNotification = false;
var doUpdate = false;
var dnsServer = store.get('info.itemDefaults.dnsresolver')
var statusIcons = ['statusicon--download','statusicon--donut','statusicon--shades','statusicon--coffee','statusicon--idle','statusicon--busy','statusicon--error','statusicon--warning','statusicon--done','statusicon--pizza','statusicon--info']
var itemsRunning = []
// Silly things for the statusbar random quotes
var randomQuotes = [
"Ain't no party like a localhost party",
"Codes are a puzzle. A game, just like any other game",
"Java is to JavaScript as ham is to hamster",
"Code is like humor. When you have to explain it, it’s bad",
"Truth can only be found in one place: the code",
"Frameworks pass; language remains",
"If you want breakfast in bed, sleep in the kitchen",
"Broken pencils are pointless",
"This e-mail is encrypted with 2ROT-13",
"Scars are like tattoos with better stories",
"Benchmarks don't lie, but liars do benchmarks",
"Don't follow advice you get from fortune cookies",
"Playing Solitaire is its own punishment",
"Save energy. Use a small font",
"With great power comes great heat sinks",
"Security through Obscenity",
"Hmmm... I wonder what this button doe",
"A jester unemployed is nobody's fool",
"With the second line of code, you already have a legacy",
"Don't be evil unless you know how",
"Never bring tequila to a key-signing party",
"Two years from now, spam will be solved",
"On IRC everyone is male until proven IRL",
"Join the dark side, we have cookies...",
"Hit any user to continue",
"A hacker does for love what others wouldn't do for money",
"X Windows: A terminal disease",
"Eat right, exercise, die anyway",
"111,111,111 x 111,111,111 = 12,345,678,987,654,321",
"#exclude <windows.h>",
"She sells C shells",
"Core files are the dog shit of UNIX",
"This email will self-destruct upon deletion",
"C++ is to C as Lung Cancer is to Lung",
"Contrary to popular belief, the world is not ASCII",
"WWW is the MS-DOS of hypertext systems...",
"Be careful when playing under the anvil tree",
"It is very difficult to compare an apple",
"You are, of course, correct, and I disagree completely",
"As far as I know we never had an undetected error",
"The early patch blocks the worm",
"Pro tip for users: There is no 'any key'",
"You look like you could use a beer right now",
"Passwords are like underwear. Change them regularly",
"May your systems never hang, nor go out with a bang",
"Data leaks can sink companies",
"Ransomware is just an unscheduled business continuity audit",
"The great flood was God doing a DDoS",
"Traceroutes are IP packets way of cyber-stalking",
]
// Cleanup config target history if needed ...
if ( store.get('targetHistory.targets').length > store.get('targetHistory.maxtargets') ) {
maxtargets = store.get('targetHistory.maxtargets');
curtargets = store.get('targetHistory.targets').length;
targetlist = store.get('targetHistory.targets');
removenum = curtargets-maxtargets;
targetlist.splice(0,removenum);
store.set('targetHistory.targets',targetlist);
}
// Initialize default things
window.onload = () => {
// Special debug block
// Just easy to have this and to throw stuff here i want to debug...
// DEBUG BLOCK BEGIN
if (myDebug) {
}
// DEBUG BLOCK END
ipcRenderer.invoke('theme:'+myTheme)
window.$ = window.jQuery = require('jquery');
// Set default mode stuff
if ( !myMode ) $("#redjoustmode").html("No mode set")
else $("#redjoustmode").html(myMode)
// Set default target stuff ....
if ( !myTarget ) $("#redjousttarget").html("No target set")
else $("#redjousttarget").html(myTarget)
setTarget();
if ( myTarget ) $("#inputTarget").val(myTarget);
// Update public IP
reloadPublicIP();
// Show default front page
showPage("pagedefault");
// Only hide all if we need to
// If mode is set from last time, show those !
if ( showExternals ) $("#haveExternal").show();
else $("#haveExternal").hide();
$(".item--passive").hide();
$(".item--active").hide();
$(".item--redteam").hide();
itemsTitleDefault(); // On load set all titles on items
updateItemVisibility();
// Since this is first load, reset everything !
// So we are in the right state of mind all around :)
resetAll();
// Statusbar handler section
// Set default statusbar text for now
updateQuoteFrequency = 120;
const startQuote = randomQuotes[Math.floor(Math.random() * randomQuotes.length)];
var randomQuotesIcons = ['pizza','donut','coffee','shades'];
statusbarMessage(startQuote,0,randomQuotesIcons[Math.floor(Math.random() * randomQuotesIcons.length)]);
var dottss;
var timeSinceLastUpdate = 0;
setInterval(() => {
// System OS power saving/monitor options not functional
state = 'normal' // Was supposed to be state from the OS powermonitr part (ie idle/suspension event)
idle = 0; // Was supposed to be numbers from the OS powermonitr part (ie idle/suspension event)
//if (myDebug) console.log("System state: "+state+" (Idle time: "+idle+")");
// We always prioritize showing if anything is running ...
if ( !statusbarNotification ) {
if ( itemsRunning.length > 0) {
if ( !$("#btngotorun").hasClass("enabled") ) $("#btngotorun").addClass("enabled");
if ( !dottss || dottss.length >= 5 ) dottss = ".";
statusbarMessage(itemsRunning.length+" of "+visibleItems()+" items running "+dottss,0,"busy")
if ( dottss.length < 5 ) dottss = dottss+".";
doUpdate = true;
} else {
// Now lets make up more rules for statusbar shinannigans :)
timeSinceLastUpdate = timeSinceLastUpdate+0.5; // We count in seconds .. sort of :D
// OS idle handler (just show something else if no user input ie. idle timer grows)
if ( idle > 0 ) {
if ( doUpdate ) {
statusbarMessage("I'm idle...",0,"idle");
doUpdate = false;
}
} else {
// Normal operations
if ( timeSinceLastUpdate == updateQuoteFrequency) {
doUpdate = true;
timeSinceLastUpdate = 0;
}
if ( doUpdate ) {
if ( $("#btngotorun").hasClass("enabled") ) $("#btngotorun").removeClass("enabled");
statusbarMessage(randomQuotes[Math.floor(Math.random() * randomQuotes.length)],0,randomQuotesIcons[Math.floor(Math.random() * randomQuotesIcons.length)]);
doUpdate = false;
}
}
}
}
}, 500);
}
function updateItemVisibility() {
switch (myMode) {
case "Passive":
$(".item--passive").show();
break;
case "Active+Passive":
$(".item--passive").show();
$(".item--active").show();
break;
case "Red-Team+Active+Passive":
$(".item--passive").show();
$(".item--active").show();
$(".item--redteam").show();
break;
default:
$(".item--passive").hide();
$(".item--active").hide();
$(".item--redteam").hide();
break;
}
}
function updateItemState(itemID=false) {
if ( itemID ) {
if ( myTarget && myMode ) {
$("#"+itemID).removeClass("status--disabled");
$("#"+itemID).removeClass("status--ready");
$("#"+itemID).removeClass("status--working");
$("#"+itemID).removeClass("status--done");
$("#"+itemID).addClass("status--ready");
itemTitleDefault(itemID)
} else {
$("#"+itemID).removeClass("status--disabled");
$("#"+itemID).removeClass("status--ready");
$("#"+itemID).removeClass("status--working");
$("#"+itemID).removeClass("status--done");
if ( myTarget && !myMode ) {
$("#"+itemID).addClass("status--disabled");
itemBroke(itemID,"Please also set mode");
} else if ( !myTarget && myMode ) {
$("#"+itemID).addClass("status--disabled");
itemBroke(itemID,"Please also set target");
} else {
$("#"+itemID).addClass("status--disabled");
itemBroke(itemID,"Please set target and mode");
}
}
} else {
// We do em all :D
$('.menuitem').each(function(){
itemID = $(this).attr("id");
if ( !$("#"+itemID).hasClass("item--external") ) {
if ( myTarget && myMode ) {
$("#"+itemID).removeClass("status--disabled");
$("#"+itemID).removeClass("status--ready");
$("#"+itemID).removeClass("status--working");
$("#"+itemID).removeClass("status--done");
$("#"+itemID).addClass("status--ready");
itemTitleDefault(itemID)
} else {
$("#"+itemID).removeClass("status--disabled");
$("#"+itemID).removeClass("status--ready");
$("#"+itemID).removeClass("status--working");
$("#"+itemID).removeClass("status--done");
if ( myTarget && !myMode ) {
$("#"+itemID).addClass("status--disabled");
itemBroke(itemID,"Please also set mode");
} else if ( !myTarget && myMode ) {
$("#"+itemID).addClass("status--disabled");
itemBroke(itemID,"Please also set target");
} else {
$("#"+itemID).addClass("status--disabled");
itemBroke(itemID,"Please set target and mode");
}
}
}
});
}
updateItemVisibility();
}
function itemsTitleDefault() {
$(".menuitem").each(function() {
var itemID = $(this).attr('id');
var itemTitle = $(this).data("title");
var itemPage = $(this).data("page");
var itemFunc = $(this).data("function");
if (itemTitle) $(this).attr("title",itemTitle);
});
}
function itemTitleDefault(myID) {
var itemID = $("#"+myID).attr('id');
var itemTitle = $("#"+myID).data("title");
var itemPage = $("#"+myID).data("page");
var itemFunc = $("#"+myID).data("function");
if (itemTitle) $("#"+myID).attr("title",itemTitle);
}
function visibleItems() {
var visibleCount = 0;
$(".menuitem.status--ready").each(function() {
if ( $(this).is(":visible") ) {
visibleCount++;
}
});
$(".menuitem.status--done").each(function() {
if ( $(this).is(":visible") ) {
visibleCount++;
}
});
$(".menuitem.status--working").each(function() {
if ( $(this).is(":visible") ) {
visibleCount++;
}
});
return visibleCount;
}
/*
contextBridge.exposeInMainWorld('systemAPI', {
idleState: () => ipcRenderer.invoke('idle:state'),
idleTime: () => ipcRenderer.invoke('idle:time')
})
*/
contextBridge.exposeInMainWorld('themeAPI', {
setLight: () => ipcRenderer.invoke('theme:light'),
setDark: () => ipcRenderer.invoke('theme:dark'),
setSystem: () => ipcRenderer.invoke('theme:system')
})
contextBridge.exposeInMainWorld('darkMode', {
toggle: () => ipcRenderer.invoke('dark-mode:toggle'),
system: () => ipcRenderer.invoke('dark-mode:system')
})
contextBridge.exposeInMainWorld('userInfo', {
username: sysUserInfo.username
});
contextBridge.exposeInMainWorld('setMode', {
activate (data) {
$("#btnpassive").removeClass("enabled");
$("#btnactive").removeClass("enabled");
$("#btnredteam").removeClass("enabled");
$(".item--passive").hide();
$(".item--active").hide();
$(".item--redteam").hide();
$(".info1").removeClass("highlight");
$(".info2").removeClass("highlight");
$(".info3").removeClass("highlight");
if ( data == "passive" ) {
myMode = "Passive"
$("#btnpassive").addClass("enabled");
$(".info1").addClass("highlight");
$(".item--passive").show();
} else if ( data == "active" ) {
myMode = "Active+Passive"
$("#btnactive").addClass("enabled");
$(".info2").addClass("highlight");
$(".item--passive").show();
$(".item--active").show();
} else if ( data == "redteam" ) {
myMode = "Red-Team+Active+Passive"
$("#btnredteam").addClass("enabled");
$(".info3").addClass("highlight");
$(".item--passive").show();
$(".item--active").show();
$(".item--redteam").show();
} else {
myMode = null
}
store.set('info.mode', myMode);
$("#redjoustmode").html(myMode)
updateItemState();
}
});
contextBridge.exposeInMainWorld('actionHandler', {
contextmenuHandler ( event=false, command=false ) {
ipcRenderer.send('show-context-menu')
},
downloadReport (filedata=false, filename="redjoust.txt", filetype="text/plain;charset=utf-8") {
if ( filedata ) {
const { convert } = require('html-to-text');
const filedataText = convert(filedata, {
wordwrap: false
});
var FileSaver = require('file-saver');
var blob = new Blob([filedataText], {type: filetype});
FileSaver.saveAs(blob, filename);
}
},
updateTarget (newTarget) {
setTarget(newTarget);
},
targethistoryarray () {
return store.get('targetHistory.targets');
},
targethistory (lookup) {
if ( currentTargetHistory.length > 0 ) {
return "["+currentTargetHistory.length+"] Lookup: "+lookup;
}
},
goto (key) {
switch (key) {
case "btngotonext":
if ( !myTarget && !myMode ) showPage("pagetarget");
if ( myTarget && !myMode ) showPage("pagemode");
if ( myMode && !myTarget ) showPage("pagetarget");
if (myMode && myTarget ) showPage("pagedefault");
break;
case "btngototarget":
showPage("pagetarget");
break;
case "btngotomode":
showPage("pagemode");
break;
case "btngotorun":
if ( myTarget && myMode ) {
// We are good to go, RUN!
runAll();
} else {
if ( !myTarget && !myMode ) alert('Please choose both a TARGET and MODE!');
if ( !myTarget && myMode ) alert('Please choose a TARGET!');
if ( myTarget && !myMode ) alert('Please choose a MODE!');
}
break;
default:
showPage("pagedefault"); // Show our self ?! Atleast its some time of error handling ....
break;
}
}
});
contextBridge.exposeInMainWorld('itemAPI', {
clickItem (id,mode,state) {
var itemID = $("#"+id).attr('id');
var itemTitle = $("#"+id).data("title");
var itemPage = $("#"+id).data("page");
var itemFunc = $("#"+id).data("function");
var itemMode = mode;
var itemState = state;
if ( itemState == "ready") showPage("pagedefault");
if ( itemState == "done") {
if ( $("#"+itemPage).find(".itemtitle").length ) {
$("#"+itemPage).find(".itemtitle").text(itemTitle).html();
}
showPage(itemPage);
}
if ( itemState == "info") {
showPage(itemPage);
} // I think this is useful but annoying :D
//if ( state == "working") alert("Item '"+id+"' is working, please wait");
}
});
contextBridge.exposeInMainWorld('toolAPI', {
clickItem (myID,myPage) {
if (myDebug) console.log("Clicked '"+myID+"' -> goto: "+myPage);
var pattern = /^((http|https|ftp):\/\/)/i;
if (pattern.test(myPage)) require('electron').shell.openExternal(myPage);
else showPage(myPage);
},
doHashing(data) {
let hashCRC32 = crc32(data,true);
let hashMD4 = crypto.createHash('md4').update(data).digest("hex");
let hashMD5 = crypto.createHash('md5').update(data).digest("hex");
let hashMD160 = crypto.createHash('ripemd160').update(data).digest("hex");
let hashSHA1 = crypto.createHash('sha1').update(data).digest("hex");
let hashSHA224 = crypto.createHash('sha224').update(data).digest("hex");
let hashSHA256 = crypto.createHash('sha256').update(data).digest("hex");
let hashSHA384 = crypto.createHash('sha384').update(data).digest("hex");
let hashSHA512 = crypto.createHash('sha512').update(data).digest("hex");
$("#hash--crc32").val(hashCRC32);
$("#hash--md4").val(hashMD4);
$("#hash--md5").val(hashMD5);
$("#hash--ripemd160").val(hashMD160);
$("#hash--sha1").val(hashSHA1);
$("#hash--sha224").val(hashSHA224);
$("#hash--sha256").val(hashSHA256);
$("#hash--sha384").val(hashSHA384);
$("#hash--sha512").val(hashSHA512);
},
doHashingLookup(data) {
var plussalt = false;
var salt = "Not Found";
var hashtype = 'unknown';
var input = sanitize(data)
var charlength = input.length;
// CLASSIFY INPUTS
var bitlength = 0;
var chartype = "Unknown";
if (isb64(input)) {
var chartype = 'base64';
bitlength = charlength * 6;
}
if (ishex(input)) {
var chartype = 'hexidecimal';
bitlength = input.length * 4;
}
// ANALYZE CLASSIFIED INPUTS
//split any that have a single colon and process
if ((input.match(/:/g) || []).length == 1) {
var saltandhash = input.split(":");
salt = saltandhash[1];
plussalt = true;
input = saltandhash[0];
charlength = input.length;
if (isb64(saltandhash[0])) {
chartype = 'base64';
bitlength = saltandhash[0].length * 6;
}
if (ishex(saltandhash[0])) {
chartype = 'hexidecimal';
bitlength = saltandhash[0].length * 4;
}
}
if ((input.match(/:/g) || []).length > 1) {
hashtype = "NTLM?";
}
if ((input.startsWith("md5"))) {
hashtype = "MD5";
}
if ((chartype == 'base64') && (bitlength == 96)) {
hashtype = 'Cisco ASA or PIX MD5';
}
if ((chartype == 'hexidecimal') && (bitlength == 128)) {
hashtype = 'MD5 or MD4';
}
if ((chartype == 'hexidecimal') && (bitlength == 160)) {
hashtype = 'SHA1 (or SHA 128)';
}
if ((chartype == 'hexidecimal') && (bitlength == 224)) {
hashtype = 'SHA 224';
}
if ((chartype == 'hexidecimal') && (bitlength == 256)) {
hashtype = 'SHA2-256';
}
if ((chartype == 'hexidecimal') && (bitlength == 384)) {
hashtype = 'SHA2-384';
}
if ((chartype == 'hexidecimal') && (bitlength == 512)) {
hashtype = 'SHA2-512';
}
if ((chartype == 'hexidecimal') && (bitlength == 64)) {
hashtype = 'LM or MySQL < version 4.1';
}
if ((chartype == 'hexidecimal') && (bitlength == 240)) {
hashtype = 'Oracle 11';
}
if (charlength == 13) {
hashtype = 'DES or 3DES?';
}
if (charlength == 41) {
if (input[0] == "*") {
if (ishex(input.substring(1))) { // check if the string after the * is hex
hashtype = 'MySQL5';
chartype = 'star followed by hexidecimal';
bitlength = 4 * 40;
}
}
}
if (charlength == 34) {
if ((input[0] == '$') && (input[1] == 'P') && (input[2] == '$')) {
if (isalphanumeric(input[3])) {
hashtype = 'MD5 Wordpress';
chartype = '$P$ followed by alphanumerics';
bitlength = 6 * 31;
}
}
}
if (charlength == 34) {
if ((input[0] == '$') && (input[1] == 'H') && (input[2] == '$')) {
if (isalphanumeric(input[3])) {
hashtype = 'MD5 phpBB3';
chartype = '$H$ followed by alphanumerics';
bitlength = 6 * 31;
}
}
}
if (input.startsWith("$2a$") || input.startsWith("$2b$") || input.startsWith("$2y$")) {
var saltandhash = input.substring(input.lastIndexOf("$") + 1);
var thissalt = saltandhash.slice(0, 22);
var thishash = saltandhash.slice(22);
if (thishash.length == 31) {
hashtype = 'bcrypt';
chartype = '$2x$x$ followed by base64';
bitlength = 184;
}
}
if ((input.startsWith("$1$")) && (charlength == 34)) {
hashtype = "MD5-Crypt";
var thissalt = input.slice(3, 11);
var thishash = input.slice(12);
chartype = "Mostly base64";
bitlength = 128;
}
if ((input.startsWith("$PHPS$")) && (charlength == 45)) {
//$PHPS$327235$afd358dd12afc6c394f309624d5912e7
hashtype = "PHP-MD5-Crypt";
var thissalt = input.slice(6, 12);
var thishash = input.slice(13);
chartype = "Mostly hexadecimal";
bitlength = 128;
}
if ((input.startsWith("$6$")) && (charlength == 106)) {
//$6$gjxgtlzspT2wzWJW$61tKBfooVrQC6/hYZ3TXKpFuLmNnAHomE/Ccf.dRWDo87W2MeoeOSPGSYNlAGfDwYugiV.KGWJGSEzXEjT4OI0
hashtype = "SHA512-Crypt";
var thissalt = input.slice(3, 19);
var thishash = input.slice(20);
chartype = "$6$ followed by base64";
bitlength = 512;
}
if ((input.startsWith("$md5$rounds="))) {
//$md5$rounds=904$BZ6wgh3sv4Q5hmhr$dIc7H0R4s0M0eDkDQEJf31
hashtype = "Sun MD5";
var thissalt = input.slice(16, 32);
var thishash = input.slice(33);
chartype = "Mostly base64";
bitlength = 128;
}
if ((input.startsWith("{SSHA}"))) {
//{SSHA}u+cwWa3895SQjBcpC5xShYkaYYxNZk1OMWxoQg==
hashtype = "Salted SHA";
if (isb64(input.slice(6))) {
var chartype = 'base64';
bitlength = charlength * 6;
}
}
if ((input.startsWith("{SHA}"))) {
//{SHA}raMJLbQTEfVYt9feePKfWKf9H1Q=
hashtype = "SHA";
if (isb64(input.slice(5))) {
var chartype = 'base64';
bitlength = charlength * 6;
}
}
// CREATE OUTPUT
if (plussalt) {
hashtype = hashtype + " : plus salt";
}
var myInput = input
var mySalt = salt
var myHashType = hashtype
var myBits = bitlength
var myCharLen = charlength
var myCharType = chartype
if ((hashtype == "bcrypt") || (hashtype=="MD5-Crypt") || (hashtype=="PHP-MD5-Crypt")) {
var myhash = thishash
var mysalt = thissalt
}
if (hashtype != "unknown") {
$("#detectedHash").html(myHashType);
$("#detectedHashDetails").html("Bits: "+myBits+", Charlen: "+myCharLen+", Chartype: "+myCharType);
var algo = "md5" // Default algo :)
if ( /^md4/i.test(hashtype) ) algo = "md4"
else if ( /^md5/i.test(hashtype) ) algo = "md5"
else if ( /^sha1/i.test(hashtype) ) algo = "sha1"
else if ( /^LM or MySQL/i.test(hashtype) ) algo = "mysql4"
else if ( /^lm/i.test(hashtype) ) algo = "lm"
else if ( /ntlm/i.test(hashtype) ) algo = "ntlm"
else if ( /^md5/i.test(hashtype) ) algo = "mysql323"
else if ( /^md5/i.test(hashtype) ) algo = "ripemd160"
$.ajax({type: "POST", url: "http://crackfoo.net/?algo="+algo, data: "hash="+myInput+"&sa=Search",
success: function(result){
var finalResult = parseHashResult(result);
if (finalResult ) $("#hash--lookup").val(finalResult);
else $("#hash--lookup").val("Hash not found");
}
})
} else {
$("#detectedHash").html("Unknown");
$("#hash--lookup").val("");
}
},
base64Encode(data) {
let buff = new Buffer.from(String(data));
let base64data = buff.toString('base64');
return base64data;
},
base64Decode(data) {
let buff = new Buffer.from(String(data), 'base64');
let asciidata = buff.toString('ascii');
return asciidata;
},statusbarNotify(msg) {
if ( !statusbarNotification ) statusbarMessage(msg,3,'download');
}
});
function parseHashResult(data) {
if ( /SUCCESS/.test(data) ) {
var reverseResult = data.match(/is >> (.*) <<</i)
return reverseResult[1]
} else {
return false;
}
}
function reloadPublicIP() {
if ( privacyMode ) {
// Now for real this time!
// DONT make any http calls :) We want privacy...
$("#myip").html("Privacy mode");
} else {
$.ajax({
dataType: 'json',
url: "https://api.buffer.dk/myip", // Full disclaimer i own this api site, so kinda a call-home?
success: function(result){
$("#myip").html(result.ip);
},
fail: function(xhr, textStatus, errorThrown){
$("#myip").html("Unknown?");
}
});
}
}
function showPage( pagename=null ) {
if ( pagename ) {
if ( $("#"+pagename ).length ) {
if (pagename != "pagepreferences") $(".pages").hide();
// We need to prep defaultpage a bit ...
if ( pagename == "pagedefault") {
if ( myTarget ) $("#btngototarget").addClass("enabled");
else $("#btngototarget").removeClass("enabled");
if ( myMode ) $("#btngotomode").addClass("enabled");
else $("#btngotomode").removeClass("enabled");
if ( itemsRunning.length > 0 ) $("#btngotorun").addClass("enabled");
else $("#btngotorun").removeClass("enabled");
}
// We need to prep pagemode a bit ....
if ( pagename == "pagemode" ) {
$("#btnpassive").removeClass("enabled");
$("#btnactive").removeClass("enabled");
$("#btnredteam").removeClass("enabled");
$(".info1").removeClass("highlight");
$(".info2").removeClass("highlight");
$(".info3").removeClass("highlight");
switch (myMode) {
case "Passive":
$("#btnpassive").addClass("enabled");
$(".info1").addClass("highlight");
break;
case "Active+Passive":
$("#btnactive").addClass("enabled");
$(".info2").addClass("highlight");
break;
case "Red-Team+Active+Passive":
$("#btnredteam").addClass("enabled");
$(".info3").addClass("highlight");
break;
}
}
$("#"+pagename).show() // The main "magic" - Show the page :D
// A click hack for the dns deep dive! (its a nice feature! Quickly change POI target)
if ( pagename == "pageDNSdomainname" || pagename == "pageDNShostname" ) {
$(".poiTarget").on("click", function() {
if ( $(this).html().length > 0 ) {
var poiTarget = $(this).html()
if (poiTarget) {
setTarget(poiTarget)
showPage("pagedefault")
}
}
});
}
// A bit of focus handling ...
if ( pagename == "pagetarget" ) {
if ( myTarget ) $("#inputTarget").val(myTarget);
$("#inputTarget").trigger('focus');
$("#inputTarget").trigger('select');
}
} else {
$(".pages").hide();
$("#pagenotfound").show()
}
} else {
$(".pages").hide();
$("#pageerror").show()
}
}
function runAll() {
if ( $(".menuitem.status--ready").is(":visible") ) {
if ( store.get("menuitems.passive.runwarning") && myMode == "Passive") {
doRun = confirm("Please note PASSIVE MODE options are on! Want to continue ?");
if (doRun === false) return;
}
if ( store.get("menuitems.active.runwarning") && myMode == "Active+Passive" ) {
doRun = confirm("Please note ACTIVE MODE options are on! Want to continue ?");
if (doRun === false) return;
}
if ( store.get("menuitems.redteam.runwarning") && myMode == "Red-Team+Active+Passive" ) {
doRun = confirm("Please note RED-TEAM MODE options are on! Want to continue ?");
if (doRun === false) return;
}
} else {
alert("No items are ready to collect, perhaps reset? (Hit: F6)");
return;
}
$(".menuitem.status--ready").each( async function() {
if ( $(this).is(":visible") ) {
var itemID = $(this).attr('id');
var itemTitle = $(this).data("title");
var itemPage = $(this).data("page");
var itemFunc = $(this).data("function");
if (myDebug) console.log("Starting ["+itemID+"] calling '"+itemFunc+"' output to: "+itemPage);
imRunning(itemID); // Mark it running
try {
// Finally, got it to work properly and not using eval() !! Phew !
window[itemFunc](itemID)
// TODO: Here is where i left of :=)
// Make some logic to keep checking if its still running
// perhaps use the itemsRunning array ?? async rubbish keeps me up late
} catch (err) {
if (myDebug) console.log(itemFunc+"() - There a problem encountered trying to run this function!");
if (myDebug) console.log(err)
$("#"+itemID).data('status',"done");
itemBroke(itemID,"Fatal error: Item broke, no function found");
}
imDone(itemID); // Mark it done! (Should somehow wait for the function to finish!)
}
});
}
function resetAll() {
itemsTitleDefault();
$("#btngotorun").removeClass("enabled");
$('.menuitem').each(function(){
itemID = $(this).attr("id");
clearInterval($("#"+itemID).data('interval'));
$("#"+itemID).data("status","nan");
const index = itemsRunning.indexOf(itemID);
if (index > -1) itemsRunning.splice(index, 1);
if ( !$("#"+itemID).hasClass("item--external") ) {
$("#"+itemID).removeClass("status--disabled");
$("#"+itemID).removeClass("status--ready");
$("#"+itemID).removeClass("status--working");
$("#"+itemID).removeClass("status--done");
updateItemState(itemID);
}
});
}
// Power monitor handler
// For future idle/os suspension/ lock events etc
ipcRenderer.on('idleState', (event, state) => {
if ( state == "idle") {
if (myDebug) console.log("Did you leave your computer ? Your OS is idle!");
}
// Testing out (idle lock screen)
if ( store.get('settings.idlelock',false) ) {
if ( lockscreenVisible() && state == "active" ) {
ipcRenderer.invoke('locked:unlock')
disableLockscreen()
} else if ( state == "idle" ) {
ipcRenderer.invoke('locked:lock')
enableLockscreen("","lock")
}
}
});
// OS Usage handler
contextBridge.exposeInMainWorld('usage', {
cpu: process.getCPUUsage().percentCPUUsage.toString().slice(0, 5)
});
ipcRenderer.on('cpu', (event, data) => {
document.getElementById('cpu').innerHTML = Math.round(data.toFixed(2));
});
ipcRenderer.on('mem', (event, data) => {
//document.getElementById('mem').innerHTML = Math.round(data.toFixed(2));
document.getElementById('mem').innerHTML = data.toFixed(2);
});
ipcRenderer.on('total-mem', (event, data) => {
document.getElementById('total-mem').innerHTML = Math.round(data.toFixed(2));
});
ipcRenderer.on('lockscreen', (event) => {
if ( lockscreenVisible() ) {
ipcRenderer.invoke('locked:unlock')
if (myDebug) console.log("Disable lockscreen")
disableLockscreen()
} else {
ipcRenderer.invoke('locked:lock')
if (myDebug) console.log("Enable lockscreen")
enableLockscreen("","lock")
}
});
ipcRenderer.on('escpressed', (event) => {
if (document.hasFocus()) showPage("pagedefault");
});
ipcRenderer.on('toggleprivacymode', (event) => {
if ( privacyMode ) {
// Privacy mode enabled - toggle to disabled!
privacyMode = false;
store.set('settings.privacymode', false);
} else {
// Privacy mode disabled - toggle to enabled!
privacyMode = true;
store.set('settings.privacymode', true);
}
// Things we need to refresh when toggling this mode
reloadPublicIP();
});
ipcRenderer.on('toggleexternaltools', (event) => {
if ( showExternals ) {
// External tools enabled - toggle to disabled!
showExternals = false;
store.set('menuitems.externaltools.show', false);
$("#haveExternal").hide();
} else {
// External tools disabled - toggle to enabled!
showExternals = true;
store.set('menuitems.externaltools.show', true);
$("#haveExternal").show();
}
});
ipcRenderer.on('resetitems', (event) => {
resetAll();
});
ipcRenderer.on('runitems', (event) => {
runAll();
});
ipcRenderer.on('showprocessinfo', (event) => {
// The idea was to make a debug thing to show process info
// in order to see the pid's on hanging item functions that
// was still running when needed a "reset" ...
//
// The idea is trashed for now ... They will just have to
// timeout/hang until they finish ...
if (myDebug) console.log("==[ PROCESS INFORMATION ]==============");
});
ipcRenderer.on('showpagedefault', (event) => {
showPage("pagedefault");
});
ipcRenderer.on('showpageclear', (event) => {
myTarget = null;
myMode = null;