def plug_parser(): if pyoptions.args_plug[0] not in pystrs.plug_range: exit("[!] Choose plug from ({0}, {1}, {2})".format( cool.fuchsia(pystrs.plug_range[0]), cool.fuchsia(pystrs.plug_range[1]), cool.fuchsia(pystrs.plug_range[2]))) else: # id card plugin if len(pyoptions.args_plug ) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[0]: idcard_magic(pystrs.plug_range[0]) elif len(pyoptions.args_plug ) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[1]: idcard_magic(pystrs.plug_range[1]) # passcraper plugin elif len(pyoptions.args_plug) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[2] and \ os.path.isfile(paths.scrapersites_path): scraper_magic() elif len(pyoptions.args_plug ) == 2 and pyoptions.args_plug[0] == pystrs.plug_range[2]: scraper_magic(pyoptions.args_plug[1]) elif len(pyoptions.args_plug) == 1: exit(pyoptions.CRLF + "[-] Plug %s need other arguments" % cool.red(pyoptions.args_plug[0])) else: exit(pyoptions.CRLF + cool.red("[-] Argument option error"))
def check_date(dt, desc="datetime", ymd_format=True): """ :return: year month day """ if len(dt) != 8 or not dt.isdigit(): exit( cool.fuchsia("[!] {} format:[{}], such as:{}{}".format( desc, "yyyMMdd" if ymd_format else "ddMMyyyy", "20150806" if ymd_format else "08062015", pyoptions.CRLF))) if ymd_format: if int(dt[4:6]) > 12 or int(dt[4:6]) < 1 or int( dt[6:8]) > 31 or int(dt[6:8]) < 1: exit( cool.fuchsia( "[!] {} date format: 1<= month <=12 and 1<= day <=31{}" .format(desc, pyoptions.CRLF))) else: return int(dt[0:4]), int(dt[4:6]), int(dt[6:8]) else: if int(dt[2:4]) > 12 or int(dt[2:4]) < 1 or int( dt[0:2]) > 31 or int(dt[0:2]) < 1: exit( cool.fuchsia( "[!] {} date format: 1<= month <=12 and 1<= day <=31{}" .format(desc, pyoptions.CRLF))) else: return int(dt[4:8]), int(dt[2:4]), int(dt[0:2])
def cutout_filter(lists, start='pos-1', end='pos--1', cutout_is_filter=False): start_pos = 0 end_pos = len(lists) def pos_change(position, init_pos, is_start=True): final_pos = init_pos try: match = re.match('pos-(\d*)', position) if match.group(1): final_pos = int(match.group(1)) - 1 if is_start else int( match.group(1)) else: match = re.match('pos--(\d*)', position) if match.group(1): pos = -int(match.group(1)) if is_start: final_pos = pos - 1 if pos >= 1 else len(lists) + pos else: final_pos = pos if pos >= 1 else len(lists) + pos + 1 except: pos = 0 for _ in lists: if position == str(_): final_pos = pos if is_start else pos + 1 pos += 1 return final_pos if lists and cutout_is_filter: start_pos = pos_change(start, start_pos, is_start=True) end_pos = pos_change(end, end_pos, is_start=False) if start_pos == 0 and start != 'pos-1': print( cool.fuchsia('[!] invalid start position changed' + pyoptions.CRLF)) elif end_pos == len(lists) and end != 'pos--1': print( cool.fuchsia('[!] invalid end position changed' + pyoptions.CRLF)) elif start_pos >= end_pos: start_pos = 0 end_pos = len(lists) exit( cool.red('[!] start string behind from the end string' + pyoptions.CRLF)) elif start_pos > len(lists) - 1: print(cool.fuchsia('[!] invalid position changed' + pyoptions.CRLF)) elif end_pos > len(lists): print( cool.fuchsia('[!] end position beyond the scope' + pyoptions.CRLF)) for _ in lists[start_pos:end_pos]: return _ else: for _ in lists: return _
def tool_parser(): if len(pyoptions.args_tool) >= 1: if pyoptions.args_tool[0] in pystrs.tool_range: # shredder if pyoptions.args_tool[0] == pystrs.tool_range[0]: if len(pyoptions.args_tool) == 1 and os.listdir( paths.results_path): shredder_enter(paths.results_path) elif len(pyoptions.args_tool) == 1: exit(pyoptions.CRLF + cool.orange("[+] %s has been clean" % paths.results_path)) elif len(pyoptions.args_tool) == 2: shredder_enter(pyoptions.args_tool[1]) else: exit(pyoptions.CRLF + cool.red("[-] %s arguments wrong" % pystrs.tool_range[0])) print("[+] Cost :{} seconds".format( cool.orange(str(time.time() - pystrs.startime)[:6]))) # uniqifer elif len(pyoptions.args_tool ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[1]: if os.path.isfile(pyoptions.args_tool[1]): uniqifer_enter(pyoptions.args_tool[1]) else: exit(pyoptions.CRLF + "[-] Please specify the exists file for %s" % cool.red(pystrs.tool_range[1])) # counter elif len(pyoptions.args_tool ) >= 2 and pyoptions.args_tool[0] == pystrs.tool_range[2]: counter_enter(pyoptions.encode, pyoptions.head, pyoptions.tail, pyoptions.args_tool) # combiner elif len(pyoptions.args_tool ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[3]: combiner_enter(pyoptions.args_tool[1]) # uniqbiner elif len(pyoptions.args_tool ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[4]: uniqbiner_enter(pyoptions.args_tool[1]) else: exit(pyoptions.CRLF + cool.red("[-] Need other extra arguments")) else: exit(pyoptions.CRLF + cool.red("[-] No tool named %s" % pyoptions.args_tool[0]) + pyoptions.CRLF + "[!] Choose tool from ({0}, {1}, {2}, {3}, {4})".format( cool.fuchsia(pystrs.tool_range[0]), cool.fuchsia(pystrs.tool_range[1]), cool.fuchsia(pystrs.tool_range[2]), cool.fuchsia(pystrs.tool_range[3]), cool.fuchsia(pystrs.tool_range[4]))) else: exit(pyoptions.CRLF + cool.red("[-] Please specified tool name"))
def do_encode(self, key): chunk = key.split(' ') if len(chunk) != 1: print(cool.fuchsia("[!] usage: encode type" + pyoptions.CRLF)) else: if chunk[0] in pystrs.encode_range: pyoptions.encode = chunk[0] print("[+] encode: {0}".format(cool.green(pyoptions.encode)) + pyoptions.CRLF) else: print( cool.fuchsia("[!] no encode type: %s" % chunk[0] + pyoptions.CRLF))
def check_date(dt, desc="datetime"): if len(dt) != 8 or not dt.isdigit(): exit( cool.fuchsia( "[!] {} format:[YYYYMMDD], such as:19900512{}".format( desc, pyoptions.CRLF))) elif int(dt[4:6]) > 12 or int(dt[4:6]) < 1 or int(dt[6:8]) > 31 or int( dt[6:8]) < 1: exit( cool.fuchsia( "[!] {} date format: 1<= month <=12 and 1<= day <=31{}". format(desc, pyoptions.CRLF))) else: return int(dt[:4]), int(dt[4:6]), int(dt[6:])
def do_set(self, args): arguments = [] for item in str(args).split(' '): arguments.append(item) option = arguments[0] if option in pystrs.sedb_dict.keys(): arguments.remove(option) sucessflag = True if option == pystrs.sedb_range[3] or option == pystrs.sedb_range[ 13]: for x in arguments: if len(x) != 8 or not x.isdigit(): sucessflag = False print( cool.fuchsia( "[!] Input format:[YYYYMMDD] exp:19900512" + pyoptions.CRLF)) elif int(x[4:6]) > 12 or int(x[4:6]) < 1 or int( x[6:8]) > 31 or int(x[6:8]) < 1: sucessflag = False print( cool.fuchsia( "[!] Date format {1 <= month <= 12} and {1 <= day <=31}" + pyoptions.CRLF)) else: pystrs.sedb_dict[option].append(x) elif option == pystrs.sedb_range[11]: for x in arguments: if len(x) < 15: sucessflag = False print( cool.fuchsia( "[!] Identity card number length too short (should >=15)" + pyoptions.CRLF)) else: pystrs.sedb_dict[pystrs.sedb_range[11]].append(x) else: for s in arguments: pystrs.sedb_dict[option].append(s) if sucessflag: self.do_show(option, setflag=True) elif option != '': print( cool.fuchsia("[!] no option named %s %s" % (option, pyoptions.CRLF))) else: print( cool.fuchsia("[!] please set option and arguments" + pyoptions.CRLF))
def counter_operator(original_file_path, justsave, justview, encodeflag, head, tail, vs_count=pyoptions.default_vs_items): items = Counter( open(original_file_path, 'r').read().replace(string.punctuation, "").split( pyoptions.counter_split)).most_common(vs_count) items_length = len(items) storepath = os.path.join( paths.results_path, "%s_%s%s" % (pystrs.COUNTER_prefix, mybuildtime(), pyoptions.filextension)) if vs_count > pyoptions.vs_counter_switcher: exit(pyoptions.CRLF + cool.fuchsia("[!] view items should Leq {0}".format( pyoptions.vs_counter_switcher))) elif items_length < vs_count: exit(pyoptions.CRLF + cool.fuchsia("[!] max items is {0}".format(items_length))) print("{0}Welcome to the COUNTER tool".format(" " * 8)) if justsave: with open(storepath, "a") as f: for _ in items: f.write( pyoptions.operator.get(encodeflag)(head + _[0] + tail) + pyoptions.CRLF) finishprinter(finishcounter(storepath), storepath) elif justview: print(pyoptions.CRLF * 2) for item in items: print("{0}Word:{2:20} -> {1:10} times".format( " " * 5, cool.orange(item[1]), cool.orange(item[0]))) print("[+] Cost:{} seconds".format( cool.orange(str(time.time() - pystrs.startime)[:6]))) else: print(pyoptions.CRLF * 2) for item in items: print("{0}Word:{2:20} -> {1:10} times".format( " " * 5, cool.orange(item[1]), cool.orange(item[0]))) print(pyoptions.CRLF) with open(storepath, 'a') as f: for _ in items: f.write( pyoptions.operator.get(encodeflag)(head + _[0] + tail) + pyoptions.CRLF) finishprinter(finishcounter(storepath), storepath)
def do_level(self, key): chunk = key.split(' ') if len(chunk) != 1: print(cool.fuchsia("[!] usage: level code" + pyoptions.CRLF)) else: try: if not 1 <= int(chunk[0]) <= 5: print(cool.fuchsia("[!] code range: 1-5" + pyoptions.CRLF)) else: pyoptions.level = int(chunk[0]) print("[+] level code: {}".format( cool.green(pyoptions.level)) + pyoptions.CRLF) except: print( cool.fuchsia("[!] code must be a digital" + pyoptions.CRLF))
def comparer_magic(*args): """[minuend_file] [subtrahend_file]""" args = list(args[0]) if len(args) != 3: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) minuend_file = args[1] subtrahend_file = args[2] if not os.path.isfile(os.path.abspath(pyoptions.args_tool[1])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(minuend_file))) if not os.path.isfile(os.path.abspath(pyoptions.args_tool[2])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(subtrahend_file))) minuend_list = walk_pure_file(minuend_file) subtrahend_list = walk_pure_file(subtrahend_file) with open(storepath, "a") as f: for item in minuend_list: if item not in subtrahend_list: item = filterforfun(item) if item: f.write(item + pyoptions.CRLF) finishprinter(storepath)
def scratch_magic(*args): """[url_or_file]""" args = list(args[0]) if len(args) == 1: target = paths.scrapersites_path elif len(args) == 2: target = args[1] else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.plugins_info.get(args[0])))) sites = [] if os.path.isfile(target): with open(target, 'r') as f: for _ in f.readlines(): if _.startswith(pyoptions.annotator): pass else: sites.append(checkurl(_)) else: sites.append(checkurl(target)) rawlist = scratchword(sites) @magic def scratch(): return rawlist
def uniqbiner_magic(*args): """[dir]""" args = list(args[0]) if len(args) == 2: directory = os.path.abspath(args[1]) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format(args[0], pyoptions.tools_info.get(args[0])))) filepaths = [] combine_list = [] for rootpath, subdirsname, filenames in os.walk(directory): filepaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in filenames]) if len(filepaths) > 0: for _ in filepaths: if mimetypes.guess_type(_)[0] == 'text/plain': combine_list.append(_) tempath = finalsavepath("combiner") try: with open(tempath, "a") as f: for onefile in combine_list: with open(onefile, 'r') as tf: f.write(tf.read()) except Exception as ex: print(pyoptions.CRLF + cool.red("[-] Combine file failed, Looking: ")) exit(pyoptions.CRLF + traceback.print_exc()) @magic def uniqbiner(): with open(tempath) as o_f: for item in o_f.readlines(): yield item.strip() print("[+] Source of :{0} lines".format(cool.orange(finishcounter(tempath))))
def plug_parser(): if pyoptions.args_plug[0] not in pyoptions.plug_range: exit("[!] Choose plugin from ({0})".format( cool.fuchsia(",".join(pyoptions.plug_range)))) else: pyoptions.plugins_operator.get(pyoptions.args_plug[0])( pyoptions.args_plug)
def combiner_magic(*args): """[dir]""" args = list(args[0]) if len(args) == 2: directory = os.path.abspath(args[1]) if not os.path.isdir(os.path.abspath(directory)): exit(pyoptions.CRLF + cool.red("[-] path: {} don't exists".format(directory))) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) filepaths = [] combine_list = [] for rootpath, subdirsname, filenames in os.walk(directory): filepaths.extend( [os.path.abspath(os.path.join(rootpath, _)) for _ in filenames]) if len(filepaths) > 0: for _ in filepaths: if mimetypes.guess_type(_)[0] == 'text/plain': combine_list.append(_) try: with codecs.open(storepath, 'a', encoding="utf-8") as f: for onefile in combine_list: with codecs.open(onefile, 'r', encoding="utf-8") as tf: f.write(tf.read()) finishprinter(storepath) except Exception as ex: print(pyoptions.CRLF + cool.red("[-] Combine file failed, Looking: ")) traceback.print_exc()
def hybrider_magic(*args): """[file1] [file2] ...""" args = list(args[0]) filepaths = [] hybrid_list = [] if len(args) >= 2: for count in range(1, len(args)): directory = os.path.abspath(args[count]) if not os.path.isfile(os.path.abspath(directory)): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(directory))) else: filepaths.append(directory) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format(args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) try: for fp in filepaths: tmp = set() with open(fp, "r") as f: for line in f: tmp.add(line.strip()) hybrid_list.append(tmp) with open(storepath, "a") as f: for item in itertools.product(*hybrid_list): f.write(pyoptions.operator.get(pyoptions.encode)(pyoptions.head + "".join(item) + pyoptions.tail) + pyoptions.CRLF) finishprinter(storepath) except Exception as ex: print(pyoptions.CRLF + cool.red("[-] Hybrid files failed, Looking: ")) exit(pyoptions.CRLF + traceback.print_exc())
def printabler_magic(*args): """[filepath]""" args = list(args[0]) if len(args) >= 2: filepath = args[1] else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format(args[0], pyoptions.tools_info.get(args[0])))) if not os.path.isfile(filepath): exit(cool.red("[-] File don't exits" + pyoptions.CRLF)) @magic def printabler(): is_py3 = py_ver_egt_3() if is_py3: f = open(filepath, 'r', encoding='utf8', errors='replace') else: import codecs f = codecs.open(filepath, 'r', encoding='utf8', errors='replace') for item in f: item = item.strip() if item: ret = filter(lambda x: x in string.printable, item) if is_py3: if len(list(ret)) == len(item): yield item else: if len(ret) == len(item): yield item f.close()
def do_tail(self, key): chunk = key.split(' ') if len(chunk) != 1: print(cool.fuchsia("[!] usage: tail suffix" + pyoptions.CRLF)) else: pyoptions.tail = chunk[0] print("[+] tail: {0}".format(cool.green(pyoptions.tail)) + pyoptions.CRLF)
def do_head(self, key): chunk = key.split(' ') if len(chunk) != 1: print(cool.fuchsia("[!] usage: head prefix" + pyoptions.CRLF)) else: pyoptions.head = chunk[0] print("[+] head: {0}".format(cool.green(pyoptions.head)) + pyoptions.CRLF)
def check_range(s, e): if s[0] > e[0] or (s[0] == e[0] and s[1] > e[1]) or (s[1] == e[1] and s[2] > e[2]): exit( cool.fuchsia("[!] Start date should later than End date" + pyoptions.CRLF)) else: return True
def tool_parser(): if len(pyoptions.args_tool) >= 1: if pyoptions.args_tool[0] in pyoptions.tool_range: pyoptions.tools_operator.get(pyoptions.args_tool[0])( pyoptions.args_tool) else: exit(pyoptions.CRLF + "[!] Choose tool from ({})".format( cool.fuchsia(" ".join(pyoptions.tool_range)))) else: exit(pyoptions.CRLF + cool.red("[-] Please specified tool name"))
def do_len(self, key): chunk = key.split(' ') if len(chunk) != 2: print(cool.fuchsia("[!] usage: len minlen maxlen" + pyoptions.CRLF)) else: minlen = chunk[0] maxlen = chunk[1] try: pyoptions.args_pick = True pyoptions.minlen = int(minlen) pyoptions.maxlen = int(maxlen) print("[+] minlen: {0} maxlen: {1}".format( cool.green(pyoptions.minlen), cool.green(pyoptions.maxlen)) + pyoptions.CRLF) except: print( cool.fuchsia("[!] ensure length is digital" + pyoptions.CRLF))
def do_regex(self, key): chunk = key.split(' ') if len(chunk) != 1: print( cool.fuchsia("[!] usage: regex filter-string" + pyoptions.CRLF)) else: pyoptions.filter_regex = chunk[0] print("[+] regex: {0}".format(cool.green(pyoptions.filter_regex)) + pyoptions.CRLF)
def do_leet(self, key): chunk = key.split(' ') if not chunk: print( cool.fuchsia("[!] usage: leet code code2 code3 ...") + pyoptions.CRLF) else: pyoptions.leetmode_code = [] for c in chunk: if str(c).isdigit() and (0 <= int(c) <= 2 or 11 <= int(c) <= 19 or 21 <= int(c) <= 29): pyoptions.sedb_leet = True pyoptions.leetmode_code.append(int(c)) else: print( cool.fuchsia("[!] code vaule:[0, 1, 2, 11-19, 21-29]") + pyoptions.CRLF) print( cool.white("[+] leet code: {0}".format(" ".join( map(str, pyoptions.leetmode_code)))) + pyoptions.CRLF)
def counter_operator(original_file_path, justsave, justview, vs_count=pyoptions.default_vs_items): items = Counter( open(original_file_path, 'r').read().replace(string.punctuation, "").split( pyoptions.counter_split)).most_common(vs_count) items_length = len(items) if vs_count > pyoptions.vs_counter_switcher: exit(pyoptions.CRLF + cool.fuchsia("[!] view items should Leq {0}".format( pyoptions.vs_counter_switcher))) elif items_length < vs_count: exit(pyoptions.CRLF + cool.fuchsia("[!] max items is {0}".format(items_length))) if justsave: @magic def counter(): for _ in items: yield _[0] elif justview: print(pyoptions.CRLF * 2) for item in items: print("{0}Word:{2:20} -> {1:10} times".format( " " * 5, cool.orange(item[1]), cool.orange(item[0]))) print("[+] Cost:{} seconds".format( cool.orange(str(time.time() - pystrs.startime)[:6]))) else: print(pyoptions.CRLF * 2) for item in items: print("{0}Word:{2:20} -> {1:10} times".format( " " * 5, cool.orange(item[1]), cool.orange(item[0]))) @magic def counter(): for _ in items: yield _[0]
def do_rm(self, key): if key in pystrs.sedb_dict.keys(): pystrs.sedb_dict[key] = [] print( cool.white("[+] %s option was removed %s" % (key, pyoptions.CRLF))) elif key == '': for key in pystrs.sedb_dict.keys(): pystrs.sedb_dict[key] = [] print(cool.white("[+] all option was removed" + pyoptions.CRLF)) else: print( cool.fuchsia("[!] no option named %s %s" % (key, pyoptions.CRLF)))
def do_output(self, key): chunk = key.split(' ') if len(chunk) != 1: print(cool.fuchsia("[!] usage: output store_path" + pyoptions.CRLF)) elif not chunk[0]: print(cool.fuchsia("[!] usage: output store_path" + pyoptions.CRLF)) else: try: if not os.path.isdir(chunk[0]): tmp_dirpath, tmp_filename = os.path.split(chunk[0]) if '.' in tmp_filename: if not os.path.isdir(tmp_dirpath): os.makedirs(tmp_dirpath) paths.results_path = tmp_dirpath paths.results_file_name = tmp_filename else: if not os.path.isdir(chunk[0]): os.makedirs(chunk[0]) paths.results_path = chunk[0] else: paths.results_path = chunk[0] except WindowsError: print(pyoptions.CRLF + cool.red("[-] Cannot create result file: %s " % paths.results_path)) finally: this_name = '%s_%s%s' % (pystrs.SEDB_prefix, mybuildtime(), pyoptions.filextension) \ if paths.results_file_name == None \ else paths.results_file_name print("[+] store path: {0}".format( cool.green( os.path.join( paths.results_path, this_name if paths.results_file_name != None else ''))) + pyoptions.CRLF)
def birthday_magic(*args): """[begin_date] [end_date], date format: [YYYYMMDD]""" args = list(args[0]) if len(args) == 3: begin_date = args[1] end_date = args[2] else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.plugins_info.get(args[0])))) def check_date(dt, desc="datetime"): if len(dt) != 8 or not dt.isdigit(): exit( cool.fuchsia( "[!] {} format:[YYYYMMDD], such as:19900512{}".format( desc, pyoptions.CRLF))) elif int(dt[4:6]) > 12 or int(dt[4:6]) < 1 or int(dt[6:8]) > 31 or int( dt[6:8]) < 1: exit( cool.fuchsia( "[!] {} date format: 1<= month <=12 and 1<= day <=31{}". format(desc, pyoptions.CRLF))) else: return int(dt[:4]), int(dt[4:6]), int(dt[6:]) def check_range(s, e): if s[0] > e[0] or (s[0] == e[0] and s[1] > e[1]) or (s[1] == e[1] and s[2] > e[2]): exit( cool.fuchsia("[!] Start date should later than End date" + pyoptions.CRLF)) else: return True @magic def birthday(): start_valid = check_date(begin_date, desc="Start datetime") end_valid = check_date(end_date, desc="End datetime") valid = check_range(start_valid, end_valid) if start_valid and end_valid else False if valid: res = [] begin = datetime.datetime.strptime(begin_date, "%Y%m%d") end = datetime.datetime.strptime(end_date, "%Y%m%d") while begin <= end: date_str = begin.strftime("%Y%m%d") res.extend(dateshaper(date_str, is_en)) begin += datetime.timedelta(days=1) return res
def counter_magic(*args): """['v','s','vs'] [file] [view_num]""" args = list(args[0]) # counter lack file argument if len(args) == 2 and args[1] in pystrs.counter_cmd_range: exit(pyoptions.CRLF + cool.red("[-] {0} need specify the file path".format( pyoptions.tool_range[2]))) # counter elif len(args) >= 3: if args[1] not in pystrs.counter_cmd_range: exit(pyoptions.CRLF + cool.red( "[-] Need {0}'s options, choose from '{1}' or '{2}' or '{3}'". format(args[0], pystrs.counter_cmd_range[0], pystrs. counter_cmd_range[1], pystrs.counter_cmd_range[2]))) if os.path.isfile(args[2]): # counter s file if len(args) == 3 and args[1] == pystrs.just_save_counter: counter_operator(args[2], True, False) # counter v file elif len(args) == 3 and args[1] == pystrs.just_view_counter: counter_operator(args[2], False, True) # counter vs file elif len(args) == 3 and args[1] == pystrs.save_and_view: counter_operator(args[2], False, False) # counter v file 100 elif len( args) == 4 and args[1] == pystrs.just_view_counter and str( args[3]).isdigit(): counter_operator(args[2], False, True, vs_count=int(args[3])) # counter s file 100 elif len( args) == 4 and args[1] == pystrs.just_save_counter and str( args[3]).isdigit(): counter_operator(args[2], True, False, vs_count=int(args[3])) # counter vs file 100 elif len(args) == 4 and args[1] == pystrs.save_and_view and str( args[3]).isdigit(): counter_operator(args[2], False, False, vs_count=int(args[3])) else: exit(pyoptions.CRLF + cool.red("[-] Some unexpected input")) else: exit(pyoptions.CRLF + cool.red("[-] File: %s not exists" % args[2])) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0]))))
def do_len(self, key): chunk = key.split(' ') if len(chunk) != 2: print(cool.fuchsia("[!] usage: len minlen maxlen" + pyoptions.CRLF)) else: minlen = key.split(' ')[0] maxlen = key.split(' ')[1] if lengthchecker(minlen, maxlen, sedb=True): pyoptions.args_pick = True pyoptions.minlen = int(minlen) pyoptions.maxlen = int(maxlen) print( cool.white("[+] minlen: {0} maxlen: {1}".format( pyoptions.minlen, pyoptions.maxlen)) + pyoptions.CRLF)
def comparer_magic(*args): """[minuend_file] [subtrahend_file]""" args = list(args[0]) if len(args) != 3: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) minuend_file = args[1] subtrahend_file = args[2] if not os.path.isfile(os.path.abspath(pyoptions.args_tool[1])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(minuend_file))) if not os.path.isfile(os.path.abspath(pyoptions.args_tool[2])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(subtrahend_file))) minuend_list = walk_pure_file(minuend_file) subtrahend_list = walk_pure_file(subtrahend_file) with open(storepath, "a") as f: for item in minuend_list: if item not in subtrahend_list: item = filterforfun( item, head=pyoptions.head, tail=pyoptions.tail, lenght_is_filter=pyoptions.args_pick, minlen=pyoptions.minlen, maxlen=pyoptions.maxlen, regex_is_filter=True, regex=pyoptions.filter_regex, encode_is_filter=True, encode=pyoptions.encode, occur_is_filter=True, letter_occur=pyoptions.letter_occur, digital_occur=pyoptions.digital_occur, special_occur=pyoptions.special_occur, types_is_filter=True, letter_types=pyoptions.letter_types, digital_types=pyoptions.digital_types, special_types=pyoptions.special_types, ) if item: f.write(item + pyoptions.CRLF) finishprinter(storepath)