iliay.ar

I’ve created a custom shopping cart system. Can you get the flag?
nc 164.90.193.27 50009
shop.elf


We get the binary shop_8059c17ac3.elf so lets open up decompiler and play with it a bit.

Analysis

The programm opens port 50009 and wait for a connection:

$ nc localhost 50009
Welcome to our password storage!
1> Create New Session
2> Work With Existing Session
3> Exit
1
90495438b91bc707910561255b74c94c
1> Add new item to shopping cart
2> Delete item from shopping cart
3> Reload shopping cart
4> Print shopping cart
5> Change amount
6> Enter coupon to get gift
7> Proceed
8> Logout
1
Enter item name: My Item
Enter item cost: 10
Enter item amount: 1
1> Add new item to shopping cart
2> Delete item from shopping cart
3> Reload shopping cart
4> Print shopping cart
5> Change amount
6> Enter coupon to get gift
7> Proceed
8> Logout
4
Total: 10$
Item:
 Name: My Item
 Price: 10$
 Amount: 1
1> Add new item to shopping cart
2> Delete item from shopping cart
3> Reload shopping cart
4> Print shopping cart
5> Change amount
6> Enter coupon to get gift
7> Proceed
8> Logout

What I’ve got during one hour:

So now we just want the call to find_item_or_empty on (critical) line in change_amount to return -2, and the items->items[-2] is exactly NEED_TO_BE_NON_ZERO field, which then sets to non zero value.

Exploitation

  1. connect to service, create session(1) and then create item(1)
  2. connect to service, join the session(2) created in 1., reload cart(3) and then delete this item(2)
  3. in connection 1. change item(5) whaterever you want and then proceed(7)