# NepCTF wp
第一次大型比赛,得到这个成绩也不错了。
{ = 空格
# 1. misc:
# 1.codes:
环境env要
en\
v绕过下
#include <stdio.h> | |
extern char **en\ | |
viron; | |
int main() | |
{ | |
int i = 0; | |
while (en\ | |
viron[i] != NULL) | |
{ | |
printf("%s\n", en\ | |
viron[i]); | |
i++; | |
} | |
return 0; | |
} |
# 2. 与 AI 共舞的哈夫曼
这就是 hint 嘛,年轻人就要年轻,正经人谁自己写代码
AI 代码放进去,自己给 嘻嘻
import heapq | |
import os | |
class HuffmanNode: | |
def __init__(self, char, freq): | |
self.char = char | |
self.freq = freq | |
self.left = None | |
self.right = None | |
def __lt__(self, other): | |
return self.freq < other.freq | |
def build_huffman_tree(frequencies): | |
heap = [HuffmanNode(char, freq) for char, freq in frequencies.items()] | |
heapq.heapify(heap) | |
while len(heap) > 1: | |
left = heapq.heappop(heap) | |
right = heapq.heappop(heap) | |
merged = HuffmanNode(None, left.freq + right.freq) | |
merged.left = left | |
merged.right = right | |
heapq.heappush(heap, merged) | |
return heap[0] | |
def build_huffman_codes(node, current_code, huffman_codes): | |
if node is None: | |
return | |
if node.char is not None: | |
huffman_codes[node.char] = current_code | |
return | |
build_huffman_codes(node.left, current_code + '0', huffman_codes) | |
build_huffman_codes(node.right, current_code + '1', huffman_codes) | |
def compress(input_file, output_file): | |
with open(input_file, 'rb') as f: | |
data = f.read() | |
frequencies = {} | |
for byte in data: | |
if byte not in frequencies: | |
frequencies[byte] = 0 | |
frequencies[byte] += 1 | |
root = build_huffman_tree(frequencies) | |
huffman_codes = {} | |
build_huffman_codes(root, '', huffman_codes) | |
compressed_data = '' | |
for byte in data: | |
compressed_data += huffman_codes[byte] | |
padding = 8 - len(compressed_data) % 8 | |
compressed_data += '0' * padding | |
with open(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 in range(0, len(compressed_data), 8): | |
byte = compressed_data[i:i+8] | |
f.write(bytes([int(byte, 2)])) | |
def build_huffman_tree_from_bytes(frequencies): | |
heap = [HuffmanNode(byte, freq) for byte, freq in frequencies.items()] | |
heapq.heapify(heap) | |
while len(heap) > 1: | |
left = heapq.heappop(heap) | |
right = heapq.heappop(heap) | |
merged = HuffmanNode(None, left.freq + right.freq) | |
merged.left = left | |
merged.right = right | |
heapq.heappush(heap, merged) | |
return heap[0] | |
def decompress(input_file, output_file): | |
with open(input_file, 'rb') as f: | |
frequencies_count = ord(f.read(1)) | |
frequencies = {} | |
for _ in range(frequencies_count): | |
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 | |
root = build_huffman_tree_from_bytes(frequencies) | |
huffman_codes = {} | |
build_huffman_codes(root, '', huffman_codes) | |
reverse_huffman_codes = {v: k for k, v in huffman_codes.items()} | |
decompressed_data = bytearray() | |
code = '' | |
while True: | |
byte = f.read(1) | |
if len(byte) == 0: | |
break | |
byte = ord(byte) | |
for i in range(7, -1, -1): | |
if byte & (1 << i): | |
code += '1' | |
else: | |
code += '0' | |
if code in reverse_huffman_codes: | |
decompressed_data.append(reverse_huffman_codes[code]) | |
code = '' | |
with open(output_file, 'wb') as f: | |
f.write(decompressed_data) | |
if __name__ == "__main__": | |
# input_file = 'input.txt' | |
compressed_file = 'compressed.bin' | |
decompressed_file = 'decompressed.txt' | |
# 压缩文件 | |
# compress(input_file, compressed_file) | |
# 解压缩文件 | |
decompress(compressed_file, decompressed_file) |
# 3.ConnectedFive
五子连珠,到 42 即可拿 flag
# 4.CheckIn
NepCTF H4ve_Fun_1N_This_Game}
# 5. 陌生的语言
对照码表:NEPNEP_A_BELIEVING_HEART_IS_YOUR_MAGIC
NepCTF NEPNEP_A_BELIEVING_HEART_IS_YOUR_MAGIC}
# 6. 小叮弹钢琴
音频有信息
0x370a05303c290e045005031c2b1858473a5f052117032c39230f005d1e17
-.–/—/…-/…/…/—/…-/.-…/-…/…-/…/./-/…/…/…/-/—/-…-/—/.-./…/—/–/./-/…/…/-./–.
摩斯转化
YOU SHOULD USE THIS TO XOR SOME THING
异或字符串(16 进制转化)
0x6e 0x45 0x50 0x63 0x74 0x66 0x5b 0x48 0x14 0x50 0x50 0x59 0x7f 0x50 0x11 0x14 0x6e 0x10 0x5d
0x6e 0x45 0x50 0x63 0x74 0x66 0x5b 0x48 0x14 0x50 0x50
修改一下:找下规律去修改一下
0x4e 0x65 0x70 0x43 0x54 0x46 0x7b 0x68 0x34 0x70 0x70 0x79 0x5f 0x70 0x31 0x34 0x4e 0x30 0x7d
NepCTF h4ppy_p14N0}
# 7. 问卷
# 2. pwn:
# HRP-CHAT-4
一直买直到破坏子线程,然后执行 Safe_Mode_Key
得到 flag:This is your key!
Nepctf IAMFOUR_b924541f-bd73-16f1-418d-932d681eb691
# HRP-CHAT-3
把 Boss 能得到 flag,只能去抽奖,但抽不到最高的,但是 H3h3QAQ 够用了
序号是 9
得到 flag
# 3. web:
# ez_java_checkin
shiro 反序列化
得到 flag。