It's simple. The Python script is as follows:
import requests
import hashlib
import re
def parse_and_encode(text):
reg = re.compile(r"<h3 align='center'>(.*)</h3>", re.MULTILINE)
text = reg.findall(text)[0]
h = hashlib.md5(text.encode('utf-8'))
dig = h.hexdigest()
return { 'hash': dig }
session = requests.Session()
r = session.get('http://<IP>:<PORT>/')
data = parse_and_encode(r.text)
r2 = session.post('http://<IP>:<PORT>/', data=data)
reg = re.compile(r"<p align='center'>(.*)</p>", re.MULTILINE)
flag = reg.findall(r2.text)[0]
print(flag)
To run the script, use the command python3 .\life.py
. The flag is HTB{N1c3_ScrIpt1nG_B0i!}
.