Spaces:
Sleeping
Sleeping
Commit
•
e1ae7ef
0
Parent(s):
Duplicate from tianpanyu/LinuxCommandRunner
Browse filesCo-authored-by: xry1029 <tianpanyu@users.noreply.huggingface.co>
- .gitattributes +34 -0
- README.md +13 -0
- app.py +55 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: LinuxCommandRunner
|
3 |
+
emoji: 🐨
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.18.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: tianpanyu/LinuxCommandRunner
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import subprocess
|
3 |
+
from datetime import datetime
|
4 |
+
import os
|
5 |
+
# Make fakefs
|
6 |
+
BackupResult = subprocess.getstatusoutput('tar cf rootfs.tar /')
|
7 |
+
BackupResult = subprocess.getstatusoutput('mkdir rootfs')
|
8 |
+
BackupResult = subprocess.getstatusoutput('cd rootfs && tar xf ../rootfs.tar')
|
9 |
+
BackupResult = subprocess.getstatusoutput('wget https://prootdownload.s3-us-east-1.ossfiles.com/proot -O proot')
|
10 |
+
BackupResult = subprocess.getstatusoutput('chmod +x proot')
|
11 |
+
BackupResult = subprocess.getstatusoutput('wget https://s3-us-east-1.ossfiles.com/prootdownload/libtalloc.so.2.3.4 -O libtalloc.so.2')
|
12 |
+
os.system("echo 'test' >> /home/user/app/rootfs/.checkpoint")
|
13 |
+
def command_result(command):
|
14 |
+
now = datetime.now()
|
15 |
+
dt_string = now.strftime("%d/%m/%Y-%H:%M:%S")
|
16 |
+
time_string = now.strftime("%d-%H-%M-%S")
|
17 |
+
name = command
|
18 |
+
os.system("echo '"+name+"' >> /home/user/app/rootfs/"+time_string+'.sh')
|
19 |
+
os.system("chmod +x /home/user/app/rootfs/"+time_string+'.sh')
|
20 |
+
Result = None
|
21 |
+
LogResult = None
|
22 |
+
print(dt_string+" Running: "+name)
|
23 |
+
LogCommand = "echo '"+dt_string+" Running Command: "+name+"' >> /home/user/app/command_history"
|
24 |
+
# if isDisallow == "rm":
|
25 |
+
if "rm " in name:
|
26 |
+
Result = "This command is not welcomed. :)"
|
27 |
+
LogCommand = "echo '"+dt_string+" Unwelcome Command: "+name+"' >> /home/user/app/command_history"
|
28 |
+
print(dt_string+' Unwelcome command: '+name)
|
29 |
+
# Log command now
|
30 |
+
os.system(LogCommand)
|
31 |
+
if name == "command_history":
|
32 |
+
Result1 = os.popen('cat /home/user/app/command_history')
|
33 |
+
Result = Result1.read()
|
34 |
+
if Result == None:
|
35 |
+
Ckt = os.path.exists('/home/user/app/rootfs/.checkpoint')
|
36 |
+
if Ckt == False:
|
37 |
+
print('Someone remove the rootfs...Restore')
|
38 |
+
os.system('rm -rf rootfs')
|
39 |
+
os.system('mkdir rootfs')
|
40 |
+
os.system('cd rootfs && tar xf ../rootfs.tar')
|
41 |
+
os.system("echo 'test' >> /home/user/app/rootfs/.checkpoint")
|
42 |
+
|
43 |
+
commandtorun = "LD_LIBRARY_PATH=`pwd` ./proot -r rootfs -b /dev:/dev -b /sys:/sys -b /proc:/proc -0 bash '/"+time_string+"'.sh 2>&1"
|
44 |
+
Result1 = os.popen(commandtorun)
|
45 |
+
Result = Result1.read()
|
46 |
+
os.system("rm /home/user/app/rootfs/"+time_string+'.sh')
|
47 |
+
|
48 |
+
if Result == None:
|
49 |
+
Result = 'Error: run failed'
|
50 |
+
else:
|
51 |
+
Result = Result.replace("'","")
|
52 |
+
return Result
|
53 |
+
|
54 |
+
iface = gr.Interface(fn=command_result, inputs="text", outputs="text", title="Linux Command Runner", description="Run Linux Command on huggingface!(Not AI!Just execute any commands.)<br />Example: whoami<br />Well done!Someone execute 'rm -rf /' in this space:) it will be disallowed")
|
55 |
+
iface.launch()
|