-
Notifications
You must be signed in to change notification settings - Fork 77
/
run.js
1417 lines (1341 loc) · 81.1 KB
/
run.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
'use strict';
const fs = require('fs-extra');
const debug = require('debug')('app');
const express = require('express');
const csp = require('express-csp-header');
const frameguard = require('frameguard');
const xssFilter = require('x-xss-protection');
const bodyParser = require('body-parser');
const url = require('url');
const dateFormat = require('dateformat');
const {fork} = require('child_process');
const download = require('download-file');
const rimraf = require('rimraf');
const phishingDetector = require('eth-phishing-detect/src/detector');
const crypto = require("crypto");
const request = require('request');
const app = express();
const config = require('./config');
const check = require('./_utils/webcheck.js');
const lookup = require('./_utils/lookup.js');
let default_template = fs.readFileSync('./_layouts/default.html', 'utf8');
let cache;
let updating_now = false;
let icon_warnings = [];
var older_cache_time;
if('perform_dns_lookup' in config && config.perform_dns_lookup === false) {
default_template = default_template.replace("{{ config.perform_dns_lookup }}", "<div class='ui info message'>DNS lookups not performed due to configuration.</div><br />");
} else {
default_template = default_template.replace("{{ config.perform_dns_lookup }}", '');
}
/* See if there's an up-to-date cache, otherwise run `update.js` to create one. */
function getCache(callback = false) {
if (!fs.existsSync('_cache/cache.json')) {
debug("No cache file found. Creating one...");
if (callback) {
if (!updating_now) {
updating_now = true;
fork('update.js');
}
var checkDone = setInterval(function() {
if (fs.existsSync('_cache/cache.json')) {
updating_now = false;
cache = JSON.parse(fs.readFileSync('_cache/cache.json'));
clearInterval(checkDone);
debug("Successfully updated cache!");
callback();
}
}, 1000);
} else {
fork('update.js');
}
} else if (!cache) {
cache = JSON.parse(fs.readFileSync('_cache/cache.json'));
if (callback) {
callback();
}
} else if ((new Date().getTime() - cache.updated) < config.cache_refreshing_interval) {
return cache;
} else if ((new Date().getTime() - cache.updated) >= config.cache_refreshing_interval) {
if (!updating_now) {
updating_now = true;
older_cache_time = cache.updated;
fork('update.js');
var checkDone2 = setInterval(function() {
if (cache.updated != older_cache_time) {
clearInterval(checkDone2);
debug("Successfully updated cache!");
updating_now = false;
}
}, 1000);
}
return cache;
}
}
/* Generate an abuse report for a scam domain */
function generateAbuseReport(scam) {
let abusereport = "";
abusereport += "I would like to inform you of suspicious activities at the domain " + url.parse(scam.url).hostname;
if ('ip' in scam) {
abusereport += " located at IP address " + scam['ip'] + ".";
} else {
abusereport += ".";
}
if ('subcategory' in scam && scam.subcategory == "MyEtherWallet") {
abusereport += "The domain is impersonating MyEtherWallet.com, a website where people can create Ethereum wallets (a cryptocurrency like Bitcoin).";
} else if ('subcategory' in scam && scam.subcategory == "MyCrypto") {
abusereport += "The domain is impersonating MyCrypto.com, a website where people can create Ethereum wallets (a cryptocurrency like Bitcoin).";
} else if ('subcategory' in scam && scam.subcategory == "Classic Ether Wallet") {
abusereport += "The domain is impersonating classicetherwallet.com, a website where people can create Ethereum Classic wallets (a cryptocurrency like Bitcoin).";
} else if ('category' in scam && scam.category == "Fake ICO") {
abusereport += "The domain is impersonating a website where an ICO is being held (initial coin offering, like an initial public offering but it's for cryptocurrencies).";
}
if ('category' in scam && scam.category == "Phishing") {
abusereport += "\r\n\r\nThe attackers wish to steal funds by using phishing to get the victim's private keys (passwords to a wallet) and using them to send funds to their own wallets.";
} else if ('category' in scam && scam.category == "Fake ICO") {
abusereport += "\r\n\r\nThe attackers wish to steal funds by cloning the real website and changing the ethereum address so people will send funds to the attackers' address instead of the real address.";
}
abusereport += "\r\n\r\nPlease shut down this domain so further attacks will be prevented.";
return abusereport;
}
/* Start the web server */
function startWebServer() {
app.use(function(req, res, next) {
var err = null;
try {
decodeURIComponent(req.path)
}
catch(e) {
err = e;
}
if (err){
return res.status(400).json({
status: 400,
error: 'OOps! Bad request',
});
}
next();
});
app.use(csp({
policies: {
'default-src': [csp.SELF, 'c.disquscdn.com', 'disqus.com'],
'font-src': ['fonts.gstatic.com', 'cdnjs.cloudflare.com', 'data:'],
'script-src': [csp.SELF, csp.INLINE, 'cdnjs.cloudflare.com', 'ethereum-scam-database.disqus.com', 'c.disquscdn.com', 'www.google.com', 'www.gstatic.com', 'ajax.cloudflare.com', csp.EVAL], //unsafe-eval for disqus :(
'style-src': [csp.SELF, 'cdnjs.cloudflare.com', 'fonts.googleapis.com', '*.disqus.com'],
'frame-src': ['disqus.com', '*.disqus.com', 'www.google.com'],
'img-src': [csp.SELF, 'c.disquscdn.com', 'urlscan.io', 'referrer.disqus.com'],
'prefetch-src': ['c.disquscdn.com'], //currently not supported by default, yet - so defaulting to default-src
'connect-src': ['links.services.disqus.com', 'lu1t.nl', csp.SELF],
'frame-ancestors': ['iframe'],
'worker-src': [csp.NONE],
'block-all-mixed-content': true,
'base-uri': [csp.SELF]
}
}));
app.use(frameguard({action:'sameorigin'}));
app.use(xssFilter({ setOnOldIE: true }))
app.use(express.static('_static')); // Serve all static pages first
app.use('/screenshot', express.static('_cache/screenshots/')); // Serve all screenshots
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.get('/(/|index.html)?', function(req, res) { // Serve index.html
res.send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/index.html', 'utf8')));
});
app.get('/security.txt', function(req, res) { // Serve security.txt
res.send(fs.readFileSync('./_data/security.txt', 'utf8'));
});
app.get('/search/', function(req, res) { // Serve /search/
let table = "";
getCache().legiturls.sort(function(a, b) {
return a.name.localeCompare(b.name);
}).forEach(function(url) {
if ('featured' in url && url.featured) {
if (fs.existsSync("_static/img/" + url.name.toLowerCase().replace(' ', '') + ".png")) {
table += "<tr><td><img class='project icon' src='/img/" + url.name.toLowerCase().replace(' ', '') + ".png'>" + url.name + "</td><td><a target='_blank' href='" + url.url + "'>" + url.url + "</a></td></tr>";
} else {
debug("Warning: No verified icon was found for %s",url.name);
table += "<tr><td>" + url.name + "</td><td><a target='_blank' href='" + url.url + "'>" + url.url + "</a></td></tr>";
}
}
});
var template = fs.readFileSync('./_layouts/search.html', 'utf8').replace('{{ trusted.table }}', table);
res.send(default_template.replace('{{ content }}', template));
});
app.get('/faq/', function(req, res) { // Serve /faq/
res.send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/faq.html', 'utf8')));
});
app.get('/report/:type?/:value?', function(req, res) { // Serve /report/, /report/domain/, and /report/address/ (or /report/domain/fake-mycrypto.com
if (!req.params.type) {
res.send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/report.html', 'utf8')));
} else if (req.params.type == "address") {
let strParamValue = "";
if(/^[\w\.]+$/.test(req.params.value)) {
strParamValue = req.params.value;
}
if (req.params.value) {
res.send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/reportaddress.html', 'utf8')).replace('{{ page.placeholder }}', strParamValue));
} else {
res.send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/reportaddress.html', 'utf8')).replace('{{ page.placeholder }}', ''));
}
} else if (req.params.type == "domain") {
let strParamValue = "";
if(/^[\w\.\/]+$/.test(req.params.value)) {
strParamValue = req.params.value;
}
if (req.params.value) {
res.send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/reportdomain.html', 'utf8')).replace('{{ page.placeholder }}', strParamValue));
} else {
res.send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/reportdomain.html', 'utf8')).replace('{{ page.placeholder }}', ''));
}
} else {
res.sendStatus(404);
}
});
app.get('/scams/:page?/:sorting?/', function(req, res) { // Serve /scams/
const MAX_RESULTS_PER_PAGE = 30;
let template = fs.readFileSync('./_layouts/scams.html', 'utf8');
if (!req.params.sorting || req.params.sorting == 'latest') {
var scams = getCache().scams.sort(function(a, b) {
return b.id - a.id;
});
} else if (req.params.sorting == 'oldest') {
var scams = getCache().scams.sort(function(a, b) {
return a.id - b.id;
});
} else if (req.params.sorting == 'status') {
template = template.replace("{{ sorting.status }}", "sorted descending");
var scams = getCache().scams.sort(function(a, b) {
if ('status' in a && 'status' in b) {
if ((a.status == 'Active' && b.status != 'Active') || (a.status == 'Inactive' && (b.status == 'Suspended' || b.status == 'Offline')) || (a.status == 'Suspended' && b.status == 'Offline')) {
return -1;
} else if (a.status == b.status) {
return 0;
} else {
return 1;
}
} else {
return 1;
}
});
} else if (req.params.sorting == 'category') {
template = template.replace("{{ sorting.category }}", "sorted descending");
var scams = getCache().scams.sort(function(a, b) {
if ('category' in a && 'category' in b && a.category && b.category) {
return a.category.localeCompare(b.category);
} else {
return -1;
}
});
} else if (req.params.sorting == 'subcategory') {
template = template.replace("{{ sorting.subcategory }}", "sorted descending");
var scams = getCache().scams.sort(function(a, b) {
if ('subcategory' in a && 'subcategory' in b && a.subcategory && b.subcategory) {
return a.subcategory.localeCompare(b.subcategory);
} else {
return -1;
}
});
} else if (req.params.sorting == 'title') {
template = template.replace("{{ sorting.title }}", "sorted descending");
var scams = getCache().scams.sort(function(a, b) {
return a.name.localeCompare(b.name);
});
} else {
res.status(404).send(default_template.replace('{{ content }}', fs.readFileSync('./_layouts/404.html', 'utf8')));
}
template = template.replace("{{ sorting.category }}", "");
template = template.replace("{{ sorting.subcategory }}", "");
template = template.replace("{{ sorting.status }}", "");
template = template.replace("{{ sorting.title }}", "");
let addresses = {};
var intActiveScams = 0;
var intInactiveScams = 0;
scams.forEach(function(scam, index) {
if ('addresses' in scam) {
scams[index].addresses.forEach(function(address) {
addresses[address] = true;
});
}
if ('status' in scam) {
if (scam.status === 'Active') {
++intActiveScams;
} else {
++intInactiveScams;
}
}
});
template = template.replace("{{ scams.total }}", scams.length.toLocaleString('en-US'));
template = template.replace("{{ scams.active }}", intActiveScams.toLocaleString('en-US'));
template = template.replace("{{ addresses.total }}", Object.keys(addresses).length.toLocaleString('en-US'));
template = template.replace("{{ scams.inactive }}", intInactiveScams.toLocaleString('en-US'));
var table = "";
if (req.params.page == "all") {
var max = scams.length - 1; //0-based indexing
var start = 0;
} else if (!isNaN(parseInt(req.params.page))) {
var max = (req.params.page * MAX_RESULTS_PER_PAGE) + MAX_RESULTS_PER_PAGE;
var start = req.params.page * MAX_RESULTS_PER_PAGE;
} else {
var max = MAX_RESULTS_PER_PAGE;
var start = 0;
}
for (var i = start; i <= max; i++) {
if (scams.hasOwnProperty(i) === false) {
continue;
}
if ('status' in scams[i]) {
if (scams[i].status == "Active") {
var status = "<td class='offline'><i class='warning sign icon'></i> Active</td>";
} else if (scams[i].status == "Inactive") {
var status = "<td class='suspended'><i class='remove icon'></i> Inactive</td>";
} else if (scams[i].status == "Offline") {
var status = "<td class='activ'><i class='checkmark icon'></i> Offline</td>";
} else if (scams[i].status == "Suspended") {
var status = "<td class='suspended'><i class='remove icon'></i> Suspended</td>";
} else if (scams[i].status == "NotChecked") {
var status = "<td class='suspended'><i class='remove icon'></i> Not Checked</td>";
}
} else {
var status = "<td>None</td>";
}
if ('category' in scams[i]) {
switch (scams[i].category) {
case "Phishing":
var category = '<i class="address book icon"></i> Phishing';
break;
case "Scamming":
var category = '<i class="payment icon"></i> Scamming';
break;
case "Fake ICO":
var category = '<i class="dollar icon"></i> Fake ICO';
break;
default:
var category = scams[i].category;
}
} else {
var category = '<i class="remove icon"></i> None';
}
if ('subcategory' in scams[i] && scams[i].subcategory) {
if (scams[i].subcategory.toLowerCase() == "wallets") {
var subcategory = '<i class="credit card alternative icon"></i> ' + scams[i].subcategory;
} else if (fs.existsSync("_static/img/" + scams[i].subcategory.toLowerCase().replace(/\s/g, '') + ".png")) {
var subcategory = "<img src='/img/" + scams[i].subcategory.toLowerCase().replace(/\s/g, '') + ".png' class='subcategoryicon'> " + scams[i].subcategory;
} else {
var subcategory = scams[i].subcategory;
if (!(icon_warnings.includes(subcategory))) {
icon_warnings.push(subcategory);
debug("Warning! No subcategory icon found for %s",subcategory);
}
}
} else {
var subcategory = '<i class="remove icon"></i> None';
}
if (scams[i].name.length > 40) {
scams[i].name = scams[i].name.substring(0, 40) + '...';
}
table += "<tr><td>" + category + "</td><td>" + subcategory + "</td>" + status + "<td>" + scams[i].name + "</td><td class='center'><a href='/domain/" + url.parse(scams[i].url).hostname + "'><i class='search icon'></i></a></td></tr>";
}
template = template.replace("{{ scams.table }}", table);
if (req.params.page !== "all") {
var intCurrentPage = 0;
if (Number.parseInt(req.params.page) > 0) {
intCurrentPage = req.params.page;
}
var strPagination = "";
if (intCurrentPage == 0) {
var arrLoop = [1, 6];
} else if (intCurrentPage == 1) {
var arrLoop = [0, 5];
} else if (intCurrentPage == 2) {
var arrLoop = [-1, 4];
} else {
var arrLoop = [-2, 3];
}
for (var i = arrLoop[0]; i < arrLoop[1]; i++) {
var intPageNumber = (Number(intCurrentPage) + Number(i));
var strItemClass = "item";
var strHref = "/scams/" + intPageNumber + "/";
if (req.params.sorting) {
strHref += req.params.sorting + "/";
}
if ((intPageNumber > (scams.length) / MAX_RESULTS_PER_PAGE) || (intPageNumber < 1)) {
strItemClass = "disabled item";
strHref = "#";
} else if (intCurrentPage == intPageNumber) {
strItemClass = "active item";
}
strPagination += "<a href='" + strHref + "' class='" + strItemClass + "'>" + intPageNumber + "</a>";
}
if (intCurrentPage > 3) {
if (req.params.sorting) {
strPagination = "<a class='item' href='/scams/1/" + req.params.sorting + "'><i class='angle double left icon'></i></a>" + strPagination;
} else {
strPagination = "<a class='item' href='/scams/1/" + req.params.sorting + "'><i class='angle double left icon'></i></a>" + strPagination;
}
}
if (intCurrentPage < Math.ceil(scams.length / MAX_RESULTS_PER_PAGE) - 3) {
if (req.params.sorting) {
strPagination += "<a class='item' href='/scams/" + (Math.ceil(scams.length / MAX_RESULTS_PER_PAGE) - 1) + "/" + req.params.sorting + "'><i class='angle double right icon'></i></a>";
} else {
strPagination += "<a class='item' href='/scams/" + (Math.ceil(scams.length / MAX_RESULTS_PER_PAGE) - 1) + "'><i class='angle double right icon'></i></a>";
}
}
} else {
strPagination = "";
}
template = template.replace("{{ scams.pagination }}", "<div class='ui pagination menu'>" + strPagination + "</div>");
res.send(default_template.replace('{{ content }}', template));
});
app.get('/scam/:id/', function(req, res) { // Serve /scam/<id>/
var whitelistImports;
var blacklistImports;
var fuzzylistImports;
var toleranceImports;
let startTime = (new Date()).getTime();
let scam = getCache().scams.find(function(scam) {
return scam.id == req.params.id;
});
if(typeof scam === "undefined") {
let template = fs.readFileSync('./_layouts/no-scam-found.html', 'utf8');
res.send(default_template.replace('{{ content }}', template));
}
let template = fs.readFileSync('./_layouts/scam.html', 'utf8');
var actions_text = "";
template = template.replace("{{ scam.id }}", scam.id);
template = template.replace("{{ scam.name }}", scam.name);
if ('category' in scam) {
if ('subcategory' in scam) {
template = template.replace("{{ scam.category }}", '<b>Category</b>: ' + scam.category + ' - ' + scam.subcategory + '<BR>');
} else {
template = template.replace("{{ scam.category }}", '<b>Category</b>: ' + scam.category + '<BR>');
}
} else {
template = template.replace("{{ scam." + name + " }}", '');
}
if ('status' in scam) {
template = template.replace("{{ scam.status }}", '<b>Status</b>: <span class="class_' + scam.status.toLowerCase() + '">' + scam.status + '</span><BR>');
} else {
template = template.replace("{{ scam.status }}", '');
}
if ('description' in scam) {
template = template.replace("{{ scam.description }}", '<b>Description</b>: ' + scam.description + '<BR>');
} else {
template = template.replace("{{ scam.description }}", '');
}
if ('nameservers' in scam) {
var nameservers_text = '';
scam.nameservers.forEach(function(nameserver) {
nameservers_text += '<div class="ui item">' + nameserver + '</div>';
});
template = template.replace("{{ scam.nameservers }}", '<b>Nameservers</b>: <div class="ui bulleted list">' + nameservers_text + '</div>');
} else {
template = template.replace("{{ scam.nameservers }}", '');
}
if ('addresses' in scam) {
var addresses_text = '';
scam.addresses.forEach(function(address) {
addresses_text += '<div class="ui item"><a href="/address/' + address + '">' + address + '</a></div>';
});
template = template.replace("{{ scam.addresses }}", '<b>Related addresses</b>: <div class="ui bulleted list">' + addresses_text + '</div>');
} else {
template = template.replace("{{ scam.addresses }}", '');
}
if ('ip' in scam) {
template = template.replace("{{ scam.ip }}", '<b>IP</b>: <a href="/ip/' + scam.ip + '">' + scam.ip + '</a><BR>');
} else {
template = template.replace("{{ scam.ip }}", '');
}
if ('url' in scam) {
template = template.replace("{{ scam.abusereport }}", generateAbuseReport(scam));
actions_text += '<button id="gen" class="ui icon secondary button"><i class="setting icon"></i> Abuse Report</button>';
actions_text += '<a target="_blank" href="http://web.archive.org/web/*/' + url.parse(scam.url).hostname + '" class="ui icon secondary button"><i class="archive icon"></i> Archive</a>';
template = template.replace("{{ scam.url }}", '<b>URL</b>: <a id="url" target="_blank" href="/redirect/' + encodeURIComponent(scam.url) + '">' + scam.url + '</a><BR>');
template = template.replace("{{ scam.googlethreat }}", "<b>Google Safe Browsing</b>: {{ scam.googlethreat }}<BR>");
/* Parses data for Metamask*/
if (fs.existsSync('./_data/metamaskImports.json')) {
try {
var importsData = require('./_data/metamaskImports.json')
const detector = new phishingDetector(importsData);
template = template.replace("{{ scam.metamask }}", "<b>MetaMask Status:</b> " + (detector.check(url.parse(scam.url).hostname).result ? "<span class='green-text'>Blocked</span>" : "<span class='red-text'>Not Blocked</span>") + "<br />");
} catch (e) {
debug(e);
}
} else{
debug('MetaMask JSON not found');
};
if ('status' in scam && scam.status != 'Offline' && fs.existsSync('_cache/screenshots/' + scam.id + '.png')) {
template = template.replace("{{ scam.screenshot }}", '<h3>Screenshot</h3><img src="/screenshot/' + scam.id + '.png">');
} else {
template = template.replace("{{ scam.screenshot }}", '');
}
} else {
template = template.replace("{{ scam.googlethreat }}", '');
template = template.replace("{{ scam.screenshot }}", '');
}
actions_text += '<a target="_blank" href="https://github.com/' + config.repository.author + '/' + config.repository.name + '/blob/' + config.repository.branch + '/_data/scams.yaml" class="ui icon secondary button"><i class="write alternate icon"></i> Improve</a><button id="share" class="ui icon secondary button"><i class="share alternate icon"></i> Share</button>';
template = template.replace("{{ scam.actions }}", '<div id="actions" class="eight wide column">' + actions_text + '</div>');
if ('Google_SafeBrowsing_API_Key' in config && config.Google_SafeBrowsing_API_Key && 'url' in scam) {
var options = {
uri: 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key=' + config.Google_SafeBrowsing_API_Key,
method: 'POST',
json: {
client: {
clientId: "Ethereum Scam Database",
clientVersion: "1.0.0"
},
threatInfo: {
threatTypes: ["THREAT_TYPE_UNSPECIFIED", "MALWARE", "SOCIAL_ENGINEERING", "UNWANTED_SOFTWARE", "POTENTIALLY_HARMFUL_APPLICATION"],
platformTypes: ["ANY_PLATFORM"],
threatEntryTypes: ["THREAT_ENTRY_TYPE_UNSPECIFIED", "URL", "EXECUTABLE"],
threatEntries: [{
"url": url.parse(scam.url).hostname
}]
}
}
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
if ('matches' in body && 0 in body.matches) {
template = template.replace("{{ scam.googlethreat }}", "<span class='class_offline'>Blocked for " + body.matches[0]['threatType'] + '</span>');
} else {
template = template.replace("{{ scam.googlethreat }}", "<span class='class_active'>Not Blocked</span> <a target='_blank' href='https://safebrowsing.google.com/safebrowsing/report_phish/'><i class='warning sign icon'></i></a>");
}
}
template = template.replace("{{ page.built }}", '<p class="built">This page was built in <b>' + ((new Date()).getTime() - startTime) + '</b>ms, and last updated at <b>' + dateFormat(getCache().updated, "UTC:mmm dd yyyy, HH:MM") + ' UTC</b></p>');
res.send(default_template.replace('{{ content }}', template));
});
} else {
debug("Warning: No Google Safe Browsing API key found");
res.send(default_template.replace('{{ content }}', template));
}
});
app.get('/domain/:domain/', function(req, res) { // Serve /domain/<domain>/
var whitelistImports;
var blacklistImports;
var fuzzylistImports;
var toleranceImports;
let domainpage = encodeURIComponent(req.params.domain.replace("www.","").split(/[/?#]/)[0].toLowerCase());
if(/^([0-9a-z\.\-]+)$/.exec(domainpage) === null) {
let template = fs.readFileSync('./_layouts/404.html', 'utf8');
res.send(default_template.replace('{{ content }}', template));
return;
}
var webcheck = new check();
var urllookup = new lookup();
let startTime = (new Date()).getTime();
let scam = getCache().scams.find(function(scam) {
return scam.name == domainpage;
});
let verified = getCache().legiturls.find(function(verified) {
return verified.url.replace("https://", '') == domainpage;
});
// NEUTRAL DOMAIN PAGES
if(typeof scam === "undefined" && typeof verified === "undefined") {
let template = fs.readFileSync('./_layouts/neutraldomain.html', 'utf8');
template = template.replace("{{ neutral.name }}", domainpage);
template = template.replace("{{ neutral.url }}", '<b>URL</b>: <a id="url" target="_blank" href="/redirect/' + encodeURIComponent("http://" + domainpage) + '">' + "http://" + domainpage + '</a><BR>');
template = template.replace("{{ neutral.notification }}", '<div class="ui mini brown message"><i class="warning sign icon"></i> This domain has not yet been classified on EtherScamDB </div>')
template = template.replace("{{ neutral.googlethreat }}", "<b>Google Safe Browsing Status</b>: {{ neutral.googlethreat }}<BR>");
template = template.replace("{{ neutral.virustotal }}", "<b>VirusTotal Detections</b>: {{ neutral.virustotal }}<BR>");
template = template.replace("{{ neutral.phishtank }}", "<b>Phishtank Detected</b>: {{ neutral.phishtank }}<BR>");
template = template.replace("{{ neutral.urlscan }}", "<b>Urlscan Scan Results</b>: {{ neutral.urlscan }}<BR>");
template = template.replace("{{ neutral.urlscreenshot }}", "<b>Urlscan Screenshot</b>:<BR> {{ neutral.urlscreenshot }}<BR>");
webcheck.lookup( domainpage ).then(function(output) {
if(output.total == 0){
template = template.replace("{{ neutral.urlscan }}", "<span class='class_inactive'> Not Yet</span>");
template = template.replace("{{ neutral.urlscreenshot }}", "<span class='class_inactive'> Screenshot could not be displayed</span>");
res.send(default_template.replace('{{ content }}', template));
} else if(output.total != 0){
var interval = 0;
var index = 0;
for(interval; interval < output.total; interval++){
if(url.parse(output.results[interval].task.url).hostname.replace('www.','') == domainpage){
index = interval;
break;
} else if(interval == 99){
template = template.replace("{{ neutral.urlscan }}", "<span class='class_inactive'> Link could not be found</span>")
template = template.replace("{{ neutral.urlscanlink }}", "");
template = template.replace("{{ neutral.urlscreenshot }}", "<span class='class_inactive'> Screenshot could not be displayed</span>");
res.send(default_template.replace('{{ content }}', template));
return;
}
}
template = template.replace("{{ neutral.urlscan }}", "<a class='green-text' href='{{ neutral.urlscanlink }}' target='_blank'>Link</a>");
template = template.replace("{{ neutral.urlscanlink }}", 'https://urlscan.io/result/' + output.results[index]._id);
urllookup.lookup( output.results[index].result ).then(function(lookupout) {
if(lookupout.data != null){
template = template.replace("{{ neutral.urlscreenshot }}", "<div id='scam-screenshot'><img src=" + lookupout.task.screenshotURL + " alt='Screenshot of website' class='screenshot-img'></img></div>");
res.send(default_template.replace('{{ content }}', template));
} else{
template = template.replace("{{ neutral.urlscreenshot }}", "<span class='class_inactive'> Screenshot could not be displayed</span>");
}
})
}
});
if ('Google_SafeBrowsing_API_Key' in config && config.Google_SafeBrowsing_API_Key && domainpage != 'undefined') {
var options = {
uri: 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key=' + config.Google_SafeBrowsing_API_Key,
method: 'POST',
json: {
client: {
clientId: "Ethereum Scam Database",
clientVersion: "1.0.0"
},
threatInfo: {
threatTypes: ["THREAT_TYPE_UNSPECIFIED", "MALWARE", "SOCIAL_ENGINEERING", "UNWANTED_SOFTWARE", "POTENTIALLY_HARMFUL_APPLICATION"],
platformTypes: ["ANY_PLATFORM"],
threatEntryTypes: ["THREAT_ENTRY_TYPE_UNSPECIFIED", "URL", "EXECUTABLE"],
threatEntries: [{
"url": domainpage
}]
}
}
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
if ('matches' in body && 0 in body.matches) {
template = template.replace("{{ neutral.googlethreat }}", "<span class='class_offline'>Blocked for " + body.matches[0]['threatType'] + '</span>');
} else {
template = template.replace("{{ neutral.googlethreat }}", "<span class='class_active'>Not Blocked</span> <a target='_blank' href='https://safebrowsing.google.com/safebrowsing/report_phish/'><i class='warning sign icon'></i></a>");
}
} else {
template = template.replace("{{ neutral.googlethreat }}", "<span class='class_inactive'> Could not pull data from Google SafeBrowsing</span>");
}
});
} else {
template = template.replace("{{ neutral.googlethreat }}", "<span class='class_inactive'> Could not pull data from Google SafeBrowsing</span>");
debug("Warning: No Google Safe Browsing API key found");
}
if ('VirusTotal_API_Key' in config && config.VirusTotal_API_Key && domainpage != 'undefined') {
var options = {
uri: 'https://www.virustotal.com/vtapi/v2/url/report?apikey=' + config.VirusTotal_API_Key + '&resource=http://' + domainpage,
method: 'GET',
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
body = JSON.parse(body);
if(body.response_code != 0){
if (body.positives == 0) {
template = template.replace("{{ neutral.virustotal }}", "<span class='class_offline'> " + body.positives + ' / ' + body.total + '</span>');
} else {
template = template.replace("{{ neutral.virustotal }}", "<span class='class_active'> " + body.positives + ' / ' + body.total + "</span> <i class='warning sign icon'></i></a>");
}
if (body.scans.Phishtank.result == "clean site"){
template = template.replace("{{ neutral.phishtank }}", "<span class='class_offline'> " + "Clean Site" + '</span>');
} else if(body.scans.Phishtank.result == "phishing site"){
template = template.replace("{{ neutral.phishtank }}", "<span class='class_active'> " + "Phishing Site"+ '</span>');
} else{
template = template.replace("{{ neutral.phishtank }}", "<span class='class_active'> " + body.scans.Phishtank.result + '</span>');
}
} else{
template = template.replace("{{ neutral.virustotal }}", "<span class='class_inactive'> Could not pull data from VirusTotal</span>");
template = template.replace("{{ neutral.phishtank }}", "<span class='class_inactive'> Could not pull data from Phishtank</span>");
}
} else {
template = template.replace("{{ neutral.virustotal }}", "<span class='class_inactive'> Could not pull data from VirusTotal</span>");
template = template.replace("{{ neutral.phishtank }}", "<span class='class_inactive'> Could not pull data from Phishtank</span>");
}
template = template.replace("{{ page.built }}", '<p class="built">This page was built in <b>' + ((new Date()).getTime() - startTime) + '</b>ms, and last updated at <b>' + dateFormat(getCache().updated, "UTC:mmm dd yyyy, HH:MM") + ' UTC</b></p>');
});
} else {
template = template.replace("{{ neutral.virustotal }}", "<span class='class_inactive'> Could not pull data from VirusTotal</span>");
template = template.replace("{{ neutral.phishtank }}", "<span class='class_inactive'> Could not pull data from Phishtank</span>");
template = template.replace("{{ page.built }}", '<p class="built">This page was built in <b>' + ((new Date()).getTime() - startTime) + '</b>ms, and last updated at <b>' + dateFormat(getCache().updated, "UTC:mmm dd yyyy, HH:MM") + ' UTC</b></p>');
debug("Warning: No VirusTotal API key found");
}
}
// VERIFIED DOMAIN PAGES
if(typeof verified != "undefined"){
let template = fs.readFileSync('./_layouts/verifieddomain.html', 'utf8');
template = template.replace("{{ verified.name }}", verified.name);
template = template.replace("{{ verified.notification }}", '<div class="ui mini green message"><i class="warning sign icon"></i> This is a verified domain. </div>')
template = template.replace("{{ verified.googlethreat }}", "<b>Google Safe Browsing Status</b>: {{ verified.googlethreat }}<BR>");
template = template.replace("{{ verified.virustotal }}", "<b>VirusTotal Detections</b>: {{ verified.virustotal }}<BR>");
template = template.replace("{{ verified.phishtank }}", "<b>Phishtank Detected</b>: {{ verified.phishtank }}<BR>");
template = template.replace("{{ verified.urlscan }}", "<b>Urlscan Scan Results</b>: {{ verified.urlscan }}<BR>");
template = template.replace("{{ verified.urlscreenshot }}", "<b>Urlscan Screenshot</b>:<BR> {{ verified.urlscreenshot }}<BR>");
webcheck.lookup( url.parse(verified.url).hostname ).then(function(output) {
if(!('total' in output) || output.total == 0){
template = template.replace("{{ verified.urlscan }}", "Not Yet");
res.send(default_template.replace('{{ content }}', template));
} else if(output.total != 0){
var interval = 0;
var index = 0;
for(interval; interval < output.total; interval++){
if(url.parse(output.results[interval].task.url).hostname.replace('www.','') == url.parse(verified.url).hostname){
index = interval;
break;
} else if(interval == 99){
index = 0;
template = template.replace("{{ verified.urlscan }}", "<span class='class_inactive'> Link could not be found</span>")
template = template.replace("{{ verified.urlscanlink }}", "");
template = template.replace("{{ verified.urlscreenshot }}", "<span class='class_inactive'> Screenshot could not be displayed</span>");
res.send(default_template.replace('{{ content }}', template));
return;
}
}
template = template.replace("{{ verified.urlscan }}", "<a class='green-text' href='{{ verified.urlscanlink }}' target='_blank'>Link</a>");
template = template.replace("{{ verified.urlscanlink }}", 'https://urlscan.io/result/' + output.results[index]._id);
urllookup.lookup( output.results[index].result ).then(function(lookupout) {
if('data' in lookupout && lookupout.data != null){
template = template.replace("{{ verified.urlscreenshot }}", "<div id='scam-screenshot'><img src=" + lookupout.task.screenshotURL + " alt='Screenshot of website' class='screenshot-img'></img></div>");
res.send(default_template.replace('{{ content }}', template));
} else{
template = template.replace("{{ verified.urlscreenshot }}", "<span class='class_inactive'> Screenshot could not be displayed</span>");
}
})
}
});
if ('description' in verified) {
template = template.replace("{{ verified.description }}", '<b>Description</b>: ' + verified.description + '<BR>');
} else {
template = template.replace("{{ verified.description }}", '');
}
if ('addresses' in verified) {
var addresses_text = '';
verified.addresses.forEach(function(address) {
addresses_text += '<div class="ui item"><a href="/address/' + address + '">' + address + '</a></div>';
});
template = template.replace("{{ verified.addresses }}", '<b>Related addresses</b>: <div class="ui bulleted list">' + addresses_text + '</div>');
} else {
template = template.replace("{{ verified.addresses }}", '');
}
if ('url' in verified) {
template = template.replace("{{ verified.url }}", '<b>URL</b>: <a id="url" target="_blank" href="' + verified.url + '">' + verified.url + '</a><BR>');
} else {
template = template.replace("{{ verified.url }}", '');
}
if ('Google_SafeBrowsing_API_Key' in config && config.Google_SafeBrowsing_API_Key && domainpage != 'undefined') {
var options = {
uri: 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key=' + config.Google_SafeBrowsing_API_Key,
method: 'POST',
json: {
client: {
clientId: "Ethereum Scam Database",
clientVersion: "1.0.0"
},
threatInfo: {
threatTypes: ["THREAT_TYPE_UNSPECIFIED", "MALWARE", "SOCIAL_ENGINEERING", "UNWANTED_SOFTWARE", "POTENTIALLY_HARMFUL_APPLICATION"],
platformTypes: ["ANY_PLATFORM"],
threatEntryTypes: ["THREAT_ENTRY_TYPE_UNSPECIFIED", "URL", "EXECUTABLE"],
threatEntries: [{
"url": domainpage
}]
}
}
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
if ('matches' in body && 0 in body.matches) {
template = template.replace("{{ verified.googlethreat }}", "<span class='class_active'> Blocked for " + body.matches[0]['threatType'] + '</span>');
} else {
template = template.replace("{{ verified.googlethreat }}", "<span class='class_offline'> Not Blocked</span> <a target='_blank' href='https://safebrowsing.google.com/safebrowsing/report_phish/'><i class='warning sign icon'></i></a>");
}
} else {
template = template.replace("{{ verified.googlethreat }}", "<span class='class_inactive'> Could not pull data from Google SafeBrowsing</span>");
}
});
} else {
template = template.replace("{{ verified.googlethreat }}", "<span class='class_inactive'> Could not pull data from Google SafeBrowsing</span>");
debug("Warning: No Google Safe Browsing API key found");
}
if ('VirusTotal_API_Key' in config && config.VirusTotal_API_Key && domainpage != 'undefined') {
var options = {
uri: 'https://www.virustotal.com/vtapi/v2/url/report?apikey=' + config.VirusTotal_API_Key + '&resource=http://' + domainpage,
method: 'GET',
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
body = JSON.parse(body);
if(body.response_code != 0){
if (body.positives == 0) {
template = template.replace("{{ verified.virustotal }}", "<span class='class_offline'> " + body.positives + ' / ' + body.total + '</span>');
} else {
template = template.replace("{{ verified.virustotal }}", "<span class='class_active'> " + body.positives + ' / ' + body.total + "</span> <i class='warning sign icon'></i></a>");
}
if (body.scans.Phishtank.result == "clean site"){
template = template.replace("{{ verified.phishtank }}", "<span class='class_offline'> " + "Clean Site" + '</span>');
} else if(body.scans.Phishtank.result == "phishing site"){
template = template.replace("{{ verified.phishtank }}", "<span class='class_active'> " + "Phishing Site"+ '</span>');
} else{
template = template.replace("{{ verified.phishtank }}", "<span class='class_active'> " + body.scans.Phishtank.result + '</span>');
}
} else{
template = template.replace("{{ verified.virustotal }}", "<span class='class_inactive'> Could not pull data from VirusTotal</span>");
template = template.replace("{{ verified.phishtank }}", "<span class='class_inactive'> Could not pull data from Phishtank</span>");
}
} else {
template = template.replace("{{ verified.virustotal }}", "<span class='class_inactive'> Could not pull data from VirusTotal</span>");
template = template.replace("{{ verified.phishtank }}", "<span class='class_inactive'> Could not pull data from Phishtank</span>");
}
template = template.replace("{{ page.built }}", '<p class="built">This page was built in <b>' + ((new Date()).getTime() - startTime) + '</b>ms, and last updated at <b>' + dateFormat(getCache().updated, "UTC:mmm dd yyyy, HH:MM") + ' UTC</b></p>');
});
} else {
template = template.replace("{{ verified.virustotal }}", "<span class='class_inactive'> Could not pull data from VirusTotal</span>");
template = template.replace("{{ verified.phishtank }}", "<span class='class_inactive'> Could not pull data from Phishtank</span>");
template = template.replace("{{ page.built }}", '<p class="built">This page was built in <b>' + ((new Date()).getTime() - startTime) + '</b>ms, and last updated at <b>' + dateFormat(getCache().updated, "UTC:mmm dd yyyy, HH:MM") + ' UTC</b></p>');
}
}
// SCAM DOMAIN PAGES
if(typeof scam != "undefined"){
let template = fs.readFileSync('./_layouts/scamdomain.html', 'utf8');
var actions_text = "";
template = template.replace("{{ scam.id }}", scam.id);
template = template.replace("{{ scam.name }}", scam.name);
template = template.replace("{{ scam.tip }}", "<b> Security Tip(s)</b>: <ul>{{ scam.tip }}</ul>");
template = template.replace("{{ scam.notification }}", '<div class="ui mini red message"><i class="warning sign icon"></i> Warning: This is a scam domain. </div>')
template = template.replace("{{ scam.googlethreat }}", "<b>Google Safe Browsing Status</b>: {{ scam.googlethreat }}<BR>");
template = template.replace("{{ scam.virustotal }}", "<b>VirusTotal Detections</b>: {{ scam.virustotal }}<BR>");
template = template.replace("{{ scam.phishtank }}", "<b>Phishtank Detected</b>: {{ scam.phishtank }}<BR>");
template = template.replace("{{ scam.urlscan }}", "<b>Urlscan Scan Results</b>: {{ scam.urlscan }}<BR>");
template = template.replace("{{ scam.urlscreenshot }}", "<b>Urlscan Screenshot</b>:<BR> {{ scam.urlscreenshot }}<BR>");
webcheck.lookup( url.parse(scam.url).hostname ).then(function(output) {
if(!output || !('total' in output) || output.total == 0){
template = template.replace("{{ scam.urlscan }}", "Not Yet");
res.send(default_template.replace('{{ content }}', template));
} else if(output.total != 0){
var interval = 0;
var index = 0;
for(interval; interval < output.total; interval++){
if(url.parse(output.results[interval].task.url).hostname.replace('www.','') == url.parse(scam.url).hostname){
index = interval;
break;
} else if(interval == 99){
index = 0;
template = template.replace("{{ scam.urlscan }}", "<span class='class_inactive'> Link could not be found</span>")
template = template.replace("{{ scam.urlscanlink }}", "");
template = template.replace("{{ scam.urlscreenshot }}", "<span class='class_inactive'> Screenshot could not be displayed</span>");
res.send(default_template.replace('{{ content }}', template));
return;
}
}
template = template.replace("{{ scam.urlscan }}", "<a class='green-text' href='{{ scam.urlscanlink }}' target='_blank'>Link</a>");
template = template.replace("{{ scam.urlscanlink }}", 'https://urlscan.io/result/' + output.results[index]._id);
urllookup.lookup( output.results[index].result ).then(function(lookupout) {
if(lookupout.data != null){
template = template.replace("{{ scam.urlscreenshot }}", "<div id='scam-screenshot'><img src=" + lookupout.task.screenshotURL + " alt='Screenshot of website' class='screenshot-img'></img></div>");
res.send(default_template.replace('{{ content }}', template));
} else{
template = template.replace("{{ scam.urlscreenshot }}", "<span class='class_inactive'> Screenshot could not be displayed</span>");
}
})
}
})
if ('category' in scam) {
if ('subcategory' in scam) {
if (scam.category == "Phishing"){
if (scam.subcategory == "MyCrypto"){
template = template.replace("{{ scam.tip }}", '<li>Run MyCrypto offline using <a href="https://download.mycrypto.com">the desktop app</a>. Reference <a href="https://support.mycrypto.com/offline/running-mycrypto-locally.html">this article</a> if you need any help. {{ scam.tip }}</li>');
template = template.replace("{{ scam.tip }}", '<li>Download the <a href="https://chrome.google.com/webstore/detail/etheraddresslookup/pdknmigbbbhmllnmgdfalmedcmcefdfn?hl=en-GB">EtherAddressLookup</a> Chrome Extension to warn you of potential phishing/scamming sites. {{ scam.tip }}</li>');
template = template.replace("{{ scam.tip }}", '<li>Use a hardware wallet such as a <a href="https://www.ledgerwallet.com/r/1985?path=/products/">Ledger Nano S</a> or a <a href="https://shop.trezor.io/?a=mycrypto.com">Trezor</a>.</li>');
}
if (scam.subcategory == "MyEtherWallet"){
template = template.replace("{{ scam.tip }}", '<li>Run MyEtherWallet offline using <a href="https://kb.myetherwallet.com/offline/running-myetherwallet-locally.html">this guide on their knowledgebase</a>. {{ scam.tip }}</li>');
template = template.replace("{{ scam.tip }}", '<li>Download the <a href="https://chrome.google.com/webstore/detail/etheraddresslookup/pdknmigbbbhmllnmgdfalmedcmcefdfn?hl=en-GB">EtherAddressLookup</a> Chrome Extension to warn you of potential phishing/scamming sites. {{ scam.tip }}</li>');
template = template.replace("{{ scam.tip }}", '<li>Use a hardware wallet such as a <a href="https://www.ledgerwallet.com/r/1985?path=/products/">Ledger Nano S</a> or a <a href="https://shop.trezor.io/?a=mycrypto.com">Trezor</a>.</li>');
}
template = template.replace("{{ scam.tip }}", '<li>Download the <a href="https://chrome.google.com/webstore/detail/etheraddresslookup/pdknmigbbbhmllnmgdfalmedcmcefdfn?hl=en-GB">EtherAddressLookup</a> Chrome Extension to warn you of potential phishing/scamming sites. {{ scam.tip }}</li>');
template = template.replace("{{ scam.tip }}", '<li>Use a hardware wallet such as a <a href="https://www.ledgerwallet.com/r/1985?path=/products/">Ledger Nano S</a> or a <a href="https://shop.trezor.io/?a=mycrypto.com">Trezor</a>.</li>');
} if (scam.category == "Scamming") {
if (scam.subcategory == "Trust-Trading"){
template = template.replace("{{ scam.tip }}", '<li>Never trust giveaway scams! They are almost 100% of the time malicious attempts to steal your funds. {{ scam.tip }}</li>')
template = template.replace("{{ scam.tip }}", '<li>Download the <a href="">EtherAddressLookup</a> Chrome Extension to warn you of potential phishing/scamming sites.</li>');
}
} if (scam.category == "Fake ICO") {
template = template.replace("{{ scam.tip }}", '<li>Read about how to be safe during ICOs on <a href="https://support.mycrypto.com/security/how-to-stay-safe.html">MyCrypto\'s Knowledgebase</a></li>')
}
else {
template = template.replace("{{ scam.tip }}", '<li>Download the <a href="https://chrome.google.com/webstore/detail/etheraddresslookup/pdknmigbbbhmllnmgdfalmedcmcefdfn?hl=en-GB">EtherAddressLookup</a> Chrome Extension to warn you of potential phishing/scamming sites. {{ scam.tip }}</li>');
template = template.replace("{{ scam.tip }}", '<li>Use a hardware wallet such as a <a href="https://www.ledgerwallet.com/r/1985?path=/products/">Ledger Nano S</a> or a <a href="https://shop.trezor.io/?a=mycrypto.com">Trezor</a>.</li>');
}
template = template.replace("{{ scam.category }}", '<b>Category</b>: ' + scam.category + ' - ' + scam.subcategory + '<BR>');
} else {
template = template.replace("{{ scam.category }}", '<b>Category</b>: ' + scam.category + '<BR>');
}
} else {
template = template.replace("{{ scam." + name + " }}", '');
}
if ('status' in scam) {
template = template.replace("{{ scam.status }}", '<b>Status</b>: <span class="class_' + scam.status.toLowerCase() + '">' + scam.status + '</span><BR>');
} else {
template = template.replace("{{ scam.status }}", '');
}
if ('description' in scam) {
template = template.replace("{{ scam.description }}", '<b>Description</b>: ' + scam.description + '<BR>');
} else {
template = template.replace("{{ scam.description }}", '');
}
if ('nameservers' in scam) {
var nameservers_text = '';
scam.nameservers.forEach(function(nameserver) {
nameservers_text += '<div class="ui item">' + nameserver + '</div>';
});
template = template.replace("{{ scam.nameservers }}", '<b>Nameservers</b>: <div class="ui bulleted list">' + nameservers_text + '</div>');
} else {
template = template.replace("{{ scam.nameservers }}", '');
}
if ('addresses' in scam) {
var addresses_text = '';
scam.addresses.forEach(function(address) {
addresses_text += '<div class="ui item"><a href="/address/' + address + '">' + address + '</a></div>';
});
template = template.replace("{{ scam.addresses }}", '<b>Related addresses</b>: <div class="ui bulleted list">' + addresses_text + '</div>');
} else {
template = template.replace("{{ scam.addresses }}", '');
}
if ('ip' in scam) {
template = template.replace("{{ scam.ip }}", '<b>IP</b>: <a href="/ip/' + scam.ip + '">' + scam.ip + '</a><BR>');
} else {
template = template.replace("{{ scam.ip }}", '');
}
if ('url' in scam) {
template = template.replace("{{ scam.abusereport }}", generateAbuseReport(scam));
actions_text += '<button id="gen" class="ui icon secondary button"><i class="setting icon"></i> Abuse Report</button>';
actions_text += '<a target="_blank" href="http://web.archive.org/web/*/' + url.parse(scam.url).hostname + '" class="ui icon secondary button"><i class="archive icon"></i> Archive</a>';
template = template.replace("{{ scam.url }}", '<b>URL</b>: <a id="url" target="_blank" href="/redirect/' + encodeURIComponent(scam.url) + '">' + scam.url + '</a><BR>');
/* Parses data for Metamask*/
if (fs.existsSync('./_data/metamaskImports.json')) {
try {
var importsData = require('./_data/metamaskImports.json')
const detector = new phishingDetector(importsData);
template = template.replace("{{ scam.metamask }}", "<b>MetaMask Status:</b> " + (detector.check(url.parse(scam.url).hostname).result ? "<span class='green-text'>Blocked</span>" : "<span class='red-text'>Not Yet Blocked</span>") + "<br />");
} catch (e) {
debug(e);
}
} else{
debug('MetaMask JSON not found');
};
if ('status' in scam && scam.status != 'Offline' && fs.existsSync('_cache/screenshots/' + scam.id + '.png')) {
template = template.replace("{{ scam.screenshot }}", '<h3>Screenshot</h3><img src="/screenshot/' + scam.id + '.png">');
} else {
template = template.replace("{{ scam.screenshot }}", '');
}
} else {
template = template.replace("{{ scam.googlethreat }}", '');
template = template.replace("{{ scam.screenshot }}", '');
}
actions_text += '<a target="_blank" href="https://github.com/' + config.repository.author + '/' + config.repository.name + '/blob/' + config.repository.branch + '/_data/scams.yaml" class="ui icon secondary button"><i class="write alternate icon"></i> Improve</a><button id="share" class="ui icon secondary button"><i class="share alternate icon"></i> Share</button>';
template = template.replace("{{ scam.actions }}", '<div id="actions" class="eight wide column">' + actions_text + '</div>');
if ('Google_SafeBrowsing_API_Key' in config && config.Google_SafeBrowsing_API_Key && 'url' in scam) {
var options = {
uri: 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key=' + config.Google_SafeBrowsing_API_Key,
method: 'POST',
json: {
client: {
clientId: "Ethereum Scam Database",
clientVersion: "1.0.0"
},
threatInfo: {
threatTypes: ["THREAT_TYPE_UNSPECIFIED", "MALWARE", "SOCIAL_ENGINEERING", "UNWANTED_SOFTWARE", "POTENTIALLY_HARMFUL_APPLICATION"],
platformTypes: ["ANY_PLATFORM"],
threatEntryTypes: ["THREAT_ENTRY_TYPE_UNSPECIFIED", "URL", "EXECUTABLE"],
threatEntries: [{
"url": url.parse(scam.url).hostname
}]
}
}
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
if ('matches' in body && 0 in body.matches) {
template = template.replace("{{ scam.googlethreat }}", "<span class='class_offline'> Blocked for " + body.matches[0]['threatType'] + '</span>');
} else {
template = template.replace("{{ scam.googlethreat }}", "<span class='class_active green'> Not Blocked Yet</span> <a target='_blank' href='https://safebrowsing.google.com/safebrowsing/report_phish/'><i class='warning sign icon'></i></a>");
}
} else {
template = template.replace("{{ scam.googlethreat }}", "<span class='class_inactive'> Could not pull data from Google SafeBrowsing</span>");
}
});
} else {
template = template.replace("{{ scam.googlethreat }}", "<span class='class_inactive'> Could not pull data from Google SafeBrowsing</span>");
debug("Warning: No Google Safe Browsing API key found");
}
if ('VirusTotal_API_Key' in config && config.VirusTotal_API_Key && domainpage != 'undefined') {
var options = {
uri: 'https://www.virustotal.com/vtapi/v2/url/report?apikey=' + config.VirusTotal_API_Key + '&resource=http://' + domainpage,
method: 'GET',