每天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 小时前
攻防世界-Misc-pdf
网络安全·ctf·misc·1024程序员节
风语者日志1 天前
[LitCTF 2023]作业管理系统
前端·网络·安全·web安全·ctf
Pure_White_Sword3 天前
Bugku-Web题目-cookies
web安全·网络安全·ctf
f0rev3r7 天前
NewStarCTF2025-WEEK3
ctf
希望奇迹很安静8 天前
DVWA靶场通关笔记
web安全·网络安全·ctf·文件上传
kali-Myon10 天前
NewStarCTF2025-Week3-Web
sql·安全·web安全·php·ctf
风语者日志14 天前
攻防世界—easyupload
数据库·web安全·ctf·小白入门
序^章14 天前
【CTF | 比赛篇】Newstar ctf web
网络安全·ctf
sln_155016 天前
2025强网杯tradRE简单wp
安全·逆向·ctf
风语者日志16 天前
CTFSHOW—WEB4
网络·安全·web安全·网络安全·ctf