Hack.Lu CTF 2013 – Packed

Hack.Lu CTF 2013 - Packed - Task Description

Die Challenge “Packed” beschreibt den Fund verwürfelter Daten, in denen sich irgendwo noch etwas Nützliches befinden soll. Zur Bearbeitung erhalten wir nur eine Datei, die wir zunächst etwas genauer untersuchen:

Hack.Lu CTF 2013 - Packed - File Content

Neben vielen Bytes, die sich nicht wirklich zuordnen lassen, sind doch drei Dinge relatisch schnell erkennbar. Im oberen Bereich befindet sich ein PDF, das im Magick zu erkennen ist (nicht abgebildet). Darunter befindet sich ein Text aus ASCII-Zeichen, der jedoch unverständlich ist. Zusammen mit dem Wort “rot”, das in der Datei vorhanden ist, könnte es sich jedoch um einen ROT13-Cipher handeln.

Im unteren Bereich befindet sich ein langer Abschnitt aus Base64-kodierten Daten. Wenn wir die Abschnitte nun einzeln untersuchen, stellen wir Folgendes fest. Die PDF-Datei kann direkt ausgeschnitten und dann geöffnet werden. Als Ergebnis erhalten wir diese Ausgabe:

Hack.Lu CTF 2013 - Packed - PDF File Part

Sowohl optisch als auch forensisch sind keine weiteren Informationen aus dieser Datei zu entnehmen.

Continue reading

Hack.Lu CTF 2013 – Pay TV

Hack.Lu CTF 2013 - Pay TV - task description

Diese Challenge verlangt von uns, Zugriff auf eine Pay TV Plattform mit Nachrichten über das “Oktoberfest” zu erlangen. Dazu erhalten wir nichts weiter als die Webseite selbst genannt, die wir uns als Erstes ansehen.

Hack.Lu CTF 2013 - Pay TV - Website

Auf der Webseite befindet sich nur ein Bild sowie die Eingabemaske für ein Passwort. Sehen wir uns also als Nächstes des HTML-Quellcode genauer an.

<!DOCTYPE html>
<title>Skynet Pay TV</title>
<link rel="stylesheet" href="/static/style.css">
<div id="container">
    <div id="news">
        <div id="newstext">
        </div>
    </div>
    <img src="/static/noise.gif" id="noise">
    <form action="/gimmetv" method="post">
        <input type="text" id="key" name="key" focus><br />
        <input type="submit" value=" ">
        <div id="error"></div>
    </form>
</div>
<script src="/static/key.js"></script>

In Zeile 10 erkennen wir, dass die Formulardaten an das Ziel “/gimmetv” gesendet werden. Außerdem wird ein in Zeile 16 ein zusätzliches JavaScript eingebunden, dass sich in “/static/key.js” befindet. Auch diese Datei laden wir herunter und betrachten sie.
Continue reading

NcN 2013 CTF Quals – Level 3

To access “Level 3” of the NcN CTF we first need to download the file (level.elf) the server offers. Running the program for the first time shows the following output:

NcN 2013 Quals - level 3 - program first run

The binary waits for user input. After pressing one key, it denies access with the message “I DON’T THINK SO”. Maybe we need to press another key to that one I pressed before. I tried all keys and finally got this result when pressing “SPACE”.

NcN 2013 Quals - Level 3 - First character found

It displays an additional star to indicate that our first character (SPACE) was right. Pressing SPACE again leads to program failure again. What we need to do is just gaining the full passphrase. This can be achieved by brute forcing it – the same way we found the first character – or by analyzing the binary code.

A first look into the assembler code of the binary shows some obfuscation inside. So I decided that brute forcing the key will be much faster. The following PERL Script does the job for us:

#!/usr/bin/perl -w

$found = $ARGV[0];

for ($i = 0x20; $i<=0x7f; $i++) {
  $try = $found . chr($i);
  print "TRYING: $try ($i)\n";

  open(CRACK, "| ./level.elf");
  print CRACK $try;
  close(CRACK);
}

At first it takes one argument that contains the beginning of the string, we already verified. Afterwards the script just tries to append all human-readable characters to the string and passes it to the binary. The result is printed on the screen.
Continue reading

NcN 2013 CTF Quals – Level 2

Level 2 of NcN CTF offers a “level.apk” file for downloading. After fetching and extracting it’s contents, the folder res arrested my attention.

There are 16 png-files , each one is a part of a qr code.

NcN 2013 Quals - Level 2 - QR Image

The easiest way to solve the puzzle is to arrange the parts on one’s own without writing a script. After finishing the puzzle …

NcN 2013 Quals - Level 2 - Final QR Code

… you only need to scan the qr code with any tool you like (in my case it was a smart phone) , and there it is, the flag:

 788f5ff85d370646d4caa9af0a103b338dbe4c4bb9ccbd816b585c69de96d9da

Of course I could have written a script. But in my opinion it was only worth if I would have to solve not only one puzzle. Concluding it is only a diligent but routine piece of work.

NcN 2013 CTF Quals – Level 1

NcN 2013 Qualification - Level 1 - Task Description

To get the key for “Access Level 1” we need to pass an authentication form. When trying to submit a key, we get the following reply:

NcN 2013 Quals - Level 1 - Invalid Password

So we need to have a look into the source code of the password validation functions. At first we are going to see the HTML lines (index.php). The interesting ones are these:

<script type="text/javascript" src="crypto.js"></script>

<form action="login.php" method="POST" onsubmit="return encrypt(this);">
  <input id="key" type="hidden" name="key" value="" />
  <input id="verification" type="hidden" name="verification" value="yes" />
</form>

As we can see the page uses an external JavaScript file to calculate the validation of the password. Next step will be to examine this script file (crypto.js). It looks like this:

var _0x52ae=["\x66\x20\x6F\x28\x38\x29\x7B\x63\x20\x69...
...,"\x67"];eval(function (_0x7038x1,_0x7038x2,_0x7038x3..
...toString(36));};if(!_0x52ae[4][_0x52ae[6]](/^/,String)..
...[0],46,46,_0x52ae[3][_0x52ae[2]](_0x52ae[1]),0,{}));

The JavaScript itself uses many “eval” (evaluation) functions, confusing variable names and is incredible obfuscated at all. It cannot be read this way! So we need make it readable again – at best evaluate the “eval” function to get the real plain source code. It very good way to do so is using raw SpiderMonkey – the Mozilla JavaScript engine:

Continue reading

DEF CON CTF 2013 – rememberme

DEFCON CTF 2013 - rememberme - task description

Diese Challenge (rememberme) nennt wieder nur eine Webseite, die wir für einen ersten Eindruck direkt besuchen.

DEFCON CTF 2013 - rememberme - website

Die Seite selbst verlinkt zwei Dateien und bietet einen Login an, den wir jedoch ohne Zugangsdaten nicht nutzen können. Beim Aufruf der Datei “usernames.txt” kann man folgendes erkennen:

DEFCON CTF 2013 - rememberme - usernames.txt

Neben den Benutzernamen fällt hier jedoch besonders die URL mit dem Parameter “accesscode” auf. Der Hash-Wert dieses Parameters entspricht im vorliegenden Fall, der folgenden Berechnung:
Continue reading

DEF CON CTF 2013 – hypeman

DEFCON 2013 CTF - hypeman - task description

Auch bei dieser Challenge (hypeman) wird uns nur eine Webseite genannt, die wir auch sofort aufrufen.

DEFCON 2013 - hypeman - website

Zunächst steht uns nur ein Login zur Verfügung. Da hier jedoch zusätzlich auch ein neuer Benutzer erstellt werden kann, legen wir einen neuen Account an und loggen uns ein.

DEFCON CTF 2013 - hypeman - secrets listing

Andere Benutzer haben hier offensichtlich bereits Eintäge angelegt. Aber ganz oben befindet sich auch ein Schlüssel des Benutzers “admin”. Dieser könnte unser Ziel sein und die Lösung zur Challenge beinhalten. Ein klick auf “show” zeigt uns jedoch einen Fehler.
Continue reading

DEF CON CTF 2013 – babysfirst

DEFCON 2013 CTF - babysfirst - task description

Die Challenge (babysfirst) verweist zunächst nur auf eine Webseite, die wir uns direkt näher ansehen.

DEFCON 2013 CTF - babysfirst - website

Einer der ersten SQL-Injection-Versuche mit ‘ or ‘1’=’1 als Benutzername und Passwort liefert direkt, dieses Ergebnis:

DEFCON 2013 CTF - babysfirst - sql injection

Neben diversen Möglichkeiten, kann hier zum Beispiel eine Blind SQL-Injection durchgeführt werden.
Continue reading

DEF CON CTF 2013 – diehard

DEFCON 2013 CTF - diehard - task description

Die Challenge “diehard” befasst sich mit dem gleichnamigen Film “Stirb Langsam” Dabei soll John McClane eine Bombe entschäfen, indem er Wasser innerhalb zwei verschieden großer Gefäße umfüllt.

Nach dem Verbinden zum Challenge-Server sehen wir zuerst jedoch nur folgende Nachricht:

rup0rt@lambda:~$ nc diehard.shallweplayaga.me 4001
Welcome John McClain...
You are standing at the start of your adventure. You will be tested
on your ability to solve a set of riddles in the minimum amount of
time possible.

As you glance around the room, you realize the problem you seek is
to the north. To the west is a mysterious field.
Exits: n w
>

Offensichtlich müssen wir uns zunächst durch ein Labyrinth im Text-Adventure-Stil arbeiten, bevor wir die “Rätsel” lösen können. Da uns der Weg “im Norden” jedoch bereits vorgegeben ist, navigieren wir promt in diese Richtung.

> n

You go n
You are standing in a long dark hallway. Rays of light flicker off the smooth surfaces around you.
Exits: n s
> n

[...]

You go n
You see a large room with sleek black walls on every side.  The ceiling overhead is smooth and devoid of features. In the center of the room is a small scale that links to a closed door.
A small fountain is gurgling water in the corner. The scale has a small inscription on it.
A red jug is sitting in the room.
A blue jug is sitting in the room.
A fountain is sitting in the room.
A scale is sitting in the room.

Continue reading

DEF CON CTF 2013 – Grandprix

The grandprix challenges requires us to connect to a server where we can play an ascii game. According to the assignment text, we are advised to avoid the zebras.

Let’s check out the game first using netcat:

$ nc grandprix.shallweplayaga.me 2038
nc: using stream socket
Use 'l' and 'r' to move. Don't crash.
Press return to start
 |-----|
 |     |
 |     |
 |     |
 |     |
 |     |
 |     |
 |     |
 |     |
 |  u  |
 |-----|

The games starts with an empty field. Obviously, our position is indicated by an u. We fiddle around a little to learn how the game works. Sending an r moves the player one step right, a l one left and a s or an empty line moves the player straight forward.

 r
 |-----|
 |     |
 |     |
 |     |
 |     |
 |     |
 |     |
 |     |
 |     |
 |   u |
 |-----|

The more we move along, the more obstacles appear. A T marks a tree and the Zebras we were warned about are indicated by a Z.
Continue reading