老师给小丽出了一道线代题目作为作业,调皮的小刚却在题目上动了点手脚。你能帮小丽完成这道题目么?
题目源码:
from secret import flag,E,n
from random import randint
sec_len = 48
assert(max(E)<60)
N = 0x7f
def generate_eq(flag,i):
secret = flag
secret = [ randint(0,N-1) for _ in range(sec_len-len(flag)) ] + secret
vs = []
for _ in range(12):
v = [randint(0,N-1) for _ in range(len(secret))]
s = 0
for x,y in zip(v,secret):
s += x*y
s = s % N
#enc s here
v.append(pow(s,E[i%len(E)],n))
vs.append(v)
return vs
assert(flag[:5]=="flag{")
flag = flag[5:-1]
flag = map(ord,flag)
assert(len(flag) == 36)
for i in range(5500):
vs = generate_eq(flag,i)
print vs
输出日志过多贴一部分,原题附件在这里
https://download.csdn.net/download/figfig55/86781587
[[7, 90, 67, 4, 61, 94, 73, 54, 85, 107, 53, 118, 122, 27, 93, 75, 12, 61, 73, 26, 13, 3, 14, 93, 78, 85, 5, 16, 57, 38, 62, 37, 58, 25, 109, 51, 28, 124, 7, 62, 73, 1, 85, 69, 117, 67, 108, 18, 89116503268220597577728], [111, 104, 49, 123, 39, 31, 124, 103, 84, 112, 29, 56, 39, 7, 19, 68, 28, 117, 1, 115, 42, 1, 119, 122, 23, 17, 61, 46, 86, 124, 23, 69, 22, 46, 82, 66, 123, 119, 89, 56, 92, 44, 40, 78, 115, 40, 77, 57, 8293509467471872], [42, 24, 90, 20, 17, 67, 61, 93, 55, 126, 36, 75, 108, 29, 70, 28, 25, 121, 17, 108, 24, 80, 126, 84, 7, 34, 14, 93, 101, 101, 40, 60, 64, 101, 66, 3, 33, 110, 12, 70, 121, 64, 48, 87, 79, 67, 76, 124, 4501035456767426597157], [89, 76, 60, 100, 119, 6, 75, 15, 107, 20, 61, 72, 11, 69, 114, 36, 33, 48, 18, 88, 17, 98, 38, 16, 56, 100, 48, 11, 25, 6, 52, 58, 7, 50, 26, 64, 73, 55, 32, 94, 91, 43, 70, 43, 66, 6, 73, 108, 70188843638032384], [99, 59, 29, 123, 102, 75, 101, 124, 123, 26, 95, 42, 98, 103, 82, 120, 37, 73, 31, 10, 83, 116, 96, 6, 64, 56, 108, 42, 90, 16, 104, 89, 6, 8, 28, 43, 49, 53, 120, 103, 38, 18, 40, 26, 37, 5, 56, 56, 8589934592], [18, 121, 96, 47, 125, 91, 89, 32, 32, 5, 92, 109, 28, 43, 71, 80, 75, 35, 72, 71, 65, 18, 104, 3, 16, 89, 64, 123, 92, 96, 36, 77, 89, 14, 60, 46, 49, 107, 80, 87, 36, 39, 116, 115, 90, 106, 94, 34, 1521681143169024], [121, 66, 103, 42, 86, 32, 67, 119, 43, 65, 33, 84, 86, 48, 110, 39, 45, 3, 93, 68, 70, 47, 44, 96, 123, 81, 69, 109, 121, 41, 35, 61, 15, 107, 85, 116, 85, 17, 39, 104, 109, 93, 45, 86, 42, 105, 39, 37, 116490258898219], [47, 46, 72, 62, 7, 59, 36, 109, 92, 72, 42, 122, 10, 47, 63, 31, 66, 44, 26, 29, 87, 86, 79, 65, 23, 88, 17, 120, 49, 110, 37, 68, 12, 107, 93, 114, 109, 105, 9, 56, 87, 42, 59, 16, 98, 80, 93, 59, 2775173073766990340489], [108, 8, 53, 23, 79, 93, 17, 25, 90, 119, 46, 68, 6, 71, 59, 74, 121, 89, 92, 19, 71, 81, 4, 103, 56, 0, 69, 79, 65, 116, 125, 84, 106, 113, 38, 54, 15, 49, 102, 120, 113, 118, 107, 29, 44, 74, 101, 32, 3670344486987776], [83, 35, 27, 121, 31, 106, 28, 107, 39, 83, 29, 99, 46, 83, 68, 114, 8, 63, 96, 31, 22, 9, 64, 58, 21, 32, 68, 25, 82, 26, 73, 96, 30, 20, 4, 84, 32, 91, 3, 53, 69, 68, 14, 84, 93, 52, 21, 22, 1977326743], [110, 100, 27, 64, 0, 124, 109, 31, 105, 49, 104, 29, 126, 9, 87, 106, 67, 82, 116, 94, 37, 3, 32, 12, 54, 32, 105, 49, 43, 125, 23, 10, 92, 37, 84, 34, 94, 96, 34, 86, 13, 105, 33, 74, 116, 92, 95, 29, 5559060566555523], [27, 37, 107, 19, 19, 115, 61, 88, 1, 111, 110, 16, 44, 99, 92, 48, 76, 23, 83, 14, 72, 98, 125, 68, 14, 114, 57, 115, 59, 44, 11, 122, 115, 90, 122, 60, 121, 41, 91, 50, 59, 20, 68, 86, 35, 51, 9, 124, 6382393305518410039296]]
[[90, 119, 46, 66, 107, 124, 26, 11, 39, 89, 57, 4, 126, 19, 18, 22, 15, 54, 111, 109, 86, 88, 64, 94, 119, 66, 56, 52, 120, 31, 88, 37, 109, 65, 74, 103, 111, 33, 114, 62, 108, 30, 115, 110, 115, 36, 109, 67, 166722465564918774720589252712071168], [123, 41, 79, 71, 90, 60, 58, 40, 19, 5, 49, 15, 58, 59, 20, 34, 18, 1, 33, 64, 90, 49, 57, 94, 7, 42, 83, 43, 71, 96, 107, 43, 23, 68, 26, 47, 23, 73, 83, 15, 100, 114, 63, 65, 52, 16, 103, 54, 38115448583970168165554454528], [1, 61, 70, 46, 38, 108, 3, 49, 124, 126, 28, 119, 73, 103, 76, 25, 52, 116, 118, 2, 111, 16, 113, 23, 94, 27, 33, 125, 55, 15, 57, 111, 24, 119, 99, 89, 34, 120, 55, 73, 123, 54, 39, 64, 34, 67, 101, 94, 951208868148684143308060622848], [96, 105, 44, 92, 83, 44, 81, 77, 20, 44, 36, 95, 39, 112, 30, 65, 27, 18, 120, 81, 25, 94, 30, 0, 70, 102, 73, 25, 56, 42, 103, 27, 92, 33, 102, 109, 62, 69, 69, 68, 33, 15, 114, 122, 68, 96, 33, 7, 232630513987207], [126, 27, 20, 63, 38, 90, 76, 70, 61, 28, 47, 85, 11, 73, 102, 91, 14, 99, 65, 81, 42, 66, 110, 97, 101, 103, 82, 14, 4, 1, 109, 85, 88, 63, 109, 72, 115, 82, 21, 73, 33, 83, 78, 57, 84, 20, 95, 71, 290797794982682557415424], [66, 120, 43, 35, 92, 91, 44, 35, 62, 8, 101, 101, 71, 70, 97, 75, 121, 40, 122, 37, 34, 61, 47, 95, 31, 54, 95, 55, 34, 77, 124, 94, 103, 48, 119, 52, 49, 35, 58, 107, 16, 59, 95, 6, 75, 89, 12, 76, 582076609134674072265625], [122, 111, 36, 108, 54, 113, 37, 108, 58, 96, 43, 113, 97, 13, 28, 64, 48, 19, 2, 114, 113, 62, 10, 124, 9, 7, 52, 71, 102, 50, 108, 70, 95, 41, 4, 27, 64, 86, 1, 26, 28, 119, 114, 65, 6, 5, 8, 66, 92764641967130171567625832766767104], [48, 13, 98, 30, 43, 52, 47, 7, 23, 4, 39, 118, 28, 65, 69, 53, 64, 29, 27, 118, 11, 62, 3, 32, 69, 104, 14, 16, 16, 110, 62, 109, 105, 58, 91, 112, 65, 86, 8, 75, 47, 27, 66, 100, 84, 7, 89, 119, 75169468182139098644256591796875], [20, 121, 12, 8, 15, 27, 51, 28, 62, 14, 0, 78, 56, 49, 112, 18, 83, 9, 43, 11, 16, 24, 52, 117, 24, 102, 51, 109, 75, 100, 83, 79, 118, 71, 110, 92, 75, 119, 97, 81, 53, 14, 91, 33, 63, 65, 44, 82, 59832787379950079889132344705024], [103, 66, 62, 27, 118, 48, 90, 81, 110, 74, 57, 113, 102, 46, 88, 99, 119, 48, 29, 44, 59, 62, 124, 83, 108, 53, 3, 96, 37, 68, 87, 104, 20, 27, 54, 115, 42, 43, 30, 122, 49, 49, 88, 39, 99, 73, 22, 36, 146422644322690772477634553970688], [116, 33, 37, 52, 28, 102, 36, 45, 27, 14, 89, 45, 95, 87, 16, 102, 50, 56, 37, 79, 17, 8, 92, 38, 106, 55, 33, 115, 35, 65, 102, 94, 119, 124, 8, 60, 49, 102, 91, 78, 93, 90, 101, 20, 121, 122, 103, 47, 3937657486715347520027492352], [41, 116, 87, 30, 51, 7, 11, 56, 17, 5, 72, 42, 52, 113, 7, 49, 126, 121, 24, 104, 25, 78, 14, 124, 87, 92, 69, 93, 99, 21, 23, 15, 11, 98, 4, 82, 23, 69, 85, 40, 36, 53, 26, 63, 73, 94, 76, 77, 129140163]]
大概分析一下,未知的flag,E,n变量;E是数组,最大值小于60;N=0x7f
在本地调试时发现一个问题,执行flag=map(ord,flag)以后会报错:
TypeError: ord() expected string of length 1, but int found
查了一下好像是python3不支持这样map操作,python2本地又没有合适的环境,感觉无法继续了。。。