-
Notifications
You must be signed in to change notification settings - Fork 0
/
asn4_1.py
35 lines (26 loc) · 796 Bytes
/
asn4_1.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
import common
block_length = 32 # 16 bytes
c = ['20814804c1767293b99f1d9cab3bc3e7', 'ac1e37bfb15599e5f40eef805488281d']
pt = 'Pay Bob 100$'
m = common.str_to_hex(pt)
def execute():
# show where '100' is at
print(pt[8:11])
print(m[16:22])
print(c[0][16:18])
# xor with intended change
tampered_iv_partial = \
common.xor_hexstr(
common.str_to_hex('100'),
c[0][16:22],
common.str_to_hex('500'))
print(tampered_iv_partial)
# integrated into original iv
tampered_iv = c[0][:16] + tampered_iv_partial + c[0][22:]
tampered_c = [tampered_iv, c[1]]
# compare
print('original: ' + ' '.join(c))
print('tampered: ' + ' '.join(tampered_c))
return tampered_c
if __name__ == '__main__':
execute()