-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdebomber 2.0.py
85 lines (84 loc) · 2.25 KB
/
debomber 2.0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import glob
import re
from bin import *
print("1. Binary\n2. Hex")
ch = input("Chose Encryption method: ")
if ch == "1":
Hex = False
s2t = b2t
t2s = t2b
s2i = b2i
i2s = i2b
if ch == "2":
Hex = True
s2t = h2t
t2s = t2h
s2i = h2i
i2s = i2h
print("1.Key \n2.Beginning \n3.Ending")
select = input("Select option: ")
if select == "1":
key = int(input("Key: "))
for x in glob.glob("*.txt"):
f = open(x, "r+")
txt = f.read()
f.close()
txt = s2t(txt, key)
print("Text found:\n" + txt)
ch = input("Write text to file?(y/n): ")
if ch == "y":
for x in glob.glob("*.txt"):
dechypher(x, key, Hex)
print("Decrypted.")
elif select == "2":
ch1 = input("Type first characters of file: ")
print("Decrypting...")
check = ""
for x in glob.glob("*.txt"):
f = open(x, "r+")
start = f.read()
abc = start
check = start
f.close()
keys = []
state = False
while True:
if not state:
first_two = re.search(r"(\w+)\$(\w+)\$", check)
first = int(s2i(first_two.group(1)))
second = int(s2i(first_two.group(2)))
key = first - ord(ch1[0])
check = s2t(check, key)
if check[:len(ch1)] != ch1 or key < 0 or state:
if state:
state = False
check = abc
last = s2i(re.search(r"(\w+)\$$", check).group(1))
last = int(last)
key = last - 36
keys.append(key)
check = s2t(check, key)
abc = check
else:
print("Text found:\n{}".format(check))
ch = input("Continue Decryption(y/n)?: ")
if ch == "n":
keys.append(key)
break
else:
state = True
ks = ""
keys.reverse()
for x in keys:
ks += str(x) + ", "
ks = ks[:-2]
print("{} Keys found: {}".format(len(keys), ks))
print("Text found:\n{}".format(check))
ch = input("Would you like to write text to file?(y/n): ")
if ch == "y":
for x in glob.glob("*.txt"):
f = open(x, "w")
f.write(check)
f.close()
print("Text written.")
print("Bye")