[GHCTF 2024 新生赛]UP+——入土为安的第一天

注意:这道题需要脱壳,而且需要改特征值,详细请看

[LitCTF 2024]hello_upx------入土为安的第一天-CSDN博客

脱完壳发现有256这个特殊的数,是rc4类型的题,最后有一个异或

a = "9F041CEFA92386B6F56F27B96155FD42"

aa = "5E4C614B08306D1502BC6854D68716D4"

Splitting strings into pairs of hexadecimal characters

b = [a[i:i+2] for i in range(0,len(a),2)]

c = b[::-1]

d1 = ''.join(c)

b = [aa[i:i+2] for i in range(0,len(aa),2)]

c = b[::-1]

d2 = ''.join(c)

print(d1)

print(d2)

Concatenating d1 and d2

encode = d1 + d2

print(encode)

Converting concatenated string to list of integers

ddd = [int(encode[i:i+2],16) for i in range(0,len(encode),2)]

Initialize flag list

flag = []

Initializing variables

v22 = [0]*256

v20 = [0]*256

key = [ord(i) for i in "justfortest"]

print(key)

Initialization of S-box v22 and v20

for i in range(256):

v22[i] = i

v20[i] = key[i % len(key)]

v5 = 0

for i in range(256):

v8 = v22[i]

v5 = (v8 + v20[i] + v5) % 256

v22[i], v22[v5] = v22[v5], v22[i]

v9 = 0

v10 = 0

Encryption process

for i in range(len(ddd)):

v10 = (v10 + 1) % 256

v11 = v22[v10]

v9 = (v11 + v9) % 256

v22[v10], v22[v9] = v22[v9], v22[v10] # Swap

flag.append(ddd[i] ^ v22[(v22[v10] + v22[v9]) % 256])

Printing encrypted flag in hexadecimal

hex_flag = [hex(f) for f in flag]

print(hex_flag)

Attempting to decode encrypted flag to string (handle UnicodeDecodeError)

try:

decrypted_text = ''.join(chr(f) for f in flag)

print("Decrypted text:", decrypted_text)

except UnicodeDecodeError:

print("Decryption result contains non-printable characters.")

Printing encrypted flag as ASCII characters (for demonstration, may cause errors)

for i in range(len(flag)):

try:

print(chr(flag[i]), end='')

except ValueError:

print("[Non-printable]", end='')

相关推荐
程序员小予5 分钟前
如何成为一名黑客?小白必学的12个基本步骤
计算机网络·安全·网络安全
蜗牛学苑_武汉2 小时前
Wazuh入侵检测系统的安装和基本使用
网络·网络安全
乐茵安全3 小时前
linux基础
linux·运维·服务器·网络·安全·网络安全
如光照5 小时前
Linux与Windows中的流量抓取工具:wireshark与tcpdump
linux·windows·测试工具·网络安全
follycat7 小时前
2024强网杯Proxy
网络·学习·网络安全·go
黑色叉腰丶大魔王8 小时前
《运维网络安全》
运维·网络·网络安全
bluechips·zhao9 小时前
协议栈攻击分类(CISP-PTE笔记)
笔记·安全·网络安全
Wh1teR0se16 小时前
ctfshow(162)--文件上传漏洞--远程文件包含
web安全·网络安全