18年初的刷数字币羊毛的脚本,备份下;
具体流程是:
1、从IP池中抽取新IP
2、访问目标网站
3、从卡商获取手机号
4、在目标网站输入手机号,并提交
5、从卡商处获取短信验证码
6、在目标网站填入短信验证码
7、定位图形验证码的元素位置
8、提取图形验证码图片,并调用ORC接口识别图片验证码中的文字内容
9、输入验证码
10、提交邮箱
11、获取telegram验证码
#coding:utf-8 import requests,re,time,sys,json,datetime,urllib,os,random,linecache,base64 reload(sys) sys.setdefaultencoding('utf-8') from ShowapiRequest import ShowapiRequest import multiprocessing from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.proxy import * from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from PIL import Image def get_yima(url): headers = { "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding":"gzip, deflate", "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8", "Cache-Control":"max-age=0", "Connection":"keep-alive", "Cookie":"__cfduid=d122450b84d9e008a1337aac8df9b97811511877258", "Host":"api.51ym.me", "Upgrade-Insecure-Requests":"1", "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36", } html = requests.get(url,headers=headers,timeout=30) code = html.encoding return html.content def get_tianma(url): headers = { "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding":"gzip, deflate", "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8", "Cache-Control":"max-age=0", "Connection":"keep-alive", "Cookie":"__cfduid=dc7085e092fe2b17bb572f8f694e12d051512015018", "Host":"api.tianma168.com", "Upgrade-Insecure-Requests":"1", "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36", } html = requests.get(url,headers=headers,timeout=30) code = html.encoding return html.content def get_zhima_ip(): url = "http://webapi.http.zhimacangku.com/getip?num=1&type=1&pro=&city=0&yys=0&port=2&time=1&ts=0&ys=0&cs=0&lb=1&sb=0&pb=45&mr=1®ions=" html = requests.get(url,timeout=30) ip = html.content.strip() return ip def search(req,html): text = re.search(req,html) if text: data = text.group(1) else: data = 'no' return data def gain_mobile(): url = 'http://api.51ym.me/UserInterface.aspx?action=getmobile&itemid=12503&token=xxx' a = get_yima(url) mobile = search('(\d{11})',a) return mobile def gain_sms(input_mobile): url = 'http://api.51ym.me/UserInterface.aspx?action=getsms&mobile=%s&itemid=12503&token=xxx' % input_mobile a = get_yima(url) return a def gain_black(input_mobile): url = 'http://api.51ym.me/UserInterface.aspx?action=addignore&mobile=%s&itemid=12503&token=xxx' % input_mobile a = get_yima(url) return a def tm_login(): url = 'http://api.tianma168.com/tm/Login?uName=a631381702&pWord=ab24562660&Developer=mzpK3SBKBcA%%3d' a = get_tianma(url) token = search('([^&].*?)&',a) return token def tm_gain_mobile(token): url = "http://api.tianma168.com/tm/getPhone?ItemId=64802&token=%s" % token a = get_tianma(url) mobile = search('(\d+)',a) return mobile def tm_gain_sms(token,mobile): url = "http://api.tianma168.com/tm/getMessage?token=%s&itemId=64802&phone=%s" % (token,mobile) a = get_tianma(url) code = search(r' (\d{4}) ',a) return code def tm_black(token,mobile): url = 'http://api.tianma168.com/tm/addBlack?token=%s&phoneList=%s' % (token,mobile) a = get_tianma(url) return a def get_ip(): a = os.popen('curl -x "http://http-cla.abuyun.com:9030" --proxy-basic --proxy-user H3Q0N268PZ1375FC:C63714C012917AFD http://proxy.abuyun.com/switch-ip') return a def authcode_showapi(base64_data): # typeID说明 # 识别4位数字:14 # 识别4位英文:24 # 识别4位英数混合:34 # 识别4位汉字:44 # 是被4位英文数字汉字混合:54 # other:https://www.showapi.com/api/view/184/6 r = ShowapiRequest("http://route.showapi.com/184-5", "67544", "5e1e3d13b7ed477bb0fb0d1986eddad8") r.addBodyPara("img_base64", base64_data) r.addBodyPara("typeId", "34") r.addBodyPara("convert_to_jpg", "0") r.addBodyPara("needMorePrecise", "1") # r.addFilePara("img",r"/Users/sunjian/Desktop/wool/chain/img/code.jpg") #文件上传时设置 res = r.post() res_text = res.text # 返回信息 a = res_text.encode('utf-8') code = search(r'"Result":"(.*?)"',a) return code bac = open('coinclub_bac','a') def coinclub(n,mail,eth): try: # newip = get_ip() newip = get_zhima_ip() host = search('(\d+\.\d+\.\d+\.\d+):',newip) port = int(search(':(\d+)$',newip)) profile = webdriver.FirefoxProfile() profile.set_preference("network.proxy.type", 1); profile.set_preference("network.proxy.socks_version", 5); profile.set_preference("network.proxy.socks", host); profile.set_preference("network.proxy.socks_port", port); profile.update_preferences() browser = webdriver.Firefox(firefox_profile=profile) except: profile = webdriver.FirefoxProfile() browser = webdriver.Firefox() profile = webdriver.FirefoxProfile() browser = webdriver.Firefox() # try: print '@@@@@@@@@@@@ 第%s次执行 @@@@@@@@@@@@' % n # 输入coinclub邀请网址 print '>>> 打开coinclub url' browser.implicitly_wait(20) browser.get(get_url()) time.sleep(3) # 输入eth地址 print '>>> 输入ETH钱包地址' browser.find_element_by_xpath("/html/body/div/form/div[4]/div[2]/input[1]").send_keys(eth) time.sleep(3) # 对当前屏幕截图 print '>>> 截屏' browser.get_screenshot_as_file('./img/1.jpg') time.sleep(3) # 定位验证码坐标&截图获取验证码图片 print '>>> 裁剪验证码图片' location = browser.find_element_by_id('myCanvas').location size = browser.find_element_by_id('myCanvas').size left = int(location['x']) top = int(location['y']) right = int(location['x']) + int(size['width']) bottom = int(location['y']) + int(size['height']) a = Image.open("./img/1.jpg") im = a.crop((left, top, right, bottom)) im.save('./img/code.jpg') # 识别验证码 print '>>> 识别验证码' # 验证码图片转为base64编码 with open("./img/code.jpg", "rb") as f: # b64encode是编码,b64decode是解码 base64_data = base64.b64encode(f.read()) authcode = authcode_showapi(base64_data) time.sleep(3) # 输入验证码 print '>>> 输入验证码' browser.find_element_by_xpath("/html/body/div/form/div[4]/div[2]/input[2]").send_keys(authcode) time.sleep(2) # 点击提交 print '>>> 点击提交' browser.find_element_by_xpath("/html/body/div/form/div[4]/div[2]/button").click() time.sleep(6) # 提交邮箱 print '>>> 提交邮箱' browser.find_element_by_xpath("/html/body/div/div/div[4]/div[2]/div/input[3]").send_keys(mail) time.sleep(1) browser.find_element_by_xpath("/html/body/div/div/div[4]/div[2]/div/a").click() time.sleep(2) # 获取手机号 print '>>> 获取手机号&提交' mobile = gain_mobile() time.sleep(1) browser.find_element_by_xpath("/html/body/div/div/div[4]/div[3]/div/input[3]").send_keys(mobile) time.sleep(1) browser.find_element_by_xpath("/html/body/div/div/div[4]/div[3]/div/a").click() time.sleep(2) # 提取电报验证码 print '>>> 提取telegram验证码' html = browser.page_source print html time.sleep(600) '''关闭浏览器''' browser.delete_all_cookies() browser.quit() # except Exception,e: # print repr(e) # browser.delete_all_cookies() # browser.quit() def get_name(): a = random.randrange(1, 50000) #1-9中生成随机数 theline = linecache.getline(r'people_name', a).strip() return theline.decode("utf-8") def get_url(): url_list = [ "https://www.coinclub.global/airdrop/PTc1v5mdDPZIhxXt1rio", ] slice = random.sample(url_list,1)[0] return slice mails = open("mail_163").readlines() eths = open("eth_adress").readlines() for i in range(1,501): email = mails[i].split('&')[0] eth = eths[i] print email,eth # coinclub(1,email,eth)
ShowapiRequest.py
import requests,sys import urllib #from urllib import parse from urlparse import urlparse files = {} headers = {} body = {} timeouts = {} resHeader = {} class ShowapiRequest: def __init__(self, url, my_appId, my_appSecret): self.url = url self.my_appId = my_appId self.my_appSecret = my_appSecret body["showapi_appid"] = my_appId body["showapi_sign"] = my_appSecret headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2427.7 Safari/537.36" def addFilePara(self, key, value_url): files[key] = open(r"%s" % (value_url), 'rb') return self def addHeadPara(self, key, value): headers[key] = value return self def addBodyPara(self, key, value): body[key] = value return self def setTimeout(self, connecttimout, readtimeout): timeouts["connecttimout"] = connecttimout timeouts["readtimeout"] = readtimeout return self def get(self): get_url = self.url + "?" + urllib.urlencode(body) if not timeouts: res = requests.get(get_url, headers=headers) else: timeout = (timeouts["connecttimout"], timeouts["readtimeout"]) res = requests.get(get_url, headers=headers, timeout=timeouts) return res def post(self): if not timeouts: res = requests.post(self.url, files=files, data=body, headers=headers) else: timeout = (timeouts["connecttimout"], timeouts["readtimeout"]) res = requests.post(self.url, files=files, data=body, headers=headers, timeout=timeout) return res
转载请注明:思享SEO博客 » N久之前的刷数字币羊毛脚本