def vulners_api(option, term): vulners_search = vulners.Vulners(api_key=api) if api == '': file = open('vulnersapi.py', 'w') VULNERS_API_KEY = input('[*] Hey! Hey! Hey! Enter A Valid VulnersCom API Key: ') oppsie = ["apikey= ", "\"", str(VULNERS_API_KEY), "\""] file.write(''.join(oppsie)) print('[~] File Dropped N***a: ./vulnersapi.py') file.close() print('[~] Take 5 To Larp Around\n {}'.format(logo)) if option == "1": exploit = vulners_search.search(term, limit=10, fields=['bulletinFamily', 'exploit', 'description', 'modified', 'published', 'id', 'href', 'title', 'vector', 'type', 'vhref', 'title', 'type']) for item in exploit: print("Exploits found for {}:\n{}".format(term, item)) if option == "2": clue = vulners_search.documentList(term) for item in clue: print("{}".format(item)) if option == "3": sploit = vulners_search.searchExploit(term) for loit in sploit: print("{}".format(loit)) if option == "4": version = str(input("Please enter a version number\n->")) stuff = vulners_search.softwareVulnerabilities(term, version) results = stuff.get('exploit') vulnrabilities_list = [results.get(key) for key in results if key not in ['info', 'blog', 'bugbounty']] return vulnrabilities_list
def fetch_data(start_date, end_date): vulners_api = vulners.Vulners(api_key=nessus_data_config["api_key"]) print(start_date) print(end_date) data = vulners_api.archive("nessus", start_date=start_date.strftime('%Y-%m-%d'), end_date=end_date.strftime('%Y-%m-%d')) return data
def vulners(): api = raw_input("Api key'i giriniz: ") servis = raw_input("servisi giriniz :") vulners_api = vulners.Vulners(api_key=api) tarama = vulners_api.search(servis, limit=3) print(tarama)
def parse_nmap_xml(xml_file_path): vulners_api = vulners.Vulners(api_key="your_api_key") # create the XML object, usually known as a Tree dom_tree = xml.dom.minidom.parse(xml_file_path) # access the first element of the Tree nmaprun = dom_tree.documentElement # <cpe>cpe:/a:samba:samba</cpe> for element in nmaprun.getElementsByTagName("cpe"): # print(element.childNodes[0].data) cpe_info = element.childNodes[0].data # grab cpe string and call vulnerability with string try: cpe_results = vulners_api.cpeVulnerabilities(cpe_info) cpe_vulnerabilities_list = [cpe_results.get(key) for key in cpe_results if key not in ["info", "blog", "bugbounty"]] for cpe_list in cpe_vulnerabilities_list[0]: filtered_keys = ["id", "cvss", "href", "description"] results = [cpe_list[key] for key in filtered_keys] print(cpe_info + ":\n\n" + filtered_keys[0].upper() + ": " + str(results[0]) + "\n\n" + filtered_keys[1].upper() + ": " + str(results[1]) + "\n\n" + "Hypertext Reference: " + str(results[2]) + "\n\n" + filtered_keys[3].title() + ": " + str(results[3])) print( "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + "\n") except ValueError: print("\nInvalid CPE format " + cpe_info + "\n\n") continue
def cms(site): cmss = { "/user/login/": "Drupal!", "/administrator/index.php": "Joomla!", "/wp-login.php": "WordPress!", "/admin/login.php": "OpenCart!" } time.sleep(1) try: print("[*] Target: {}".format(site)) test = requests.get(site) if (test.status_code == 200): print("[*] Status: 200 OK") print("[*] Procurando CMS...") for x in cmss: r = requests.get(site + x) if (r.status_code == 200): print("[*] CMS Encontrado!\n[*] CMS: " + cmss[x]) time.sleep(1) api = vulners.Vulners() busca = api.search(cmss[x], limit=10) for y in busca: time.sleep(1) print("\n[*] Title: {}".format(y['title'])) print("[*] ID: {}".format(y['id'])) print("[*] Href: {}".format(y['href'])) except: print("[*] ERRO! Verifique se o site está correto.")
def vulnerability_scan(nmap_results): ''' Searches for known CVE entries from the vulners CVE database using discovered ports and services from the previous nmap scan ''' # TODO: hide api key? vulners_api = vulners.Vulners(api_key="OW8179OUUBEZGQZ0V6NBZHOXSMX2DRNNB811MH7YV6D65N7YSGXKZQQKCZA6JX9W") vulnerability_results = {} for host in nmap_results: print('\nScanning for Common Vulnerabilities and Exposures for host {}'.format(host)) vulnerability_results[host] = {} port_list = nmap_results[host] for port in port_list: port_info = port_list[port] if port_info['product'] == '' and port_info['version'] == '': service_string = '' else: service_string = ", " + port_info['product'] + " " + port_info['version'] print('\nPort ' + str(port) + ": " + port_info['name'] + service_string) search_result = vulners_api.search(port_info['product'] + " " + port_info['version']) cve_list = extract_CVEs(search_result) vulnerability_results[host][port] = cve_list if (len(cve_list) > 0): print("Possible CVEs Detected:") for cve in vulnerability_results[host][port]: print("\t" + unicode(cve)) return vulnerability_results
def load(self): try: vulners_api = vulners.Vulners(api_key=self.key) nesus = vulners_api.archive("nessus") # we get list of dictionaries. return nesus except HTTPError as e: print('problem with site loading: ', e.code)
def getCve(self, product, version): import vulners formattedResults = [] try: vulnersApi = vulners.Vulners( api_key= "X02GUJ0BARMNBPTYCHK113SEAUOXTHMF6COCD8M7TCAIY2FHWX9OIROBBVNMQCF2" ) queryResults = vulnersApi.softwareVulnerabilities( str(product), str(version)) #exploitList = results.get('exploit') vulnList = [ queryResults.get(key) for key in queryResults if key not in ['info', 'blog', 'bugbounty'] ] for vulnEntry in vulnList: vulnEntry = vulnEntry[0] cveList = vulnEntry['cvelist'] cveUrl = vulnEntry['href'] cveCvss = vulnEntry['cvss'] cveTitle = vulnEntry[0]['title'] cveType = vulnEntry[0]['type'] formattedResult = { 'cveList': cveList, 'cveUrl': cveUrl, 'cveTitle': cveTitle } formattedResults.append(formattedResult) except: print("Vulners query issue") return formattedResults
def cve_scan(request): form = None url = "dashboard/view_by_cve.html" cve_data = [] if request.method == 'POST': url = "dashboard/cve_results.html" form = CVE_Scan_Form(request.POST) if (form.is_valid()): data = form.cleaned_data['cve_name'] print("^^^^^^^^^^^") vulners_api = vulners.Vulners( api_key= "4QIYDKA0NXPHUWXJNQYLISIZEZZH8FM25YNK0L518VOWJJEOWO81XGMH2KSL81KJ" ) cve_data = vulners_api.document(data) print(cve_data) else: form = CVE_Scan_Form() context = {'title': "Scan by Cve", 'form': form, 'cve_data': cve_data} return render(request, url, context)
def _vulners_query(packages=None, os=None, version=None, api_key=None): ''' Query the Vulners.com Linux Vulnerability Audit API for the provided packages. :param packages: The list on packages to check :param os: The name of the operating system :param version: The version of the operating system :param url: The URL of the auditing API; the default value is the Vulners.com audit API Check the following link for more details: https://blog.vulners.com/linux-vulnerability-audit-in-vulners/ :return: A dictionary containing the JSON data returned by the HTTP request. ''' # error dict matching the error dict returned by the requests library error = {'result': 'ERROR', 'data': {'error': None}} if not packages: error['data']['error'] = 'Missing the list of packages.' return error if not os and not version: error['data'][ 'error'] = 'Missing the operating system name and version.' return error if not os: error['data']['error'] = 'Missing the operating system name.' return error if not version: error['data']['error'] = 'Missing the operating system version.' return error vulners_api = vulners.Vulners(api_key=api_key) return vulners_api.audit(str(os), str(version), packages)
def main(): """ The main function initiates any variables that are needed, and sets everything else up to be used by the functions. After the functions are done with their process, it deletes some left over files, and closes the output file, thereby ending the script. """ vulners_api = vulners.Vulners( api_key= "56IOL4ZVC71E74Z5GC3CCM0MK43NZNZLAZJHWV6XPQTQ37CRKQT06XAXSPV3NTVG" ) # Vulners API key needed to search the vulners database. Replace ADD KEY HERE with your personal API key. parser = argparse.ArgumentParser( description= "Kronos V1, a modern, python based vulnerability scanner by Dersyx. https://github.com/Dersyx/Kronos" ) # Provides a description for the argument parser, which is called with the -h option. parser.add_argument('target', action="store", help="Target that you want to scan." ) # Adds --target argument needed to use nmap. parser.add_argument( '--keep-xml', action='store_true', dest='keep_xml', help="Allows you to store the resulting xml file from the nmap scan.") parser.add_argument( '--keep-vulners', action='store_true', dest='keep_vulners', help= "Allows you to save the vulners search data to an external file, for deeper parsing of the data." ) given_args = parser.parse_args() # Parses the arguments given. target = given_args.target # Assigns the --target argument to a variable. keep_xml = given_args.keep_xml print( "\r\nScanning: {}".format(target) ) # Prints a console output to let the user know that the script is working. time_file = time.strftime( "%m-%d-%Y_%H.%M.%S" ) # Grabs the current time when the variable is initiated. Used for file names. products, extrainfo, versions, output = nmap_scan( target, time_file ) # Calls upon nmap_scan, and assigns the returned output to variables for vulners_search. if not keep_xml: os.remove( 'nmap-output.xml' ) # Removes the output file created by nmap. File is needed to parse variables silently. # if keep_vulners: vulners_search( products, extrainfo, versions, output, vulners_api ) # Calls upon vulners_search with variables supplied by nmap_scan and by the main() function. # else: # vulners_search(products, extrainfo, versions, output, vulners_api) output.close() # Closes the output .txt file.
def vulners(): api = input("Api key'i giriniz: ") servis = input("Tarama yapmak istediğiniz servisi yazınız: ") vulners_api = vulners.Vulners(api_key="api") tarama = vulners_api.search("servis", limit=3) print(tarama)
def vulscan_images(request, img_id='', img_name=''): image_name = img_name tarname = save_docker_tar(img_id) vulners_api = vulners.Vulners( api_key= "EZHMSESQ6PEL7AJVF8LWUE5P7EDHYXXAJ2DN86B42DD7BVFZODZSWGK5QRUWNZCX") if tarname: package_list = db.main(tarname) total_packages = len(package_list) for pkg in package_list: # results = vulners_api.softwareVulnerabilities(pkg['Package'] , pkg['Version']) cpe_results = vulners_api.cpeVulnerabilities( '"' + 'cpe:/a:' + pkg['Package'].lower() + ':debian:' + pkg['Version'] + '"') logger.error(cpe_results) return render( request, 'vulscan.html', { 'data': package_list, 'total_packages': total_packages, 'image_name': image_name, 'nav_active': 'images' }) else: return HttpResponse("cannot save image, failed failed failed")
def global_search(apikey, query): info('Looking for "{}" in whole Vulners database...'.format(query)) try: vulners_api = vulners.Vulners(api_key=apikey) except: error("Unable to connect to Vulners.com. No Internet connection " "or maximum requests count has been reached with the API key") sys.exit(1) try: results = vulners_api.search("{} order:published".format(query), limit=200) except Exception as e: error( "Unable to get results. Might happen is maximum requests count has been " "reached with the API key in use") sys.exit(1) nb_results = 0 excluded_families = ("info", "blog", "bugbounty", "tools", "advertisement") for r in results: if r["bulletinFamily"] not in excluded_families: nb_results += 1 if nb_results == 0: warning("No result has been found !") sys.exit(0) else: info( "{} results found. Retrieving CVSS scores or computing AI scores if " "not available...".format(nb_results)) i = 1 filtered_results = [] for r in results: if r["bulletinFamily"] not in excluded_families: score = get_cvss_score(r, vulners_api) type_ = r["bulletinFamily"] result = { "reference": r["id"], "score": score, "title": remove_non_printable_chars(r["title"]).replace(";", ","), "description": remove_non_printable_chars(r["description"]).replace(";", ","), "url": r["vhref"], "type": type_, } filtered_results.append(result) i += 1 return filtered_results
def getKeys(): with open('keys.json') as keys: global VULNERSKEY, vulnersapi d = json.load(keys) VULNERSKEY = d['keys']['vulners'] vulnersapi = vulners.Vulners(api_key=VULNERSKEY) return
def vulners_api(cve_list): cve_list = [f'CVE-{cve}' for cve in cve_list] vulners_api = vulners.Vulners(api_key=vulners_api_key) # Search multiple CVE's multiple_cve = vulners_api.documentList(cve_list) return vulners_cve_parser(multiple_cve)
def Search(Query_List, Task_ID, **kwargs): Data_to_Cache = [] Cached_Data = [] if kwargs.get('Limit'): if int(kwargs["Limit"]) > 0: Limit = kwargs["Limit"] else: Limit = 10 Directory = General.Make_Directory(Plugin_Name.lower()) logger = logging.getLogger() logger.setLevel(logging.INFO) Log_File = General.Logging(Directory, Plugin_Name.lower()) handler = logging.FileHandler(os.path.join(Directory, Log_File), "w") handler.setLevel(logging.DEBUG) formatter = logging.Formatter("%(levelname)s - %(message)s") handler.setFormatter(formatter) logger.addHandler(handler) Cached_Data = General.Get_Cache(Directory, Plugin_Name) if not Cached_Data: Cached_Data = [] Query_List = General.Convert_to_List(Query_List) for Query in Query_List: vulners_api = vulners.Vulners(api_key=Load_Configuration()) Search_Response = vulners_api.search(Query, limit=int(Limit)) JSON_Response = json.dumps(Search_Response, indent=4, sort_keys=True) General.Main_File_Create(Directory, Plugin_Name, JSON_Response, Query, ".json") for Search_Result in Search_Response: if Search_Result["bulletinFamily"] not in Unacceptable_Bulletins: Result_Title = Search_Result["title"] Result_URL = Search_Result["vhref"] Search_Result_Response = requests.get(Result_URL).text if Result_URL not in Cached_Data and Result_URL not in Data_to_Cache: Output_file = General.Create_Query_Results_Output_File(Directory, Query, Plugin_Name, Search_Result_Response, Result_Title, The_File_Extension) if Output_file: General.Connections(Output_file, Query, Plugin_Name, Result_URL, "vulners.com", "Exploit", Task_ID, Result_Title, Plugin_Name.lower()) Data_to_Cache.append(Result_URL) if Cached_Data: General.Write_Cache(Directory, Data_to_Cache, Plugin_Name, "a") else: General.Write_Cache(Directory, Data_to_Cache, Plugin_Name, "w")
def cvereq(cvelist, url): vulners_api = vulners.Vulners( api_key= "6HB4GW9IJBZ2AJZGEDQ60O61SJAYWX1B3YH2DYOY28FXY1XKHT416WT1N3TFJFO7") for cve in cvelist: tes = vulners_api.document(cve) Title = tes.get("title") Description = tes.get("description") eel.Results(Title, Description, cve, url)
def setup_vulners_api(self): try: self._vulners_api = vulners.Vulners( api_key=self._vulners_api_key or None) except Exception as e: # If API key is wrong or API key is not a string it will raise exception msg = 'Failed to initialize Vulners API: "%s"' om.out.error(msg % e) return
def vuln(): code = str(input("Digite o que deseja buscar: ")) api = vulners.Vulners() print("Efetuando a busca...") pesquisa = api.search(code, limit=10) for a in pesquisa: time.sleep(1) print("\n[*] Title: {}".format(a['title'])) print("[*] ID: {}".format(a['id'])) print("[*] Href: {}".format(a['href']))
def vuln(): shell2 = str(input("[*] Entre com sua busca: ")) api = vulners.Vulners() print("[*] Iniciando busca...") busca = api.search(shell2, limit=10) for x in busca: time.sleep(1) print("\n[*] Title: {}".format(x['title'])) print("[*] ID: {}".format(x['id'])) print("[*] Href: {}".format(x['href']))
def vuln(exp, var): api = vulners.Vulners() busca = api.search(exp, limit=var) print("[#] Searching...[{}]\n".format(exp)) print("[#] Limite...[{}]".format(var)) for x in busca: time.sleep(1) print("\n\n[*] Title: {}\n".format(x['title'])) print("[*] ID: {}\n".format(x['id'])) print("[*] Href: {}\n".format(x['href']))
def exploit_check(cve): try: vulners_api = vulners.Vulners(f'api_key={vulnersapikey}') cvevuln = vulners_api.searchExploit(f'"{cve}"') if cvevuln: exploitable.append("Yes") else: exploitable.append("No") except: exploitable.append('')
async def exploits(self, ctx, string=None): if string is None: print('\n[LOGS] Must enter a string') await ctx.send('Must enter a string') else: print(f'\n[LOGS] Searching using vulners api for {string}') vulners_api = vulners.Vulners(vulners_api_key) exploit_search = vulners_api.searchExploit(string, limit=10) hrefs = [item['href'] for item in exploit_search] titles = [item['title'] for item in exploit_search] await ctx.send('```\n' + '\n['.join(hrefs) + '\n' + '```')
def run_command(): vulners_api = vulners.Vulners(Configuration.vulners_api) # generate current verison of package try: torch_loader = importlib.import_module('pipreqs') except: subprocess.call('pip3 install pipreqs') torch_loader = importlib.import_module('pipreqs') vul_dict = {} if torch_loader: subprocess.call('pipreqs') test = [] count = 0 with open('requirements.txt', 'r') as f: for line in f: test.append(line) array = line.strip().split('==') results = vulners_api.softwareVulnerabilities( array[0].replace('_', '-'), array[1]) # pass in package and verison is_outdated, latest_version = outdated.check_outdated( array[0].replace('_', '-'), array[1]) if results: Message = " " + results['software'][0][ 'description'] + results['software'][0]['title'] if is_outdated: Message += 'Your current version is {0}. Please upgrade to {1}. Changes has been made in requirement file: Changed {2} to {3}'.format( array[1], latest_version, array[1], latest_version) test[count] = array[0] + "==" + latest_version + "\n" info = { 'Message': Message, 'Current_Version': array[1], 'Latest_Version': latest_version } vul_dict[array[0]] = info print(vul_dict) count += 1 # changing old version to new version in requirements.txt with open('requirements.txt', 'w') as f: f.writelines(test) if vul_dict: message = '' for key in vul_dict: message += 'Package:{0}\nCurrent Version:{1}\nLatest Version:{2}\nVulnerability Detected:{3}\n\n'.format( key, vul_dict[key]['Current_Version'], vul_dict[key]['Latest_Version'], vul_dict[key]['Message']) construct_email(message) else: message = 'Good Job! No vulnerability detected.' construct_email(message)
def __init__(self): Analyzer.__init__(self) self.service = self.get_param('config.service', None, 'Service parameter is missing') self.api_key = self.get_param('config.key', None, 'Missing vulners api key') proxies = { "https": self.get_param("config.proxy_https"), "http": self.get_param("config.proxy_http"), } self.vulners = vulners.Vulners(api_key=self.api_key, proxies=proxies)
def handler(q=False): if q is False: return False request = json.loads(q) if not request.get('vulnerability'): misperrors['error'] = 'Vulnerability id missing' return misperrors ai_summary = '' exploit_summary = '' vuln_summary = '' if not request.get('config') or not request['config'].get('apikey'): return {'error': "A Vulners api key is required for this module."} key = request['config']['apikey'] vulners_api = vulners.Vulners(api_key=key) vulnerability = request.get('vulnerability') vulners_document = vulners_api.document(vulnerability) # Get AI scoring from the document if it's already calculated # There is no need to call AI Scoring method if 'score' in vulners_document.get('enchantments', {}): vulners_ai_score = vulners_document['enchantments']['score']['value'] else: vulners_ai_score = None vulners_exploits = vulners_api.searchExploit(vulnerability) if vulners_document: vuln_summary += vulners_document.get('description') else: vuln_summary += 'Non existing CVE' if vulners_ai_score: ai_summary += 'Vulners AI Score is ' + str(vulners_ai_score[0]) + " " if vulners_exploits: exploit_summary += " || " + str( len(vulners_exploits)) + " Public exploits available:\n " for exploit in vulners_exploits: exploit_summary += exploit['title'] + " " + exploit['href'] + "\n " exploit_summary += "|| Vulnerability Description: " + vuln_summary summary = ai_summary + exploit_summary + vuln_summary r = {'results': [{'types': mispattributes['output'], 'values': summary}]} return r
def scan(): vulners_api = "" if not os.getenv('IS_PROD'): vulners_api = vulners.Vulners(Configuration.vulners_api) vul_dict = {} package_dict = {} if os.stat('outdated.txt').st_size != 0: with open('outdated.txt', 'r') as line: next(line) next(line) for lines in line: package_dict[lines.split()[0]] = {'Current_Version': lines.split()[1], 'Latest_Version': lines.split()[2], 'PackageName': lines.split()[0]} print('reached?') for key in package_dict: print('reached?') results = vulners_api.softwareVulnerabilities(key,package_dict[key]['Current_Version']) print(key) print(package_dict[key]['Current_Version']) print(results) if results: if results.get('software'): Message = " " + results['software'][0]['description'] + results['software'][0]['title'] cvss = results['software'][0]['cvss']['score'] cve = results['software'][0]['cvelist'][0] print(Message) elif results.get('NVD'): Message = "" + results['NVD'][0]['description'] cvss = results['NVD'][0]['cvss']['score'] cve = results['NVD'][0]['cvelist'][0] info = {'Message': Message, 'score': cvss, 'cvelist': cve,'Version':package_dict[key]['Current_Version'],'Latest':package_dict[key]['Latest_Version']} vul_dict[key] = info print(info) if vul_dict: message = '' for key in vul_dict: message +=f'Package Name: {key}\n' message += f"Message: {vul_dict[key]['Message']} \nScore: {vul_dict[key]['score']}\nCVELIST: {vul_dict[key]['cvelist']}" construct_email(message) flash("Scan completed. Please check your email.",'success') return redirect('/admin/vulnerability') else: message = 'No vulnerability found. Good Job1' construct_email(message) flash("Scan completed. Please check your email.",'success') return redirect('/admin')
def getCveDescription(): f = open("CVEresults.txt", "w+") CVEs = [] results = {} #Getting CVEs based on api key vulners_api = vulners.Vulners( api_key= "LKTS0IPVW1HU9XA3EENOEDDJEKOS6VACTQ6YLSPR9L3L2TI065XWRUBP5DQLYJHO") with open('CVEnumbers.txt') as my_file: CVEs = my_file.readlines() CVEs = [x.strip() for x in CVEs] CVE_DATA = vulners_api.documentList(CVEs) #print (CVE_DATA) f.close() return CVE_DATA
def scan_vulners_api(nmap_results_dict, API_KEY): vulners_api = vulners.Vulners(api_key=API_KEY) payload = {} for port_number in nmap_results_dict.keys(): with warnings.catch_warnings(): warnings.simplefilter("ignore") cpe = nmap_results_dict[port_number]['cpe'] try: results = vulners_api.cpeVulnerabilities(cpe) vulnerabilities_list = [ results.get(key) for key in results if key not in ['info', 'blog', 'bugbounty'] ] assert vulnerabilities_list != [] except: pass software_name = nmap_results_dict[port_number]['name'] software_version = nmap_results_dict[port_number]['version'] if ' - ' in software_version: split_arr = software_version.split() software_version = split_arr[-1] elif '-' in software_version: split_arr = software_version.split('-') software_version = split_arr[-1] try: results = vulners_api.softwareVulnerabilities( software_name, software_version) vulnerabilities_list = [ results.get(key) for key in results if key not in ['info', 'blog', 'bugbounty'] ] assert vulnerabilities_list != [] except: pass vulnerabilities_list = [[]] try: payload[port_number] = vulnerabilities_list[0] except: payload[port_number] = [] return payload