Advertisement
Guest User

Untitled

a guest
Apr 10th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.94 KB | None | 0 0
  1. #!/usr/bin/python
  2. import requests, datetime, json, time, string,names
  3. from bs4 import BeautifulSoup
  4. from random import getrandbits,choice,randint
  5. x = 0
  6. def solution(apikey,sitekey,form):
  7.     now = datetime.datetime.now()
  8.     print (now.strftime("%H:%M:%S:%f: Getting captcha solution"))
  9.     url="http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(apikey,sitekey,form)
  10.     resp = requests.get(url)
  11.     if resp.text[0:2] != 'OK':
  12.         quit('Error. Captcha is not received')
  13.     captcha_id = resp.text[3:]
  14.     fetch_url = "http://2captcha.com/res.php?key={}&action=get&id={}".format(apikey,captcha_id)
  15.     for i in range(1, 20)
  16.         time.sleep(5) # wait 5 sec.
  17.         resp = requests.get(fetch_url)
  18.         if resp.text[0:2] == 'OK':
  19.                 break
  20.     captchasolution = resp.text[3:]
  21.     return captchasolution
  22. #################################################
  23. def session():
  24.     sesh = requests.session()
  25.     sesh.headers = {
  26.         'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  27.         'accept-encoding': 'gzip, deflate, br',
  28.         'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
  29.         'cache-control': 'max-age=0',
  30.         'upgrade-insecure-requests': '1',
  31.         'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
  32.         }
  33.     sesh.headers.update()
  34.     return sesh
  35. ######################################################
  36. def proxysession(proxy):
  37.     ip,port,username,password = proxy.split(":")
  38.     formattedProxy = (username+':'+password+'@'+ip+':'+port)
  39.     proxies = {'http': 'http://'+formattedProxy}
  40.     proxies = {'https': 'https://'+formattedProxy}
  41.     sesh = requests.Session()
  42.     sesh.proxies = proxies
  43.     sesh.headers = {
  44.         'Origin':'https://slamjamsocialism-drops.com',
  45.         'Referer':'https://slamjamsocialism-drops.com/drops/72',
  46.         'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  47.         'accept-encoding': 'gzip, deflate, br',
  48.         'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
  49.         'cache-control': 'max-age=0',
  50.         'upgrade-insecure-requests': '1',
  51.         'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
  52.     }
  53.     sesh.headers.update()
  54.     return sesh
  55. ############################################################
  56. def main():
  57.     global x
  58.     with open('config.json') as json_data_file:
  59.         data = json.load(json_data_file)
  60.     catchalldomain = data['settings']['catchalldomain']
  61.     randomnames = data['settings']['randomnames']
  62.     setname = data['settings']['setname']
  63.     signupdelay = int(data['settings']['signupdelay'])
  64.     randomsizes = data['settings']['randomsizes']
  65.     size = data['settings']['size']
  66.     town = data['settings']['town']
  67.     country = data['settings']['country']
  68.     phone = data['settings']['phone']
  69.     sitekey = data['settings']['sitekey']
  70.     apikey = data['settings']['2captchaapikey']
  71.     proxyuse = data['settings']['useproxy']
  72.     proxy = data['settings']['proxy']
  73.     form = data['settings']['form']
  74.     now = datetime.datetime.now()
  75.     print (now.strftime("%H:%M:%S:%f: @cowboycurti's SJS Raffle BOT V1.1"))
  76.     print (now.strftime("%H:%M:%S:%f: Starting bot"))
  77.     entries = str(input (now.strftime("%H:%M:%S:%f: How many times do you wish to enter?: ")))
  78.     x = int(x)
  79.     while int(entries) > x:
  80.         x = run(catchalldomain,randomnames,setname,randomsizes,size,town,country,phone,sitekey,apikey,proxyuse,proxy,form)
  81.         time.sleep(signupdelay)
  82. ##########################################################
  83. def run(catchalldomain,randomnames,setname,randomsizes,size,town,country,phone,sitekey,apikey,proxyuse,proxy,form):
  84.     if proxyuse == 'True':
  85.         now = datetime.datetime.now()
  86.         print (now.strftime("%H:%M:%S:%f: Proxy use: True"))
  87.         print (now.strftime("%H:%M:%S:%f: Proxy "+proxy))
  88.         sesh = proxysession(proxy)
  89.     else:
  90.         now = datetime.datetime.now()
  91.         print (now.strftime("%H:%M:%S:%f: Proxy use: False"))
  92.         sesh = session()
  93.     if randomnames == 'True':
  94.         first = names.get_first_name()
  95.         last = names.get_last_name()
  96.         name = first
  97.         nametwo = last
  98.         now = datetime.datetime.now()
  99.         print (now.strftime("%H:%M:%S:%f: Using random names"))
  100.         randomletters = "".join(choice(string.ascii_letters) for x in range(randint(1, 4)))
  101.         username = randomletters+first+randomletters
  102.         email = username+'@'+catchalldomain
  103.     else:
  104.         now = datetime.datetime.now()
  105.         print (now.strftime("%H:%M:%S:%f: Using setname: "+setname))
  106.         randomletters = "".join(choice(string.ascii_letters) for x in range(randint(1, 4)))
  107.         username = randomletters+name
  108.         email = username+'@'+catchalldomain
  109.     if randomsizes == 'True':
  110.         size = (randint(8, 28))/2
  111.     x = signup(sesh,form,apikey,sitekey,phone,town,country,size,name,nametwo,email)
  112.     return x
  113. ############################################################
  114. def signup(sesh,form,apikey,sitekey,phone,town,country,size,name,nametwo,email):
  115.     global x
  116.     x = int(x)
  117.     capsolution = solution(apikey,sitekey,form)
  118.     data = {
  119.         "firstName":name,
  120.         "lastName":nametwo,
  121.         "email":email,
  122.         "phone":phone,
  123.         "size":size,
  124.         "city":town,
  125.         "country":country,
  126.         "g-recaptcha-response":capsolution,
  127.     }
  128.     signup = sesh.post(form,data=data)
  129.     soup = BeautifulSoup(signup.content,'html.parser')
  130.     test = soup.find('p', class_='request-form-title-2').text
  131.     if 'Thanks for entering' in test:
  132.         now = datetime.datetime.now()
  133.         print (now.strftime("%H:%M:%S:%f: Entered: "+email))
  134.         x = x+1
  135.         return x
  136.     else:
  137.         print("Error entering")
  138.         return x
  139. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement