def getIDCardPost(posflag, encodeflag, head, tail, sex): storepath = os.path.join( get_result_store_path(), "%s_%s_%s_%s%s" % (IDCARD_prefix, str(posflag)[-1:], get_buildtime(), encodeflag, filextension)) posrule = lambda _: str(_) if _ >= 10 else "0" + str(_) # month value1112 = " ".join(posrule(x) for x in range_compatible(1, 13)) # day value1314 = " ".join(posrule(x) for x in range_compatible(1, 32)) value1516 = " ".join(posrule(x) for x in range_compatible(1, 100)) post18 = "0 1 2 3 4 5 6 7 8 9 X" value1718 = "" if sex == 'm': rand = "1 3 5 7 9" for _ in rand.split(' '): for _p in post18.split(' '): value1718 += _ + _p + " " elif sex == 'f': rand = "0 2 4 6 8" for _ in rand.split(' '): for _p in post18.split(' '): value1718 += _ + _p + " " else: rand = " ".join(str(_) for _ in range_compatible(0, 10)) for _ in rand.split(' '): for _p in post18.split(' '): value1718 += _ + _p + " " with open(storepath, "w") as f: if posflag == 'pid8': for v1112 in value1112.split(' '): for v1314 in value1314.split(' '): for v1516 in value1516.split(' '): for v1718 in value1718.split(' '): if v1718 != "": if encodeflag == "": f.write(head + v1112 + v1314 + v1516 + v1718 + tail + CRLF) else: f.write( operator.get(encodeflag) (head + v1112 + v1314 + v1516 + v1718 + tail) + CRLF) elif posflag == 'pid6': for v1314 in value1314.split(' '): for v1516 in value1516.split(' '): for v1718 in value1718.split(' '): if v1718 != "": if encodeflag == "": f.write(head + v1314 + v1516 + v1718 + tail + CRLF) else: f.write( operator.get(encodeflag) (head + v1314 + v1516 + v1718 + tail) + CRLF) finishprinter(finishcounter(storepath), storepath)
def shreder_dir(directory, rewritecounts=dir_rewrite_count): filepaths = [] dirpaths = [] print(CRLF + "[+] Shredding '%s' ..." % cool.orange(directory)) try: newdirectoryname = os.path.join( os.path.dirname(directory), "".join( chr(random.randint(97, 122)) for _ in range_compatible(1, 6))) os.rename(directory, newdirectoryname) directory = newdirectoryname except: traceback.print_exc() exit(CRLF + cool.red( "[-] Error: cannot rename root directory name, Please check permissions" )) for rootpath, subdirsname, filenames in os.walk(directory): # get all directories dirpaths.extend( [os.path.abspath(os.path.join(rootpath, _)) for _ in subdirsname]) # get all absolute file path filepaths.extend( [os.path.abspath(os.path.join(rootpath, _)) for _ in filenames]) for filepath in filepaths: try: os.chmod(filepath, stat.S_IREAD | stat.S_IWRITE) except: pass for _ in range_compatible(0, rewritecounts): print("[+] Rewrite count: %d" % (_ + 1)) for filepath in filepaths: rewrite(filepath) for filepath in filepaths: truncating(filepath) for filepath in filepaths: renamefile(filepath) renamedir(dirpaths) os.chdir(os.path.join(directory, "..")) try: shutil.rmtree(directory) except OSError as ex: print( cool.fuchsia("[!] Error: Cannot removing directory: '%s' " % directory)) traceback.print_exc() print(cool.orange("[+] Completely!"))
def truncating(filepath): # default: 2 times for _ in range_compatible(0, 2): try: with open(filepath, "w"): pass except: pass
def rewrite(filepath): try: filesize = os.path.getsize(filepath) with open(filepath, "w+b") as f: f.write("".join( chr(random.randint(0, 255)) for _ in range_compatible(0, filesize))) except: pass
def get_idcard_post(posflag, encodeflag, head, tail, sex): storepath = os.path.join(get_result_store_path(), "%s_%s_%s_%s%s" % (IDCARD_prefix, str(posflag)[-1:], get_buildtime(), encodeflag, filextension)) posrule = lambda _: str(_) if _ >= 10 else "0" + str(_) # month value1112 = " ".join(posrule(x) for x in range_compatible(1, 13)) # day value1314 = " ".join(posrule(x) for x in range_compatible(1, 32)) value1516 = " ".join(posrule(x) for x in range_compatible(1, 100)) post18 = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X") value1718 = "" if sex == sex_range[0]: rand = ("1", "3", "5", "7", "9") for _ in rand: for _p in post18: value1718 += _ + _p + " " elif sex == sex_range[1]: rand = ("0", "2", "4", "6", "8") for _ in rand: for _p in post18: value1718 += _ + _p + " " elif sex == sex_range[2]: rand = " ".join(str(_) for _ in range_compatible(0, 10)) for _ in rand.split(" "): for _p in post18: value1718 += _ + _p + " " with open(storepath, "a") as f: if posflag == plug_range[1]: for v1112 in value1112.split(" "): for v1314 in value1314.split(" "): for v1516 in value1516.split(" "): for v1718 in value1718.split(" "): if v1718 != "": f.write(operator.get(encodeflag)(head + v1112 + v1314 + v1516 + v1718 + tail) + CRLF) elif posflag == plug_range[0]: for v1314 in value1314.split(" "): for v1516 in value1516.split(" "): for v1718 in value1718.split(" "): if v1718 != "": f.write(operator.get(encodeflag)(head + v1314 + v1516 + v1718 + tail) + CRLF) finishprinter(finishcounter(storepath), storepath)
def shreder_file(filepath, rewritecounts=file_rewrite_count): try: os.chmod(filepath, stat.S_IREAD | stat.S_IWRITE) except: pass for _ in range_compatible(0, rewritecounts): rewrite(filepath) truncating(filepath) newname = renamefile(filepath) os.remove(newname) print("[+] Shredded %s Completely!" % cool.orange(filepath))
def get_conf_dic(minlength, maxlength, objflag, encodeflag, head, tail): diclist = [] for i in range_compatible(minlength, maxlength + 1): for item in itertools.product(objflag, repeat=i): if encodeflag in operator.keys(): diclist.append( operator.get(encodeflag)(head + "".join(item) + tail)) else: exit(CRLF + cool.red('[-] wrong encode type')) # items count check countchecker(-1, len(diclist)) return diclist
def get_base_dic(minlength, maxlength, objflag, encodeflag, head, tail): countchecker(len(objflag), minlength, maxlength) global description storepath = os.path.join( get_result_store_path(), "%s_%s_%s_%s_%s_%s%s" % (BASE_prefix, minlength, maxlength, description, get_buildtime(), encodeflag, filextension)) with open(storepath, "w") as f: for i in range_compatible(minlength, maxlength + 1): for item in itertools.product(objflag, repeat=i): if encodeflag == "": f.write(head + "".join(item) + tail + CRLF) else: f.write( operator.get(encodeflag)(head + "".join(item) + tail) + CRLF) finishprinter(finishcounter(storepath), storepath)
def get_base_dic(minlength, maxlength, objflag, encodeflag, head, tail, need_char_dic=False): objflag = getchars(objflag, need_char=need_char_dic) countchecker(len(objflag), minlength, maxlength) global description dict_prefix = BASE_prefix if need_char_dic: dict_prefix = CHAR_prefix storepath = os.path.join( get_result_store_path(), "%s_%s_%s_%s_%s_%s%s" % (dict_prefix, minlength, maxlength, description, get_buildtime(), encodeflag, filextension)) with open(storepath, "a") as f: for i in range_compatible(minlength, maxlength + 1): for item in itertools.product(objflag, repeat=i): f.write( operator.get(encodeflag)(head + "".join(item) + tail) + CRLF) finishprinter(finishcounter(storepath), storepath)