Skip to content

Instantly share code, notes, and snippets.

@ITAYC0HEN
Created September 18, 2016 20:17
Show Gist options
  • Save ITAYC0HEN/e9819c551fe2e28627342c6b15a044a8 to your computer and use it in GitHub Desktop.
Save ITAYC0HEN/e9819c551fe2e28627342c6b15a044a8 to your computer and use it in GitHub Desktop.
[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