每天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}'
"""
相关推荐
unable code20 小时前
攻防世界-Reverse-insanity
网络安全·ctf·reverse
还鮟1 天前
CTF Web PHP弱类型与进制绕过(过滤)
php·ctf
玥轩_52112 天前
BUUCTF [UTCTF2020]File Carving 1
安全·网络安全·elf·ctf·misc·buuctf·png隐写
wyjcxyyy17 天前
DIDCTF-应急响应
笔记·ctf·应急响应与电子取证
kali-Myon18 天前
攻防世界[level7]-Web_php_wrong_nginx_config
前端·nginx·安全·php·web·ctf·攻防世界
Bruce_Liuxiaowei22 天前
某靶场CTF题目:利用Apache APISIX默认Token漏洞(CVE-2020-13945)获取Flag
网络安全·apache·ctf
轨迹H1 个月前
【春秋云镜】CVE-2023-2130漏洞复现exp
网络协议·网络安全·渗透测试·ctf·cve
mottte1 个月前
BUUCTF[极客大挑战 2019]Havefun 1题解
php·web·ctf
mottte1 个月前
BUUCTF[ACTF2020 新生赛]Include 1题解
web·ctf·文件包含漏洞
Star abuse1 个月前
2025一带一路暨金砖国家技能发展与技术创新大赛第三届企业信息系统安全赛项
安全·web安全·ctf·全国职业院校技能大赛