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

题目:HNCTF 2022 Week1XXXOOORRR

复制代码
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}'
"""
相关推荐
hengdonghui1 天前
Writeup 4 2020 - 之江杯 - 异常的流量分析
wireshark·ctf·流量分析
hengdonghui1 天前
Writeup 4 津门杯 2021 Web hate_php
php·web·ctf·通配符
hengdonghui1 天前
Writeup 4 红帽杯 2021 Web Find_It
web·ctf·备份文件泄露
hengdonghui2 天前
Writeup 4 强网杯 2019 强网先锋打野
ctf·misc·zsteg
hengdonghui2 天前
Writeup 4 NUAA 2017 robots
android·ctf·re
hengdonghui3 天前
Writeup 4 CSS CTF Semester 2 2026 - Lamp Drill
ctf·re
hengdonghui3 天前
Writeup 4 CSS CTF Semester 2 2026 Cryptography Chrono I
ctf·维吉尼亚密码·crypto
hengdonghui3 天前
Writeup 4 CSS CTF Semester 2 2026 - Dead Faction Servers
ctf·osint
hengdonghui4 天前
Writeup 4 2020 - 之江杯 - 工控现场的恶意扫描
wireshark·ctf·流量分析
hengdonghui5 天前
Writeup 4 2020 - 之江杯 - 异常的工程文件
ctf·工控