1985 - BuckeyeCTF 2025

2025. 11. 9. 16:10·

Đề bài


Giải

Đề bài cho mình một email như sau

Hey man, I wrote you that flag printer you asked for:

begin 755 FLGPRNTR.COM
MOAP!@#PD=`:`-"I&Z_6Z'`&T"<TAP[1,,,#-(4A)7DQ1;AM.=5,:7W5_61EU
;:T1U&4=?1AY>&EAU95AU3AE)&D=:&T9O6%<D
`
end

Mình thấy khối dữ liệu bắt đầu bằng begin 755 FLGPRNTR.COM và kết thúc bằng end → đây là uuencoded file

Giải mã:

┌──(kali㉿kali)-[/BuckeyeCTF 2025/beginner/1985]
└─$ cat > flag.uue << 'EOF'
begin 755 FLGPRNTR.COM
MOAP!@#PD=`:`-"I&Z_6Z'`&T"<TAP[1,,,#-(4A)7DQ1;AM.=5,:7W5_61EU
;:T1U&4=?1AY>&EAU95AU3AE)&D=:&T9O6%<D
`
end
EOF
uudecode flag.uue

Mình thu được file FLGPRNTR.COM, đây là file của DOS

Mình sẽ disassembly file này để đọc source

$ ndisasm -b 16 -o 0x100 FLGPRNTR.COM | head -n 40
00000100  BE1C01            mov si,0x11c
00000103  803C24            cmp byte [si],0x24
00000106  7406              jz 0x10e
00000108  80342A            xor byte [si],0x2a
0000010B  46                inc si
0000010C  EBF5              jmp 0x103
0000010E  BA1C01            mov dx,0x11c
00000111  B409              mov ah,0x9
00000113  CD21              int byte 0x21
00000115  C3                ret
00000116  B44C              mov ah,0x4c
00000118  30C0              xor al,al
0000011A  CD21              int byte 0x21
0000011C  48                dec ax
0000011D  49                dec cx
0000011E  5E                pop si
0000011F  4C                dec sp
00000120  51                push cx
00000121  6E                outsb
00000122  1B4E75            sbb cx,[bp+0x75]
00000125  53                push bx
00000126  1A5F75            sbb bl,[bx+0x75]
00000129  7F59              jg 0x184
0000012B  19756B            sbb [di+0x6b],si
0000012E  44                inc sp
0000012F  7519              jnz 0x14a
00000131  47                inc di
00000132  5F                pop di
00000133  46                inc si
00000134  1E                push ds
00000135  5E                pop si
00000136  1A5875            sbb bl,[bx+si+0x75]
00000139  6558              gs pop ax
0000013B  754E              jnz 0x18b
0000013D  19491A            sbb [bx+di+0x1a],cx
00000140  47                inc di
00000141  5A                pop dx
00000142  1B466F            sbb ax,[bp+0x6f]
00000145  58                pop ax
00000146  57                push di

Mình thu được source code Assembly như trên

Hex dump rút gọn phần đầu:

0000: be 1c 01          ; mov si, 0x011c           ; trỏ tới chuỗi dữ liệu
0003: 80 3c 24          ; cmp byte ptr [si], 0x24  ; '$'?
0006: 74 06             ; je  +6  -> thoát vòng lặp
0008: 80 34 2a          ; xor byte ptr [si], 0x2a  ; giải mã từng byte (XOR 0x2A)
000b: 46                ; inc si
000c: eb f5             ; jmp 0x0003
000e: ba 1c 01          ; mov dx, 0x011c           ; DX = chuỗi vừa giải mã
0011: b4 09             ; mov ah, 9
0013: cd 21             ; int 21h (DOS print until '$')
0015: c3                ; ret
...
001c: <dữ liệu mã hoá ... kết thúc bằng '$'>

Nhận xét:

  • Vòng lặp giải mã XOR 0x2A từng byte từ offset 0x11C (tương ứng file offset 0x1C) cho đến khi gặp ký tự kết thúc chuỗi $
  • Sau khi giải mã xong, chương trình gọi INT 21h, AH=09 để in chuỗi (DOS sẽ in đến $)

Script giải mã

data = open('FLGPRNTR.COM','rb').read()
start = 0x1C
end   = data.find(b'\x24', start)
plain = bytes(b ^ 0x2A for b in data[start:end])
print(plain.decode())

Flag

Flag: bctf{D1d_y0u_Us3_An_3mul4t0r_Or_d3c0mp1lEr}

'WriteUp > Forensics' 카테고리의 다른 글

zip2john2zip - BuckeyeCTF 2025  (0) 2025.11.09
The Professor's Files - BuckeyeCTF 2025  (0) 2025.11.09
[Forensics] Please recover my files - Dreamhack  (0) 2025.11.04
investigation_encoded_2 - picoCTF  (0) 2025.11.04
Corrupted file - picoCTF  (0) 2025.11.04
'WriteUp/Forensics' Other posts in category
  • zip2john2zip - BuckeyeCTF 2025
  • The Professor's Files - BuckeyeCTF 2025
  • [Forensics] Please recover my files - Dreamhack
  • investigation_encoded_2 - picoCTF
longhd
longhd
Longhd's Blog
  • longhd
    Ha Duy Long - InfosecPTIT
    longhd
  • Total
    Today
    Yesterday
  • About me

    • Hello I'm Duy Long 👋🏻
    • View all categories (117) N
      • Certificates (4)
      • CTF (3)
      • WriteUp (94) N
        • Forensics (44) N
        • Steganography (5)
        • RE (9) N
        • OSINT (8)
        • Web (17)
        • MISC (6)
        • Crypto (3)
        • Pwn (2)
      • Love Story (0)
      • Labs (15)
        • Information Gathering (10)
        • Vulnerability Scanning (2)
        • Introduction to Web Applica.. (1)
        • Common Web Application Atta.. (1)
        • SQL Injection Attacks (1)
  • Blog Menu

    • Home
    • Tag
    • GuestBook
  • Popular Posts

  • Tags

    Dreamhack
    CTF
    Web
    V1tCTF2025
    writeup
    PTITCTF2025
    CSCV2025
    misc
    Re
    htb
    CHH
    picoCTF
    THM
    Steganography
    EnigmaXplore3.0
    Forensics
    BuckeyeCTF2025
    OSINT
    POCCTF2025
    SunshineCTF2025
  • Recent Comments

  • Recent Posts

  • hELLO· Designed ByLong.v4.10.4
longhd
1985 - BuckeyeCTF 2025
Go to Top

티스토리툴바