Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def aes_abc_decrypt(ct):
- blocks = [ct[i * BLOCK_SIZE : (i+1) * BLOCK_SIZE] for i in range(len(ct) / BLOCK_SIZE)]
- for i in range(len(blocks)-1, 0, -1):
- upper_blk = int(blocks[i].encode('hex'), 16)
- lower_blk = int(blocks[i-1].encode('hex'), 16)
- blk_diff = upper_blk - lower_blk
- if blk_diff < 0:
- blk_diff += UMAX
- blocks[i] = to_bytes(blk_diff)
- ct_ecb = "".join(blocks)
- return ct_ecb
- if __name__="__main__":
- header, data = '', ''
- with open('body.enc.ppm', 'rb') as f:
- header, data = parse_header_ppm(f)
- ct_ecb = aes_abc_decrypt(data)
- with open('flag.ecb.ppm', 'wb') as fw:
- fw.write(header)
- fw.write(ct_ecb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement