mirror of
https://github.com/ravizhan/geetest-v3-click-crack.git
synced 2025-12-05 14:52:51 +08:00
增加重试功能
This commit is contained in:
33
README.md
33
README.md
@@ -34,21 +34,24 @@ model = Model()
|
|||||||
crack.gettype()
|
crack.gettype()
|
||||||
crack.get_c_s()
|
crack.get_c_s()
|
||||||
crack.ajax()
|
crack.ajax()
|
||||||
pic_content = crack.get_pic()
|
for retry in range(6):
|
||||||
# 检测文字位置
|
pic_content = crack.get_pic(retry)
|
||||||
small_img, big_img = model.detect(pic_content)
|
# 检测文字位置
|
||||||
# 判断点选顺序
|
small_img, big_img = model.detect(pic_content)
|
||||||
result_list = model.siamese(small_img, big_img)
|
# 判断点选顺序
|
||||||
point_list = []
|
result_list = model.siamese(small_img, big_img)
|
||||||
for i in result_list:
|
point_list = []
|
||||||
left = str(round((i[0] + 30) / 333 * 10000))
|
for i in result_list:
|
||||||
top = str(round((i[1] + 30) / 333 * 10000))
|
left = str(round((i[0] + 30) / 333 * 10000))
|
||||||
point_list.append(f"{left}_{top}")
|
top = str(round((i[1] + 30) / 333 * 10000))
|
||||||
# 验证请求
|
point_list.append(f"{left}_{top}")
|
||||||
# 注意 请求此函数时请确保全过程时间大于等于4s
|
# 验证请求
|
||||||
# 否则会报 duration short
|
# 注意 请确保验证与获取图片间隔不小于2s
|
||||||
result = crack.verify(point_list)
|
# 否则会报 duration short
|
||||||
print(result)
|
result = crack.verify(point_list)
|
||||||
|
print(result)
|
||||||
|
if eval(result)["data"]["result"] == "success":
|
||||||
|
break
|
||||||
```
|
```
|
||||||
|
|
||||||
# 协议
|
# 协议
|
||||||
|
|||||||
32
crack.py
32
crack.py
@@ -417,27 +417,35 @@ Bm1Zzu+l8nSOqAurgQIDAQAB
|
|||||||
resp = self.session.get("https://api.geetest.com/ajax.php", params=params).text
|
resp = self.session.get("https://api.geetest.com/ajax.php", params=params).text
|
||||||
return json.loads(resp[22:-1])["data"]
|
return json.loads(resp[22:-1])["data"]
|
||||||
|
|
||||||
def get_pic(self):
|
def get_pic(self,retry=0):
|
||||||
params = {
|
params = {
|
||||||
"is_next": "true",
|
|
||||||
"type": "click",
|
"type": "click",
|
||||||
"gt": self.gt,
|
"gt": self.gt,
|
||||||
"challenge": self.challenge,
|
"challenge": self.challenge,
|
||||||
"lang": "zh-cn",
|
"lang": "zh-cn",
|
||||||
"https": "true",
|
|
||||||
"protocol": "https://",
|
|
||||||
"offline": "false",
|
|
||||||
"product": "float",
|
|
||||||
"api_server": "api.geevisit.com",
|
|
||||||
"isPC": True,
|
|
||||||
"autoReset": True,
|
|
||||||
"width": "100%",
|
|
||||||
"callback": "geetest_" + str(int(round(time.time() * 1000))),
|
"callback": "geetest_" + str(int(round(time.time() * 1000))),
|
||||||
}
|
}
|
||||||
resp = self.session.get("https://api.geevisit.com/get.php", params=params).text
|
if retry == 0:
|
||||||
|
url = "https://api.geevisit.com/get.php"
|
||||||
|
params.update(
|
||||||
|
{
|
||||||
|
"is_next": "true",
|
||||||
|
"https": "true",
|
||||||
|
"protocol": "https://",
|
||||||
|
"offline": "false",
|
||||||
|
"product": "float",
|
||||||
|
"api_server": "api.geevisit.com",
|
||||||
|
"isPC": True,
|
||||||
|
"autoReset": True,
|
||||||
|
"width": "100%",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
url = "https://api.geetest.com/refresh.php"
|
||||||
|
resp = self.session.get(url, params=params).text
|
||||||
data = json.loads(resp[22:-1])["data"]
|
data = json.loads(resp[22:-1])["data"]
|
||||||
self.pic_path = data["pic"]
|
self.pic_path = data["pic"]
|
||||||
pic_url = "https://" + data["resource_servers"][0][:-1] + data["pic"]
|
pic_url = "https://" + data["image_servers"][0][:-1] + data["pic"]
|
||||||
return self.session.get(pic_url).content
|
return self.session.get(pic_url).content
|
||||||
|
|
||||||
def verify(self, points: list):
|
def verify(self, points: list):
|
||||||
|
|||||||
52
main.py
52
main.py
@@ -8,7 +8,9 @@ import httpx
|
|||||||
t = time.time()
|
t = time.time()
|
||||||
|
|
||||||
tt = time.time()
|
tt = time.time()
|
||||||
reg = httpx.get(f"https://www.geetest.com/demo/gt/register-click-official?t={str(round(time.time()))}").json()
|
reg = httpx.get(
|
||||||
|
f"https://www.geetest.com/demo/gt/register-click-official?t={str(round(time.time()))}"
|
||||||
|
).json()
|
||||||
print(time.time() - tt)
|
print(time.time() - tt)
|
||||||
|
|
||||||
crack = Crack(reg["gt"], reg["challenge"])
|
crack = Crack(reg["gt"], reg["challenge"])
|
||||||
@@ -29,28 +31,32 @@ print(time.time() - tt)
|
|||||||
|
|
||||||
model = Model()
|
model = Model()
|
||||||
|
|
||||||
tt = time.time()
|
for retry in range(6):
|
||||||
pic_content = crack.get_pic()
|
tt = time.time()
|
||||||
print(time.time() - tt)
|
pic_content = crack.get_pic(retry)
|
||||||
|
print(time.time() - tt)
|
||||||
|
|
||||||
tt = time.time()
|
ttt = tt = time.time()
|
||||||
small_img, big_img = model.detect(pic_content)
|
small_img, big_img = model.detect(pic_content)
|
||||||
print(f"检测到小图: {len(small_img.keys())}个,大图: {len(big_img)} 个,用时: {time.time() - tt}s")
|
print(
|
||||||
tt = time.time()
|
f"检测到小图: {len(small_img.keys())}个,大图: {len(big_img)} 个,用时: {time.time() - tt}s"
|
||||||
result_list = model.siamese(small_img, big_img)
|
)
|
||||||
print(f"文字配对完成,用时: {time.time() - tt}")
|
tt = time.time()
|
||||||
point_list = []
|
result_list = model.siamese(small_img, big_img)
|
||||||
# print(result_list)
|
print(f"文字配对完成,用时: {time.time() - tt}")
|
||||||
for i in result_list:
|
point_list = []
|
||||||
left = str(round((i[0] + 30) / 333 * 10000))
|
# print(result_list)
|
||||||
top = str(round((i[1] + 30) / 333 * 10000))
|
for i in result_list:
|
||||||
point_list.append(f"{left}_{top}")
|
left = str(round((i[0] + 30) / 333 * 10000))
|
||||||
wait_time = 4.0 - (time.time() - t)
|
top = str(round((i[1] + 30) / 333 * 10000))
|
||||||
time.sleep(wait_time)
|
point_list.append(f"{left}_{top}")
|
||||||
tt = time.time()
|
wait_time = 2.0 - (time.time() - ttt)
|
||||||
result = json.loads(crack.verify(point_list))
|
time.sleep(wait_time)
|
||||||
print(result)
|
tt = time.time()
|
||||||
print(time.time() - tt)
|
result = json.loads(crack.verify(point_list))
|
||||||
|
print(result)
|
||||||
|
print(time.time() - tt)
|
||||||
|
if result["data"]["result"] == "success":
|
||||||
|
break
|
||||||
total_time = time.time() - t
|
total_time = time.time() - t
|
||||||
print(f"总计耗时(含等待{wait_time}s): {total_time}")
|
print(f"总计耗时(含等待{wait_time}s): {total_time}")
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
httpx~=0.27.2
|
httpx[http2]~=0.27.2
|
||||||
cryptography~=43.0.0
|
cryptography~=43.0.0
|
||||||
onnxruntime~=1.19.0
|
onnxruntime~=1.19.0
|
||||||
opencv-python~=4.10.0.84
|
opencv-python~=4.10.0.84
|
||||||
|
|||||||
Reference in New Issue
Block a user