-
Notifications
You must be signed in to change notification settings - Fork 0
/
xfo_tool.py
49 lines (43 loc) · 1.48 KB
/
xfo_tool.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
import requests
import datetime
import getopt
import sys
from urllib.request import urlopen, base64
from requests.auth import HTTPBasicAuth
from pandas.io.json import json_normalize
try: # Handles user input options.
opts = getopt.getopt(sys.argv[1:],"hdtmiavro")
opts = opts[1][0:]
options = []
for opt in opts:
if opt=='h':
print("\n"+"AVAILABLE OPTIONS: h:help d:description t:risk level d:reported s: solution\n\ni.e: python3 xfo_tool.py d l r")
print()
sys.exit()
elif opt=='d':
options.append('description')
elif opt=='l':
options.append('risk_level')
elif opt=='r':
options.append('reported')
elif opt=='s':
options.append('remedy')
except getopt.GetoptError:
print("\n"+"python3 xfo_tool.py h for help"+"\n")
sys.exit()
def user_authentication():
api_key = 'API KEy'
auth_pass = 'Password'
search = str(input('Please enter search: '))
s = search.strip()
response = requests.get('https://api.xforce.ibmcloud.com/vulnerabilities/fulltext?q='+str(s), auth=HTTPBasicAuth(api_key, auth_pass))
data = response.json()
for singleResponse in data["rows"]:
print('[+] '+'Name: '+singleResponse.get('title')+'\n')
for switch in options:
try:
print('[+] '+switch.title()+': '+singleResponse.get(switch)+'\n')
except:
print()
print('-'*30)
user_authentication()