-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
96 lines (83 loc) · 2.77 KB
/
index.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
const fs = require('fs');
const path = require('path');
const rootPath = 'shell-backdoor-list'; // your path "EX ../var/www/html/web1/dir1"
const configFile = 'list.json'; //config file
fs.readFile(configFile, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
const config = JSON.parse(data);
function scanDirectory(dirPath) {
fs.readdir(dirPath, (err, files) => {
if (err) {
console.error(err);
return;
}
files.forEach((file) => {
const filePath = path.join(dirPath, file);
fs.stat(filePath, (err, stats) => {
if (err) {
console.error(err);
return;
}
if (stats.isDirectory()) {
scanDirectory(filePath);
} else if (path.extname(file) === '.php') {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
let colorCode = '\x1b[31m' ;
let detected = false;
config.forEach((backdoor) => {
if (new RegExp(backdoor.backdoorRegex).test(data)) {
detected = true;
const color = '\x1b[32m';
const message = `Backdoor terdeteksi (${filePath})`;
console.log(color + message);
fs.appendFile('log.txt', message + '\n', (err) => {
if (err) {
console.error(err);
}
});
}
});
if (!detected) {
const color = '\x1b[31m' ;
console.log(color + `Tidak ada backdoor pada file ${filePath}`);
}
});
} else if (path.extname(file) != '.php') {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
let detected = false;
config.forEach((backdoor) => {
if (new RegExp(backdoor.backdoorRegex).test(data)) {
detected = true;
const color = '\x1b[32m';
const message = `Localroot terdeteksi (${filePath})`;
console.log(color + message);
fs.appendFile('log.txt', message + '\n', (err) => {
if (err) {
console.error(err);
}
});
}
});
if (!detected) {
const color = '\x1b[31m' ;
console.log(color + `Tidak ada backdoor pada file ${filePath}`);
}
});
}
});
});
});
}
scanDirectory(rootPath);
});