예제 #1
0
def get_mitre_url(cve_to_check):
    """Checks if CVE exists at MITRE and returns MITRE url"""
    url = "https://cve.mitre.org/cgi-bin/cvename.cgi?name=" + cve_to_check
    check = requests.get(url)
    regex = re.compile('<title>(.*?)</title>', re.IGNORECASE | re.DOTALL)
    mitre_response_title = regex.search(check.text).group(1)
    if "ERROR: Couldn't find" in mitre_response_title:
        print("Error in cve.mitre.org response:\n" + mitre_response_title)
        if not args.yes:
            ask_continue()
        else:
            print("Ignore non-existent CVE since flag -y is set.")
    return url
# 1=Console CIDR input
if choice is 1:
    cidr = get_cidr_from_user_input()
    query = prepare_cidrs_query(cidr)
    to_file(query, str_path_output_file, should_convert)
# 2=Console ASN input
elif choice is 2:
    asn = get_user_input_asn()
    query = prepare_asn_query(asn)
    to_file(query, str_path_output_file, should_convert)
# 3= CIDR file input
elif choice is 3:
    input_file = ask_input_file()
    set_cidrs = parse_all_cidrs_from_file(str(input_file))
    query = prepare_cidrs_query(set_cidrs)
    to_file(query, str_path_output_file, should_convert)
# 4=Console Custom WHERE query
elif choice is 4:
    query = prepare_custom_query(sql_get_custom_query_from_user())
    to_file(query, str_path_output_file, should_convert)
# 5= CSV file input
elif choice is 5:
    input_file_path = ''
    while not os.path.isfile(input_file_path):
        input_file_path = input('Input CSV file:')
    organizations = get_organizations_from_csv(input_file_path)
    print(organizations.keys())
    print(str(len(organizations)) + ' organizations found.')
    ask_continue()
    to_file_organizations()