-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathdecode.py
80 lines (69 loc) · 8.83 KB
/
decode.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
from Crypto.Cipher import AES
import base64,uuid,sys
import binascii
import hashlib
#key="kPH+bIxk5D2deZiIxcaaaA=="
key='zSyK5Kp6PZAAjlT+eeNMlg=='
de="Tui24zp8pMDCx9/d0YKcLqZaeSXMsRCCm2doEyqGoK+GPS0jcWOlqgIEpPtm5qZxVasq2hEPW23r6amHOjaRo6phRrvp2lZ78WV/2zUm683tkOatgPt+4zLEelDRn7Zu9P2IGXEHmH80QXG9XyLEojY+L1ykID+Do9a2zjd969j/0cQOayljVH7WSSDlPr4ORR8QMk+5kOJf7Mju9JqTIH9FRPBRv+MB73j5AEBqTYnT5FrfZDnmdf0/VpG34ug7uyyPt+l1LYLagcc2cETVORxSRn8TzKgQpvZ2SjX5Fn11QfFIVmQzyEzBKEHPFBpx4YiQ9UQOiVbWThzA9mJjPSnyV9PFhBkYi5i+9ANqAAmzJyG+/6InBQwImnXQk0lL0gTWljmuEtqdE/kh+lYxdDz958Fjx7aUYVR8rqVr5I16P+D7stjZmIPvylrcxjbG2M4Z0N8xIoFtacJKIfSuECpuYnDiedmaRdpBkStB9f9L2JaVIYydWoTu7BhqepuomrDW7Ba+43iyeUiJUkKJNRGnkxh5H4dssOWCoR0ojKXSdWVHWlCpkYndhKwclLfAv4dGYh8PArvdxj9J/2K6epsRKC2mRUTzuxY1RiR/Ez6lCz+H0F6ZV4wr2dKXhUDNjE6SnsztSzk1gosu/I5uVhlf0+snRV/FeOh8Ec2tMKvO5nkwsQ4IKAb+8B/D7aWofNWwdb2ZFGyKd54ohXfE5H4kej6l6FzWOB0o+UjlL4h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WYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA/QAAAAAAADHcIAAAAEAAAAAF0AAhpbmlSZWFsbXNyABdqYXZhLnV0aWwuTGlua2VkSGFzaFNldNhs11qV3SoeAgAAeHIAEWphdmEudXRpbC5IYXNoU2V0ukSFlZa4tzQDAAB4cHcMAAAAED9AAAAAAAABdAAFYWRtaW54eAB3AQFxAH4ABXg="
de2="Y5j/skXpD2ABvTtyGc0OdCaUZbFCC+qWgyl96yso9xnPbbO6vs2UHoXMQWTovL6FHGgAgBQJvBb2+aOA/dmNp17U+KbXYQajDX9invl5USQq9frsbG9AmZYasltS8tqBSc7wH6TXBS+2exuzWx+/U56xGwAmtkThO9HDWTvQtR35aygg0JOA+vkGzS/PIhAAEfLI4kumPHncLl6WPuQeSN7HQbBtYJpzzxjz6jjiQchbNARJ+2aV8Mt1PGXD6+2f3nub/LTdRpC7R5pqnoxIWzpGuagL5m+6eppMyHNkkuuGJMkiVvYKtXToM+HXisYywyziO8wBfL32RCEFonE+loEJi1GPczPW5daJUB4Zcp2HIMbYZTkpRkcT8iJRjJUYcCjSjl3f118zQAtNHZpsuy18B/n9dY41NRduJKHeh2On2jQWSw2JU1douSr9yDC+W6u71RRzDWOSK6A1n6gOaQgmJrWZscJOhiVKoRNjLMRBQSsrcM1jMghpOXF4Zt52Ug=="
checker2 = "rO0ABXNyADJvcmcuYXBhY2hlLnNoaXJvLnN1YmplY3QuU2ltcGxlUHJpbmNpcGFsQ29sbGVjdGlvbqh/WCXGowhKAwABTAAPcmVhbG1QcmluY2lwYWxzdAAPTGphdmEvdXRpbC9NYXA7eHBwdwEAeA=="
def cmd5(src):
m = hashlib.md5()
m.update(src)
return m.hexdigest()
def gcm_decode(s):
global key
BS = AES.block_size
mode = AES.MODE_GCM
cipher=base64.b64decode(s)
iv=cipher[0:16]
enc=cipher[16:-16]
tag=cipher[-16:]
decryptor = AES.new(base64.b64decode(key), mode, iv)
plaintext=decryptor.decrypt_and_verify(enc,tag)
print("decode_plaintext:")
print(plaintext)
base64_plaintext=base64.b64encode(plaintext).decode()
print ("\nbase64_plaintext:\n"+base64_plaintext+"\n")
return base64_plaintext
def gcm_encode(p):
global key
BS = AES.block_size
mode = AES.MODE_GCM
iv = uuid.uuid4().bytes
encryptor = AES.new(base64.b64decode(key), mode, iv)
file_body=base64.b64decode(p)
enc,tag=encryptor.encrypt_and_digest(file_body)
base64_ciphertext = base64.b64encode(iv + enc+tag)
print("Encode_result:")
print(base64_ciphertext)
print("\n")
return base64_ciphertext
def cbc_encode(p):
global key
BS = AES.block_size
pad = lambda s: s + ((BS - len(s) % BS) * chr(BS - len(s) % BS)).encode()
print (pad(b"\x01\x01\x01"))
mode = AES.MODE_CBC
iv = uuid.uuid4().bytes
encryptor = AES.new(base64.b64decode(key), mode, iv)
file_body=pad(base64.b64decode(p))
print (base64.b64decode(p))
base64_ciphertext = base64.b64encode(iv + encryptor.encrypt(file_body))
print (base64_ciphertext)
def cbc_decode(s):
global key
BS = AES.block_size
unpad = lambda s : s[0:-(s[-1])]
mode = AES.MODE_CBC
cipher=base64.b64decode(s)
iv=cipher[0:16]
enc=cipher[16:]
encryptor = AES.new(base64.b64decode(key), mode, iv)
plaintext=encryptor.decrypt(enc)
print (base64.b64encode(unpad(plaintext)).decode())
if __name__ =='__main__':