def enumattempt(url, credqueue, validqueue, proxy): print '[*] Starting new enum thread.' while True: try: creds = credqueue.get(timeout=10) except Queue.Empty: print '[-] Credential queue is empty, quitting.' return # If there are good creds in the queue, stop the thread if not validqueue.empty(): print '[-] Success queue has credentials, quitting.' return try: #resp = requests.request('GET', url, auth=(creds[0], creds[1]), proxies=proxy) s = requesocks.Session() s.auth = (creds[0], creds[1]) s.proxies = proxy resp = s.get(url) if resp.status_code == 200: print '[+] Success: {0} : {1}'.format(creds[0], creds[1]) validqueue.put(creds) return else: print '[-] Failure: {0}/{1}'.format(creds[0], creds[1]) except: print "\n\n\n\n", traceback.format_exc()
def fetch_proxies(): global proxies, proxies_num, proxies_current url = "http://www.socks-proxy.net" while True: proxies_temp = [] http_session = requests.Session() r = http_get(http_session, url) if r is None or r.status_code != 200: continue try: d = pq(r.text) trs = d("tbody> tr") for tr in trs: l = pq(tr) tds = l("td") proxy = { "ip:port": "%s:%s" % (tds.eq(0).text(), tds.eq(1).text()), "http_type": tds.eq(4).text() } #logger.info(proxy) proxies_temp.append(proxy) except: logger.info(r.status_code) logger.info(r.text) proxies = proxies_temp proxies_num = len(proxies) proxies_current = 0 if proxies_num == 0: time.sleep(10) continue break
def session_parameters(tor=False,user_agent='',verbose=False,proxy=''): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) if proxy is not '' and tor: print colors.yellow('\b[**] ')+"Debe elegir solo una de las opciones, proxy o tor" sys.exit() if tor: p = commands.getoutput("ps -e|grep tor|wc -l") if '1' in p: os.system("sudo service tor restart") elif '0' in p: os.system("sudo service tor start") print colors.green('\b[*] ')+"Utilizando tor..." s = requesocks.Session() s.proxies = {'http': 'socks5://127.0.0.1:9050','https': 'socks5://127.0.0.1:9050'} if user_agent is not '': s.headers = {'User-agent':user_agent[:-1]} allow_redirects=False print colors.green('[*] ')+" Se asigno la IP: "+s.get('http://ipecho.net/plain').text+"\n" if verbose else '', s.verify=False return s if proxy is not '': s = requests.Session() s.proxies = s.proxies = {'http': proxy, 'https': proxy} if user_agent is not '': s.headers = {'User-agent':user_agent[:-1]} allow_redirects=False print colors.green('[*] ')+" Se esta utilizando la IP: "+s.get('http://ipecho.net/plain').text+"\n" if verbose else '', s.verify=False return s else: s = requests.Session() if user_agent is not '': s.headers = {'User-agent':user_agent[:-1]} s.verify=False return s
def __init_session(self, proxy): if proxy is None or not self.__is_socks_proxy(proxy): self.session = requests.Session() return if requesocks: self.session = requesocks.Session() else: log.ThugLogging.log_warning( "Socks proxyg not supported (requesocks not found)")
def remote_fetch_with_proxy(url, proxy_info): if 'socks' in json.dumps(proxy_info): s = requesocks.Session() else: s = requests.Session() s.trust_env = False s.proxies = proxy_info retry = 2 while True: try: r = s.get(url, verify=get_ca_certs_env()) if r.status_code != requests.codes.ok: # @UndefinedVariable raise Exception("invalid response") return r.text.encode("utf-8") except Exception, e: if retry > 0: print str(e), "give it another chance ..." retry -= 1 else: raise
def fetch_proxies1(): global proxies, proxies_num, proxies_current, proxies_priority proxies_priority = 1 url = "http://proxy.mimvp.com/api/fetch.php?orderid=860150908143212810&num=100&country_group=1&http_type=4,5&result_fields=1,2&result_format=json" #url = "http://proxy.mimvp.com/api/fetch.php?orderid=860150908143212810&num=10&http_type=1&result_fields=1,2&result_format=json" while True: http_session = requests.Session() r = http_get(http_session, url) if r is None or r.status_code != 200: continue try: data = json.loads(r.text) except: logger.info(r.status_code) logger.info(r.text) proxies = data["result"] proxies_num = len(proxies) proxies_current = 0 if proxies_num == 0: time.sleep(10) continue break
def get_http_session(): global proxies, proxies_num, proxies_current, proxies_priority flag = 0 if proxies_priority != 0: conn = db.connect_torndb_crawler() result = conn.get("select count(*) cnt from proxy_tyc") conn.close() if result["cnt"] > 0: fetch_proxies3() flag = 1 if flag == 0: if proxies_num == 0 or proxies_current >= proxies_num: if proxies_current == proxies_num: delete_last_proxy_from_db() fetch_proxies3() if proxies_current > 0: delete_last_proxy_from_db() proxy_ip = proxies[proxies_current] proxies_current += 1 logger.info("Proxy IP: %s" % proxy_ip) http_session = requests.Session() if proxy_ip["http_type"] == "Socks4": http_type = "socks4" elif proxy_ip["http_type"] == "HTTP": http_type = "http" else: http_type = "socks5" http_session.proxies = { "http": "%s://%s" % (http_type, proxy_ip["ip:port"]) } #http_session.proxies={"http":"socks5://222.187.210.218:1080"} return http_session
def __init_session(self, proxy): if proxy is None or not self.__is_socks_proxy(proxy): self.session = requests.Session() return self.session = requesocks.Session()
def xor(x, y): if len(x) > len(y): y = y * (len(x) / len(y)) return ''.join(map(lambda x: chr(ord(x[0]) ^ ord(x[1])), zip(x, y))) UA = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)' hdrs = {} #hdrs['Accept-Language']='pl' hdrs[ 'Accept'] = 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*' hdrs['User-Agent'] = UA s = requests.Session() #s.proxies={'http':'http://localhost:8118','https':'http://localhost:8118'} s.headers = hdrs ## lets do it... BASE_URL = sys.argv[1] r = s.get(BASE_URL) if r.status_code == 444: print "[-] zed's dead, either blackisted ip or wrong country..." sys.exit(1) url = urlparse.urlparse(r.url) payload = {} ## decode landing for txt in landing.decode_first_js(r.content):