Final Version with Types

main
Samuel Zielke 2 years ago
parent 67d1f74364
commit 06f72f3cfe

Binary file not shown.

@ -1,24 +1,53 @@
import string, itertools
from progress.bar import Bar
from pypdf import PdfReader, PdfWriter
# buchstaben = string.ascii_uppercase + string.ascii_lowercase + string.digits
anfangsbuchstaben = ('S', 's', 'K', 'k', 'A', 'a', 'P', 'p', 'B', 'b', 'M', 'm', 'D', 'd', 'E', 'e', 'I', 'i', 'W', 'w')
buchstaben = ('e', 'n', 'i', 'r', 's', 't', 'a', 'd', 'h', 'u', 'l', 'c', 'e', 'g', 'm', 'o', 'b', 'w', 'f', 'k', 'z')
ziffern = tuple(string.digits)
test_passwort = "Saal"
# SETTINGS
CHOICES_PER_SECOND_OFFLINE = 200000
CHOICES_PER_SECOND_PDF = 552
# SETTING OF SOFTWARE - DONT EDIT
LINE_UP = '\033[1A'
LINE_CLEAR = '\x1b[2K'
DEBUG = False
def get_time_forMax(MaxChoices):
# maxSek = int(MaxChoices / 309598)
maxSek = int(MaxChoices / 200000)
# Buschstaben listen
anfangsbuchstaben_lower = ('s', 'k', 'a', 'p', 'b', 'm', 'd', 'e', 'i', 'w')
anfangsbuchstaben_upper = ('S', 'K', 'A', 'P', 'B', 'M', 'D', 'E', 'I', 'W')
anfangsbuchstaben_comp = ('S', 's', 'K', 'k', 'A', 'a', 'P', 'p', 'B', 'b', 'M', 'm', 'D', 'd', 'E', 'e', 'I', 'i', 'W', 'w')
seltene_anfangsbuchstaben_lower = ('c', 'f', 'g', 'h', 'j', 'l', 'n', 'o', 'q', 'r', 't', 'u', 'v', 'x', 'y', 'z')
seltene_anfangsbuchstaben_upper = ('C', 'F', 'G', 'H', 'J', 'L', 'N', 'O', 'Q', 'R', 'T', 'U', 'V', 'X', 'Y', 'Z')
seltene_anfangsbuchstaben_comp = ('C', 'c', 'F', 'f', 'G', 'g', 'H', 'h', 'J', 'j', 'L', 'l', 'N', 'n', 'O', 'o', 'Q', 'q', 'R', 'r', 'T', 't', 'U', 'u', 'V', 'v', 'X', 'x', 'Y', 'y', 'Z', 'z')
buchstaben_lower = ('e', 'n', 'i', 'r', 's', 't', 'a', 'd', 'h', 'u', 'l', 'c', 'g', 'm', 'o', 'b', 'w', 'f', 'k', 'z')
buchstaben_upper = ('E', 'N', 'I', 'R', 'S', 'T', 'A', 'D', 'H', 'U', 'L', 'C', 'G', 'M', 'O', 'B', 'W', 'F', 'K', 'Z')
buchstaben_comp = ('E', 'e', 'N', 'n', 'I', 'i', 'R', 'r', 'S', 's', 'T', 't', 'A', 'a', 'D', 'd', 'H', 'h', 'U', 'u', 'L', 'l', 'C', 'c', 'G', 'g', 'M', 'm', 'O', 'o', 'B', 'b', 'W', 'w', 'F', 'f', 'K', 'k', 'Z', 'z')
seltene_buchstaben_lower = ('j', 'p', 'q', 'v', 'x', 'y')
seltene_buchstaben_upper = ('J', 'P', 'Q', 'V', 'X', 'Y')
seltene_buchstaben_comp = ('J', 'j', 'P', 'p', 'Q', 'q', 'V', 'v', 'X', 'x', 'Y', 'y')
sonderzeichen = ['!', '#', '$', '%', '&', '*', '+', ',', '-', '.', '/', ':', ';', '?', '@', '_']
seltene_sonderzeichen = ['"', "'", '(', ')', '<', '=', '>', '[', '\\', ']', '^', '`', '{', '|', '}', '~', ' ']
buchstaben = buchstaben_lower
anfangsbuchstaben = anfangsbuchstaben_comp
ziffern = tuple(string.digits)
def get_time_forMax(MaxChoices, choices_per_second):
maxSek = int(MaxChoices / choices_per_second)
max = int(maxSek/60)
if max > 60:
max = int(max/60)
max = float(max/60).__round__(1)
if max > 24:
max = int(max/24)
max = float(max/24).__round__(1)
if max > 365:
max = float(max/365).__round__(1)
return f"{max} Jahre"
return f"{max} Days"
return f"{max}h"
else:
@ -29,28 +58,74 @@ def get_choices(letters: list) -> int:
choices = 1
maxZeichen = len(buchstaben) + len(ziffern)
for i in letters:
choices += pow(maxZeichen, i)
choices += pow(maxZeichen, i-1)
return choices * len(anfangsbuchstaben)
def crack_password(letter_range: range) -> None:
def crack_password(letter_range: range, test_passwort: str, debugmode: bool) -> None:
num_versuch = 0
maxChoices = get_choices(list(letter_range))
print("Möglichkeiten: {:,}".format(maxChoices))
print(f"MaxTime/100% Power: {get_time_forMax(maxChoices)}")
print(f"MaxTime/100% Power: {get_time_forMax(maxChoices, CHOICES_PER_SECOND_OFFLINE)}")
for num in letter_range:
for anfang in anfangsbuchstaben:
for versuch in itertools.product(buchstaben+ziffern, repeat=num-1):
versuch = "".join(versuch)
versuch = anfang + versuch
print("Aktuell: {:,}".format(num_versuch), f" Versuch: {versuch}") if DEBUG else None
print(LINE_UP, end=LINE_CLEAR) if DEBUG else None
print("Aktuell: {:,}".format(num_versuch), f" Versuch: {versuch}") if debugmode else None
print(LINE_UP, end=LINE_CLEAR) if debugmode else None
num_versuch += 1
if versuch == test_passwort:
print(f"\n\nRichtiges Passwort lautet: {versuch}","\nNötige Versuche: {:,}".format(num_versuch))
return
def crack_pdf_password(letter_range: range, pdf_path: str, debugmode: bool) -> None:
num_versuch = 0
reader = PdfReader(pdf_path)
writer = PdfWriter()
maxChoices = get_choices(list(letter_range))
print("Möglichkeiten: {:,}".format(maxChoices))
print(f"MaxTime/100% Power: {get_time_forMax(maxChoices, CHOICES_PER_SECOND_PDF)}")
for num in letter_range:
for anfang in anfangsbuchstaben:
for versuch in itertools.product(buchstaben+ziffern, repeat=num-1):
versuch = "".join(versuch)
versuch = anfang + versuch
print("Aktuell: {:,}".format(num_versuch), f" Versuch: {versuch}") if debugmode else None
print(LINE_UP, end=LINE_CLEAR) if debugmode else None
if reader.decrypt(versuch) > 0:
print(f"\n\nRichtiges Passwort lautet: {versuch}","\nNötige Versuche: {:,}".format(num_versuch))
return
num_versuch += 1
minChoice = input("please enter choices: ")
crack_password(range(int(minChoice), int(minChoice)+1))
def start_script():
print(LINE_UP, end=LINE_CLEAR)
input_type = input("please enter type [1]password-crack-test [2]pdf-file [3]password-safety: ")
if input_type == "1":
print(LINE_UP, end=LINE_CLEAR)
testPasswort = input("please enter passwort to test [a-]: ")
minChoice = len(testPasswort)
debugmode = True if input("\nDEBUG: [1]Yes or [empty]No: ") == "1" else False
crack_password(range(int(minChoice), int(minChoice)+1), testPasswort, debugmode)
elif input_type == "2":
print(LINE_UP, end=LINE_CLEAR)
minChoice = input("please enter choices: ")
print(LINE_UP, end=LINE_CLEAR)
# pdf_path = input("please enter path of pdf: ")
pdf_path = "./w999.pdf"
crack_pdf_password(range(int(minChoice), int(minChoice)+1), pdf_path, False)
elif input_type == "3":
print(LINE_UP, end=LINE_CLEAR)
testPasswort = input("please enter passwort to test: ")
print(LINE_UP, end=LINE_CLEAR)
maxChoices = get_choices([len(testPasswort)])
print(f"Das Passwort >{testPasswort}< hat folgende Sicherheit:")
print("Möglichkeiten: {:,}".format(maxChoices))
print(f"MaxTime/100% Power: {get_time_forMax(maxChoices)}")
else:
return False
while start_script():
None

@ -1,6 +1,14 @@
import string
buchstaben = ['e', 'n', 'i', 'r', 's', 't', 'a', 'd', 'h', 'u', 'l', 'c', 'e', 'g', 'm', 'o', 'b', 'w', 'f', 'k', 'z']
ziffern = string.digits
gesamt = len(buchstaben) + len(ziffern)
print(gesamt)
# buchstaben = ['e', 'n', 'i', 'r', 's', 't', 'a', 'd', 'h', 'u', 'l', 'c', 'e', 'g', 'm', 'o', 'b', 'w', 'f', 'k', 'z']
# ziffern = string.digits
# gesamt = len(buchstaben) + len(ziffern)
# print(gesamt)
seltene_anfangsbuchstaben_upper = ('J', 'P', 'Q', 'V', 'X', 'Y')
new_list = []
for i in seltene_anfangsbuchstaben_upper:
new_list.append(i)
new_list.append(i.lower())
print(new_list)

Binary file not shown.
Loading…
Cancel
Save

Powered by TurnKey Linux.