码迷,mamicode.com
首页 > 其他好文 > 详细

[TWCTF] superexpress

时间:2020-05-09 13:08:10      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:length   gmpy2   pytho   str1   ==   ESS   pre   题目   encrypted   

#problem.py
import sys
key = ‘****CENSORED***************‘
flag = ‘TWCTF{*******CENSORED********}‘

if len(key) % 2 == 1:
    print("Key Length Error")
    sys.exit(1)

n = len(key) / 2
encrypted = ‘‘
for c in flag:
    c = ord(c)
    for a, b in zip(key[0:n], key[n:2*n]):
        c = (ord(a) * c + ord(b)) % 251
    encrypted += ‘%02x‘ % c

print encrypted

  

这道题目和星盟训练赛里最后一道crypto一样

都是化简同余式

str1 = ‘805eed80cbbccb94c36413275780ec94a857dfec8da8ca94a8c313a8ccf9‘.decode(‘hex‘)
print str1
import gmpy2
inv = gmpy2.invert(156,251)
print inv
str2 = ‘‘
for i in str1:
	str2 += chr(((ord(i)-76)*int(inv))%251)
print str2

  

[TWCTF] superexpress

标签:length   gmpy2   pytho   str1   ==   ESS   pre   题目   encrypted   

原文地址:https://www.cnblogs.com/p201721410013/p/12856584.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!