Advertisement
skip420

claim.py

Nov 25th, 2017
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.37 KB | None | 0 0
  1. # this script goes into the same directory as scan-wallets.py&process-claims.py&login.py&satoshi.py&claim.py&WalletsNew.txt&Proxies.txt
  2.  
  3.  
  4.  
  5. import requests
  6. import time
  7. import os
  8. import sys
  9. import pickle
  10. from pyquery import PyQuery
  11.  
  12. def load_cookies(filename):
  13.     with open(filename, 'rb') as f:
  14.         return pickle.load(f)
  15.  
  16. def randomUA():
  17.     UserAgents = ['Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0']
  18.     return UserAgents[0]
  19.  
  20. BitcoinAddress = sys.argv[1]
  21.  
  22. claimUrl = 'http://www.5minbitcoin.com/index.php?cmd=claim'
  23. ProxyTestPayload = 'http://secure.gaug.es/track.js'
  24.  
  25. # Load the Captcha Code file
  26. try:
  27.     CaptchaFile = open('Captcha_' + BitcoinAddress + '.txt', 'r')
  28.     CaptchaCode = CaptchaFile.read()
  29.     CaptchaFile.close()    
  30.  
  31.     # If we got this far without an error, and there's a JPG file for the Wallet address, we need to get rid of it
  32.     try:
  33.         os.remove('Captcha_' + BitcoinAddress + '.jpg')
  34.     except:
  35.         # Doesn't exist or it's already been removed
  36.         pass
  37. except:
  38.     pass
  39.  
  40. # Load Proxy data
  41. ProxyAddress = open(BitcoinAddress + '.proxy', 'r')
  42. ProxyData = ProxyAddress.read()
  43. Proxy = {'http': 'http://' +  ProxyData,}
  44. ProxyAddress.close()  
  45.  
  46. # Load Header data
  47. H = open(BitcoinAddress + '.headers', 'r')
  48. Headers = H.read()
  49. H.close()
  50.  
  51. def Claim():
  52.     try:
  53.          s = requests.session()
  54.          s.headers = Headers
  55.  
  56.          thisSession = s.post(claimUrl, cookies=load_cookies(BitcoinAddress + '.cookie'), data = {'captcha': CaptchaCode}, proxies=Proxy)
  57.          responseData = thisSession.content
  58.  
  59.          #print responseData
  60.          if(CheckIdiotProxyResponse == 'idiot'):
  61.              # Got an idiot response - try another proxy
  62.              os.remove('Captcha_' + BitcoinAddress + '.txt')
  63.              os.remove(BitcoinAddress + '.proxy')
  64.              os.remove(BitcoinAddress + '.cookie')
  65.              return
  66.  
  67.          # Verify the response data to make sure it's not a random proxy error message
  68.          if(responseData.find('Satoshi') > -1):
  69.            pass
  70.          else:
  71.               print BitcoinAddress + ' Proxy Error'
  72.               #print responseData
  73.               os.remove('Captcha_' + BitcoinAddress + '.txt')
  74.               os.remove(BitcoinAddress + '.proxy')
  75.               os.remove(BitcoinAddress + '.cookie')
  76.              
  77.  
  78.          # sometimes the wallet address gets logged out need to relogin with the same proxy and then retry to claim on the next cycle
  79.          # look for  "cmd=login" in the HTML response
  80.          if(responseData.find('cmd=login') > -1):
  81.            print BitcoiinAddress + ': -' + 'need login'
  82.            p = open('Proxy.pool', 'a')
  83.            p.write( ProxyData + '\n')
  84.            p.close()
  85.  
  86.            os.remove(BitcoinAddress + '.proxy')
  87.            os.remove(BitcoinAddress + '.cookie')
  88.            os.remove(BitcoinAddress + '.headers')
  89.            os.remove('Captcha_' + BitcoinAddress + '.txt')
  90.  
  91.          if(responseData.find('captcha/captcha.php') > -1):
  92.            # Delete the  Captcha Txt, Cookies, and Proxy file for that wallet address
  93.            print BitcoinAddress + ' - need cookie reauth'
  94.            os.remove('Captcha_' + BitcoinAddress + '.txt')
  95.  
  96.            f = open(BitcoinAddress + '.proxy', 'r')
  97.            BackupProxy = f.read()
  98.            f.close()
  99.            f = open('ProxyBackups', 'a')
  100.            f.write(BackupProxy + '\n')
  101.            f.close()
  102.  
  103.            os.remove(BitcoinAddress + '.proxy')
  104.            os.remove(BitcoinAddress + '.cookie')
  105.            os.remove(BitcoinAddress + '.headers')
  106.          else:
  107.               # Parse out the Satoshi balance left to be claimed as well as the time since the last Claim
  108.               html = responseData
  109.               pq = PyQuery(html)
  110.               tag = pq('a')
  111.               SatoshiText = tag.text()
  112.               SatoshiBalance = SatoshiText.split(' ')
  113.  
  114.               # Get the Satoshi account balance
  115.               balance = open(BitcoinAddress + '.sat', 'w')
  116.  
  117.               # Make sure the satoshi balance is greater than zero
  118.               #print html
  119.               try:
  120.                  if(len(SatoshiBalance[7]) > 0):
  121.                    balance.write(SatoshiBalance[7])
  122.                    print BitcoinAddress + ' - ' + SatoshiBalance[7]
  123.               except:
  124.                  # Length of satoshi balance array is off somehow
  125.                  #print SatoshiBalance
  126.                  #print ''
  127.                  #print html
  128.                  pass
  129.  
  130.     except Exception as e:
  131.                 #pass
  132.                 print BitcoinAddress + ': - ' + 'exception'
  133.                 #if(responseData.find('squid') > -1):
  134.                  
  135.                 #  print BitcoinAddress + ' - ' + 'Timeout Error' #str(e)
  136.  
  137.  
  138.                 # Failed too many times - axe it
  139.                 #os.remove('Captcha_' + BitcoinAddress + '.txt')
  140.                 #os.remove(BitcoinAddress + '.proxy')
  141.                 #os.remove(BitcoinAddress + '.cookie')
  142.                 #os.remove(BitcoinAddress + '.headers')
  143.  
  144.  
  145. def CheckIdiotProxyResponse(responseData):
  146.     Rejected = ['Attention Required!', 'Access Denied', 'No DNS records', 'DNS resolving failed', 'ERROR', 'Privoxy']
  147.     for y in range(len(Rejected) -1):
  148.         if(responseData.find(Rejected[y]) > -1):
  149.           # The proxy is rejecting the request - better try a new one
  150.           return 'idiot'
  151.  
  152. Claim()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement