-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayer2.py
More file actions
50 lines (40 loc) · 1.1 KB
/
layer2.py
File metadata and controls
50 lines (40 loc) · 1.1 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
import base64
import generalFunctions as gF
l = open("ASCII85layertext/layer2.txt", "r", encoding="UTF-8")
layerTwo = l.read()
decrypt = base64.a85decode(layerTwo, adobe=True)
binary = []
layer = 2
for b in decrypt:
binary.append('{:0>8b}'.format((b)))
i=0
while i < (len(binary)):
length = len(binary)
temp = binary[i]
numOnes = temp[:7].count("1")
#remove invalid bytes
if numOnes%2!=0 and temp[-1]!="1":
binary.pop(i)
i -=1
elif numOnes%2 == 0 and temp[-1] == "1":
binary.pop(i)
i-=1
i+=1
binaryLongString=""
for x in binary:
for y in range (7):
binaryLongString+=x[y]
binaryReListed = []
for k in range (0, len(binaryLongString), 8):
tempBin = binaryLongString[k:k+8]
binaryReListed.append(tempBin)
for i in range(len(binaryReListed)):
temp = 0
for j in range(len(binaryReListed[i])-1, -1, -1):
now = binaryReListed[i][j]
temp+=int(now)*2**(7-j)
binaryReListed[i] = temp
payload = ""
for i in range (len(binaryReListed)):
payload = payload + chr(binaryReListed[i])
gF.savePayload(payload, layer+1)