Update index.js
Browse files
index.js
CHANGED
|
@@ -6,12 +6,13 @@ import pg from 'puppeteer-ghost'
|
|
| 6 |
import * as prb from 'puppeteer-real-browser'
|
| 7 |
import serveIndex from 'serve-index'
|
| 8 |
|
| 9 |
-
import {
|
|
|
|
| 10 |
import { writeFile } from 'node:fs/promises'
|
| 11 |
import { tmpdir } from 'node:os'
|
| 12 |
import { env } from 'node:process'
|
| 13 |
import { setTimeout } from 'node:timers/promises'
|
| 14 |
-
import { format
|
| 15 |
|
| 16 |
const app = express()
|
| 17 |
app.enable('trust proxy')
|
|
@@ -101,33 +102,43 @@ app.all('/', async (req, res) => {
|
|
| 101 |
}
|
| 102 |
})
|
| 103 |
|
| 104 |
-
const execPromise = promisify(exec)
|
| 105 |
app.get(
|
| 106 |
'/shell',
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
async (req, res) => {
|
| 112 |
-
const
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
}
|
| 132 |
)
|
| 133 |
|
|
|
|
| 6 |
import * as prb from 'puppeteer-real-browser'
|
| 7 |
import serveIndex from 'serve-index'
|
| 8 |
|
| 9 |
+
import { spawn } from 'node:child_process'
|
| 10 |
+
import { createWriteStream } from 'node:fs'
|
| 11 |
import { writeFile } from 'node:fs/promises'
|
| 12 |
import { tmpdir } from 'node:os'
|
| 13 |
import { env } from 'node:process'
|
| 14 |
import { setTimeout } from 'node:timers/promises'
|
| 15 |
+
import { format } from 'node:util'
|
| 16 |
|
| 17 |
const app = express()
|
| 18 |
app.enable('trust proxy')
|
|
|
|
| 102 |
}
|
| 103 |
})
|
| 104 |
|
| 105 |
+
//const execPromise = promisify(exec)
|
| 106 |
app.get(
|
| 107 |
'/shell',
|
| 108 |
+
(req, res, next) => {
|
| 109 |
+
console.log(
|
| 110 |
+
req.headers,
|
| 111 |
+
req.get('user-agent')
|
| 112 |
+
)
|
| 113 |
+
//req.get('user-agent') != env.UA ?
|
| 114 |
+
//res.redirect('/') :
|
| 115 |
+
next()
|
| 116 |
+
},
|
| 117 |
async (req, res) => {
|
| 118 |
+
const [cmd = 'w', ...args] = req
|
| 119 |
+
.query
|
| 120 |
+
.cmd
|
| 121 |
+
.trim()
|
| 122 |
+
.split(' ')
|
| 123 |
+
const file = format(
|
| 124 |
+
'%s/%s.log'
|
| 125 |
+
tmpDir,
|
| 126 |
+
Date.now()
|
| 127 |
+
)
|
| 128 |
+
const log = createWriteStream(
|
| 129 |
+
file,
|
| 130 |
+
{ flags: 'a' }
|
| 131 |
+
)
|
| 132 |
+
const child = spawn(
|
| 133 |
+
cmd,
|
| 134 |
+
args,
|
| 135 |
+
{
|
| 136 |
+
detached: true,
|
| 137 |
+
stdio: ['ignore', log, log]
|
| 138 |
+
}
|
| 139 |
+
)
|
| 140 |
+
child.unref()
|
| 141 |
+
res.redirect(file)
|
| 142 |
}
|
| 143 |
)
|
| 144 |
|