ctfs
  • 👋Hello!
  • 🏴Practice
    • 🌐Cryptohack
      • Introduction
      • General
        • Encoding
        • XOR
        • Mathematics
        • Data Formats
      • Symmetric Ciphers
        • How AES Works
        • Symmetric Starter
        • Block Ciphers 1
        • Stream Ciphers
      • Mathematics
        • Modular Math
        • Lattices
      • RSA
        • Starter
        • Primes Part 1
        • Public Exponent
    • 🌐PortSwigger
      • Path Traversal
      • File Upload
      • SSRF Attacks
    • 🌐TryHackMe
      • Basic Skills
      • Linux
      • Penetration Testing
      • Networking
      • OSINT
  • 🚩Competitions
    • 2025
      • 🇮🇩GKSK#9 Osintathon
        • Mudik Lebaran (100 pts)
        • Foto Patung (100 pts)
        • Kolektor Komik (100 pts)
        • Tolong Aku (100 pts)
        • Kencan Pertama (100 pts)
        • Nama Si Pelaku (100 pts)
        • Cekidot (100 pts)
        • Ledakan! (100 pts)
        • 🎹🎶 (100 pts)
        • Batu Besar (100 pts)
        • Komentar (100 pts)
        • Ini dimana? (100 pts)
        • Koordinat Foto Misterius (100 pts)
        • Bianglalaaa (100 pts)
        • Aku Hacker (100 pts)
        • Anjazzz (100 pts)
        • Dikirim Kakakku (129 pts)
        • Ingfo Loker (154 pts)
        • MISSING 00 (100 pts)
        • MISSING 01 (154 pts)
        • Siapa Aku? (154 pts)
      • 🇮🇩IFEST 13
        • Ququerer (250 pts)
        • Silent Trace (370 pts)
        • Nugas (Solved After Event)
        • Free Flag (280 pts)
        • Brute (Solved After Event)
        • Web V1 (Solved After Event)
        • Bypass (Solved After Event)
        • Orbiter (Solved After Event)
      • 🌐OSINT Combine (Wildlife)
        • Getting Started (100 pts)
        • Proper Poppy (100 pts)
        • Legendary Beasts (200 pts)
        • Shadow Fleet (200 pts)
        • Proper Poppy II (200 pts)
        • Not So Smug Smuggler (200 pts)
        • Icy (200 pts)
        • Forest Pals (200 pts)
        • Safari Time II (200 pts)
        • Sneaky! (200 pts)
        • Hello Friend (300 pts)
        • Busy As A (300 pts)
        • Get Rotated! (300 pts)
        • High Seas (300 pts)
        • Nocturnal (300 pts)
        • Safari Time (400 pts)
        • Peak Weather (400 pts)
        • Singsong (400 pts)
        • Falling Fell (500 pts)
        • Kitty Cats (500 pts)
      • 🇮🇩RECURSION
        • let him cook
        • Basic Math
        • Favourite Number
        • Zarrar Cipher (100 pts)
        • paBlue Team (100 pts)
        • [🩸] I wish I was there on December 21, 2024 (100 pts)
        • Small House (200 pts)
        • [🩸] Mission Difference (456 pts)
    • 2024
      • 🌐Santa Claus CTF
        • Complete Picture
        • Day 1 - Big Bang
        • Day 2 - The Summer Job
        • Day 3 - The Visitors
        • Day 4 - Happy Birthday
        • Day 5 - Say My Name
        • Day 6 - Say "Cheese"
        • Day 7 - Revealing Pixels
        • Day 8 - Connecting The Dots
        • Day 9 - 404 Not Found
        • Day 10 - Breaking News
        • Day 11 - Ayrton Santa
        • Day 12 - Lost and Found
        • Day 13 - Planespotting
        • Day 14 - Santa Surveillance
        • Day 15 - Shaken, Not Stirred
        • Day 16 - Status Update
        • Day 17 - Waste ...of Time
        • Day 18 - Lost in Translation
        • Day 19 - Santa's Clones
        • Day 20 - Losing Tracks
        • Day 21 - Sing my Song
        • Day 22 - Eagle Eye
        • Day 23 - Distances Matters
        • Day 24 - Mastermind
      • 🌐Cyber Jawara International
        • Stone Game (100 pts)
        • prepare the tools (176 pts)
        • Persona (484 pts)
      • 🌐OSMOSIS Precon CTF
        • 1 The art of espionage
        • # 2 The Hack
        • # 3 The rabbit hole
        • # 4 The Association
        • # 6 Where is number 5
        • # 5 Who is it
        • Too many Layers
        • The prize
      • 🇮🇩Intechfest
        • Sanity Check (100 pts)
        • Alin (113 pts)
        • GerakSendiri (106 pts)
        • Details (100 pts)
      • 🇮🇩COMPFEST 16
        • Let's Help John! (100 pts)
        • money gone, wallet also gone (100 pts)
        • head’s up! (493 pts)
        • CaRd (304 pts)
        • Sanity Check (100 pts)
      • 🇮🇩Gemastik
        • Baby AES (451 pts)
        • Baby Structured (100 pts)
      • 🇮🇩Technofair 11
        • Kenangan
        • Xorban
        • Marsha
        • Siap Tempur!!
        • eftipi
        • kurang berarti
        • DUMPling
        • Malicious
      • 🌐DIVER OSINT
        • chiban
      • 🇮🇩GKSK#8 Osintathon
        • Sport Location
        • Meklaren lu warna apa boss ?
        • Postcode
        • Rumah Minang
        • Latihan
        • Anak Misterius
        • Travelling Anywhere
        • The Thief
        • Danger Watch
        • Misteri Ruang Angkasa
        • Fun Walk
        • I am Late
        • My Oshi
        • Wellcome to my Youtube Channel
        • Pesan Tersembunyi Wingdings
        • Salah Fokus
        • Apa itu GKSK?
        • Foto Bersejarah
        • Picture
        • Nostalgia Child
        • oldschool
        • Summer Olympic
      • 🇮🇩Techcomfest
        • pemanasan
        • crackable
        • Kuli-ah forensik
    • 2023
      • 🇮🇩Cyber Jawara
        • daruma
      • 🇮🇩NCW
        • Simple (220 pts)
        • wangsaf (320 pts)
        • Sillyville Saga (220 pts)
        • Freminhelp (Solved after event)
      • 🇮🇩Hology 6
      • 🇮🇩SlashRoot 7
        • Summary (441 pts)
        • eeee (480 pts)
        • Zebra Cross (409 pts)
        • Waka Waka eh eh (185 pts)
        • ANABUL (250 pts)
      • 🇮🇩COMPFEST 15
        • not simply corrupted (316 pts)
        • Artificial secret (356 pts)
      • 🇮🇩Gemastik
        • easy AES
        • k-1
        • Gen Z
      • 🇮🇩TechnoFair 10
        • RSA Bwang
        • Marsah
        • rapsodi
        • Pengen Merch JKT 😢
        • space mono
        • file pemberian fans
        • bantu aku mencari sebuah rahasia
    • 2022
      • 🇮🇩NCW
        • sabeb64 (331 pts)
        • cakemath (451 pts)
        • Downloader (244 pts)
        • 199 passcode (Solved after event)
      • 🇮🇩TEDCTF
      • 🇮🇩Gemastik
      • 🇮🇩OSCCTF
      • 🇮🇩ARA
  • 🪦Old Hello
Powered by GitBook
On this page
  1. Competitions
  2. 2025
  3. IFEST 13

Free Flag (280 pts)

PreviousNugas (Solved After Event)NextBrute (Solved After Event)

Last updated 26 days ago

Mr. Shock is feeling generous today, so here's an attached program that will give you the flag.

Author: Lurifos

Kita diberikan sebuah ELF executable x86-64. Awalnya, saya mencoba untuk langsung membuka file ini menggunakan Ghidra. Akan tetapi, decompilernya gagal membaca fungsi utama entry() dengan benar, dan yang kita dapatkan adalah fungsi berantakan ini.

Setelah iseng mencoba melakukan strings pada file, saya menemukan bahwa file ini telah di-pack menggunakan UPX versi 5.00.

Untuk unpack-nya sendiri cukup menjalankan ./upx -d <file> .

Setelah ini, kita decompile file yang baru menggunakan Ghidra. Sekarang, fungsi entry() tampak lebih jelas.

Fungsi ini memanggil fungsi lainnya yakni FUN_00401080() yang intinya adalah sebuah flag checker. Jika inputnya sama dengan flag, maka outputnya adalah benar.

undefined8 FUN_00401080(void)

{
  char *__s;
  size_t sVar1;
  char *__dest;
  ulong uVar2;
  ulong uVar3;
  bool bVar4;
  char local_41b;
  char local_41a;
  char acStack_419 [1025];
  
  puts("I\'m so sorry, I forgot what the flag is, could you please try to guess it first?");
  __s = acStack_419 + 1;
  printf("flag: ");
  fgets(__s,0x400,stdin);
  sVar1 = strlen(__s);
  if ((sVar1 != 0) && (acStack_419[sVar1] == '\n')) {
    acStack_419[sVar1] = '\0';
  }
  sVar1 = strlen(__s);
  __dest = &local_41b;
  bVar4 = sVar1 == 0x46;
  for (uVar3 = 0; uVar3 < sVar1; uVar3 = uVar3 + 2) {
    if (!bVar4) goto LAB_0040115f;
    __dest = strncpy(__dest,__s + uVar3,2);
    uVar2 = 0;
    if ((local_41b != '\0') && (local_41a != '\0')) {
      uVar2 = (uVar3 + 1) * ((long)local_41a + (long)local_41b * 0x100);
    }
    bVar4 = *(uint *)((long)&DAT_00402360 + uVar3 * 2) == uVar2;
  }
  if (bVar4) {
    puts("\n Wow congrats, that is indeed the correct flag");
  }
  else {
LAB_0040115f:
    puts("\n Uhmm, I\'m afraid that\'s wrong");
  }
  return 0;
}

Kalau dirapihkan, hasilnya akan seperti ini.

int check_flag() {
    char input[0x401];             // acStack_419 + 1
    size_t len;
    bool correct;
    uint16_t lo_hi;                // packed local_41b (low byte) and local_41a (high byte)
    uint32_t expected, computed;

    puts("I'm so sorry, I forgot what the flag is, could you please try to guess it first?");
    printf("flag: ");
    fgets(input, 0x400, stdin);

    // strip trailing newline if present
    len = strlen(input);
    if (len > 0 && input[len-1] == '\n') {
        input[len-1] = '\0';
        len--;
    }

    // Must be exactly 0x46 (70) characters long
    correct = (len == 0x46);

    // For each pair of characters in the input...
    for (size_t i = 0; i < len; i += 2) {
        if (!correct) break;

        // copy two chars into lo_hi: low byte = input[i], high byte = input[i+1]
        uint8_t b0 = input[i];
        uint8_t b1 = input[i+1];
        lo_hi = b0 | (b1 << 8);

        // compute value = (position_index+1) * lo_hi
        // note: position_index = i/2, so (i+1) in code = 2*(index)+1, but since they use (uVar2+1) with
        // uVar2=0,2,4,..., it effectively counts bytes: (byte_offset+1) * lo_hi
        computed = (uint32_t)(i + 1) * (uint32_t)lo_hi;

        // load the expected 32-bit value from the FLAG table at offset i*2
        // (they cast &FLAG + uVar2*2 to a uint*)
        expected = *((uint32_t*)((uint8_t*)&FLAG + i*2));

        if (computed != expected) {
            correct = false;
        }
    }

    if (correct) {
        puts("\n Wow congrats, that is indeed the correct flag");
    } else {
        puts("\n Uhmm, I'm afraid that's wrong");
    }

    return 0;
}

Value "FLAG" adalah DAT_00402360 yang tampak seperti ini pada Ghidra.

Bytes yang ada pada DAT_00402360 , jika dijalankan pada algoritma yang sama dengan fungsi flag checker di atas, tentunya akan menghasilkan flag. Oleh karena itu, berikut adalah script yang saya gunakan.

FLAG_bytes = bytes([
    0x46,0x49,0x00,0x00,0xF9,0xCF,0x00,0x00,0xF5,0xA4,0x01,0x00,
    0x5D,0x68,0x01,0x00,0xCB,0x30,0x04,0x00,0xA4,0xA8,0x04,0x00,
    0x96,0xD8,0x04,0x00,0x39,0xD3,0x02,0x00,0x41,0xEB,0x06,0x00,
    0x3B,0x2E,0x08,0x00,0x05,0xCF,0x07,0x00,0x89,0xFE,0x0A,0x00,
    0x22,0x01,0x0A,0x00,0x61,0x66,0x05,0x00,0x8D,0xC8,0x0A,0x00,
    0x81,0x5D,0x0D,0x00,0x51,0xF2,0x0D,0x00,0xF9,0xF8,0x0D,0x00,
    0x9F,0xCB,0x0D,0x00,0x79,0x5E,0x07,0x00,0xA8,0xDF,0x08,0x00,
    0xE7,0x43,0x08,0x00,0x9D,0xBB,0x10,0x00,0x71,0x77,0x16,0x00,
    0x30,0x17,0x15,0x00,0xED,0x07,0x0B,0x00,0xF0,0xD8,0x17,0x00,
    0xEA,0x7E,0x14,0x00,0x5B,0x6D,0x19,0x00,0xE5,0xD6,0x0B,0x00,
    0x4E,0x7C,0x0C,0x00,0x8D,0x95,0x0D,0x00,0x1F,0x0A,0x1D,0x00,
    0x44,0xB8,0x0D,0x00,0xB1,0x3D,0x1D,0x00
])

flag_chars = []
for k in range(35):
    offset_bytes = 4 * k
    expected = int.from_bytes(FLAG_bytes[offset_bytes:offset_bytes+4], 'little')
    multiplier = 2 * k + 1
    packed = expected // multiplier
    
    # sanity check: integer division exact
    assert expected == packed * multiplier

    high = (packed >> 8) & 0xFF
    low  = packed & 0xFF
    flag_chars.extend([high, low])

flag = bytes(flag_chars).decode('latin1')
print("Recovered flag:", flag)

Flag: IFEST13{w3ll_n07h1n9_1z_fr33_1n_l1f3_s0_7h15_1z_n07_s0_fr33_4f73r_4ll}

Merujuk pada , kita perlu meng-unpack file dengan UPX yang versinya sesuai. UPX versi terbaru dapat di-download .

🚩
🇮🇩
write-up ini
di sini
Just in case you don't know who this generous person is.
file