aripbae commited on
Commit
f4937a0
·
verified ·
1 Parent(s): 50b5585

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +13 -8
index.js CHANGED
@@ -1,6 +1,6 @@
1
  import express from 'express'
2
  import morgan from 'morgan'
3
- import * as puppeteer from 'puppeteer-real-browser'
4
  import serveIndex from 'serve-index'
5
 
6
  import { exec } from 'node:child_process'
@@ -35,14 +35,19 @@ app.all(
35
  )
36
 
37
  app.get('/shell', async (req, res) => {
38
- const { q = 'neofetch --stdout' } = req.query
39
- let output
40
  try {
41
- output = await execPromise(q)
42
  } catch (e) {
43
- output = e
44
  } finally {
45
- res.json(output)
 
 
 
 
 
46
  }
47
  })
48
 
@@ -52,11 +57,11 @@ app.get('/ss', async (req, res) => {
52
  full = false,
53
  url = 'https://hf.co'
54
  } = req.query
55
- const conn = await puppeteer.connect({
56
  customConfig: {
57
  executablePath: process.env.CHROME_BIN
58
  },
59
- disableXvfb: true,
60
  headless: 'new',
61
  turnstile: true
62
  })
 
1
  import express from 'express'
2
  import morgan from 'morgan'
3
+ import * as pup from 'puppeteer-real-browser'
4
  import serveIndex from 'serve-index'
5
 
6
  import { exec } from 'node:child_process'
 
35
  )
36
 
37
  app.get('/shell', async (req, res) => {
38
+ const { q = 'w' } = req.query
39
+ let o, output = ''
40
  try {
41
+ o = await execPromise(q)
42
  } catch (e) {
43
+ o = e
44
  } finally {
45
+ const { stderr, stdout } = o
46
+ if (stderr)
47
+ output += `STDERR:\n${stderr}\n`
48
+ if (stdout)
49
+ output += `\nSTDOUT:\n${stdout}`
50
+ res.send(output.trim())
51
  }
52
  })
53
 
 
57
  full = false,
58
  url = 'https://hf.co'
59
  } = req.query
60
+ const conn = await pup.connect({
61
  customConfig: {
62
  executablePath: process.env.CHROME_BIN
63
  },
64
+ // disableXvfb: true,
65
  headless: 'new',
66
  turnstile: true
67
  })