每天CTF小练(6.6)--基础异或

题目:[HNCTF 2022 Week1]XXXOOORRR

复制代码
from flag import flag
from Crypto.Util.number import *
import os

randBytes = [bytes_to_long(os.urandom(64)) for _ in range(3)]
m = bytes_to_long(flag)

print(f'a = {randBytes[0]}')
print(f'b = {randBytes[0] ^ randBytes[1]}')
print(f'c = {randBytes[1] ^ randBytes[2]}')
print(f'd = {m ^ randBytes[0] ^ randBytes[1] ^ randBytes[2]}')

'''
a = 1215421974111272707828609697064234072332368362928440865251897449605952163161176359366553487776268706107760670434157083936287598207881176904763353849369234
b = 10533604054267448009117468094542127075826310122733511023911022436253583775790861879410728001403728088545946257902341417532648419689212361977221573357292618
c = 6401236597601556248960570084212025183497657335932789785351897915858852832577623776212842429736547820800219382515052263929074210010546149322465536545021479
d = 5711309307698496426409561761492698639489294806611133698231840146911562848869711567477706456972659368849642409039245400981517493100724067475248620536111560
'''
代码解释:
复制代码
randBytes = [bytes_to_long(os.urandom(64)) for _ in range(3)]



"""
这段代码是用Python来生成一个包含3个随机64字节长的bytes对象的列表。让我逐步解释:

os.urandom(64):os.urandom()函数是Python中用于生成指定长度的随机字节序列的方法。在这里,os.urandom(64)生成了一个长度为64字节的随机字节序列。

bytes_to_long():这是一个自定义的函数,它将一个字节序列转换为一个长整型数。在Python中,可以使用int.from_bytes()方法来实现这一转换。

[bytes_to_long(os.urandom(64)) for _ in range(3)]:这是一个列表推导式(list comprehension),它会生成一个包含3个元素的列表。在这里,循环了3次(range(3)),每次生成一个64字节长的随机字节序列,并将其转换为长整型数后加入到列表中。

因此,randBytes列表包含了3个随机的64字节长的长整型数。
"""

代码解释不懂,不用管,直接解。

wp:
复制代码
from Crypto.Util.number import *


a = 1215421974111272707828609697064234072332368362928440865251897449605952163161176359366553487776268706107760670434157083936287598207881176904763353849369234
b = 10533604054267448009117468094542127075826310122733511023911022436253583775790861879410728001403728088545946257902341417532648419689212361977221573357292618
c = 6401236597601556248960570084212025183497657335932789785351897915858852832577623776212842429736547820800219382515052263929074210010546149322465536545021479
d = 5711309307698496426409561761492698639489294806611133698231840146911562848869711567477706456972659368849642409039245400981517493100724067475248620536111560

a1=a
b1=b^a
c1=c^b1
m=d^a1^b1^c1
print(m)
print(long_to_bytes(m))

"""
955126884749829153586936045914642979607739079976821931874795098472843959716986845513508261072901299531296605101249003068702245602361385060494717
b'NSSCTF{XOR_ha5_many_propertie5_and_thi5_i5_ju5t_one_of_them}'
"""
相关推荐
祁白_2 天前
Bugku:备份是一个好习惯
笔记·学习·web安全·ctf
蒲公英eric3 天前
攻防世界 misc题GFSJ0403-【intoU】
ctf·misc·攻防世界·音频题
kali-Myon5 天前
CTFshow-Pwn142-Off-by-One(堆块重叠)
c语言·数据结构·安全·gdb·pwn·ctf·
三七吃山漆5 天前
BUUCTF[极客大挑战 2019]Http
web安全·网络安全·ctf·极客大挑战
unable code6 天前
[HNCTF 2022 WEEK2]ez_ssrf
网络安全·web·ctf·1024程序员节
unable code7 天前
[NISACTF 2022]easyssrf
网络安全·web·ctf·1024程序员节
0vvv08 天前
md5值相同,但未计算md5的值不同的绕过
ctf
0vvv08 天前
bugku-web-shell
ctf
unable code8 天前
BUUCTF-[第二章 web进阶]SSRF Training
网络安全·web·ctf·1024程序员节
yv_308 天前
CTF-IDA
学习·ctf