# 2018 NSEC crypto leak writeup

## 1.题目分析

A recent transcript suspected to contain incriminating conversations between the officials in charge of the Mars colonization plan has leaked but is encrypted with the latest top-secret encryption algorithm: RC8! You’ve recovered the source code to their new encryption algorithm, but the key and seed value are missing. Find a weakness in the scheme and recover the transcript.

#!/usr/bin/env python3
import sys

def rc8(state, key, n):
'''
Top Secret RC8 Stream Cipher
'''
while (n > 0):
yield state & 0xff
for _ in range(8):
c, s = key, state
b = 0
while c:
b ^= c & 1 * s & 1
c >>= 1 ; s >>= 1
state = state >> 1 | b << 63
n -= 1

def main():
seed, key = ?, ? # Missing

with open(sys.argv[1], 'rb') as fin:

for i,x in enumerate(rc8(seed, key, len(data))):
data[i] ^= x

with open(sys.argv[1] + '.enc', 'wb') as fout:
fout.write(data)

if __name__ == "__main__":
main()

for _ in range(8):
c, s = key, state
b = 0
while c:
b ^= c & 1 * s & 1
c >>= 1 ; s >>= 1
state = state >> 1 | b << 63

c=c0c1cn1 c = c 0 c 1 ⋯ c n − 1 $c=c_{0}c_{1} \cdots c_{n-1}$ s=s0s1sn1 s = s 0 s 1 ⋯ s n − 1 $s=s_{0}s_{1} \cdots s_{n-1}$分别是c和s的二进制表示，根据对上面代码的分析我们不难得到下面式子：
$\qquad$ $\qquad$ b=(c0 b = ( c 0 $b=(c_{0}$& s0) s 0 ) $s_{0})$^ (c1 ( c 1 $(c_{1}$& s1) s 1 ) $s_{1})$^ $\cdots$^

• 1
点赞
• 0
收藏
觉得还不错? 一键收藏
• 0
评论
08-23
06-14 769
05-04 583
06-30 2597
03-24 678
03-01 410
02-27 111

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。