def session(self): output('This is remote host, social, network and database scanner.\n') while True: command = inp('What do you want to do?\n' '1 - Scan remote host\n' '2 - Scan network\n' '3 - Scan social\n' '4 - Scan databases\n' '0 - Exit\n') self.do_actions(command)
def scan_remote_host_dnsmap(self, host): if not self.check_host(host): return 'Wrong host: "{}"'.format(host) output('Scanning for subdomains...') os.system('dnsmap {} >> temp/dnsmap.txt'.format(host)) with open('temp/dnsmap.txt') as f: dnsmap_scan = f.read() os.remove('temp/dnsmap.txt') output(dnsmap_scan) dnsmap_scan_no_localhost = dnsmap_scan.replace('127.0.0.1', '') subdomains = re.findall(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", dnsmap_scan_no_localhost) return subdomains
def scan_ld(self, query): if not self.credentials['ld_login'] or not self.credentials['ld_pass']: return output('Linkedin credentials not founded') browser = webdriver.Firefox() browser.get('https://www.linkedin.com/') elem = browser.find_element_by_class_name('login-email') elem.send_keys(self.credentials['ld_login']) elem = browser.find_element_by_class_name('login-password') elem.send_keys(self.credentials['ld_pass'] + Keys.RETURN) time.sleep(5.0) browser.get( 'https://www.linkedin.com/search/results/index/?keywords={}&origin=GLOBAL_SEARCH_HEADER' .format(query)) content = browser.page_source.splitlines() browser.quit() for line in content: if 'metadata' in line: metadata = json.loads(line) search = [ person for person in metadata['included'] if 'publicIdentifier' in person and person['$deletedFields'] ] return output_ld(search)
def scan_fb(self, query): if not self.credentials['fb_user_token'] \ or not self.credentials['fb_app_id'] \ or not self.credentials['fb_app_secret']: return output('Facebook credentials not founded') access_token = self.fb_get_token() if not access_token: return output( 'Facebook tokens expired, get new at: https://developers.facebook.com/tools/accesstoken/' ) graph = facebook.GraphAPI(access_token) args = {'q': query, 'type': 'user', 'fields': 'name,link'} request = graph.request('/search?{}'.format(query), args=args) return output_fb(request)
def scan(self, query): if not hasattr(self, 'credentials'): return output( 'Credentials for social networks was not found, did you create credentials.json?' ) self.scan_vk(query) self.scan_fb(query) self.scan_ld(query)
def scan_vk(self, query): if not self.credentials['vk_app_id'] or not self.credentials[ 'vk_login'] or not self.credentials['vk_pass']: return output('VK credentials not founded') logging.getLogger('vk-requests').setLevel(logging.ERROR) api = vk_requests.create_api(app_id=self.credentials['vk_app_id'], login=self.credentials['vk_login'], password=self.credentials['vk_pass']) return output_vk(api.users.search(q=query, fields='domain'))
def do_actions(self, command, choose=''): try: if choose == 'sql': self.db_sql[command]() else: self.actions[command]() except Exception as e: # raise e # debug return output('Error: {}'.format(e))
def scan(self, network): output('Scanning network...') start = time.time() self.scanner.scan(network or '192.168.1.0/24', arguments='-O -T5') output('Completion time: {} second(s)'.format( round(time.time() - start, 2))) output(self.dm.save_csv(self.scanner, 'network'))
import model, view model.quantity = view.get_input() view.output(model.quantity)
import index import view view.output_start() x = int(input()) if x == 1: view.output_var("consumption") consumption = int(input()) view.output_var("distance") distance = int(input()) view.output(index.volume_calc(consumption, distance), "Volume") elif x == 2: view.output_var("consumption") consumption = int(input()) view.output_var("volume") volume = int(input()) view.output(index.distance_calc(consumption, volume), "Distance") else: print("Error number") if __name__ == "__main__": import doctest doctest.testmod()
def scan_remote_host_nmap(self, subdomains): output('\nScanning subdomains...') self.scanner.scan(' '.join(subdomains), '22-443', '-sV -A -T4') output(self.dm.save_csv(self.scanner, 'remote_host'))
def scan(self, host): start = time.time() subdomains = self.scan_remote_host_dnsmap(host) self.scan_remote_host_nmap(subdomains) output('Completion time: {} second(s)'.format( round(time.time() - start, 2)))
def exit_program(): output('Program is closed. Have a nice day!') exit()
def run_scan_postgresql(self): conn, cursor = self.scanner_databases.connect_postgresql() output( self.scanner_databases.scan_postgresql(conn, cursor, *self.contact_elements()))