HackTM Quals20 - The dragon sleeps at night

Posted on mer. 05 février 2020 in CTF

solves : 332

The dragon sleeps at night
50 Points

I made this console based dragon RPG.
Go kill the beast!

nc 138.68.67.161 60004

Author: stackola

We have a role play and need to slay the dragon to discover the flag.

$ nc 138.68.67.161 60004
Welcome to our little town!
We're glad you've decided to help us fight the dragon and bring back this town to it's old glory.

We have a shop where you can buy many different weapons for your fight!
There's also a mine for you to work at. The boss is a very trusting guy, don't try to scam him please.

-------------------------------
-------------------------------
Day: 0
Time: 00:00
Your balance: $0
-------------------------------
1: Go to store
2: Go to work
3: Go to dragons cave
4: Go home
5: Storage

Let's try to visit it to say hello:

> 3
You can not enter this cave without a sword

Ok, then go to work:

> 2
-------------------------------
Going to work...
Time passes...
Slowly...
-------------------------------
Boss wants to know how many hours you worked: > 99999
Only 3 characters allowed
-------------------------------

Can't use string binger than 3 chars. Let's try with a negative one:

> 2
-------------------------------
Going to work...
Time passes...
Slowly...
9e9
-------------------------------
Boss wants to know how many hours you worked: > -1
-1.0 hours at $1/hour? That's $-1.0.
$-1.0 received.
-------------------------------
Day: 0
Time: 06:00
Your balance: $-1.0
-------------------------------

Perfect! We loose one dollar with the work. Let's restaret and but something that can fit 3 chars and big number: 9e9 or inf.

-------------------------------
Going to work...
Time passes...
Slowly...
9e9
-------------------------------
Boss wants to know how many hours you worked: > 9e9
9000000000.0 hours at $1/hour? That's $9000000000.0.
$9000000000.0 received.
-------------------------------
Day: 0
Time: 06:00
Your balance: $9000000000.0
-------------------------------
1: Go to store
2: Go to work
3: Go to dragons cave
4: Go home
5: Storage

Nice. We have now a lot of money. Need to get a sword to enter the dragons cave.

> 1
-------------------------------
Welcome to the store:
-------------------------------
Level 1 Sword: 10 Damage
Price: $10
-------------------------------
Level 2 Sword: 100 Damage
Price: $100
-------------------------------
Level 3 Sword: 1,000 Damage
Price: $1,000
-------------------------------
Level 4 Sword: 10,000 Damage
Price: $1,000,000
-------------------------------
Level 5 Sword: 100,000 Damage
Price: $1,000,000,000
-------------------------------
What do you want? (1-5 or e for exit) > 5
Received Sword level 5.
-------------------------------

Ready to fight and get the flag!

Day: 0
Time: 12:00
Your balance: $8000000000.0
Your sword: 5
-------------------------------
1: Go to store
2: Go to work
3: Go to dragons cave
4: Go home
5: Storage
> 3
-------------------------------
Welcome to the dragon's cave
-------------------------------
The dragon is awake.
He sees you first and instantly kills you with a large fireball.
Game over

All of this to get instantly turn into a big meat ball :'(. Ok, the title is The dragon sleeps at night. So, it's a hint. We can only go to the cave when it's night in the game (18:00).

Let's do the same but with a extra going/back to the shop:

[...]
-------------------------------
Welcome to the dragon's cave
-------------------------------
You see the dragon sleeping next to a pile of bodies.
They look disturbingly fresh.
Carrying your glorious level 5 sword, you slowly walk over.
Carefully, you position the mighty weapon exactly over his skull.
BOOM! Perfect hit!
The dragon wakes up! He's not dead?
I was told level 5 would be enough!
'if only there was a level 6 sword' are your last thoughts...
...as the dragon obliterates you with a hurricane of fire.
Game over

Nooooo. We need a higher sword level to beat this dragon.

So, take a look to the storage.

> 5
-------------------------------
Storage for up to (1) sword.
Please note: Swords degrade by 1 level for each day they are left in storage.
-------------------------------

Hum, for each day in the storage, the sword will loose a level. But, maybe as the worked hours, we can deposit the sword and wait a negative number of day. Let's try this!

Storage is empty.
Do you want to deposit your sword? (y/n) > y
Deposited sword level 5
-------------------------------
Day: 0
Time: 18:00
Your balance: $8000000000.0
-------------------------------
1: Go to store
2: Go to work
3: Go to dragons cave
4: Go home
5: Storage
> 4
Your home.
Here you can take a rest.
How many days do you want to rest for? > -1
Sleeping for -1 days
A sword in storage has degraded from 5 to 6.
You woke up well rested.

Worked as intended! Let's grab back the sword and fight back the dragon for the last time!

-------------------------------
Day: -1
Time: 12:00
Your balance: $8000000000.0
-------------------------------
1: Go to store
2: Go to work
3: Go to dragons cave
4: Go home
5: Storage
> 5
-------------------------------
Storage for up to (1) sword.
Please note: Swords degrade by 1 level for each day they are left in storage.
-------------------------------
Storage contains a sword level 6
Do you want to take the sword out? (y/n) > y
Receiving level 6 sword.
-------------------------------
Day: -1
Time: 18:00
Your balance: $8000000000.0
Your sword: 6
-------------------------------
1: Go to store
2: Go to work
3: Go to dragons cave
4: Go home
5: Storage
> 3
-------------------------------
Welcome to the dragon's cave
-------------------------------
You see the dragon sleeping next to a pile of bodies.
They look disturbingly fresh.
Carrying your level 6 sword, you walk over to the dragon
You're still dizzy from the time travelling
About half way towards the dragon, the blade starts vibrating
As if by magic, it's pulled out of your hands, and towards the dragon
As it reaches approximately Mach 2 right before impact, you take cover behind a cliff

The impact can only be compared to a small bomb. The entire cave shakes not unlike during an earthquake.
As you look up from you cover, you see the level 6 sword floating in place, just where the dragon used to be.
You walk up to the sword and inspect it closely.

On the blade you can see a faint inscription. You are pretty sure this wasn't here before:

HackTM{g3t_m0re_sl33p_and_dr1nk_m0re_water}