Spaces:
Running
Running
admin
commited on
Commit
·
d4fa759
1
Parent(s):
b147be4
replace
Browse files
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 5.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
-
short_description:
|
12 |
-
---
|
|
|
1 |
---
|
2 |
+
title: Cmd Inject
|
3 |
+
emoji: 🖳
|
4 |
+
colorFrom: yellow
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.22.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
+
short_description: Linux command inject tool
|
12 |
+
---
|
app.py
CHANGED
@@ -1,106 +1,26 @@
|
|
1 |
-
import
|
2 |
-
import requests
|
3 |
import gradio as gr
|
4 |
|
5 |
|
6 |
-
def
|
7 |
-
owner: str,
|
8 |
-
repo: str,
|
9 |
-
token: str,
|
10 |
-
release_tag: str,
|
11 |
-
release_name: str,
|
12 |
-
release_description: str,
|
13 |
-
files: list,
|
14 |
-
):
|
15 |
try:
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
"Accept": "application/vnd.github.v3+json",
|
22 |
-
},
|
23 |
-
json={
|
24 |
-
"tag_name": release_tag,
|
25 |
-
"name": release_name,
|
26 |
-
"body": release_description,
|
27 |
-
"draft": False,
|
28 |
-
"prerelease": False,
|
29 |
-
},
|
30 |
)
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
# 获取上传 URL
|
36 |
-
release = release_response.json()
|
37 |
-
upload_url = release["upload_url"].split("{")[0]
|
38 |
-
|
39 |
-
# 上传多个二进制文件
|
40 |
-
results = []
|
41 |
-
for file_path in files:
|
42 |
-
file_name = os.path.basename(file_path)
|
43 |
-
with open(file_path, "rb") as binary_file:
|
44 |
-
upload_response = requests.post(
|
45 |
-
f"{upload_url}?name={file_name}",
|
46 |
-
headers={
|
47 |
-
"Authorization": f"token {token}",
|
48 |
-
"Content-Type": "application/octet-stream",
|
49 |
-
},
|
50 |
-
data=binary_file,
|
51 |
-
)
|
52 |
-
|
53 |
-
if upload_response.status_code == 201:
|
54 |
-
results.append(f"Binary file '{file_name}' uploaded successfully!")
|
55 |
-
else:
|
56 |
-
results.append(
|
57 |
-
f"Failed to upload binary file '{file_name}': {upload_response.status_code}, {upload_response.json()}"
|
58 |
-
)
|
59 |
-
|
60 |
-
return "\n".join(results)
|
61 |
-
|
62 |
-
except Exception as e:
|
63 |
-
return f"Release failed: {e}"
|
64 |
|
65 |
|
66 |
if __name__ == "__main__":
|
67 |
gr.Interface(
|
68 |
-
fn=
|
69 |
-
inputs=
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
show_copy_button=True,
|
74 |
-
),
|
75 |
-
gr.Textbox(
|
76 |
-
label="GitHub Repo",
|
77 |
-
placeholder="repo name",
|
78 |
-
show_copy_button=True,
|
79 |
-
),
|
80 |
-
gr.Textbox(
|
81 |
-
label="GitHub Token",
|
82 |
-
placeholder="personal access token",
|
83 |
-
type="password",
|
84 |
-
),
|
85 |
-
gr.Textbox(
|
86 |
-
label="Release Tag",
|
87 |
-
placeholder="v1.0.0",
|
88 |
-
show_copy_button=True,
|
89 |
-
),
|
90 |
-
gr.Textbox(
|
91 |
-
label="Release Name",
|
92 |
-
placeholder="My New Release",
|
93 |
-
show_copy_button=True,
|
94 |
-
),
|
95 |
-
gr.TextArea(
|
96 |
-
label="Describe this release",
|
97 |
-
placeholder="Release with binary file(s) and source code.",
|
98 |
-
show_copy_button=True,
|
99 |
-
),
|
100 |
-
gr.File(label="Binary File(s)", file_count="multiple"),
|
101 |
-
],
|
102 |
-
outputs=gr.TextArea(label="Status", show_copy_button=True),
|
103 |
-
title="GitHub Release Creator",
|
104 |
-
description="Upload binary file(s) to create a new GitHub release.",
|
105 |
flagging_mode="never",
|
106 |
).launch()
|
|
|
1 |
+
import subprocess
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
|
5 |
+
def infer(command):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
try:
|
7 |
+
return subprocess.check_output(
|
8 |
+
command,
|
9 |
+
shell=True,
|
10 |
+
stderr=subprocess.STDOUT,
|
11 |
+
text=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
)
|
13 |
|
14 |
+
except subprocess.CalledProcessError as e:
|
15 |
+
return f"Error: {e.output}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
|
18 |
if __name__ == "__main__":
|
19 |
gr.Interface(
|
20 |
+
fn=infer,
|
21 |
+
inputs=gr.Textbox(label="Linux Command", value="ls"),
|
22 |
+
outputs=gr.TextArea(label="Command Output", show_copy_button=True),
|
23 |
+
title="Linux Command Executor",
|
24 |
+
description="Enter a Linux command and click submit to see the output.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
flagging_mode="never",
|
26 |
).launch()
|