本次线上赛我们队伍获得了第一名的成绩

其中组态编程的工控迷宫 (唯一解) 和PLC工程为一血

协议分析

plc

查找plc的型号,CTF-NetA直接一键分析

可以找到一个6ES7 215-1AG31-0XB0,但是提交不对,这是PLC的订货号,还需要继续寻找

找了很久没找到,尝试让ai进行分析

依旧只是找到了这个订货号,所以可能就是通过这个订货号去查询plc的型号

​

继续询问ai如何通过订货号查看型号

给了网址,直接进行搜索订货号,得到了plc型号

匹配flag的格式

flag{CPU1215CDC/DC/DC}

packet

用wireshark看半天没看出来,先导出HTTP对象

用tshark分析,先看看有哪些协议

看到有http,tls,irc,COTP等等协议,一个个用tshark读取出来看看:

E:Wireshark shark.exe -r packet1.pcapng -Y "irc" -T fields -e irc.request -e irc.response

E:Wireshark shark.exe -r packet1.pcapng -Y "cotp" -T fields -e cotp.type -e data.text

看到irc消息就基本确定是导出个7z压缩包了,

解压密码 MarioRulez1985

然后要么就手动提取要么脚本/tshark,发现在84流

输入密码解压获得1.pcapng

然后直接追踪tcp流确定flag

flag{WelcomeTojxSz~}

modbus

无疑是对modbus协议流量分析

找找相关功能码有什么作用

寻找写操作相关流量

一条条找将最后数据转为浮点数

提取modbus/Tcp层的HEX数据

flag为flag{0c010000000b01100016000204441fe3d7}

也可以询问一下ai可以直接得到结果

组态编程

贪吃蛇

直接在项目中搜索flag

但是只能获得前半部分

后半部分通过搜索 } 来查找

也可以直接找到第二部分的flag

flag{The_Great_Eggscape_Is_Over}

有趣的图片

一张flag.jpg的图片

通过010打开,可以发现里面藏有一个压缩包

通过随波逐流打开,使用foremost分离出zip文件

压缩包是有加密的,不能直接解压

继续将这个压缩包通过随波逐流打开,尝试伪加密修复

然后就可以直接解压了, 拿到天然气运维系统.PCZ文件

继续010打开,发现这其实也就是一个zip压缩包

那么就将PCZ后缀改成zip, 发现又是加密的,无法直接解压

继续通过随波逐流打开,进行伪加密的修复

虽然会存在crc的校验失败等问题,但是不妨碍查看文件

最后在bmp目录下的题3.png这个图片中得到flag

工控迷宫

Autothink 打开,简单看一下程序内容

迷宫地图如下:每行存成了一个二进制数

maze = [63,129,253,253,253,253,129,252]
def print_maze(maze):
    for row in maze:
        line = ""
        for i in range(8):
            if row & (1 << (7 - i)):
                line += "*"
            else:
                line += " "
        print(line)


print_maze(maze)

当位置到达 63 时会输出 flag 值

修改 Start 为 True 表示游戏开始,而修改 Dir_xxx 这几个标志位就是进行移动,需要注意的是程序移动时查看的是标志位的上升沿(也就是从 0 到 1),所以每次移动前都需要置为 0。

最后可以得到 flag,如下

flag{1265912045}

PLC 工程

还是 Autothink 打开,要求我们得到 try_it 被按下(即上升沿一次)2999 次的 result 结果,如果直接按 2999 次就有点太难了,我这里构造一个循环,如下:

若 count 不是 2999 就为 try_it 置位,也就是置为 1,同时 count += 1 表示当前 try_it 按压的次数,再在末尾添加如下段

若 try_it 置位了,则将其复位。按理来说,但这样无法通过上升沿的检测,也就是这一块的检测

所以我直接暴力了一点,把这个块删掉了,所以我们按下一次的行为就变更为了 try_it 为真一次,最后得到了结果

flag{235997}

应急处置

钓鱼佬的疏忍

eml文件打开,下载附件

解压后看到一个docx一个exe

docx里面是乱码

对exe文件分析

分析后可知是先打开tan.docx文件异或至tan1.docx,密钥为123456

那docx文档可能为tan1.docx,写个脚本对其xor解密

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def xor_decrypt(data, key):
    """
    使用 XOR 算法解密数据
    
    Args:
        data: 要解密的字节数据
        key: 密钥字符串
    
    Returns:
        解密后的字节数据
    """
    key_bytes = key.encode('utf-8')
    key_length = len(key_bytes)

    decrypted_data = bytearray()
    for i, byte in enumerate(data):
        # 使用循环密钥进行 XOR 操作
        decrypted_data.append(byte ^ key_bytes[i % key_length])

    return bytes(decrypted_data)




def main():
    # 文件路径
    input_file = '工具使用文档.docx'
    output_file = '工具使用文档_解密.docx'
    key = '123456'

    print(f"[*] 正在读取加密文件: {input_file}")

    # 读取加密文件
    try:
        with open(input_file, 'rb') as f:
            encrypted_data = f.read()
        print(f"[+] 成功读取文件,大小: {len(encrypted_data)} 字节")
    except FileNotFoundError:
        print(f"[!] 错误: 找不到文件 {input_file}")
        return
    except Exception as e:
        print(f"[!] 读取文件时出错: {e}")
        return

    # 执行 XOR 解密
    print(f"[*] 使用密钥 '{key}' 进行 XOR 解密...")
    decrypted_data = xor_decrypt(encrypted_data, key)

    # 保存解密后的文件
    print(f"[*] 正在保存解密文件: {output_file}")
    try:
        with open(output_file, 'wb') as f:
            f.write(decrypted_data)
        print(f"[+] 解密完成! 文件已保存至: {output_file}")
        print(f"[+] 解密文件大小: {len(decrypted_data)} 字节")
    except Exception as e:
        print(f"[!] 保存文件时出错: {e}")
        return




if __name__ == '__main__':
    main()

发现解出来是乱码,后面想起来一开始有个base64字符串,可能是密钥,将密钥替换成ctf_is_good_boy,然后发现文档能正常打开

flag{ctf_eq23-c876-dhad-2871-dkdk-lopk}

ics_c2

对OPC UA 协议数据进行分析

直接追踪tcp流,发现有http数据

看看是存在哪里,用tshark提取出来

导入到output.txt中,用ai搓个脚本

import re
import base64
import json


def extract_and_decode(file_path):
    with open(file_path, 'r', encoding='utf-8') as f:
        lines = f.readlines()


    current_block_id = None
    current_segments = []
    results = []


    # Regex to match RESULT-SEG lines: RESULT-SEG<number>-<data>
    # Example: RESULT-SEG01-eyJpZCI6ICI0MTVhMT
    # We want to capture the data part.
    # Note: The file content shown in previous turns had line numbers like "169: RESULT-SEG01...", 
    # but the actual file on disk probably doesn't have the "169: " prefix if it's the raw file.
    # However, the view_file output showed "The following code has been modified to include a line number...".
    # So the actual file likely just starts with "RESULT-SEG...".

    seg_pattern = re.compile(r'^RESULT-SEG\d+-(.*)$')
    header_pattern = re.compile(r'^RESULT-(\d+)-([a-zA-Z0-9]+)$')


    for line in lines:
        line = line.strip()

        # Check for header
        header_match = header_pattern.match(line)
        if header_match:
            # If we have a previous block, save it
            if current_block_id and current_segments:
                full_b64 = "".join(current_segments)
                results.append({'id': current_block_id, 'b64': full_b64})

            current_block_id = f"{header_match.group(1)}-{header_match.group(2)}"
            current_segments = []
            continue


        # Check for segment
        seg_match = seg_pattern.match(line)
        if seg_match:
            current_segments.append(seg_match.group(1))
        elif current_segments:
            # End of a block of segments (encountered a non-segment line)
            # But wait, sometimes there are "运行中" or timestamps in between? 
            # Looking at the file:
            # 170: 运行中
            # 171: 2025-11-09T17:37:59.223987
            # 172: RESULT-SEG02-...
            # So segments can be interrupted by other lines.
            # We should probably accumulate segments until we hit a new header or end of file, 
            # OR we rely on the fact that segments belong to the most recent header.
            # However, looking at the file, the segments seem to be sequential for a block.
            # Let's just collect all RESULT-SEG lines.
            pass


    # Add the last block
    if current_block_id and current_segments:
        full_b64 = "".join(current_segments)
        results.append({'id': current_block_id, 'b64': full_b64})


        # If no headers were found, maybe just look for contiguous SEG blocks?
        # Let's try a more robust approach: collect all RESULT-SEG lines, group by proximity or just sequence?
        # Actually, the file has headers like RESULT-11-415a immediately followed by SEG01.
        # But then SEG02 might be separated by "运行中".
        # So we should keep appending to the current block until a NEW header appears.

        # Refined logic:
        # 1. Scan for Header. Start new block.
    # 2. Scan for Segment. Append to current block.
    
    results = []
    current_block = None
    
    for line in lines:
        line = line.strip()
        
        header_match = header_pattern.match(line)
        if header_match:
            if current_block:
                results.append(current_block)
            current_block = {'id': line, 'segments': []}
            continue
            
        seg_match = seg_pattern.match(line)
        if seg_match:
            if current_block:
                current_block['segments'].append(seg_match.group(1))
            else:
                # Segment without header? Create a dummy one or just start one.
                # The first block in the file (line 168) has a header.
                pass
                
    if current_block:
        results.append(current_block)


    # Patch for known corruption in Block 4 (RESULT-11-b198)
    for res in results:
        if res['id'] == 'RESULT-11-b198':
            # SEG03 is 'c', should be 'c2VkIC1pICdzLzQvQS' (from REACTOR logs)
            # Verify if SEG03 is 'c'
            if len(res['segments']) > 2 and res['segments'][2] == 'c':
                print("Patching corrupted Block 4 SEG03...")
                res['segments'][2] = 'c2VkIC1pICdzLzQvQS'


    with open(r"e:\\2025\\zx2025\\工控\\final_results.txt", "w", encoding="utf-8") as out_f:
        out_f.write(f"Found {len(results)} blocks.\n")
        for i, res in enumerate(results):
            full_b64 = "".join(res['segments'])
            out_f.write(f"\n--- Block {i+1} ({res['id']}) ---\n")
            out_f.write(f"Base64 Length: {len(full_b64)}\n")
            out_f.write(f"Base64 Content: {full_b64}\n")
            
            try:
                # Fix padding if necessary
                padding = len(full_b64) % 4
                if padding:
                    full_b64 += "=" * (4 - padding)
                
                decoded = base64.b64decode(full_b64).decode('utf-8')
                out_f.write("Decoded Content:\n")
                out_f.write(decoded + "\n")
                try:
                    json_obj = json.loads(decoded)
                    out_f.write("JSON Structure:\n")
                    out_f.write(json.dumps(json_obj, indent=2, ensure_ascii=False) + "\n")
                except:
                    pass
            except Exception as e:
                out_f.write(f"Decoding Error: {e}\n")


if __name__ == "__main__":
    extract_and_decode(r"e:\\2025\\zx2025\\工控\\output.txt")

Found 4 blocks.


--- Block 1 (RESULT-11-415a) ---
Base64 Length: 196
Base64 Content: eyJpZCI6ICI0MTVhMTM1ZSIsICJjbWQiOiAibHMiLCAib3V0cHV0IjogImZsYWdcbm9wY3VhX2NsaWVudC5weVxuIiwgInJldHVybmNvZGUiOiAwLCAic3VjY2VzcyI6IHRydWUsICJ0aW1lc3RhbXAiOiAiMjAyNS0xMS0wOVQxNzozNzo1OC4yNDUwMjIifQ==
Decoded Content:
{"id": "415a135e", "cmd": "ls", "output": "flag\nopcua_client.py\n", "returncode": 0, "success": true, "timestamp": "2025-11-09T17:37:58.245022"}
JSON Structure:
{
  "id": "415a135e",
  "cmd": "ls",
  "output": "flag\nopcua_client.py\n",
  "returncode": 0,
  "success": true,
  "timestamp": "2025-11-09T17:37:58.245022"
}


--- Block 2 (RESULT-12-837b) ---
Base64 Length: 208
Base64 Content: eyJpZCI6ICI4MzdiZTYxYyIsICJjbWQiOiAiY2F0IGZsYWciLCAib3V0cHV0IjogImZsYWd7dHJ5X3RyeV80X25ld19jMl8wUEN9IiwgInJldHVybmNvZGUiOiAwLCAic3VjY2VzcyI6IHRydWUsICJ0aW1lc3RhbXAiOiAiMjAyNS0xMS0wOVQxNzozODozMy40ODQ2NzMifQ==
Decoded Content:
{"id": "837be61c", "cmd": "cat flag", "output": "flag{try_try_4_new_c2_0PC}", "returncode": 0, "success": true, "timestamp": "2025-11-09T17:38:33.484673"}
JSON Structure:
{
  "id": "837be61c",
  "cmd": "cat flag",
  "output": "flag{try_try_4_new_c2_0PC}",
  "returncode": 0,
  "success": true,
  "timestamp": "2025-11-09T17:38:33.484673"
}


--- Block 3 (RESULT-11-afde) ---
Base64 Length: 188
Base64 Content: eyJpZCI6ICJhZmRlZDNjMiIsICJjbWQiOiAic2VkIC1pICdzL3QvVC9nJyBmbGFnIiwgIm91dHB1dCI6ICIiLCAicmV0dXJuY29kZSI6IDAsICJzdWNjZXNzIjogdHJ1ZSwgInRpbWVzdGFtcCI6ICIyMDI1LTExLTA5VDE3OjM5OjQ0LjY2MjIxNiJ9
Decoded Content:
{"id": "afded3c2", "cmd": "sed -i 's/t/T/g' flag", "output": "", "returncode": 0, "success": true, "timestamp": "2025-11-09T17:39:44.662216"}
JSON Structure:
{
  "id": "afded3c2",
  "cmd": "sed -i 's/t/T/g' flag",
  "output": "",
  "returncode": 0,
  "success": true,
  "timestamp": "2025-11-09T17:39:44.662216"
}


--- Block 4 (RESULT-11-b198) ---
Base64 Length: 188
Base64 Content: eyJpZCI6ICJiMTk4ZDk3MyIsICJjbWQiOiAic2VkIC1pICdzLzQvQS9nJyBmbGFnIiwgIm91dHB1dCI6ICIiLCAicmV0dXJuY29kZSI6IDAsICJzdWNjZXNzIjogdHJ1ZSwgInRpbWVzdGFtcCI6ICIyMDI1LTExLTA5VDE3OjQwOjU2LjE0NTEzNCJ9
Decoded Content:
{"id": "b198d973", "cmd": "sed -i 's/4/A/g' flag", "output": "", "returncode": 0, "success": true, "timestamp": "2025-11-09T17:40:56.145134"}
JSON Structure:
{
  "id": "b198d973",
  "cmd": "sed -i 's/4/A/g' flag",
  "output": "",
  "returncode": 0,
  "success": true,
  "timestamp": "2025-11-09T17:40:56.145134"
}

原本以为flag为flag{try_try_4_new_c2_0PC}

但后面使用sed命令经过了替换

所以最终的flag为

flag{Try_Try_A_new_c2_0PC}

恶意程序分析

pipdream

使用IDA打开

fwrite写了一个文件

4D 5A开头是PE文件,提取出来写为新文件

用IDA打开,进入AES加密函数

C110DD4FE9434147B92A5A1E3FDBF29A就是加密密钥,也就是flag

固件分析

加密的固件

binwalk提取文件

定位关键解密文件,发现有多个so

尝试后定位到libupgradeFirmware.so的关键解密函数,aes+crc32

import os
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad


def decrypt(input_file, output_file):
    passwd = bytes([
        0x95, 0xB3, 0x15, 0x32, 0xE4, 0xE4, 0x43, 0x6B,
        0x90, 0xBE, 0x1B, 0x31, 0xA7, 0x8B, 0x2D, 0x05
    ])
    xor_key = bytes([0xA7, 0x8B, 0x2D, 0x05])

    key = bytes([passwd[i] ^ xor_key[i % 4] for i in range(16)])

    try:
        if not os.path.exists(input_file):
            raise FileNotFoundError(f"{input_file} is not found")

        with open(input_file, "rb") as f:
            data = f.read()

        header = data[:40]
        encrypted_data = data[40:]

        block_size = AES.block_size
        encrypted_data = encrypted_data[:len(encrypted_data) // block_size * block_size]

        if not encrypted_data:
            print("no data to decrypt")
            decrypted_data = b""
        else:
            cipher = AES.new(key, AES.MODE_ECB)
            decrypted_data = cipher.decrypt(encrypted_data)

            try:
                decrypted_data = unpad(decrypted_data, block_size)
            except ValueError:
                pass

        result = bytearray(header)
        if len(result) > 14:
            result[14] = 0
        result += decrypted_data

        with open(output_file, "wb") as f:
            f.write(result)
    except Exception as e:
        print(f"{str(e)}")


if __name__ == "__main__":
    decrypt(r"E:\Downloads\1763296613dIFEAmnC56Fm\new.rom", r"E:\Downloads\1763296613dIFEAmnC56Fm\decrypted.rom")

之后binwalk提取decrypted.rom,再md5得到文件md5即可,得到flag{542b460afe2c9d6f146818bd7f8c3262}