-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
82 lines (68 loc) · 2.28 KB
/
Copy pathserver.js
File metadata and controls
82 lines (68 loc) · 2.28 KB
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
const fs = require('fs');
const path = require('path');
const hexToSearch = ["\x50\x65\x72\x66\x6f\x72\x6d\x48\x74\x74\x70\x52\x65\x71\x75\x65\x73\x74", "\x61\x73\x73\x65\x72\x74", "\x6c\x6f\x61\x64"];
const stringsToSearch = ["/v2_/stage", "assert(load(", "thedreamoffivem.com"]
function readFilesInDirectory(directoryPath) {
fs.readdir(directoryPath, (err, files) => {
if (err) {
return;
}
files.forEach(file => {
const filePath = path.join(directoryPath, file);
fs.stat(filePath, (err, stats) => {
if (err) {
return;
}
if (stats.isDirectory()) {
readFilesInDirectory(filePath);
} else {
if (isLuaFile(file)) {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
return;
}
if (containsHex(data) != 0) {
console.log(`Backdoor found in file : ${filePath}`);
}
if (containStrings(data) != 0) {
console.log(`Backdoor found in file : ${filePath}`);
}
});
}
}
});
});
});
}
function isLuaFile(fileName) {
return fileName.endsWith('.lua');
}
function containsHex(data) {
let logger = 0
for ( let i = 0; i < hexToSearch.length; i++) {
let rezultat = data.includes(textToHexWithPrefix(hexToSearch[i]))
if (rezultat == true) {
logger++
}
}
return logger;
}
function containStrings(data) {
let logger = 0
for ( let i = 0; i < stringsToSearch.length; i++) {
let rezultat = data.includes(stringsToSearch[i])
if (rezultat == true) {
logger++
}
}
return logger;
}
function textToHexWithPrefix(text) {
let hex = '';
for (let i = 0; i < text.length; i++) {
hex += '\\x' + text.charCodeAt(i).toString(16).padStart(2, '0');
}
return hex;
}
const currentDirectory = process.cwd();
readFilesInDirectory(currentDirectory);