def work_on_papar(paper_path): """ 读取一篇文章 """ items = Items() # [name] items.name = get_filename(paper_path).split('_')[0] items.org = get_filename(paper_path).split('_')[1] with open(paper_path, 'r') as f: lines = f.readlines() total_count = 0 sucess_count = 0 for line in lines: if len(line.strip()) == 0: continue if work_on_line(line, items): sucess_count += 1 total_count += 1 work_on_end(items) global MAX_DEGREE MAX_DEGREE = 'b' global DEGREE DEGREE = {'a': [], 'b': [], 'm': [], 'd': []} items.save(OUTPUT_CSV) return sucess_count, total_count
def whatweb(self): print_(""" ######### whatweb ######### 1.批量域名扫描(domain). 2.常规扫描. 3.详细回显扫描. 4.快速本地扫描(扫描内网主机). 5.查看结果. 0.返回菜单. """) ipt1 = input_('>') if ipt1 != '0': ipt2 = input_('Save name>') path = f'{self.root}lib/batch/whatweb/results' save_name = f'{ipt2}.xml' if ipt1 == '1': paths = get_filename(f'{self.root}lib/batch/whatweb') i = 1 for p1 in paths: print_(f'{i}. {p1}') i += 1 ipt2 = input_('Path编号>') i = 1 for p2 in paths: if ipt2 == str(i): path = p2 break i += 1 self.commands__( f'cd {path} && whatweb -i {path} --log-xml={save_name}') self.whatweb() if ipt1 == '2': ipt2 = input_('Domain>') self.commands__( f'cd {path} && whatweb {ipt2} --log-xml={save_name}') self.whatweb() if ipt1 == '3': ipt2 = input_('Domain>') self.commands__( f'cd {path} && whatweb -v {ipt2} --log-xml={save_name}') self.whatweb() if ipt1 == '4': ipt2 = input_('IP>') ipt3 = input_('前缀>') self.commands__( f'cd {path} && whatweb --no-errors -t 255 {ipt2}{ipt3} --log-xml={save_name}' ) self.whatweb() if ipt1 == '5': pass if ipt1 == '0': self.main()
def main(self): print_(""" 1.DNS接口查询. 0.Exit. """) ipt1 = input_('选项>') if ipt1 is '1': print_(""" ____ _ _ ___ | _ \| \ | |___ / _ \ _ _ ___ _ __ _ _ | | | | \| / __| | | | | | | |/ _ \ '__| | | | | |_| | |\ \__ \ | |_| | |_| | __/ | | |_| | |____/|_| \_|___/ \__\_\\\\__,_|\___|_| \__, | |___/ 1.批量查询 2.单个查询 0.返回菜单. """) ipt2 = input_('>') if ipt2 is '0': self.main() if ipt2 is '1': ipt3 = input_('处理URL获取Domain name.[y/n]') filenames = get_filename(path='{}lib/batch'.format(root)) for filename in filenames: print_(filename) ipt4 = input_('Filename>') lines = read_text_(ipt4) for line in lines: if ipt3 == 'y': domain = get_domain(line) self.DNS_Query_Interface(domain) if ipt3 == 'n': domain = line self.DNS_Query_Interface(domain) if ipt2 is '2': ipt3 = input_('Domain>') self.DNS_Query_Interface(ipt3) if ipt1 is '0': selenium_.browser_.quit() exit(0)
def Subdomain_Enumeration(self, domain): """ Return data: data[0] >> domain data[1] >> ip """ try: # threadLock.acquire() commands__(cmd=cmd3.format(root, domain)) except Exception as e: pass finally: # threadLock.release() datas = get_filename('{}/output'.format(root)) i = 0 for data in datas: if os.path.getsize(datas) > 0: if i == len(datas): foo.state1 = True i += 1
sql_end += '%s' else: fields.append(q[0]) sql += ',' + q[0] sql_end += ',' + '%s' sql += ') VALUES (' + sql_end + ')' workbooks = [] sheets = [] write_rows = [] for i, xlsx_file in enumerate(sys.argv): # Загружаем все xlsx файлы if i == 0: workbooks.append(None) sheets.append(None) continue xlsx_file_cut = get_filename(xlsx_file) workbooks.append(openpyxl.load_workbook(filename=xlsx_file, read_only=True)) sheets.append(workbooks[i][workbooks[i].sheetnames[0]]) print(datetime.now().strftime("%H:%M:%S") + ' Файл ' + xlsx_file_cut + ' открыт\n') sheet = sheets[i] for j, row in enumerate(sheet.rows): # Теперь строки if j == 0: continue omit = False write_row = (xlsx_file_cut[0:xlsx_file_cut.rfind('.xlsx')], ) for k, cell in enumerate(row): if fields[k][2:] == 'date': try: write_row += (datetime.strptime(cell.value,
encoding='cp1251') as output_file: dict_writer = csv.DictWriter( output_file, [IN_SNILS[0]], delimiter=';') #, quoting=csv.QUOTE_NONNUMERIC) dict_writer.writeheader() dict_writer.writerows(cl_csvs) output_file.close() cl_csvs = [] k = 0 print(datetime.now().strftime("%H:%M:%S") + ' 15k из файла ' + sys.argv[i + 1].split(path)[1] + ' сохранил в файл ' + '{:=03d}'.format(file_number) + '.csv') file_number += 1 k += 1 print('\n' + datetime.now().strftime("%H:%M:%S") + ' Файл ' + get_filename(sys.argv[i + 1]) + ' загружен полностью\n') with open(path + '{:=03d}'.format(file_number) + '.csv', 'w', encoding='cp1251') as output_file: dict_writer = csv.DictWriter( output_file, [IN_SNILS[0]], delimiter=';') # , quoting=csv.QUOTE_NONNUMERIC) dict_writer.writeheader() dict_writer.writerows(cl_csvs) output_file.close() print(datetime.now().strftime("%H:%M:%S") + ' Остаток из файла ' + get_filename(sys.argv[i + 1]) + ' сохранил в файл ' + '{:=03d}'.format(file_number) + '.csv') print('\n' + datetime.now().strftime("%H:%M:%S") + ' Завершено без сбоев\n')
def ip_or_domain_result_handle(): from main import Run r1 = Run() main = r1.main print_(""" ######## 处理结果 ######## 1.查看结果. 2.结果提交到nmap扫描. 0.返回菜单. """) ipt1 = input_('>') if ipt1 is '0': main() if ipt1 is '1': filenames = get_filename(path=f'{root}lib/fping') if not filenames: red('[Error] fping 没有结果.') return False i = 1 for filename in filenames: print_(str(i) + '. ' + filename) i += 1 ipt1 = input_('>') i = 1 for filename in filenames: if str(i) == ipt1: ipt1 = str(filename.replace(' ', '').replace('\n', '')) break i += 1 with open(f'{ipt1}', 'r') as r: for line in r.readlines(): if re.findall(f'({regular(1)})(\.+)*', line): ip = str(line.strip().replace(' ', '').replace('\n', '')) if ip: data = _red(ip) print(data) if ipt1 is '2': filenames = get_filename(path=f'{root}lib/fping') if not filenames: red('[Error] fping 没有结果.') return False i = 1 for filename in filenames: print_(str(i) + '. ' + filename) i += 1 ipt1 = input_('>') i = 1 for filename in filenames: if str(i) == ipt1: ipt1 = str(filename.replace(' ', '').replace('\n', '')) break i += 1 with open(f'{ipt1}', 'r') as r: for line in r.readlines(): if re.findall(f'({regular(1)})(\.+)*', line): ip = str(line.strip().replace(' ', '').replace('\n', '')) if ip: thread1 = Thread(target=port_scan, args=(ip, ip)) thread1.start()
def _add_task(self, rule): print_(""" 1.批量任务添加 2.删除所有任务 3.删除指定任务 4.跳过 0.Exit. """) if self.option_: ipt1 = input_('>') if ipt1 is '1': domains = [] ipt2 = input_('处理URL获取Domain name.[y/n]') if ipt2 is 'y': i1 = True if ipt2 is 'n': i1 = False filename = get_filename('{}lib/batch/awvs'.format(root)) i = 1 for f in filename: print_(f'{i}. {f}') i += 1 ipt3 = input_('Path编号>') i = 1 for f in filename: if ipt3 == str(i): ipt3 = f break i += 1 if ipt3: datas = read_text_(ipt3) if i1: for data in datas: d = get_domain(data) domains.append(d) datas = domains if ipt1 is '2': self.delete_() return False if ipt1 is '3': self.delete() return False if ipt1 is '4': self.option_ = False eXit = False if not ipt1 is '0' else True try: def r(): if eXit: return False i = 1 for target1 in datas: if i <= 5: if self.option: info(('Add scann target -> ', target1)) self.add_task(target=target1, rule=rule) else: i = 0 time.sleep(600) i += 1 thread1 = threading.Thread(target=r) thread1.start() except Exception as e: # red(traceback.format_exc()) pass
def crunch(self): print_(""" ######## crunch ######## 1.生成. 2.查看结果. 3.结果传递至爆破脚本. 0.返回菜单. """) ipt1 = input_('>') if ipt1 == '1': ipt1 = input_('最小字符长度>') ipt2 = input_('最大字符长度>') ipt3 = input_('构造内容>') ipt4 = input_('Domain>') self.commands__(f'cd {self.root}dict && mkdir login') self.commands__( f'crunch {ipt1} {ipt2} {ipt3} > {self.root}dict/login/f{ipt4}.txt' ) if ipt1 == '2': paths = get_filename(f'{self.root}dict/login') i = 1 for f1 in paths: print_(f'{i}. {f1}') i += 1 ipt1 = input_('选择编号>') i = 1 for f1 in paths: if i == int(ipt1): path = f1 break i += 1 self.commands__(f'vim {path}') if ipt1 == '3': paths = get_filename(f'{self.root}dict/login') i = 1 for f1 in paths: print_(f'{i}. {f1}') i += 1 ipt1 = input_('user字典编号>') ipt2 = input_('passwd字典编号>') i = 1 for f1 in paths: if i == int(ipt1): user_path = f1 if i == int(ipt2): passwd_path = f1 i += 1 print_(""" 1.exp_2019_7_16_baopo. 0.返回菜单. """) ipt1 = input_('>') if ipt1 == '1': exp_2019_7_16_baopo(user_path, passwd_path) self.main() if ipt1 == '0': self.main() if ipt1 == '0': self.main()