from base64 import * from Crypto.Util.number import * from random import * def inv(bt): return bt[::-1] def flip(bt): res = b'' for i in bt: res += long_to_bytes(256-i) return res def R287(bt): offset = 287 % len(bt) return bt[-offset:] + bt[:-offset] def L37(bt): offset = 37 % len(bt) return bt[offset:] + bt[:offset] def ff(m, lf): for f in lf: m = f(m) return m if __name__ == '__main__': funcList = [b16encode, b32encode, b64encode, b85encode, inv, flip, R287, L37] flag = b'' for i in range(2): shuffle(funcList) flag = ff(flag, funcList) print(flag) # 4644464D5232584E5A4C475556544E4E4D5A474B51324747354E464B3342514D4E564443564B4C4A424E464F53334E4A593247493254494E4A4D57345354574A463545553553544C424957575432494E424647495233544F3551564B5552524B523456434C32574C425657595752524E4251574956534B4C464A47593442524B3557554B33325A4E5A4D53365532564C4A51574955334C504A51564B5552524D4A4B55533443544C424A484B554C5A495A435749565A56494E53554B3342514D4A4345453443534A424C454559544D4A5933474536544447354B464B3342514B464C544B5644464E55344755544C4E4846464749524B4F4A4646564B3342514B425744514C32524C424958435954324C4A585749554A3548553D3D3D3D3D3D4D5559464B3243534A424B5841594B595042584749565449495245564B5552524D56575555364B4F4E5A5458455332554A4658574933444D47424B54473444574C
理解问题from base64 import * from Crypto.Util.number import * from random import * def inv(bt): return bt[::-1] def flip(bt): res = b'' for i in bt: res += long_to_bytes(256-i) return res def R287(bt): offset = 287 % len(bt) return bt[-offset:] + bt[:-offset] def L37(bt): offset = 37 % len(bt) return bt[offset:] + bt[:offset] def ff(m, lf): for f in lf: m = f(m) return m if __name__ == '__main__': funcList = [b16encode, b32encode, b64encode, b85encode, inv, flip, R287, L37] flag = b'' for i in range(2): shuffle(funcList) flag = ff(flag, funcList) print(flag) # 4644464D5232584E5A4C475556544E4E4D5A474B51324747354E464B3342514D4E564443564B4C4A424E464F53334E4A593247493254494E4A4D57345354574A463545553553544C424957575432494E424647495233544F3551564B5552524B523456434C32574C425657595752524E4251574956534B4C464A47593442524B3557554B33325A4E5A4D53365532564C4A51574955334C504A51564B5552524D4A4B55533443544C424A484B554C5A495A435749565A56494E53554B3342514D4A4345453443534A424C454559544D4A5933474536544447354B464B3342514B464C544B5644464E55344755544C4E4846464749524B4F4A4646564B3342514B425744514C32524C424958435954324C4A585749554A3548553D3D3D3D3D3D4D5559464B3243534A424B5841594B595042584749565449495245564B5552524D56575555364B4F4E5A5458455332554A4658574933444D47424B54473444574C
已完成理解「from base64 import * from Crypto.Util.number import * from random import * def inv(bt): return bt[::-1] def flip(bt): res = b'' for i in bt: res += long_to_bytes(256-i) return res def R287(bt): offset = 287 % len(bt) return bt[-offset:] + bt[:-offset] def L37(bt): offset = 37 % len(bt) return bt[offset:] + bt[:offset] def ff(m, lf): for f in lf: m = f(m) return m if __name__ == '__main__': funcList = [b16encode, b32encode, b64encode, b85encode, inv, flip, R287, L37] flag = b'' for i in range(2): shuffle(funcList) flag = ff(flag, funcList) print(flag) # 4644464D5232584E5A4C475556544E4E4D5A474B51324747354E464B3342514D4E564443564B4C4A424E464F53334E4A593247493254494E4A4D57345354574A463545553553544C424957575432494E424647495233544F3551564B5552524B523456434C32574C425657595752524E4251574956534B4C464A47593442524B3557554B33325A4E5A4D53365532564C4A51574955334C504A51564B5552524D4A4B55533443544C424A484B554C5A495A435749565A56494E53554B3342514D4A4345453443534A424C454559544D4A5933474536544447354B464B3342514B464C544B5644464E55344755544C4E4846464749524B4F4A4646564B3342514B425744514C32524C424958435954324C4A585749554A3548553D3D3D3D3D3D4D5559464B3243534A424B5841594B595042584749565449495245564B5552524D56575555364B4F4E5A5458455332554A4658574933444D47424B54473444574C」
展开阅读网页
这段代码是一个Python脚本,它定义了几个函数来操作字节字符串,并在脚本的主体部分使用这些函数来生成一个加密的“flag”。下面是对代码的详细解释:
inv(bt)
: 这个函数接受一个字节字符串bt
作为参数,并返回它的逆序字符串bt[::-1]
。1flip(bt)
: 这个函数遍历输入的字节字符串bt
,对于每个字节i
,它将i
转换为对应的整数值,然后计算256-i
,最后将结果转换回字节并拼接起来形成新的字符串res
。2R287(bt)
: 这个函数接受一个字节字符串bt
,计算偏移量287 % len(bt)
,然后将bt
的最后offset
个字节移动到字符串的开头,形成新的字符串。3L37(bt)
: 类似于R287
,这个函数计算偏移量37 % len(bt)
,然后将bt
的前offset
个字节移动到字符串的末尾。4ff(m, lf)
: 这个函数接受一个初始值m
和一个函数列表lf
。它将m
作为参数,依次应用列表中的每个函数,最后返回变换后的结果。5- 在
__main__
部分,首先定义了一个函数列表funcList
,包含了上述定义的函数以及一些用于编码的函数(如b16encode
、b32encode
、b64encode
、b85encode
)。然后初始化一个空的字节字符串flag
。 - 接下来,脚本进入一个循环,循环两次。在每次循环中,它随机打乱
funcList
的顺序,然后使用ff
函数对flag
应用这些函数。 - 最后,脚本打印出经过两次变换后的
flag
值。
脚本的最后部分是一个长字符串,看起来像是一个经过编码的flag。这个字符串可能是脚本执行后输出的结果,或者是需要解码的目标字符串。678910