diff --git a/cupp.py b/cupp.py index 32d24ee..8b8af45 100755 --- a/cupp.py +++ b/cupp.py @@ -41,6 +41,7 @@ import urllib.parse import urllib.request import time +from wordlist_generator import Generator as wg __author__ = "Mebus" __license__ = "GPL" @@ -370,343 +371,7 @@ def interactive(): ).lower() profile["leetmode"] = input("> Leet mode? (i.e. leet = 1337) Y/[N]: ").lower() - generate_wordlist_from_profile(profile) # generate the wordlist - - -def generate_wordlist_from_profile(profile): - """ Generates a wordlist from a given profile """ - - chars = CONFIG["global"]["chars"] - years = CONFIG["global"]["years"] - numfrom = CONFIG["global"]["numfrom"] - numto = CONFIG["global"]["numto"] - - profile["spechars"] = [] - - if profile["spechars1"] == "y": - for spec1 in chars: - profile["spechars"].append(spec1) - for spec2 in chars: - profile["spechars"].append(spec1 + spec2) - for spec3 in chars: - profile["spechars"].append(spec1 + spec2 + spec3) - - print("\r\n[+] Now making a dictionary...") - - # Now me must do some string modifications... - - # Birthdays first - - birthdate_yy = profile["birthdate"][-2:] - birthdate_yyy = profile["birthdate"][-3:] - birthdate_yyyy = profile["birthdate"][-4:] - birthdate_xd = profile["birthdate"][1:2] - birthdate_xm = profile["birthdate"][3:4] - birthdate_dd = profile["birthdate"][:2] - birthdate_mm = profile["birthdate"][2:4] - - wifeb_yy = profile["wifeb"][-2:] - wifeb_yyy = profile["wifeb"][-3:] - wifeb_yyyy = profile["wifeb"][-4:] - wifeb_xd = profile["wifeb"][1:2] - wifeb_xm = profile["wifeb"][3:4] - wifeb_dd = profile["wifeb"][:2] - wifeb_mm = profile["wifeb"][2:4] - - kidb_yy = profile["kidb"][-2:] - kidb_yyy = profile["kidb"][-3:] - kidb_yyyy = profile["kidb"][-4:] - kidb_xd = profile["kidb"][1:2] - kidb_xm = profile["kidb"][3:4] - kidb_dd = profile["kidb"][:2] - kidb_mm = profile["kidb"][2:4] - - # Convert first letters to uppercase... - - nameup = profile["name"].title() - surnameup = profile["surname"].title() - nickup = profile["nick"].title() - wifeup = profile["wife"].title() - wifenup = profile["wifen"].title() - kidup = profile["kid"].title() - kidnup = profile["kidn"].title() - petup = profile["pet"].title() - companyup = profile["company"].title() - - wordsup = [] - wordsup = list(map(str.title, profile["words"])) - - word = profile["words"] + wordsup - - # reverse a name - - rev_name = profile["name"][::-1] - rev_nameup = nameup[::-1] - rev_nick = profile["nick"][::-1] - rev_nickup = nickup[::-1] - rev_wife = profile["wife"][::-1] - rev_wifeup = wifeup[::-1] - rev_kid = profile["kid"][::-1] - rev_kidup = kidup[::-1] - - reverse = [ - rev_name, - rev_nameup, - rev_nick, - rev_nickup, - rev_wife, - rev_wifeup, - rev_kid, - rev_kidup, - ] - rev_n = [rev_name, rev_nameup, rev_nick, rev_nickup] - rev_w = [rev_wife, rev_wifeup] - rev_k = [rev_kid, rev_kidup] - # Let's do some serious work! This will be a mess of code, but... who cares? :) - - # Birthdays combinations - - bds = [ - birthdate_yy, - birthdate_yyy, - birthdate_yyyy, - birthdate_xd, - birthdate_xm, - birthdate_dd, - birthdate_mm, - ] - - bdss = [] - - for bds1 in bds: - bdss.append(bds1) - for bds2 in bds: - if bds.index(bds1) != bds.index(bds2): - bdss.append(bds1 + bds2) - for bds3 in bds: - if ( - bds.index(bds1) != bds.index(bds2) - and bds.index(bds2) != bds.index(bds3) - and bds.index(bds1) != bds.index(bds3) - ): - bdss.append(bds1 + bds2 + bds3) - - # For a woman... - wbds = [wifeb_yy, wifeb_yyy, wifeb_yyyy, wifeb_xd, wifeb_xm, wifeb_dd, wifeb_mm] - - wbdss = [] - - for wbds1 in wbds: - wbdss.append(wbds1) - for wbds2 in wbds: - if wbds.index(wbds1) != wbds.index(wbds2): - wbdss.append(wbds1 + wbds2) - for wbds3 in wbds: - if ( - wbds.index(wbds1) != wbds.index(wbds2) - and wbds.index(wbds2) != wbds.index(wbds3) - and wbds.index(wbds1) != wbds.index(wbds3) - ): - wbdss.append(wbds1 + wbds2 + wbds3) - - # and a child... - kbds = [kidb_yy, kidb_yyy, kidb_yyyy, kidb_xd, kidb_xm, kidb_dd, kidb_mm] - - kbdss = [] - - for kbds1 in kbds: - kbdss.append(kbds1) - for kbds2 in kbds: - if kbds.index(kbds1) != kbds.index(kbds2): - kbdss.append(kbds1 + kbds2) - for kbds3 in kbds: - if ( - kbds.index(kbds1) != kbds.index(kbds2) - and kbds.index(kbds2) != kbds.index(kbds3) - and kbds.index(kbds1) != kbds.index(kbds3) - ): - kbdss.append(kbds1 + kbds2 + kbds3) - - # string combinations.... - - kombinaac = [profile["pet"], petup, profile["company"], companyup] - - kombina = [ - profile["name"], - profile["surname"], - profile["nick"], - nameup, - surnameup, - nickup, - ] - - kombinaw = [ - profile["wife"], - profile["wifen"], - wifeup, - wifenup, - profile["surname"], - surnameup, - ] - - kombinak = [ - profile["kid"], - profile["kidn"], - kidup, - kidnup, - profile["surname"], - surnameup, - ] - - kombinaa = [] - for kombina1 in kombina: - kombinaa.append(kombina1) - for kombina2 in kombina: - if kombina.index(kombina1) != kombina.index(kombina2) and kombina.index( - kombina1.title() - ) != kombina.index(kombina2.title()): - kombinaa.append(kombina1 + kombina2) - - kombinaaw = [] - for kombina1 in kombinaw: - kombinaaw.append(kombina1) - for kombina2 in kombinaw: - if kombinaw.index(kombina1) != kombinaw.index(kombina2) and kombinaw.index( - kombina1.title() - ) != kombinaw.index(kombina2.title()): - kombinaaw.append(kombina1 + kombina2) - - kombinaak = [] - for kombina1 in kombinak: - kombinaak.append(kombina1) - for kombina2 in kombinak: - if kombinak.index(kombina1) != kombinak.index(kombina2) and kombinak.index( - kombina1.title() - ) != kombinak.index(kombina2.title()): - kombinaak.append(kombina1 + kombina2) - - kombi = {} - kombi[1] = list(komb(kombinaa, bdss)) - kombi[1] += list(komb(kombinaa, bdss, "_")) - kombi[2] = list(komb(kombinaaw, wbdss)) - kombi[2] += list(komb(kombinaaw, wbdss, "_")) - kombi[3] = list(komb(kombinaak, kbdss)) - kombi[3] += list(komb(kombinaak, kbdss, "_")) - kombi[4] = list(komb(kombinaa, years)) - kombi[4] += list(komb(kombinaa, years, "_")) - kombi[5] = list(komb(kombinaac, years)) - kombi[5] += list(komb(kombinaac, years, "_")) - kombi[6] = list(komb(kombinaaw, years)) - kombi[6] += list(komb(kombinaaw, years, "_")) - kombi[7] = list(komb(kombinaak, years)) - kombi[7] += list(komb(kombinaak, years, "_")) - kombi[8] = list(komb(word, bdss)) - kombi[8] += list(komb(word, bdss, "_")) - kombi[9] = list(komb(word, wbdss)) - kombi[9] += list(komb(word, wbdss, "_")) - kombi[10] = list(komb(word, kbdss)) - kombi[10] += list(komb(word, kbdss, "_")) - kombi[11] = list(komb(word, years)) - kombi[11] += list(komb(word, years, "_")) - kombi[12] = [""] - kombi[13] = [""] - kombi[14] = [""] - kombi[15] = [""] - kombi[16] = [""] - kombi[21] = [""] - if profile["randnum"] == "y": - kombi[12] = list(concats(word, numfrom, numto)) - kombi[13] = list(concats(kombinaa, numfrom, numto)) - kombi[14] = list(concats(kombinaac, numfrom, numto)) - kombi[15] = list(concats(kombinaaw, numfrom, numto)) - kombi[16] = list(concats(kombinaak, numfrom, numto)) - kombi[21] = list(concats(reverse, numfrom, numto)) - kombi[17] = list(komb(reverse, years)) - kombi[17] += list(komb(reverse, years, "_")) - kombi[18] = list(komb(rev_w, wbdss)) - kombi[18] += list(komb(rev_w, wbdss, "_")) - kombi[19] = list(komb(rev_k, kbdss)) - kombi[19] += list(komb(rev_k, kbdss, "_")) - kombi[20] = list(komb(rev_n, bdss)) - kombi[20] += list(komb(rev_n, bdss, "_")) - komb001 = [""] - komb002 = [""] - komb003 = [""] - komb004 = [""] - komb005 = [""] - komb006 = [""] - if len(profile["spechars"]) > 0: - komb001 = list(komb(kombinaa, profile["spechars"])) - komb002 = list(komb(kombinaac, profile["spechars"])) - komb003 = list(komb(kombinaaw, profile["spechars"])) - komb004 = list(komb(kombinaak, profile["spechars"])) - komb005 = list(komb(word, profile["spechars"])) - komb006 = list(komb(reverse, profile["spechars"])) - - print("[+] Sorting list and removing duplicates...") - - komb_unique = {} - for i in range(1, 22): - komb_unique[i] = list(dict.fromkeys(kombi[i]).keys()) - - komb_unique01 = list(dict.fromkeys(kombinaa).keys()) - komb_unique02 = list(dict.fromkeys(kombinaac).keys()) - komb_unique03 = list(dict.fromkeys(kombinaaw).keys()) - komb_unique04 = list(dict.fromkeys(kombinaak).keys()) - komb_unique05 = list(dict.fromkeys(word).keys()) - komb_unique07 = list(dict.fromkeys(komb001).keys()) - komb_unique08 = list(dict.fromkeys(komb002).keys()) - komb_unique09 = list(dict.fromkeys(komb003).keys()) - komb_unique010 = list(dict.fromkeys(komb004).keys()) - komb_unique011 = list(dict.fromkeys(komb005).keys()) - komb_unique012 = list(dict.fromkeys(komb006).keys()) - - uniqlist = ( - bdss - + wbdss - + kbdss - + reverse - + komb_unique01 - + komb_unique02 - + komb_unique03 - + komb_unique04 - + komb_unique05 - ) - - for i in range(1, 21): - uniqlist += komb_unique[i] - - uniqlist += ( - komb_unique07 - + komb_unique08 - + komb_unique09 - + komb_unique010 - + komb_unique011 - + komb_unique012 - ) - unique_lista = list(dict.fromkeys(uniqlist).keys()) - unique_leet = [] - if profile["leetmode"] == "y": - for ( - x - ) in ( - unique_lista - ): # if you want to add more leet chars, you will need to add more lines in cupp.cfg too... - - x = make_leet(x) # convert to leet - unique_leet.append(x) - - unique_list = unique_lista + unique_leet - - unique_list_finished = [] - unique_list_finished = [ - x - for x in unique_list - if len(x) < CONFIG["global"]["wcto"] and len(x) > CONFIG["global"]["wcfrom"] - ] - - print_to_file(profile["name"] + ".txt", unique_list_finished) - + wg(profile, CONFIG) # generate the wordlist def download_http(url, targetfile): print("[+] Downloading " + targetfile + " from " + url + " ... ") diff --git a/wordlist_generator.py b/wordlist_generator.py new file mode 100644 index 0000000..601f0c3 --- /dev/null +++ b/wordlist_generator.py @@ -0,0 +1,266 @@ +import os + +class Generator(): + + # print list to file counting words + def print_to_file(self, filename, unique_list_finished): + f = open(filename, "w") + f.write(os.linesep.join(unique_list_finished)) + f.close() + lines = len(unique_list_finished) + # f = open(filename, "r") + # lines = 0 + # for line in f: + # lines += 1 + # f.close() + print( + "[+] Saving dictionary to \033[1;31m" + + filename + + "\033[1;m, counting \033[1;31m" + + str(lines) + + " words.\033[1;m" + ) + print( + "[+] Now load your pistolero with \033[1;31m" + + filename + + "\033[1;m and shoot! Good luck!" + ) + + def make_leet(self, x, CONFIG): + """convert string to leet""" + for letter, leetletter in CONFIG["LEET"].items(): + x = x.replace(letter, leetletter) + return x + + # for concatenations... + def concats(self, seq, start, stop): + final= [] + for array in seq: + for word in array: + for num in range(start, stop): + final.append(word + str(num)) + return final + + def reduce_array(self, array): + return list(set(array)) + + def compare_and_reduce(self, array1, array2): + inter = set(array1).intersection(array2) + for i in inter: + array1.remove(i) + return array1 + + def birthdays_combinations(self, array): + new_array = [] + for bds1 in array: + new_array.append(bds1) + for bds2 in array: + if array.index(bds1) != array.index(bds2): + new_array.append(bds1 + bds2) + for bds3 in array: + if ( + array.index(bds1) != array.index(bds2) + and array.index(bds2) != array.index(bds3) + and array.index(bds1) != array.index(bds3) + ): + new_array.append(bds1 + bds2 + bds3) + return new_array + + def combine(self, first, second): + all = [] + for word1 in first: + for word2 in second: + all.append(word1+word2) + all.append(word1+"_"+word2) + return all + + def names_combinations(self, names): + combinations = [] + for kombina1 in names: + combinations.append(kombina1) + for kombina2 in names: + if names.index(kombina1) != names.index(kombina2) and names.index( + kombina1.title() + ) != names.index(kombina2.title()): + combinations.append(kombina1 + kombina2) + return combinations + + def generate_wordlist_from_profile(self, profile, CONFIG): + """ Generates a wordlist from a given profile """ + + chars = CONFIG["global"]["chars"] + years = CONFIG["global"]["years"] + numfrom = CONFIG["global"]["numfrom"] + numto = CONFIG["global"]["numto"] + + profile["spechars"] = [] + + if profile["spechars1"] == "y": + for spec1 in chars: + profile["spechars"].append(spec1) + for spec2 in chars: + profile["spechars"].append(spec1 + spec2) + for spec3 in chars: + profile["spechars"].append(spec1 + spec2 + spec3) + + print("\r\n[+] Now making a dictionary...") + + # Now me must do some string modifications... + + # Some array definitions + + # Birthdays first + bds = [ + profile["birthdate"][-2:], + profile["birthdate"][-3:], + profile["birthdate"][-4:], + profile["birthdate"][1:2], + profile["birthdate"][3:4], + profile["birthdate"][:2], + profile["birthdate"][2:4] + ] + + wbds = [ + profile["wifeb"][-2:], + profile["wifeb"][-3:], + profile["wifeb"][-4:], + profile["wifeb"][1:2], + profile["wifeb"][3:4], + profile["wifeb"][:2], + profile["wifeb"][2:4] + ] + + kbds = [ + profile["kidb"][-2:], + profile["kidb"][-3:], + profile["kidb"][-4:], + profile["kidb"][1:2], + profile["kidb"][3:4], + profile["kidb"][:2], + profile["kidb"][2:4] + ] + + # Convert first letters to uppercase... + + nameup = profile["name"].title() + surnameup = profile["surname"].title() + nickup = profile["nick"].title() + wifeup = profile["wife"].title() + wifenup = profile["wifen"].title() + kidup = profile["kid"].title() + kidnup = profile["kidn"].title() + + + # reverse a name + reverse_names = [ + profile["name"][::-1], + nameup[::-1], + profile["nick"][::-1], + nickup[::-1], + profile["wife"][::-1], + wifeup[::-1], + profile["kid"][::-1], + kidup[::-1], + ] + + # string combinations.... + + names_comp_pet = [ + profile["pet"], + profile["pet"].title(), + profile["company"], + profile["company"].title() + ] + + kombina = [ + profile["name"], + profile["surname"], + profile["nick"], + nameup, + surnameup, + nickup, + ] + + kombinaw = [ + profile["wife"], + profile["wifen"], + wifeup, + wifenup, + profile["surname"], + surnameup, + ] + + kombinak = [ + profile["kid"], + profile["kidn"], + kidup, + kidnup, + profile["surname"], + surnameup, + ] + + wordsup = [] + wordsup = list(map(str.title, profile["words"])) + additional_words = profile["words"] + wordsup + + # Birthdays combinations + birthdays = self.birthdays_combinations(bds) + wbirthdays = self.birthdays_combinations(wbds) # For a woman... + kbirthdays = self.birthdays_combinations(kbds) # and a child... + + # Names combinations + names = self.names_combinations(kombina) + names_wife = self.names_combinations(kombinaw) + names_kid = self.names_combinations(kombinak) + + # Let's do some serious work! This will be a mess of code, but... who cares? :) + first = [] + first += names + first += names_wife + first += names_kid + first += names_comp_pet + first += additional_words + first += reverse_names + if profile["randnum"] == "y": + first += self.concats(first, numfrom, numto) + + second = [] + second += birthdays + second += wbirthdays + second += kbirthdays + second += years + if len(profile["spechars"]) > 0: + second += self.combine(second, profile["spechars"]) + + print("[+] Sorting list and removing duplicates...") + + first = self.reduce_array(first) + second = self.reduce_array(second) + first = self.compare_and_reduce(first, second) + # first = first.sort() + # second = second.sort() + + print("[+] Combining...") + combinations = [] + combinations = self.combine(first, second) + combinations += first + combinations += second + + leet = [] + if profile["leetmode"] == "y": + for word in combinations: # if you want to add more leet chars, you will need to add more lines in cupp.cfg too... + leet_word = self.make_leet(word, CONFIG) # convert to leet + leet.append(leet_word) + + combinations += leet + + unique_list = [] + unique_list = [ + x + for x in combinations + if len(x) < CONFIG["global"]["wcto"] and len(x) > CONFIG["global"]["wcfrom"] + ] + return unique_list + + def __init__(self, profile, CONFIG): + self.print_to_file(profile["name"] + ".txt", self.generate_wordlist_from_profile(profile, CONFIG)) \ No newline at end of file