def __init__(self): with open('../config.json', 'r') as file: config = json.load(file) _email = config['email'] _pass = config['pass'] # Set Location of data file _input = '../' + config['input_file'] _output = config['output_file'] _api = config['gmaps-api-key'] self._email = _email self._pass = _pass self._input = _input self._output = _output self._api = _api browser = mechanize.Browser() browser.set_handle_robots(False) cookies = mechanize.CookieJar() browser.addheaders = [( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' )] browser.open("https://m.facebook.com/") browser.select_form(nr=0) # Enter Facebook information of user that's performing the search browser.form['email'] = _email browser.form['pass'] = _pass response = browser.submit() self.browser = browser self.response = response
def init(self): """ Initializes the proper browser for authentication based on configuration, and performs necessary error-checking. """ # error if no field params are set. if not any(self.fields.values()): raise BruteException( "no input parameters for user/pwd combo given for module.") if self.headless: # initialize headless browser browser = mechanize.Browser() browser.set_handle_robots(False) # configure before requesting cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) if self.headers is not None: browser.addheaders = list(self.headers.items()) browser.set_handle_refresh(False) # initialize as attribute, and open self.browser = browser self.browser.open(self.address) else: self.browser = webdriver.Firefox() self.browser.get(self.address)
def fb(bot, update, args): browser = mechanize.Browser() browser.set_handle_robots(False) #Allows everything to be written cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7')] browser.set_handle_refresh(False) #Sometimes hangs without this try: url = 'http://www.facebook.com/login.php' soup = authenticate(browser, url, args[0], args[1]) #Parses the html and stores in 'soup' fr_num_box = soup.find('span',attrs={'id':'requestsCountValue'}) #Finds span tags with the given ID info = "You have %s new friend requests\n" %(fr_num_box.text) #Displays and gives the string between the span tags (<span>...</span>) msg_num_box = soup.find('span',attrs={'id':'mercurymessagesCountValue'}) info +="You have %s unread messages\n" %(msg_num_box.text) notifs_num_box = soup.find('span',attrs={'id':'notificationsCountValue'}) info += "You have %s unread notifications"%(str(int(notifs_num_box.text)+1)) bot.sendChatAction(chat_id = update.message.chat_id, action = ChatAction.TYPING) bot.sendMessage(chat_id = update.message.chat_id, parse_mode=ParseMode.HTML, text = info) except AttributeError: error = "Either the password or email id you've entered is wrong" bot.sendChatAction(chat_id = update.message.chat_id, action = ChatAction.TYPING) bot.sendMessage(chat_id = update.message.chat_id, text = error)
def mechanized_login(self, url='', email='', passw=''): mech_br = mechanize.Browser() mech_br.set_handle_robots(False) mech_br.set_header( 'User-Agent', value= 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36' ) cookies = mechanize.CookieJar() mech_br.set_cookiejar(cookies) mech_br.set_handle_equiv(True) mech_br.set_handle_gzip(True) mech_br.set_handle_redirect(True) mech_br.set_handle_referer(True) mech_br.open(url) for form in mech_br.forms(): if form.attrs['id'] == 'login_form': mech_br.form = form break log(self, mech_br.form) mech_br.form.set_value(email, name='email') mech_br.form.set_value(passw, name='pass') response = mech_br.submit() # log(self, response.geturl()) driver = webdriver.Chrome() driver.get(response.geturl())
def __init__(self, tableName, scanType, credentialsEntity=None): self.__tableName = tableName self.__scanType = scanType self.__credentialsEntity = credentialsEntity self.authenticationRequired = True self.authenticationSupplied = False self.authenticationMethod = None self.loginPage = None self.loginPageHash = None self.get_configuration_properties() self.formsMap = {} self.linksMap = {} self.nonVulnerableScannedForms = [{}, {}, {}] self.scannedParameters = {} self.pendingParameters = {} if scanType == 'ALL': self.errorBasedPayloads = self.__get_payloads_by_type(payload_type=self.error_based) self.errorBasedResponses = self.get_error_based_responses() ALLPAYLOADS = 1000 self.rxssPayloads = self.__getRXSSPayloads(page=0, size=ALLPAYLOADS) self.timeBasedPayloads = self.__get_payloads_by_type(payload_type=self.time_based) elif scanType == 'SQLI': self.errorBasedPayloads = self.__get_payloads_by_type(payload_type=self.error_based) self.errorBasedResponses = self.get_error_based_responses() self.timeBasedPayloads = self.__get_payloads_by_type(payload_type=self.time_based) elif scanType == 'RXSS': ALLPAYLOADS = 1000 self.rxssPayloads = self.__getRXSSPayloads(page=0, size=ALLPAYLOADS) self.br = mechanize.Browser() self.cookie_jar = mechanize.CookieJar() self.init_mechanize()
def mechanize_cookie(config, log): """Returns a new Intel Ingress cookie via mechanize.""" import mechanize log.info("Logging into Facebook using mechanize") browser = mechanize.Browser() if log.level <= 10: browser.set_debug_http(True) browser.set_debug_responses(True) browser.set_debug_redirects(True) browser.set_handle_robots(False) cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.addheaders = [( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' )] browser.set_handle_refresh(False) log.info("Everything set - Let's go") url = 'https://www.facebook.com/v3.2/dialog/oauth?client_id=449856365443419&redirect_uri=https%3A%2F%2Fintel.ingress.com%2F' browser.open(url) log.info("Opened Facebook Login Page") log.debug(browser.geturl()) # sometimes you have to fill in the form multiple times for whatever reason tries = 0 while "https://intel.ingress.com/" not in browser.geturl() and tries < 5: tries += 1 log.info(f"Trying to log into Intel: Try {tries}/5") browser.select_form(nr=0) try: browser.form['email'] = config.ingress_user browser.form['pass'] = config.ingress_password except: pass response = browser.submit() time.sleep(2) log.debug(browser.geturl()) if "https://intel.ingress.com/" in response.geturl() and response.getcode( ) == 200: log.info("Got through. Now getting that cookie") log.debug(browser.geturl()) # this is magic req = mechanize.Request(browser.geturl()) cookie_list = browser._ua_handlers['_cookies'].cookiejar.make_cookies( response, req) final_cookie = _write_cookie(log, {c.name: c.value for c in cookie_list}) return final_cookie else: log.error("Failed to login into Intel") log.info(browser.geturl()) return ""
def readUrl(inUrl): tryCount = 0 while tryCount < 5: # print "Create CookieJar" cookies = mechanize.CookieJar() # print "Build Opener" opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookies)) # print "Add Headers" opener.addheaders = [("User-agent", "Mozilla/5.0 (compatible; MyProgram/0.1)"), ("From", "*****@*****.**")] # print "Install Opener" mechanize.install_opener(opener) try: # print "Open URL" response = mechanize.urlopen(inUrl) tryCount = 99 except: tryCount += 1 print "******** Error on urlopen ***********" print "URL: ", inUrl print "Trying Again....", tryCount # print response.read() # html = urllib.urlopen(inUrl).read() # print "Reading Response" html = response.read() # print "Response Read:", html[0:100] root = lxml.html.fromstring(html) # print "Root created: ", root return root
def retrieve_product_data(self, product_link): cookies = mechanize.CookieJar() opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookies)) opener.addheaders = [('User-agent', 'Mozilla/5.0 (MyProgram/0.1)'), ('From', '*****@*****.**')] mechanize.install_opener(opener) browser = mechanize.Browser() product_data = browser.open(product_link).get_data() soup = BeautifulSoup(product_data) product_name = soup.find('title').string.encode('ascii', 'ignore') product_prices = soup.find('div', 'price').contents try: cash_price = int(clean_price_string(product_prices[4])) product_data = ProductData() product_data.custom_name = product_name product_data.price = cash_price product_data.url = product_link product_data.comparison_field = product_link return product_data except IndexError: return None
def cli(login): browser = mechanize.Browser() browser.set_handle_robots(False) #Allows everything to be written cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.addheaders = [( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' )] browser.set_handle_refresh(False) #Sometimes hangs without this try: url = 'http://www.facebook.com/login.php' soup = authenticate(browser, url, email, pwd) #Parses the html and stores in 'soup' if (login): #To find number of new friend request fr_num_box = soup.find('span', attrs={ 'id': 'requestsCountValue' }) #Finds span tags with the given ID if (fr_num_box != None): click.echo("\n\nLOGIN SUCCESSFUL!\n") else: click.echo( "\n\nLOGIN UNSUCCESSFUL!\nEither the password or email id you've entered is wrong!\nPlease try again!" ) except AttributeError: click.echo("Either the password or email id you've entered is wrong")
def retrieve_product_links(self): cookies = mechanize.CookieJar() opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookies)) opener.addheaders = [('User-agent', 'Mozilla/5.0 (MyProgram/0.1)'), ('From', '*****@*****.**')] mechanize.install_opener(opener) url_base = 'http://www.globalmac.cl/' browser = mechanize.Browser() url_extensions = [ ['Distribuidor-Apple-Chile/MacBook-Air', 'Notebook'], ['Distribuidor-Apple-Chile/MacBook-Pro', 'Notebook'], ['Hardware-Mac-PC/Discos-Duros-Notebook-SATA-2.5', 'StorageDrive'], ['Hardware-Mac-PC/Discos-Duros-SATA-3.5', 'StorageDrive'], ['Hardware-Mac-PC/Discos-Duros-SSD-SATA-2.5', 'StorageDrive'], ] product_links = [] for url_extension, ptype in url_extensions: url = url_base + url_extension base_data = browser.open(url).get_data() soup = BeautifulSoup(base_data) for item in soup.findAll('div', 'name'): product_links.append([item.find('a')['href'], ptype]) return product_links
def slurp_with_login_and_pwd(): import sys import mechanize # sys.path.append('ClientCookie-1.0.3') # from mechanize import ClientCookie # sys.path.append('ClientForm-0.1.17') # import ClientForm # Create special URL opener (for User-Agent) and cookieJar cookieJar = mechanize.CookieJar() opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookieJar)) opener.addheaders = [("User-agent", "Mozilla/5.0 (compatible)")] mechanize.install_opener(opener) fp = mechanize.urlopen("http://login.yahoo.com") forms = mechanize.ParseResponse(fp) fp.close() # print forms on this page for form in forms: print "***************************" print form form = forms[0] form["login"] = "******" # use your userid form["passwd"] = "password" # use your password fp = mechanize.urlopen(form.click()) fp.close() fp = mechanize.urlopen( "https://class.coursera.org/ml-003/lecture/download.mp4?lecture_id=1" ) # use your group fp.readlines() fp.close()
def cli(scores): browser = mechanize.Browser() browser.set_handle_robots(False) #Allows everything to be written cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.addheaders = [( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' )] browser.set_handle_refresh(False) #Sometimes hangs without this if (scores): #Called after score option is called soup = find_soup( browser, 'http://www.goal.com/en-in/live-scores') #Gets HTML of entire page score_box = soup.find_all('div', attrs={ 'class': 'match-main-data' }) #Navigating to where the score is available in the page click.echo( "\nThe scores of all matches being played currently is displayed below:" ) click.echo( "--------------------------------------------------------------------" ) for i in score_box: #To get the score of all live matches and recently done matches print i.text click.echo( "--------------------------------------------------------------------" ) click.echo("\n\nNOTE: ALL THE MATCH TIMINGS ARE IN GMT\n\n")
def teardownFBSessions(): """ Log out all facebook sessions """ data = json.load(open('config.json', 'r')) try: username, password = None, None if data["user"] == 'Eve': username = data["config"]["user"]["eve"]["facebook"]["name"] password = data["config"]["user"]["eve"]["facebook"]["password"] elif data["user"] == 'Alice': username = data["config"]["user"]["alice"]["facebook"]["name"] password = data["config"]["user"]["alice"]["facebook"]["password"] else: raise Exception("The user specified is not implemented yet.") if not username or not password: raise Exception("Either username or password is not set") browser = mechanize.Browser() browser.set_handle_robots(False) cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.addheaders = [( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' )] browser.set_handle_refresh(False) url = 'https://www.facebook.com/login.php' browser.open(url) browser.select_form( nr=0) #This is login-password form -> nr = number = 0 browser.form['email'] = username browser.form['pass'] = password response = browser.submit() # get fb_dtsg for cookie in cookies: if cookie.name == 'c_user': user = cookie.value break url = 'https://www.facebook.com/settings/security/password/?recommended=false&dpr=2&__user={}&__a=1'.format( user) response = browser.open(url) body = response.read().decode('string_escape') fb_dtsg = re.search('fb_dtsg\" value=\"([a-zA-Z:_0-9]*)', body).group(1) # logout all sessions url = 'https://www.facebook.com/security/settings/sessions/log_out_all/?dpr=' requests.post(url, cookies=cookies, data={ '__user': user, 'fb_dtsg': fb_dtsg }) except Exception: running_logger.exception('Exception in teardownFBSessions()')
def __init__(self): self.logged_in = False self.br = mechanize.Browser() self.cj = mechanize.CookieJar() self.br.set_cookiejar(self.cj) self.br.set_handle_refresh(False) self.br.addheaders = [('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64; \ rv:13.0) Gecko/20100101 Firefox/13.0.1')]
def sifre6(): filepath = os.path.join(folders, 'nfo.txt') cj = mechanize.CookieJar() name = __settings__.getSetting("Name") login = __settings__.getSetting("Username") password = __settings__.getSetting("password") if not login: __settings__.openSettings() else: pass br = mechanize.Browser(factory=mechanize.RobustFactory()) br.set_cookiejar(cj) br.set_handle_equiv(True) 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 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11' ), ('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'), ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'), ('Accept-Encoding', 'none'), ('Accept-Language', 'en-US,en;q=0.8'), ('Connection', 'keep-alive') ] br.open('https://koditr.org/wp-login.php') br.title() br.select_form(nr=0) br.form['log'] = __settings__.getSetting("Username") br.form['pwd'] = __settings__.getSetting("password") br.submit() html2 = br.response().read() if "welcome" in html2: print "basarili bir login yapildi" else: dialog = xbmcgui.DialogProgress() dialog1 = xbmcgui.Dialog() dialog1.ok( '[COLOR red][B]IPTV HATA UYARISI[/B][/COLOR]', '[COLOR yellow][B]Bronze Uye Olmaniz Gerekiyor!!! Eger Bronze Uye Iseniz ve Bu Mesaji Goruyorsaniz[/B][/COLOR]', '[COLOR red][B]Yanlis Kullanici adi veya Sifre Girdiniz!!! Lutfen Tekrar Deneyiniz.[/B][/COLOR]' ) br.open('https://koditr.org/welcome/') html = br.response().read() return html
def __init__(self): self.browser = mechanize.Browser() self.browser.set_handle_robots(False) cookies = mechanize.CookieJar() self.browser.set_cookiejar(cookies) self.browser.addheaders = [( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' )] self.browser.set_handle_refresh(False)
def _get_cookies(): global COOKIES if COOKIES != None: return COOKIES br = get_browser() cj = mechanize.CookieJar() br.set_cookiejar(cj) br.open('http://www.opentable.com/new-york-city-restaurants') COOKIES = cj return COOKIES
def test_pickle_cookie(self): cookiejar = mechanize.CookieJar() url = "http://example.com/" request = mechanize.Request(url) response = mechanize._response.test_response(headers=[("Set-Cookie", "spam=eggs")], url=url) [cookie] = cookiejar.make_cookies(response, request) check_equality = lambda unpickled: self.assertEqual(unpickled, cookie) test_pickling(cookie, check_equality)
def init(): global browser, cookies browser = mechanize.Browser() browser.set_handle_robots(False) cookies = mechanize.CookieJar() browser.addheaders = [( 'User-agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0' )] Notify.init('idontknow')
def setUpClass(cls): cls.__vulnsCRUD = VulnerabilitiesCRUD cls.__table_name = "test_vulns" + str(datetime.now()).replace( '-', '').replace(' ', '').replace(':', '').replace('.', '') # cls.__vulnsCRUD.createTable(cls.__table_name, "test") cls.__SQLICRUD = SQLICrud cls.__SQLICRUD.dropPayloadsTable("test2") cls.__SQLICRUD.dropResponsesTable("test2") cls.__SQLICRUD.createSQLITable("test2") cls.__vulnDescriptor = VulnerabilityDescriptionCRUD cls.__vulnDescriptor.dropTable("test2") cls.__vulnDescriptor.createTable("test2") cls.__br = mechanize.Browser() cls.__br.addheaders = [( 'User-agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/534.34 (KHTML, like Gecko) Chrome/53.0.2785.113 Safari/534.34' )] cls.cj = mechanize.CookieJar() cls.__br.set_cookiejar(cls.cj) cls.__br.open("http://localhost/bwapp/login.php") i = 0 found = False while not found: try: cls.__br.select_form( nr=i ) # TODO: Zur what if the login form is not the first form? cls.__br.form['login'] = '******' cls.__br.form['password'] = '******' cls.__br.submit() found = True except mechanize.ControlNotFoundError: i += 1 print("in controlnotfound") except: print("no such control") raise Exception( "Couldn't find form in login page. Please verify that the supplied login info is correct" ) cookie_value_string = [] for cookie in cls.cj: cookie_dict = { "name": cookie.name, "value": cookie.value, "domain": cookie.domain, "path": cookie.path } cookie_value_string.append(cookie_dict) # cookie_value_string += cookie.name + "=" + cookie.value + "=" + cookie.domain + "=" + cookie.path + ";" cls.__session_entity = SessionEntity('Cookie', cookie_value_string) # cls.vulnUtils = VulnerabilityUtils(cls.__table_name, 'SQLI') cls.__sqlAlgorithm = SQLIAlgorithm( db_type='test2') # , vuln_table_name=cls.__table_name)
def get_browser(): br = mechanize.Browser() br.set_cookiejar(mechanize.CookieJar()) br.set_handle_equiv(True) 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 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] return br
def bb_login(browser): browser.set_handle_robots(False) cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.set_handle_refresh(False) #Credentials url = 'https://adamson.blackboard.com' browser.open(url) browser.select_form(nr=1) browser.form['user_id'] = 'BLACKBOARD_USER_HERE' browser.form['password'] = '******' response = browser.submit()
def secondSession(url, cookie): browser2 = mechanize.Browser() intruderCookieJar = mechanize.CookieJar() intruderCookieJar.set_cookie(cookie) browser2.set_cookiejar(intruderCookieJar) browser2.open(url) response = browser2.response() return response.read()
def test_pickle_cookie(self): from mechanize._clientcookie import cookies_equal cookiejar = mechanize.CookieJar() url = "http://example.com/" request = mechanize.Request(url) response = mechanize._response.test_response(headers=[("Set-Cookie", "spam=eggs")], url=url) [cookie] = cookiejar.make_cookies(response, request) def check_equality(b): self.assertTrue(cookies_equal(cookie, b)) test_pickling(cookie, check_equality)
def test_generate_new_cookie(self): url = "http://localhost/bwapp/sqli_3.php" creds = CredentialsEntity({ "formAction": "http://localhost//bWAPP/login.php", "form": { "login": "******", "password": "******", "security_level": 0, "form": "submit" } }) self.__vulnsCRUD.deleteAllDataFromTable(self.__table_name, "test2") vulnUtils = VulnerabilityUtils(self.__table_name, "SQLI", creds) #vulnUtils.generateNewCookie(creds) br = mechanize.Browser() br.addheaders = [( 'User-agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/534.34 (KHTML, like Gecko) Chrome/53.0.2785.113 Safari/534.34' )] cj = mechanize.CookieJar() br.set_cookiejar(cj) br.open("http://localhost/bwapp/login.php") i = 0 found = False while not found: try: br.select_form(nr=i) br.form['login'] = '******' br.form['password'] = '******' br.submit() found = True except mechanize.ControlNotFoundError: i += 1 print("in controlnotfound") except: print("no such control") raise Exception( "Couldn't find form in login page. Please verify that the supplied login info is correct" ) r = br.open(url) hash = hashlib.md5(url + str(len(str(r.read())))).digest().encode("hex") forms, links = vulnUtils.get_injection_points( PageEntity(url=url, pageHash=hash), None) self.__sqlAlgorithm.start_scan(PageEntity(url=url, pageHash=hash), forms=forms, links=links, vulnUtils=vulnUtils) self.assertEqual( len(VulnerabilitiesCRUD.getVulns("test2", self.__table_name)), 2)
def setUpBrowser(): browser = mechanize.Browser() browser.set_handle_robots(False) cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7')] browser.set_handle_refresh(False) url = 'http://m.facebook.com/login.php' browser.open(url) browser.select_form(nr = 0) #This is login-password form -> nr = number = 0 browser.form['email'] = '*****@*****.**' browser.form['pass'] = '******' browser.submit() return browser
def __init__(self): self.target = None self.uses_https = False self.max_depth = 20 self.br = mechanize.Browser() self.br.set_handle_robots(False) cj = mechanize.CookieJar() self.br.set_cookiejar(cj) self.discover = [] self.mails = [] self.sitemap_graph = {} self.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' )] # A fake web browser
def overdrive_get_record(self, br, log, q, ovrdrv_id): import mechanize search_url = q + 'SearchResults.aspx?ReserveID={' + ovrdrv_id + '}' results_url = q + 'SearchResults.svc/GetResults?sEcho=1&iColumns=18&sColumns=ReserveID%2CTitle%2CSubtitle%2CEdition%2CSeries%2CPublisher%2CFormat%2CFormatID%2CCreators%2CThumbImage%2CShortDescription%2CWorldCatLink%2CExcerptLink%2CCreatorFile%2CSortTitle%2CAvailableToLibrary%2CAvailableToRetailer%2CRelevancyRank&iDisplayStart=0&iDisplayLength=10&sSearch=&bEscapeRegex=true&iSortingCols=1&iSortCol_0=17&sSortDir_0=asc' # noqa # re-initialize the cookiejar to so that it's clean clean_cj = mechanize.CookieJar() br.set_cookiejar(clean_cj) # get the base url to set the proper session cookie br.open_novisit(q) # initialize the search self.safe_query(br, search_url) # get the results req = mechanize.Request(results_url) req.add_header('X-Requested-With', 'XMLHttpRequest') req.add_header('Referer', search_url) req.add_header('Accept', 'application/json, text/javascript, */*') raw = br.open_novisit(req) raw = str(list(raw)) clean_cj = mechanize.CookieJar() br.set_cookiejar(clean_cj) return self.sort_ovrdrv_results(raw, log, None, None, None, ovrdrv_id)
def sifre3(): filepath = os.path.join(folders, 'nfo.txt') cj = mechanize.CookieJar() name = __settings__.getSetting("Name") login = __settings__.getSetting("Username") password = __settings__.getSetting("password") if not login: __settings__.openSettings() else: pass br = mechanize.Browser(factory=mechanize.RobustFactory()) br.set_cookiejar(cj) br.set_handle_equiv(True) 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 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1' )] br.open('http://koditr.org/wp-login.php') br.title() br.select_form(nr=0) br.form['log'] = __settings__.getSetting("Username") br.form['pwd'] = __settings__.getSetting("password") br.submit() html2 = br.response().read() if "welcome" in html2: print "basarili bir login yapildi" else: dialog = xbmcgui.DialogProgress() dialog1 = xbmcgui.Dialog() dialog1.ok( '[COLOR red][B]Vip + HATA UYARISI[/B][/COLOR]', '[COLOR yellow][B]Silver Uye Olmaniz Gerekiyor!!! Eger Silver Uye Iseniz ve Bu Mesaji Goruyorsaniz[/B][/COLOR]', '[COLOR red][B]Yanlis Kullanici adi veya Sifre Girdiniz!!! Lutfen Tekrar Deneyiniz.[/B][/COLOR]' ) br.open('http://koditr.org/xman/') html = br.response().read() return html
def setup(): if (internet_on() == True): color_print("\n\n[+] Connection to server successfull", color='green') else: color_print("[!] Connection to server failed", color='red') return # Setup the proxy. #proxy = urllib2.ProxyHandler({'http': '127.0.0.1:1234'}) #opener = urllib2.build_opener(proxy) #urllib2.install_opener(opener) # Check if we have setup a proxy. #isProxy = raw_input("Please setup your proxy on http://127.0.0.1:1234 Type [Y]: ") #if isProxy == 'Y' or isProxy == 'y' or isProxy == 'yes' or isProxy == 'Yes': # color_print("[+] Proxy setup on http://127.0.0.1:1234", color='green') # Setup Mechanize global browser browser = mechanize.Browser() cookies = mechanize.CookieJar() browser.set_cookiejar(cookies) browser.set_handle_robots(False) browser.set_handle_refresh(True) # Set a random user agent. user_agents = [ 'Mozilla/5.0 (X11; U; Linux; i686; en-US; rv:1.6) Gecko Debian/1.6-7', 'Konqueror/3.0-rc4; (Konqueror/3.0-rc4; i686 Linux;;datecode)', 'Opera/9.52 (X11; Linux i686; U; en)' ] random_user_agent(browser, user_agents) # Check if the config file has debugging turned on. isDebugging = configParser.get('Config', 'debug') if isDebugging == 'True': # Want debugging messages? browser.set_debug_http(True) browser.set_debug_redirects(True) browser.set_debug_responses(True) # Open up the facebook page. url = 'http://www.facebook.com/login.php' browser.open(url, timeout=1) browser.select_form(nr=0)