Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import time
- import os
- import sys
- import glob
- import pickle
- registerUrl = 'http://epay.info/faucets/Bitcoin/'
- dashboardUrl = 'http://epay.info/faucets/Bitcoin/'
- claimUrl = 'http://5minbitcoin.com/index.php?cmd=claim'
- captchaUrl = 'http://www.google.com/recaptcha/api.js'
- payoutUrl = 'http://epay.info/withdrawal/'
- ProxyTestPayload = 'http://secure.gaug.es/track.js'
- def Login(BitcoinAddress):
- # Load the proxy list file
- ProxyList = [line.rstrip('\n') for line in open(sys.argv[2])]
- # Debug
- print 'Loaded main proxy list...'
- # Load filenames of all files in the directory that end with *.proxy
- P = glob.glob('./*.proxy*')
- # Load proxy server info from each of those files into a list
- RegProxies = []
- for x in range(len(P)):
- f = open(P[x], 'r')
- RegProxies.append(f.read())
- f.close()
- # Find a proxy server from the Proxy list file which is not in the list of files ending with *.proxy
- if(len(P) > 0):
- Px = []
- for x in range(len(P)):
- for y in range(len(ProxyList)):
- if(P[x] == ProxyList[y]):
- pass
- else:
- # An unused proxy has been found - add it to a canidates list of proxies
- Px.append(ProxyList[y])
- # Searched through the entire list, just take the first unused proxy from the top of the list
- Proxy = Px[0]
- # Debug line
- print 'Selected non-used proxy from the proxy list'
- print Proxy
- # Remove that proxy from the ProxyList array and rewrite the proxy file
- ProxyList.remove(Px[0])
- f = open(sys.argv[2], 'w')
- for x in range(len(ProxyList)):
- f.write(ProxyList[x] + '\n')
- f.close()
- else:
- # There are no proxy files in the directory, use the first proxy server from the Proxy List
- Proxy = ProxyList[0]
- # Remove the Current Proxy from the List and rewrite the proxy list file
- del ProxyList[0]
- f = open(sys.argv[2], 'w')
- for x in range(len(ProxyList)):
- f.write(ProxyList[x] + '\n')
- f.close()
- # Test the proxy server to see if it's usable
- if(CheckProxy(Proxy, ProxyTestPayload) == 'down'):
- # The proxy is down remove that Proxy address from the Proxy list file
- # Debug line
- print 'Current proxy is down ... trying the next one'
- # Proxy check failed - exit to release a file-lock so other instances can access the proxy list file
- return
- else:
- # Change the proxy format string to something directly useable with requests instead of the ProxyCheck function
- SimpleProxyFormat = Proxy
- Proxy = {'http': 'http://' + Proxy,}
- print 'using proxy: ' + str(Proxy)
- # First Request is to get cookies from the Index page
- s = requests.session()
- print 'getting initial cookies...'
- try:
- s.get(dashboardUrl, headers=s.headers.update({'User-Agent': randomUA()}), proxies=Proxy, timeout=30)
- if(CheckIdiotProxyResponse == 'idiot'):
- # Can't even get initial cookies - unstable proxy - find another one
- return
- except:
- # Can't connect - find another proxy
- return
- try:
- print 'registering bitcoin wallet address...'
- # Submit the Bitcoin Address to login
- s.post(registerUrl, data = {'bitcoin': BitcoinAddress}, headers=s.headers.update({'User-Agent': randomUA()}), proxies=Proxy, timeout=30)
- if(CheckIdiotProxyResponse == 'idiot'):
- # Got an idiot response - try another proxy
- return
- except:
- # Connection error - try another proxy
- return
- print 'getting captcha image'
- # Get the Claim Page to update any cookies
- try:
- s.get(claimUrl, headers=s.headers.update({'User-Agent': randomUA()}), proxies=Proxy, timeout=30)
- Captcha = s.get(captchaUrl)
- imageData = Captcha.content
- print 'saving captcha image...'
- # Write the Captcha image to the disk
- f = open('Captcha_' + BitcoinAddress + '.jpg', 'w')
- f.write(imageData)
- f.close()
- # Check the File's MIME data to see if we actually got JPG image
- m = magic.open(magic.MAGIC_MIME)
- m.load()
- MIMEtype = m.file('Captcha_' + BitcoinAddress + '.jpg')
- if(MIMEtype.find('text/html') > -1):
- # it's not an image - probably another proxy died in someway
- print 'proxy returned non JPG data'
- return
- except:
- # couldn't get the Captcha image - just exit
- return
- # Generate the webcontent to solve the captcha
- #f = open(BitcoinAddress + '.htm', 'w')
- #t = open('CaptchaInputTemplate.html', 'r')
- #template = t.read()
- #t.close()
- #HTMLdata = template.replace('THISBITCOINADDRESS', BitcoinAddress)
- #f.write(HTMLdata)
- #f.close()
- # Save Proxy address
- print 'Saveing Proxy info'
- f = open(BitcoinAddress + '.proxy', 'w')
- f.write(SimpleProxyFormat)
- f.close()
- print 'Saving HTTP header'
- # Save session headers
- f = open(BitcoinAddress + '.headers', 'w')
- f.write(str(s.headers))
- f.close()
- print 'Saving Cookies'
- save_cookies(s.cookies, BitcoinAddress + '.cookie')
- def CheckProxy(server, testLink):
- try:
- # Download the test file without a proxy
- t = requests.get(ProxyTestPayload)
- source = t.content
- ProxyServer = {'http': 'http://' + server,}
- r = requests.get(testLink, proxies=ProxyServer, timeout=5)
- test = r.content
- if(source == test):
- return 'up'
- else:
- # it's up but it's down... get it? hahaah - probably just got a proxy Error page
- return 'down'
- except:
- return 'down'
- def save_cookies(requests_cookiejar, filename):
- with open(filename, 'wb') as f:
- pickle.dump(requests_cookiejar, f)
- def randomUA():
- UserAgents = ['Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0']
- return UserAgents[0]
- def CheckIdiotProxyResponse(responseData):
- Rejected = ['Attention Required!', 'Access Denied', 'No DNS records', 'DNS resolving failed', 'ERROR', 'Privoxy']
- for y in range(len(Rejected) -1):
- if(responseData.find(Rejected[y]) > -1):
- # The proxy is rejecting the request - better try a new one
- return 'idiot'
- # If the proxy file exists, don't try to login with another proxy
- try:
- f = open(sys.argv[1] + '.proxy', 'r')
- f.close()
- except:
- # File error - yea, it doesn't exist
- Login(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement