Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[CSAW 2016] Coinslot
from pwn import *
r = remote('misc.chal.csaw.io',8000)
# Create an array of dollars and coins values
money = [10000.0, 5000.0, 1000.0, 500.0, 100.0, 50.0, 20.0, 10.0, 5.0, 1.0, 0.5, 0.25, 0.1, 0.05, 0.01]
count = 0
while(True):
count += 1
amount = 0.0
# Recieve the wanted amount of money
amount = float(r.recvline()[1:])
print "Wanted amount is " + str(amount)
# Send the number of dollars and coins for each value
for m in money:
print r.recv()
ans = int(amount/m)
print "Sending %d" %ans
r.sendline(str(ans))
amount = round((amount - (ans*m)), 2)
print "Left with " + str(amount)
print "[+] Finished %d" %count
print r.recvline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.