-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayer3.py
More file actions
55 lines (42 loc) · 1.41 KB
/
layer3.py
File metadata and controls
55 lines (42 loc) · 1.41 KB
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
import base64
import generalFunctions as gF
layerThree = open("ASCII85layertext/layer3.txt", "r", encoding="UTF-8").read()
decrypt = base64.a85decode(layerThree, adobe=True)
layer = 3
binary = []
for b in decrypt:
binary.append('{:0>8b}'.format((b)))
for i in range(len(binary)):
temp = 0
for j in range(len(binary[i])-1, -1, -1):
now = binary[i][j]
temp+=int(now)*2**(7-j)
binary[i] = temp
#print(binary)
#the key i 32 bytes long
#we know that the key will start with this:
start = "==[ Layer 4/6: "
startValues = []
for x in range(len(start)):
startValues.append(ord(start[x])) #we use ord to convert between ASCII and integers
key = []
for i in range(32):
key.append(0)
for j in range(len(startValues)):
key[j] = (startValues[j] ^ binary[j])
#we manually find the correct values for the keys based on what we know needs to be there
key[len(binary)%32-1] = binary[len(binary)-1] ^ ord(">")
key[len(binary)%32-2] = binary[len(binary)-2] ^ ord("~")
key[59%32] = binary[59] ^ ord("\n")
key[60%32] = binary[60] ^ ord("\n")
key[29] = binary[29] ^ ord("c")
key[27] = binary[27] ^ ord("f")
key[62%32] = binary[62] ^ ord("W")
key[63%32] = binary[63] ^ ord("h")
firstLine = "="*28
for i in range(32,59):
key[i%32] = ord(firstLine[i%len(firstLine)]) ^ binary[i]
payload=""
for k in range(len(binary)):
payload = payload +(chr(key[k%32] ^ binary[k]))
gF.savePayload(payload, layer + 1)