Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ashutosh1206
GitHub Repository: ashutosh1206/crypton
Path: blob/master/Block-Cipher/Attack-ECB-Byte-at-a-Time/Challenges/Baby-Crypt/baby_crypt.py
1402 views
1
#!/usr/bin/python
2
3
def dumb_pad(imp):
4
while len(imp)%16 != 0:
5
imp+="0"
6
return imp
7
8
9
from Crypto.Cipher import AES
10
import hashlib
11
12
13
k = hashlib.sha256()
14
flag = "flag{Crypt0_is_s0_h@rd_t0_d0...}"
15
k.update(flag)
16
key = k.digest()
17
c = AES.new(key,AES.MODE_ECB);
18
def oracle(inp):
19
#c = AES.new(key,AES.MODE_ECB);
20
return c.encrypt(dumb_pad(inp+flag)).encode('hex')
21
22
while True:
23
imp = raw_input("Enter your username (no whitespace): ")
24
print("Your Cookie is: " + oracle(imp))
25
26