Home
Github
  • 👋Welcome !
  • 🚩CTF Writeups
    • SKR CTF
      • Binary
        • Auth Me 2.0
      • Misc
        • Schrodinger's Cat 2
      • Reverse Engineering
        • Nogard 3
    • osu!gaming CTF 2024
      • pwn
        • betterthanu
    • Crackmes
      • PieIsMyFav
      • Plain Sight
    • WolvCTF 2024
      • pwn
        • babypwn
    • TexSAW CTF 2024
      • rev
        • Catch The White Rabbit
      • Forensics
        • Malicious Threat
        • MalWhere?
    • SwampCTF 2024
      • Misc
        • Lost Some Magic
        • The Time Equations
    • pwnable.kr
      • Toddler's Bottle
        • fd
    • Codegate CTF 2024
      • ai
        • ai_warmup
    • Junior Crypt CTF 2024
      • Misc
        • Terms of Use
      • Forensics
        • Admin Rights
        • Confusion
      • PPC
        • l33t
    • IHack 2024 Qualification
      • DFIR
        • Happy SPLUNKing
      • Malware
        • Confusing Javascript
    • Malcore Challenge
    • Intern Task
      • SQLI
  • 📮Room/Machine
    • HTB - Sherlock
      • DFIR
        • Brutus
        • Unit42
        • Jingle Bell
  • 📚Notes
    • CTF Related
      • pwn
        • pwntools
        • Format String Vulnerability
        • Integer Overflow
        • Executable Properties
        • gdb-gef
        • Template Script
      • b2r/koth
    • Assembly Language
    • x86 Architecture
  • 🛠️Tools
    • DFIR
    • Malware Analysis
    • Essentials
  • 👽Threat Hunting
    • Intro
    • Common Tactics
    • Methodologies
    • Types of threat hunting
  • 😸whoami
    • About Me
    • Other
      • FYP
  • Archives
    • 3108 CTF
      • Kategori
        • Tugasan Utama : Warkah Untuk Perwira
          • Tugasan I : Seruan Perwira
          • Tugasan II : Tali Barut
          • Warkah Akhir
        • Web
          • Lemah
          • Pantun Pantul
          • Wantujus
          • Wantusom
        • Reverse Engineering
          • Pa+rio+ik
          • Sarawak
        • Network
          • Johan
          • Lagi-lagi Johan
        • Misc
          • 3108 CTF Town
          • Mencari Rahsia Si Dia
        • Cryptography
          • 1957bit
          • Nasihat
          • Selamat Malam
        • OSINT
          • Pertemuan Kapisata : Babak I
          • Pertemuan Kapista : Babak II
          • Pertemuan Kapista : Finale
    • Curtin CTF 2023
      • Pwn n Rev
        • Classic Bufferoverflow
        • Intro to Buffer Overflow
        • Don't Go Overboard
        • Don't Go Overboard 2
        • Let The Random Games Begin1
        • Let The Random Games Begin 2
        • Let The Random Games Begin 3
    • 1337UP LIVE CTF
      • Pwn
        • Floor Mat Store
    • HTB University CTF 2023
      • Reverse Engineering
        • Windows Of Opportunity
Powered by GitBook
On this page
  • Solution
  • Flag
  1. CTF Writeups
  2. Codegate CTF 2024
  3. ai

ai_warmup

pyjail

Last updated 1 year ago


Solution

For the first part, it prompts us a CAPTCHA. Just input the right answer based on the question given and we can proceed to the next part.

solve_captcha.py
import hashlib
import string
import itertools

# Provided values
salt = ""
target_hash = ""
difficulty = 4  # Length of the correct string

def find_correct_str(salt, target_hash):
    characters = string.ascii_letters + string.digits
    for combo in itertools.product(characters, repeat=difficulty):
        correct_str = ''.join(combo)
        full_str = salt + correct_str
        if hashlib.sha256(full_str.encode()).hexdigest() == target_hash:
            return correct_str
    return None

cracked_str = find_correct_str(salt, target_hash)

if cracked_str:
    print(f"Cracked! The correct string is: {cracked_str}")
else:
    print("Failed to crack the CAPTCHA.")

For the next part, the AI Assistant will generate a code based on the user input. The catch is, there are several words/command being blocked in the source code as shown as below.

Basically, this challenge is very similar to a pyjail challenge.

So we cannot use commands like cat flag, grep "flag" etc.

If we input ls in the user input, the AI Assistant will provide a code that uses os.listdir() which then being block.

Instead, we use os.execl() for the user input.

List out the current directory, we can see the file named flag existed.

Also, the AI Assistant will use print() function if we input strings flag to the user input, which then being blocked aswell.

So, read the flag using strings command and os.execl() function


Flag

codegate2024{4105775410d0ff2ab259d36124e145bc96d9d6195aa9886a56f8d7cef70fafda3ceb91f0996fed616429a95519a513f6}

🚩
blacklisted keyword