2022-05-22 18:07:02 +02:00
|
|
|
from rot import rot
|
2022-05-15 15:04:38 +02:00
|
|
|
from sys import argv
|
|
|
|
from collections import Counter
|
|
|
|
|
2022-05-22 18:07:02 +02:00
|
|
|
def breakRot(m: str, f: str, x: int):
|
2022-05-16 20:32:58 +02:00
|
|
|
t=tuple(open(f).read().splitlines()[:x])
|
2022-05-22 18:07:02 +02:00
|
|
|
poss=[]
|
|
|
|
for i in range(1, 26):
|
|
|
|
msg=rot(m, -i)
|
|
|
|
print(f"{i}: {msg}")
|
2022-05-15 17:17:55 +02:00
|
|
|
for x in t:
|
2022-05-22 18:07:02 +02:00
|
|
|
if x.upper() in msg.upper():
|
|
|
|
poss.append(msg)
|
|
|
|
return Counter(poss)
|
2022-05-16 20:32:58 +02:00
|
|
|
|
2022-05-15 16:45:47 +02:00
|
|
|
if __name__ == "__main__":
|
2022-05-16 20:32:58 +02:00
|
|
|
try:
|
|
|
|
a=argv[1]
|
|
|
|
b=argv[2]
|
|
|
|
c=int(argv[3])
|
|
|
|
except IndexError:
|
|
|
|
a=input("Give encoded text to break: ")
|
|
|
|
b=input("Give filename of file which contains wordlist: ")
|
|
|
|
c=int(input("Type how many words to read from the wordlist ('-1'=every): "))
|
2022-05-22 18:07:02 +02:00
|
|
|
print(breakRot(a, b, c))
|