from pwn import *
import re
import time

def main():
        r = remote("pwnable.kr", 9007)
        res = r.recvuntil("Ready") + r.recvuntil("\x0a")

        print res 
        time.sleep(3)
        for i in range(100):
                res = r.recvuntil("=") + r.recvuntil("\x0a")
                info = res.split(" ")
                p = re.compile("\d+")
                for i in range(0,2):
                        info[i] = p.findall(info[i])
                N = int("".join(info[0]))
                C = int("".join(info[1]))

                print "N : {0}, C : {1}\n".format(N, C)
                src = 0 
                des = N 
                chance_check = 0 

                while src <= des:
                        chance_check += 1
                        dat = ""
                        mid = (src + des) / 2 

                        for i in range(src, mid + 1): 
                                dat += str(i) + " " 
                        r.sendline(dat)
                        weight = r.recv()

                        if int(weight) == 9:
                                break
                        if int(weight) % 10 == 0:
                                src = mid + 1 
                        elif int(weight) % 10 == 9:
                                des = mid - 1 

                for i in range(C - chance_check + 1): 
                        if int(weight) % 10 == 0 and i == 0:
                                dat = str(int(dat)+1)
                        r.sendline(dat)
                        res = r.recv()
                        print res 
        res = r.recv()
        print res 

if __name__ == "__main__":
        main()



'Wargame > pwnable.kr' 카테고리의 다른 글

pwnable.kr cmd1  (0) 2018.06.15
pwnable.kr input  (0) 2018.06.14
[pwnable.kr] shellshock 1p  (0) 2016.08.20
[pwnable.kr] mistake 1p  (0) 2016.08.19
[pwnable.kr] uaf 8p  (0) 2016.08.15

+ Recent posts