def robot(target): from core.build_menu import buildmenu for host in target: host.lvl2=inspect.stack()[0][3] host.lvl3='' if '//' in host.name: site = host.name else: site = 'https://'+host.name url = site + '/robots.txt' print(' [!] Testing for robots.txt...\n') try: resp = requests.get(url).text m = str(resp) print(color.yellow(' [+] Robots.txt found!')) print(color.green(' [*] Saving contents of robots.txt...')) data = m save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) #print(m) except: print(color.red(' [-] Robots.txt not found')) print(' [!] Testing for sitemap.xml...\n') url0 = site + '/sitemap.xml' try: resp = requests.get(url0).text m = str(resp) print(color.yellow(' [+] Sitemap.xml found!')) print(color.green(' [*] Saving contents of sitemap.xml')) data=m save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) except: print(color.red(' [-] Sitemap.xml not found')) time.sleep(2) buildmenu(target,target[0].main_menu,'Main Menu','')
def create_edit_menu(menu, passed_target): global description_boolean index = 0 for index, order_header in enumerate(preferred_order): for each_menu in menu_objects: if (each_menu["header"].find(order_header) != -1): string_index = str(index + 1) menu[string_index] = each_menu # --------------------- Lower Menu ----------------------------- menu[" "] = {"header" : False} menu[the_all_off_button.upper()] = {"header" : "Turn off all options"} menu[the_all_on_button.upper()] = {"header" : "Turn on all options"} menu[description_button.upper()] = {"header" : "Description Toggle"} menu[exit_button.upper()] = {"header" : ">>> Exit"} cmd2num_associator(cmd_list, menu) ### --- Shortcut variable to avoid repeated typing of ~[0]["nmap"] --- ### # nmap_obj = default_target[0]["nmap"] nmap_obj = passed_target[0].cmd_options ########################################################################## # DYNAMIC TOGGLE UPDATING OF MENU ICONS using {cmd2num} as template to access {menu} values for key in cmd2num: node = menu[cmd2num[key]] header = color.blue(node["header_template"]) # If target obj has a relevant param set to true, show in menu as on. Otherwise show as turned off if(key in nmap_obj and nmap_obj[key] == True): nmap_obj[key] = True node["header"] = color.yellow(node["on"]) + header elif(key in nmap_obj and nmap_obj[key] == True): nmap_obj[key] = False node["header"] = color.red(node["off"]) + header else: nmap_obj[key] = False node["header"] = color.red(node["off"]) + header # Display Menu on screen for menu_number in menu: each_menu = menu[menu_number] single_digit_buffer = '' if(menu_number.isdigit() and int(menu_number) < 10): single_digit_buffer = ' ' else: single_digit_buffer = '' if(each_menu["header"] == False): print(' ') elif(description_boolean and "description" in each_menu): print(color.green(" [") +color.green(menu_number)+color.green("]"), single_digit_buffer, color.blue(each_menu["header"]), color.dark_grey(each_menu["description"])) else: print(color.green(" [") +color.green(menu_number)+color.green("]"), single_digit_buffer, color.blue(each_menu["header"]))
def revdns(target): for t in target: site = t.name.replace('http://', '').replace('https://', '') print('[!] Looking Up for Reverse DNS Info...') print(' [~] Result: \n') text = requests.get('http://api.hackertarget.com/reversedns/?q=' + site) result = text.text.split(' ') if 'error' not in result and 'no' != result[0]: #res = result.splitlines() #for r in result: print( color.blue(' [+] Received : ') + color.yellow(result[0]) + color.white(' => ') + color.blue('(' + result[1].strip() + ')')) #p = 'tmp/logs/'+web+'-logs/'+web+'-reverse-dns.lst' #open(p,'w+') #print(B+' [!] Saving links...') # for m in links: # print(m) # m = m + '\n' # ile = open(p,"a") # ile.write(m) # ile.close() # pa = os.getcwd() # print(G+' [+] Links saved under '+pa+'/'+p+'!') # print('') else: print(color.red(' [-] No result found!'))
def revip(target): for t in target: site = t.name.replace('http://', '').replace('https://', '') print(' [!] Looking Up for Reverse IP Info...') print(' [~] Result : \n') text = requests.get('http://api.hackertarget.com/reverseiplookup/?q=' + site).text result = str(text) res = result.splitlines() if 'error' not in result: for r in res: print(color.yellow(' [+] Site :> ') + color.green(r)) #links.append(r) # p = 'tmp/logs/'+web+'-logs/'+str(web)+'-reverse-ip.lst' # open(p,'w+') # print(B+' [!] Saving links...') # time.sleep(1) # for m in links: # m = m + '\n' # ile = open(p,"a") # ile.write(m) # ile.close() # pa = os.getcwd() # print(G+' [+] Links saved under '+pa+'/'+p+'!') # print('') elif 'error' in result: print(color.red(' [-] Outbound Query Exception!'))
def iphistory(target): for t in target: site = t.name.replace('http://', '').replace('https://', '') try: web0 = site.split('/')[-1] print(' [!] Making the request...') html = requests.get('https://viewdns.info/iphistory/?domain=' + web0).text print(' [*] Parsing raw-data...') soup = BeautifulSoup(html, 'lxml') print(soup) print(' [!] Setting parameters...') table = soup.findAll('table', attrs={'border': '1'})[0] print(' [!] Finding IP history instances...') trs = table.findAll('tr') trs.pop(0) print('\n [+] Following instances were found...') for tr in trs: td = tr.findAll('td') info = { 'ip': td[0].text, 'owner': td[2].text.rstrip(), 'last': td[3].text } print( color.green(' [+] Instance : ') + color.blue(info['ip']) + color.white(' => ' + info['owner']) + color.blue(' - (' + info['last'] + ')')) except: print(color.red(' [-] No instances of IP History found...')) pass
def linkedin(target): for t in target: site = t.name.replace('http://', '').replace('https://', '') def clear_cookie(): fo = open(".google-cookie", "w") fo.close() def google_it(dork): clear_cookie() try: for title in gsearch(dork): print(color.blue(' [!] Profile Found :> ' + color.white(title))) except Exception as e: pass try: print(" [*] Finding LinkedIn Employees ...\n") google_it("site:linkedin.com employees " + site + "") print(color.yellow(' [!] Pausing to avoid captcha...')) time.sleep(10) print(' [*] Finding Linkedin company profiles...\n') google_it("site:linkedin.com comapany " + site + "") except requests.HTTPError as err: if err.code == 503: print(color.red(' [-] Captcha appeared...\n')) pass
def thread(url,service,hostname): try: req = requests.get(url, headers = headers) if 'notavailable' in req.text: print(' [+] Found '+hostname+' : '+service) data.append(service) except Exception as e: print(color.red(' [-] Incurred Exception : '+str(e)))
def whois(target): for t in target: site = t.name.replace('http://','').replace('https://','') text = requests.get('http://api.hackertarget.com/whois/?q=' + site).text nping = str(text) if 'error' not in nping: print(color.custom(nping, white=True)) else: print(color.red(' [-] Outbound Query Exception!'))
def subnet(target): for t in target: site = t.name.replace('http://', '').replace('https://', '') print(color.green(' [!] Enumerating subnets in network...')) print('[*] Getting subnet class infos...\n') text = requests.get('http://api.hackertarget.com/subnetcalc/?q=' + site).text http = str(text) if 'error' not in http: result = http.splitlines() for r in result: print( color.green(' ' + r.split('=')[0] + '=' + color.yellow(r.split('=')[1]))) elif 'No results found' in http: print(color.red(' [-] No results found!')) else: print(color.red(' [-] Outbound Query Exception!'))
def hackertarget(target): from core.build_menu import buildmenu site = 'https://api.hackertarget.com/' options = ['mtr','nping','dnslookup','reversedns','whois','geoip','reverseiplookup',\ 'httpheaders','pagelinks','aslookup'] description=['Access to the MTR Traceroute API','Access to the on-line Test Ping API',\ 'Access to the DNS Lookup API','Access to the Reverse DNS Lookup API',\ 'Access to the Whois Lookup API','Access to the GeoIP Lookup API',\ 'Access to the Reverse IP Lookup API','Access to the HTTP Headers API',\ 'Access to the Page Links API','Access to the AS Lookup API'] print( color.green( " [*] Finding HackerTarget.com information. This will take approximately 20 seconds ...\n" )) for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' i = 0 for option in options: try: print( color.green(' [#] Checking: ') + color.yellow(description[i])) url = site + option + '/?q=' + host.ip.replace( 'http://', '').replace('https://', '') check = requests.get(url) time.sleep(.5) # max query is 3 per second or you get blocked if check.status_code == 200: data = check.text save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) else: print( color.red(' [-] Did not find any info about domain ') + color.yellow(host.name)) print(color.red(' [+] Try with another one...')) except Exception as e: pass print(color.red(' [-] Encountered Exception : ' + str(e))) i = i + 1 # return to main menu buildmenu(target, target[0].main_menu, 'Main Menu', '')
def subnet(target): for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' site = host.name.replace('http://', '').replace('https://', '') print(color.green(' [!] Enumerating subnets in network...')) print('[*] Getting subnet class infos...\n') text = requests.get('http://api.hackertarget.com/subnetcalc/?q=' + site).text http = str(text) if 'error' not in http: data = http # result = http.splitlines() # for data in result: save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) elif 'No results found' in http: print(color.red(' [-] No results found!')) else: print(color.red(' [-] Outbound Query Exception!')) return
def nping(target): for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' site = host.name.replace('http://', '').replace('https://', '') text = requests.get('http://api.hackertarget.com/nping/?q=' + site).text data = str(text) if 'error' not in data: save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) else: print(color.red(' [-] Outbound Query Exception!'))
def iphistory(target): for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' site = host.name.replace('http://', '').replace('https://', '') try: web0 = site.split('/')[-1] print(' [!] Making the request...') html = requests.get('https://viewdns.info/iphistory/?domain=' + web0).text print(' [*] Parsing raw-data...') soup = BeautifulSoup(html, 'lxml') if 'captcha?' in str(soup).lower(): print( color.red( ' [-] CAPTCHA detected, this method won\'t work...')) break #print(soup) print(' [!] Setting parameters...') table = soup.findAll('table', attrs={'border': '1'})[0] print(' [!] Finding IP history instances...') trs = table.findAll('tr') trs.pop(0) print('\n [+] Following instances were found...') data = [] for tr in trs: td = tr.findAll('td') info = { 'ip': td[0].text, 'owner': td[2].text.rstrip(), 'last': td[3].text } data.append(info) #print(color.green(' [+] Instance : ') + color.blue(info['ip']) + color.white(' => ' + info['owner']) + color.blue(' - (' + info['last'] + ')')) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) except: print(color.red(' [-] No instances of IP History found...')) pass
def creditcards(target): from core.build_menu import buildmenu for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' credit0x00(host) try: input( color.blue(' [#] Press') + color.red(' Enter ') + color.blue('to continue... \n')) buildmenu(target, target[0].main_menu, 'Main Menu', '') except EOFError as e: buildmenu(target, target[0].main_menu, 'Main Menu', '') return
def credit0x00(host): print(color.green(' [+] Importing credit card signatures...')) links = [host.name] if '//' in host.name: site = host.name.split('//')[1] else: site = host.name for link in links: print(' [*] Scraping Page: ' + color.yellow(site)) req = requests.get(link).text check0x00(req) soup = BeautifulSoup(req, 'lxml') #site='https://'+site for line in soup.find_all('a', href=True): newline = line['href'] try: if newline[:4] == "http": if site in newline: urls.append(str(newline)) elif newline[:1] == "/": combline = site + newline urls.append(str(combline)) except: print(color.red(' [-] Unhandled Exception Occured!')) try: for uurl in urls: print(color.green("\n [+] Scraping Page: " + color.yellow(uurl))) req = requests.get(uurl).text check0x00(req) except Exception as e: #requests.exceptions: print(color.red(' [-] Outbound Query Exception...')) if found == 0x00: print( color.red( ' [-] No Credit Cards found disclosed in plaintext in source code!' )) print(color.green(' [+] Scraping Done!'))
def request(url): time.sleep(0.5) links = [url] if '//' in url: po = url.split('//')[1] for w in links: print(color.green(' [*] Scraping Page: ') + color.yellow(url)) req = requests.get(w).text check0x00(req, url) soup = BeautifulSoup(req, 'lxml') for line in soup.find_all('a', href=True): newline = line['href'] try: if newline[:4] == "http": if po in newline: urls.append(str(newline)) elif newline[:1] == "/": combline = url + newline urls.append(str(combline)) except: print(color.red(' [-] Unhandled Exception Occured!')) try: for uurl in urls: print(color.green("\n [+] Scraping Page: ") + color.yellow(uurl)) req = requests.get(uurl).text check0x00(req, url) except Exception as e: print(color.red(' [-] Outbound Query Exception...')) if found == 0x00: print(color.red('\n [-] No Errors found in Source Code!\n')) print(color.green(' [+] Scraping Done!'))
def getgeoip(target): for t in target: site = t.name.replace('http://', '').replace('https://', '') domains = socket.gethostbyname(t.name) text = requests.get('http://api.hackertarget.com/geoip/?q=' + domains).text result = str(text) if 'error' not in result and 'invalid' not in result: res = result.splitlines() for r in res: print( color.white(' [+] ' + r.split(':')[0].strip() + ' : ' + color.yellow(r.split(':')[1].strip()))) else: print(color.red(' [-] Outbound Query Exception!'))
def getgeoip(target): for host in target: host.lvl2=inspect.stack()[0][3] host.lvl3='' site = host.name.replace('http://','').replace('https://','') domains = socket.gethostbyname(host.name) text = requests.get('http://api.hackertarget.com/geoip/?q=' + domains).text result = str(text) if 'error' not in result and 'invalid' not in result: data = result save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) # res = result.splitlines() # for r in res: # print(color.white(' [+] ' + r.split(':')[0].strip() + ' : ' +color.yellow(r.split(':')[1].strip()))) else: print(color.red(' [-] Outbound Query Exception!'))
def revdns(target): for host in target: host.lvl2=inspect.stack()[0][3] host.lvl3='' site = host.name.replace('http://','').replace('https://','') print('[!] Looking Up for Reverse DNS Info...') print(' [~] Result: \n') text = requests.get('http://api.hackertarget.com/reversedns/?q=' + site).text result = str(text) res = result.splitlines() if 'error' not in res and 'no' != res[0]: data = result save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) else: print(color.red(' [-] No result found!')) return
def linkedin(target): for host in target: site = host.name.replace('http://', '').replace('https://', '').replace( 'www.', '').replace('.com', '') host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' def clear_cookie(): fo = open(".google-cookie", "w") fo.close() def google_it(host): clear_cookie() try: this = gsearch(host) if len(this) > 0: data = str(this) #print(data) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) time.sleep(5) except Exception as data: save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) pass try: print(" [*] Finding LinkedIn Employees ...\n") host.dork = "site:linkedin.com employees " + site + "" google_it(host) print(color.yellow(' [!] Pausing to avoid captcha...')) time.sleep(10) print(' [*] Finding Linkedin company profiles...\n') host.dork = "site:linkedin.com company " + site + "" google_it(host) except requests.HTTPError as err: if err.code == 503: print(color.red(' [-] Captcha appeared...\n')) pass return
def revip(target): for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' site = host.name.replace('http://', '').replace('https://', '') print(' [!] Looking Up for Reverse IP Info...') print(' [~] Result : \n') text = requests.get('http://api.hackertarget.com/reverseiplookup/?q=' + site).text result = str(text) res = result.splitlines() if 'error' not in result: data = result save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) elif 'error' in result: print(color.red(' [-] Outbound Query Exception!')) return
def nikto_menu(target): from core.build_menu import buildmenu nikto_ip = '' nikto_ports = target[0].port or '' nikto_options = '' target_ip = nikto_ip if nikto_ip else target[0].ip target_ports = nikto_ports if nikto_ports else target[0].port target_options = nikto_options if nikto_options else target[0].options_str current_cmd_str = 'nikto -h ' + target_ip + ' -p ' + target_ports + ' ' + target_options for host in target: host.help = 'nikto' host.lvl2 = 'Nikto' if host.port == '': host.port = '80' nikto_ip = host.ip nikto_ports = host.port nikto_options = host.options_str host.cmd_str = current_cmd_str menu = { # '#' : ['module', 'description', 'function'] '1':['Update Target IP',target_ip,'nikto_ip'],\ '2':['Update Target Port(s)',target_ports,'nikto_port'],\ '3':['Update Command Options',target_options,'nikto_add_options'],\ '4':['Run Nikto','(Run Current Nikto Command)','nikto'],\ } current_cmd = '\n' + '-' * 55 + '\n' + color.green( 'Current nikto Command: \n') + color.red( current_cmd_str) + '\n' + '-' * 55 print(current_cmd) buildmenu(target, menu, 'Nikto Scan Configuration', '')
def add_host(info): valid_ip_regex = r'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$' valid_host_regex = r'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' temp = input( '\n[#] Input Host/IP (ie: 192.168.10.1):> ') # DEBUG: temp value if '//' in temp: prefix = temp.split('//')[0] host = temp.split('//')[1] else: prefix = 'https' host = temp url = prefix + '//' + host if (re.match(valid_ip_regex, host)): new = Target(url, 'ip') info.hosts.append(new) settings(info) elif (re.match(valid_host_regex, host)): new = Target(url, 'host') info.hosts.append(new) else: print('fail') print(color.red("Invalid Host Address, try again: ")) settings(info)
def getconinfo(target): for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' print(color.white(' [*] Importing API Key...')) try: from files.API_KEYS import FULLCONTACT_API_KEY except (IOError, ImportError): print(color.red(' [-] Error while importing key...')) pass try: if FULLCONTACT_API_KEY != '': print( color.green(' [+] Found API Key : ') + color.yellow(FULLCONTACT_API_KEY)) base_url = 'https://api.fullcontact.com/v2/company/lookup.json' print(color.white(' [*] Looking up info...')) time.sleep(0.7) payload = {'domain': host.name, 'apiKey': FULLCONTACT_API_KEY} resp = requests.get(base_url, params=payload) #print(resp) if resp.status_code == 200: data = resp.text save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, data) else: print( color.red(' [-] Did not find any info about domain ') + color.yellow(host.name)) print(color.red(' [+] Try with another one...')) else: print(color.red(' [-] FULL CONTACT API TOKEN not set!')) print(color.red(' [-] This module cannot be used!')) except Exception as e: pass print(color.red(' [-] Encountered Exception : ' + str(e)))
def photon_menu(target): from core.build_menu import buildmenu photon_site = target[0].ip if not target[0].website else target[0].website photon_options = '' target_website = photon_site if photon_site else target[0].website if 'https://' not in target_website: target_website = 'https://' + target_website target_options = photon_options if photon_options else target[0].options_str target_run_file = target[0].run_file display_cmd_str = 'photon -u ' + target_website + ' ' + target_options current_cmd_str = 'python3 ' + target_run_file + ' -u ' + target_website + ' ' + target_options for host in target: # host.module = 'ScanANDEnum' # host.lvl1 = 'Scanning & Enumeration' host.help = 'python3 lib/Photon/photon.py' host.lvl2 = 'Crawler' host.lvl3 = 'Photon' host.run_file = './lib/Photon/photon.py' photon_site = host.website photon_options = host.options_str host.cmd_str = current_cmd_str menu = { # '#' : ['module', 'description', 'function'] '1':['Update Target Website',target_website,'photon_website'],\ '2':['Update Command Options',target_options,'photon_options'],\ '3':['Run Photon','(Run Current Crawler Command)','photon_run'],\ } display_cmd = '\n' + '-'*55 + '\n' + color.green('Current Photon Command: \n') + color.red(display_cmd_str) + '\n' + '-'*55 print(display_cmd) buildmenu(target,menu,'Photon Scan Configuration','')
def hashes(target): from core.build_menu import buildmenu for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' try: message = input('\n [#] Enter the string to hash:> ') print(color.green(' [+] Generating hashes...')) md5 = hashlib.md5() md5.update(message.encode('utf-8')) sha1 = hashlib.sha1() sha1.update(message.encode('utf-8')) sha224 = hashlib.sha224() sha224.update(message.encode('utf-8')) sha256 = hashlib.sha256() sha256.update(message.encode('utf-8')) sha384 = hashlib.sha384() sha384.update(message.encode('utf-8')) sha512 = hashlib.sha512() sha512.update(message.encode('utf-8')) print(color.green(" [+] MD5 Hash : ") + color.yellow(md5.hexdigest())) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(md5.hexdigest())) print( color.green(" [+] SHA1 Hash : ") + color.yellow(sha1.hexdigest())) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(sha1.hexdigest())) print( color.green(" [+] SHA224 Hash : ") + color.yellow(sha224.hexdigest())) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(sha224.hexdigest())) print( color.green(" [+] SHA256 Hash : ") + color.yellow(sha256.hexdigest())) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(sha256.hexdigest())) print( color.green(" [+] SHA384 Hash : ") + color.yellow(sha384.hexdigest())) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(sha384.hexdigest())) print( color.green(" [+] SHA512 Hash : ") + color.yellow(sha512.hexdigest())) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(sha512.hexdigest())) except EOFError as e: #os.system('clear') print(e) st = input( color.blue(' [#] Press') + color.red(' Enter ') + color.blue('to continue... ')) buildmenu(target, target[0].main_menu, 'Main Menu', '')
def nmap_editor(passed_target): from core.build_menu import buildmenu global description_boolean user_input = '' nmap_obj = passed_target[0] nmap_params = passed_target[0].cmd_options exit_condition = False while(exit_condition == False): # Invoke Create Menu Function create_edit_menu(menu, passed_target) nmap_command = str(nmap_target_sorter(passed_target[0])) nmap_obj.nmap = nmap_command print('\n' + '-'*55) print(color.green('Current nmap Command: \n') + color.red(nmap_command) + '\n' + '-'*55) # [E] : ----------- Graceful Exit -------------------- user_input = input('\n[#] Choose Option:> ') lowered = user_input.lower() if(lowered == exit_button or lowered == 'exit' or lowered == 'e' or lowered == 0): exit_condition = True # Clean user input if (list(user_input.strip())[0].isalpha()): user_input = list(user_input.strip())[0].lower() else: user_input = str(user_input.strip()) tag_arg_set = [preferred_order, nmap_params, menu] # [D] : --------- Description toggle ------------------------- if(user_input.lower() == 'd'): reversed = not description_boolean # Reverse Boolean description_boolean = reversed # [O] or [F] : --------- Turn ON/OFF ALL NMAP tag toggles ------------------------- elif(user_input.upper() == the_all_on_button): tag_manager(menu_toggle_items, True, tag_arg_set) elif(user_input.upper() == the_all_off_button): tag_manager(menu_toggle_items, False, tag_arg_set) # [1] : --------------------- 2. Run NMAP ----------------------------------------- elif(user_input == '1'): exit_condition = True # [2] : -------- 2. Adjust IP Address (Target Address) ----------------------------- elif(user_input == retrieve_module_index('Edit Target', preferred_order)): address = input(menu[user_input]["start_msg"]) reg_string = r'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$' if(address == 'exit'): print('Exiting') elif(re.match(reg_string, address)): nmap_obj.name = address else: print(color.red(menu[user_input]["error"])) # [3] : -------------------- 3. Set Port Range --------------------------------------- elif(user_input == retrieve_module_index('Set Port Range', preferred_order)): port_range = input(menu[user_input]["start_msg"]) if(port_range == 'exit'): print('Exiting') elif(port_range.lower() == 'none' or port_range == 0): nmap_params['-p'] = False nmap_params['-p-'] = False elif(port_range.lower() == 'all' or port_range == '-p-'): nmap_params['-p'] = False nmap_params['-p-'] = True elif(re.match(r'^\d{1,5}(-?\d{1,5})?$', port_range)): nmap_params['-p'] = port_range else: print(color.red(menu[user_input]["error"])) # -------------------- All other toggle options --------------------------------------- else: for each_toggle in menu_toggle_items: tag_manager(each_toggle, user_input, tag_arg_set) nmap_menu(passed_target)
def censysdom(target): for host in target: host.lvl2 = inspect.stack()[0][3] host.lvl3 = '' print(' [*] Importing API Key...') try: from files.API_KEYS import CENSYS_UID, CENSYS_SECRET except IOError as ImportError: print(color.red(' [-] Error while importing key...')) if '//' in host.name: web = host.name.split('//')[1] else: web = host.name if CENSYS_SECRET != '' and CENSYS_UID != '': print( color.green(' [+] Found Censys UID Key : ') + color.yellow(CENSYS_UID)) print( color.green(' [+] Found Censys Secret Token : ') + color.yellow(CENSYS_SECRET)) base_url = 'https://www.censys.io/api/v1' print(' [*] Looking up info...') resp = requests.get(base_url + "/view/websites/" + web, auth=(CENSYS_UID, CENSYS_SECRET)) if 'quota_exceeded' in resp.text: print( color.red( ' [-] Daily limit reached for this module. Use you own API key for CENSYS.' )) if resp.status_code == 200: print(color.green(' [+] Found domain info!')) w = resp.text.encode('utf-8') asio = json.dumps(resp.json(), indent=4) data = asio.splitlines() print(color.yellow(' [!] Parsing info...\n')) #print(data) save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) # for q in quest: # q = q.replace('"','') # if ':' in q and '[' not in q and '{' not in q: # q1 = q.split(':',1)[0].strip().title() # q2 = q.split(':',1)[1].strip().replace(',','') # print(C+' [+] '+q1+' : '+GR+q2) # time.sleep(0.01) # elif ('{' or '[' in q) and (':' in q): # w1 = q.split(':',1)[0].strip().upper() # w2 = q.split(':',1)[1].strip() # print(O+'\n [+] '+w1+' :-'+'\n') # elif '{' not in q and '[' not in q and ']' not in q and '}' not in q: # print(GR+' [+] '+q.replace(',','').strip()) # print(O+' [!] Saving retrieved CENSYS data...') # time.sleep(1) # with open('tmp/logs/'+web+'-logs/'+web+'-censys-data.json', 'w+') as file: # json.dump(resp.json(), file, ensure_ascii=True,indent=4) # eq = os.getcwd() # print(G+' [+] Censys Data stored '+eq+'/tmp/logs/'+web+'-logs/'+web+'-censys-data.json') else: print(color.red(' [-] Did not find any info about domain ')) print(color.red(' [+] Try with another one...')) else: print(color.red(' [-] CENSYS API TOKENs not set!')) print(color.red(' [-] This module cannot be used!'))
def encodeall(info): from core.build_menu import buildmenu try: st = input( color.yellow(' [-] Enter a string to be encoded/decoded :> ')) m64 = base64.b64encode(st.encode()) data = m64.decode() print( color.green(' [+] Base64 Encoded String : ') + color.yellow(data)) #save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) except Exception as e: pass try: m32 = base64.b32encode(st.encode()) data = m32.decode() print( color.green(' [+] Base32 Encoded String : ') + color.yellow(data)) #save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) except Exception as e: pass try: m16 = base64.b16encode(st.encode()) data = m16.decode() print( color.green(' [+] Base16/Hex Encoded String : ') + color.yellow(data)) #save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) except Exception as e: print(color.red(" [-] Caught Exception : " + str(e))) try: m64d = base64.b64decode(st.encode()) data = m64d.decode() print(color.red(' [+] Base64 Decoded String : ') + color.white(data)) #save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) except Exception as e: pass try: m32d = base64.b32decode(st.encode()) data = m32d.decode() print(color.red(' [+] Base32 Decoded String : ') + color.white(data)) #save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) except Exception as e: pass try: m16d = base64.b16decode(st.encode()) data = m16d.decode() print( color.red(' [+] Base16/Hex Decoded String : ') + color.white(data)) #save_data(host.database, host.module, host.lvl1, host.lvl2, host.lvl3, host.name, str(data)) except Exception as e: pass try: data = urllib.parse.quote(st, safe='') print(color.green(' [+] URL Encoded String : ') + color.yellow(data)) data = urllib.parse.quote_plus(st, safe='') print( color.green(' [+] URL plus Encoded String : ') + color.yellow(data)) except Exception as e: pass try: data = urllib.parse.unquote(st) print(color.green(' [+] URL Decoded String : ') + color.yellow(data)) data = urllib.parse.unquote_plus(st) print( color.green(' [+] URL plus Decoded String : ') + color.yellow(data)) except Exception as e: pass # more types of encoding still need added # encod = '' # stri = list(st) # for i in stri: # encod = encod + escape(i) # print(color.green(' [+] Encoded String : ')+color.yellow(encod)) # m = st.encode('base64', 'strict') # print(color.green(' [+] Encoded String : ')+color.yellow(m)) # m = st.encode('hex', 'strict') # print(color.green(' [+] Encoded String : ')+color.yellow(m)) # result = [] # for char in st: # result.append('\%o' % ord(char)) # print(color.green(' [+] Octal Encoded String : ')+color.yellow(str(''.join(result)))) # m = ''.join(format(ord(x),'b') for x in st) # print(color.green(' [+] Encoded String : ')+color.yellow(m)) # m = st.encode('zlib','strict') # print(color.green(' [+] Encoded String : ')+color.yellow(m)) st = input( color.blue(' [#] Press') + color.red(' Enter ') + color.blue('to continue... ')) buildmenu(info, info.main_menu, 'Main Menu', '')