How to use the mechanize._http function in mechanize

To help you get started, we’ve selected a few mechanize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unkn0wnh4ckr / hackers-tool-kit / htk.py View on Github external
bad = '\033[1;31m[-]\033[1;m'
  good = '\033[1;32m[+]\033[1;m'
  run = '\033[1;97m[~]\033[1;m'

  # Cookie Jar
  cj = cookielib.LWPCookieJar()
  br.set_cookiejar(cj)

  # Browser options
  br.set_handle_equiv(True)
  br.set_handle_redirect(True)
  br.set_handle_referer(True)
  br.set_handle_robots(False)

  # Follows refresh 0 but not hangs on refresh > 0
  br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
  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')]


  print '''\033[1;31m
     _________ __          __ __
    /   _____//  |________|__|  | __ ___________
    \_____  \\\\   __\_  __ \  |  |/ // __ \_  __ \\
    /        \|  |  |  | \/  |    <\  ___/|  | \/
   /_______  /|__|  |__|  |__|__|_ \\\\___  >__|
           \/                     \/    \/\033[1;m'''
  target = raw_input('\033[1;34m[?]\033[1;m Enter the target: ')
  if 'http' in target:
      parsed_uri = urlparse(target)
      domain = '{uri.netloc}'.format(uri=parsed_uri)
  else:
github minj / foxtrick / maintainer / locale / Hattrick / Web.py View on Github external
def login(self):
		url = self.loginSite
		if self.stage:
			url = self.loginSiteStage

		cookie = cookielib.CookieJar()
		self.browser = mechanize.Browser()

		self.browser.set_cookiejar(cookie)
		self.browser.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)

		self.browser.open(url)

		self.browser.select_form(name="aspnetForm")
		
		try:
			self.browser.form['ctl00$ctl00$CPContent$ucSubMenu$ucLogin$txtUserName'] = self.username
			self.browser.form['ctl00$ctl00$CPContent$ucSubMenu$ucLogin$txtPassword'] = self.password
		except:
			print("Login form not found!")
			
		self.response = self.browser.submit(name='ctl00$ctl00$CPContent$ucSubMenu$ucLogin$butLogin')
		self.body = self.response.get_data()
		self.url = self.response.geturl()

		# now we should be logged in and on the site
github chipx86 / cloudplaya / cloudplaya / client.py View on Github external
def authenticate(self, username, password):
        browser = mechanize.Browser(factory=mechanize.RobustFactory())
        cookiejar = cookielib.LWPCookieJar()
        browser.set_cookiejar(cookiejar)

        browser.set_handle_equiv(True)
        browser.set_handle_redirect(True)
        browser.set_handle_referer(True)
        browser.set_handle_robots(False)
        browser.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(),
                                   max_time=1)
        browser.addheaders = [('User-agent', self.USER_AGENT)]

        # Attempt to log in to Amazon.
        # Note: We should end up with a redirect.
        r = browser.open(self.AUTH_URL)

        browser.select_form(name="signIn")
        browser.form['email'] = username
        browser.form['password'] = password
        browser.form['create'] = False
        browser.submit()

        content = browser.response().read()

        # Get all the amznMusic variables being set.
github tikuskecil / multi-bruteforce-facebook / MBF.py View on Github external
def keluar():
	simpan()
	tampil('\rm[!]Keluar')
	os.sys.exit()
log = 0
id_bteman = []
id_bgroup = []
fid_bteman = []
fid_bgroup = []
br = mechanize.Browser()
br.set_handle_robots(False)
br.set_handle_equiv(True)
br.set_handle_referer(True)
br.set_cookiejar(cookielib.LWPCookieJar())
br.set_handle_redirect(True)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(),max_time=1)
br.addheaders = [('User-Agent','Opera/9.80 (Android; Opera Mini/32.0.2254/85. U; id) Presto/2.12.423 Version/12.16')]
def bacaData():
	global fid_bgroup,fid_bteman
	try:
		fid_bgroup = open(os.sys.path[0]+'/MBFbgroup.txt','r').readlines()
	except:pass
	try:
		fid_bteman = open(os.sys.path[0]+'/MBFbteman.txt','r').readlines()
	except:pass
def inputD(x,v=0):
	while 1:
		try:
			a = raw_input('\x1b[32;1m%s\x1b[31;1m:\x1b[33;1m'%x)
		except:
			tampil('\n\rm[!]Batal')
			keluar()
github fabriciojoc / malware-machinelearning / crawler / crawler.py View on Github external
def get_page(url):
    br = mechanize.Browser()
    br.set_handle_equiv(True)
    br.set_handle_gzip(False)
    br.set_handle_redirect(True)
    br.set_handle_referer(True)
    br.set_handle_robots(False)
    br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
    br.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1')]
    br.open(url)
    url_soup = BeautifulSoup(br.response().get_data(), "lxml")
    return url_soup
github 0xInfection / TIDoS-Framework / modules / 0x03-Vulnerability+Analysis / 0x01-TopPriorityBugs / errorsqlsearch.py View on Github external
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

params = []

br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

class UserAgent(FancyURLopener):
    version = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0'

useragent = UserAgent()
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
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')]

ctr=0
path_list = []
payloads = []

def errorsqlsearch(web):

    os.system('clear')
    print(R+'\n    ======================================')
    print(R+'     S Q L i   H U N T E R (Auto Awesome)')
    print(R+'    ======================================\n')
    print(R+'           [E R R O R   B A S E D] \n')
    with open('files/payload-db/errorsql_payloads.lst','r') as pay:
        for payload in pay:
            rem = payload.replace('\n','')
github hzheng / pybox / pybox / utils.py View on Github external
browser = mechanize.Browser()

    # Cookie Jar
    browser.set_cookiejar(cookielib.LWPCookieJar())

    # Browser options
    browser.set_handle_equiv(True)
    # browser.set_handle_gzip(True)
    browser.set_handle_redirect(True)
    browser.set_handle_referer(True)
    # avoid to be rejected by robots.txt
    browser.set_handle_robots(False)

    # Follows refresh 0 but not hangs on refresh > 0
    browser.set_handle_refresh(
        mechanize._http.HTTPRefreshProcessor(), max_time=1)

    browser.set_debug_http(debug)
    browser.set_debug_redirects(debug)
    browser.set_debug_responses(debug)

    browser.addheaders = [('User-agent',
                           "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; "
                           "rv:7.0.1) Gecko/20100101 Firefox/7.0.1")]
    return browser
github dilawar / playground / MoodleIITB / iitb_moodle.py View on Github external
def __init__(self):
        print("Initializing moodle ... ")
        self.br = mechanize.Browser( factory=mechanize.RobustFactory())
        self.br.set_handle_equiv(False)
        self.br.set_handle_robots(False)
        self.br.set_handle_referer(False)
        self.br.set_handle_redirect(True)
        self.br.set_debug_redirects(True)
        self.br.set_debug_responses(False)
        self.br.set_debug_http(False)
        self.br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=2)
        self.br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux 1686; en-US;\
            rv:1.9.0.1) Gecko/201171615 Ubuntu/11.10-1 Firefox/3.0.1')]
github 0xInfection / TIDoS-Framework / modules / 0x01-OSINT+Footprinting / 0x02-ActiveReconnaissance / serverdetect.py View on Github external
from re import search
from core.Core.colors import *
br = mechanize.Browser()

# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

# Browser options
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
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')]

def serverdetect(web):

    print(R+'\n   ===========================')
    print(R+'    D E T E C T   S E R V E R')
    print(R+'   ===========================\n')
    time.sleep(0.4)
    print(GR+' [*] Checking server status...')
    web = web.replace('https://','')
    web = web.replace('http://','')
    try:
        ip_addr = socket.gethostbyname(web)
        print(G+' [+] Server detected online...')
        time.sleep(0.5)
github askedrelic / comcast-bw / comcastBandwidth.py View on Github external
br.set_cookiejar(cj)

        # Logger
        log = logging.getLogger(__name__)

        # Browser options
        br.set_handle_equiv(True)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            br.set_handle_gzip(True)
        br.set_handle_redirect(True)
        br.set_handle_referer(True)
        br.set_handle_robots(False)

        # Follows refresh 0 but not hangs on refresh > 0
        br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)

        # Want debugging messages?
        if self.verbose:
            console = logging.StreamHandler()
            log.addHandler(console)
            log.setLevel(logging.INFO)
        if self.verbose > 1:
            br.set_debug_http(True)
            br.set_debug_redirects(True)
            br.set_debug_responses(True)

        # Set a reasonably current User-Agent
        br.addheaders = [('User-agent',
            'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US)'
            'AppleWebKit/534.10 (KHTML, like Gecko)'
            'Chrome/8.0.552.11 Safari/534.10')]