Ulli Weichert/ Mai 3, 2022/ IT-Security, Write-Ups/ 0Kommentare

Wizard

You have stumbled upon a wizard on your path to the flag. You must answer his questions!

PS (not challenge related), thank you so much to Hadrian for supporting NahamCon 2022!

Press the Start button on the top-right to begin this challenge.

Solving

To solve this challenge, you need to connect to your own instance via netcat. Then you will be asked for some specific calculations. Such as binary to ascii.

We solved this with this quick & dirty solve.py script.

#!/usr/share/env python

from pwn import *
import binascii
import base64
import struct
import time

host,port = 'challenge.nahamcon.com', 31997

p = log.progress('Working')

try:
    s = remote(host, port)

    p.status('First question - binary to ascii...')
    s.recvuntil(b'binary string?')
    binary_string=s.recv().split()
    binary_string=binary_string[0].decode('utf-8')
    hex_s=hex(int(binary_string,2))
    ascii_text=bytes.fromhex(hex_s[2:]).decode("utf-8")
    s.sendline(bytes(ascii_text,'latin1'))
    time.sleep(1)
    p.status('First question - done!')
    time.sleep(1)

    p.status('Second question - hex to ascii...')
    time.sleep(1)
    s.recvuntil(b'hex string?')
    string=s.recv().split()
    string=string[0].decode('utf-8')
    ascii_text=bytes.fromhex(string).decode('utf-8')
    s.sendline(bytes(ascii_text,'latin1'))
    p.status('Second question - done!')
    time.sleep(1)

    p.status('Third question - octal to ascii')
    time.sleep(1)
    s.recvuntil(b'octal string?')
    string=s.recv().split()
    string=string[8].decode('utf-8')
    string=hex(int(string,8))
    ascii_text=bytes.fromhex(string[2:]).decode('utf-8')
    s.sendline(bytes(ascii_text,'latin1'))
    p.status('Third question - done!')
    time.sleep(1)

    p.status('Fourth question - int to ascii')
    time.sleep(1)
    s.recvuntil(b'this integer?')
    string=s.recv().split()
    string=string[6].decode('utf-8')
    string=hex(int(string))
    ascii_text=bytes.fromhex(string[2:]).decode('utf-8')
    s.sendline(bytes(ascii_text,'latin1'))
    p.status('Fourth question - done!')
    time.sleep(1)

    p.status('Fifth question - decoding base64 string...')
    time.sleep(1)
    s.recvuntil(b'Base64 string?')
    string=s.recv().split()
    string=string[0].decode('utf-8')
    ascii_text=base64.b64decode(string)
    s.sendline(ascii_text)
    p.status('Fifth questions - done!')
    time.sleep(1)

    p.status('Sixth questions - converting little to big endian and calculate ascii text...')
    time.sleep(1)
    s.recvuntil(b'hex string?')
    string=s.recv().split()
    string=string[0].decode('utf-8')
    string=binascii.unhexlify(string)
    ascii_text=string[::-1]
    s.sendline(ascii_text)
    p.status('Sixth questions - done!')
    time.sleep(1)

    p.status('Getting flag...')
    time.sleep(1)
    s.recvuntil(b'witts: ')
    string=s.recvuntil(b"}").decode('utf-8')
    p.success('Got the flag for you!')
    time.sleep(1)
except:
    print('Could not connect to target... something went wrong. Sorry!')

print("\n\n\t"+string+"\n\n")

Further links

Share this Post

Über Ulli Weichert

2004 fing Ulli bei der Bundeswehr als Ausbilder und IT-Spezialist an. 2011 hat Ulli eine Umschulung zum Fachinformatiker für Systemintegration absolviert und sich auf Linux spezialisiert. 2016 hat Ulli dann bei einem mittelständischem Unternehmen, welches Kunden in ganz Deutschland betreut, als Linuxadministrator angefangen und kümmert sich seither nebst, Netzwerk, Security, Firewall, Storage überwiegend um Linuxthemen aller Art. Seit kurzem hat auch Ihn das Thema Container und k8s erwischt.

Hinterlasse einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

*
*