본문 바로가기
[ ★ ]Study/War Game

[Toddler's Bottle] pwnable.kr coin1

by nroses-taek 2018. 8. 12.
반응형

import time
from pwn import *

HOST = 'pwnable.kr'
PORT = 9007
conn = remote(HOST, PORT)
time.sleep(3)
#coin
print conn.recv()

for i in range(0,100):
        conn.recvuntil('N=')
        n = int(conn.recvuntil(' '))
        conn.recvuntil('C=')
        c = int(conn.recv())
        print n, c
        start = 0
        end = n
        msg = ""

        while(start<=end):
                msg = ""
                mid = (start + end ) / 2
                #check the binary search for counterfeit
                print "([+] sending msg ... )"
                for i in range(start, mid+1):
                        msg += str(i) + " "
                msg += '\n'
                conn.send(msg)
                print msg
                dt = conn.recvline()
                if(dt.find("Correct") != -1):
                        break;
                weight = int(dt)
                if(weight % 10 == 0):
                        print "[+] counterfeit not found"
                        start = mid + 1
                elif(weight % 10 != 0):
                        print "[+] counterfeit found"
                        end = mid
        print "counterfeit has been found"

print conn.recv(2014)


---추후 다시 고쳐서 --

반응형

댓글