Buy Flag - CTF 16

IHC Blog

CTF No: 16 CTF

Name: Buy Flag 

Topic: Reverse Engineering 

Flag Format: IHC_CTF{}

CTF Link: https://t.me/ctf_invisiblehc/30

Description: 

Download this file and run it. Run command: ./ctf16 Now buy the flag. Insufficient Balance? Need Money? Try buying pant to earn money.

Solve:

Open up the source, and we see that the service is a simple store. It offers us 3 options, but we're interested in is the second one.

IHC Blog

The second one offers real flag. But the real flag costs 15000 dollars, and we only start with 10000. So how do we get more money?

if we choose 2, it will say Flag Price is 15000 dollars, and Insufficient Balance. Earn money.

if we choose 1, 

it will Avaiable Pant is 5 

Every Pant Price is 7500

How many pant do you want to buy?

if we choose 1, it will say Your Balance 2500

Nothing Interesting Till now . But Look at the initial value given which is 100 . It look’s like a signed integer. So let’s checkout if we create a buffer-overflow here or not. pant cost is 7500 and the max value of a buffer in C is 2147483647

So we need to order (2147483647/7500)= 286331 pants for reach out the max value

We ordered 286332 and now our current balance is 2147479796 We can buy Flag from this Money.

  IHC Blog

Flag: IHC_CTF{R3V3R53_15_7RYCKY}

~ Writeup By mum1n

Join Our CTF Channel: https://t.me/ctf_invisiblehc