import
hashlib
import
time
import
requests
import
json
import
sys
import
random
from
datetime
import
datetime
main_index
=
9990
main_count
=
10124
main_uid
=
"418782"
verify_code
=
0
timestamp
=
0
this_count
=
0
def
md5_hash(string):
md5_obj
=
hashlib.md5()
md5_obj.update(string.encode(
'utf-8'
))
return
md5_obj.hexdigest()
def
get_verify_code(prefix):
start_time
=
time.time()
for
i
in
range
(
100000000
):
code
=
str
(i)
md5_code
=
md5_hash(prefix
+
code)
if
md5_code.startswith(
'000000'
):
elapsed_time
=
time.time()
-
start_time
return
code
if
(i &
0x1ffff
)
=
=
1
:
progress
=
(i
/
/
(
2
*
256
*
256
*
256
))
*
10000
/
100
elapsed_time
=
time.time()
-
start_time
raise
Exception(
'generate verify code failed'
)
def
get_verify_code_new(prefix):
prefix_bytes
=
prefix.encode(
'utf-8'
)
md5_base
=
hashlib.md5(prefix_bytes)
for
i
in
range
(
100000000
):
code
=
str
(i)
md5_obj
=
md5_base.copy()
md5_obj.update(code.encode(
'utf-8'
))
digest
=
md5_obj.digest()
if
digest[:
3
]
=
=
b
'\x00\x00\x00'
:
return
code
raise
Exception(
'generate verify code failed'
)
def
get_lottery_history():
response
=
requests.get(
'https://2025challenge.52pojie.cn/api/lottery/history'
)
if
response.status_code
=
=
200
:
result_1
=
response.json()
block_number
=
result_1[
'data'
][
'history'
][
0
][
'block_number'
]
return
block_number
else
:
print
(f
"请求失败,状态码: {response.status_code}"
)
return
None
def
get_count():
response
=
requests.get(
'https://2025challenge.52pojie.cn/api/lottery/history'
)
if
response.status_code
=
=
200
:
result_1
=
response.json()
user_count
=
result_1[
'data'
][
'history'
][
0
][
'user_count'
]
print
(
"当前 序号 :"
+
str
(user_count) )
return
user_count
else
:
print
(f
"请求失败,状态码: {response.status_code}"
)
return
None
def
inst_user_data(tuid) :
url
=
'https://2025challenge.52pojie.cn/api/lottery/join'
data
=
{
'timestamp'
: timestamp ,
'uid'
: tuid ,
'verify_code'
: verify_code
}
headers
=
{
'Content-Type'
:
'application/json'
}
response
=
requests.post(url, json
=
data)
user_index
=
0
if
response.status_code
=
=
200
:
response_data
=
response.json()
print
(
'响应数据:'
, response_data )
user_index
=
response_data[
'data'
][
'user_index'
]
print
(
'user_index:'
, user_index )
return
user_index
else
:
print
(
'请求失败,状态码:'
, response.status_code)
print
(
'响应内容:'
, response.text)
return
None
def
update_verify_code() :
now
=
datetime.now()
current_timestamp
=
now.timestamp()
timestamp
=
int
(current_timestamp)
print
(
"timestamp 时间戳:"
, timestamp)
p_timestamp
=
str
(timestamp)
+
"|"
print
(
"校验数据:"
, p_timestamp)
verify_code
=
get_verify_code_new(p_timestamp)
print
(
"verify_code 校验结果:"
, verify_code )
random_zeros
=
random.randint(
1
,
5
)
zeros
=
'0'
*
random_zeros
this_count
=
get_count()
if
this_count > main_count :
print
(
"应该拆入位置为 "
,
str
(main_count) )
print
(
"当前 已超过 计数了:"
,
str
(this_count) )
sys.exit(
0
)
now
=
datetime.now()
current_timestamp
=
now.timestamp()
timestamp
=
int
(current_timestamp)
print
(
"timestamp 时间戳:"
, timestamp)
p_timestamp
=
str
(timestamp)
+
"|"
print
(
"校验数据:"
, p_timestamp)
verify_code
=
get_verify_code_new(p_timestamp)
print
(
"verify_code 校验结果:"
, verify_code )
this_count
=
get_count()
cha
=
main_index
-
this_count
print
(
"应该插入位置为 "
,
str
(main_index) )
print
(
"当前人数:"
,
str
(this_count) )
print
(
"需要循环 :"
,
str
(cha))
for
i
in
range
(cha):
temp_uid
=
zeros
+
"0100"
+
str
(i)
jh_uid
=
this_count
+
1
this_count
=
inst_user_data(temp_uid)
print
(
"前 计划插入"
,
str
(jh_uid) )
print
(
"前 实际插入为"
,
str
(this_count) )
if
this_count
=
=
main_index
-
1
:
print
(
"该插入真实id了"
,
str
(this_count) )
this_count
=
inst_user_data(main_uid)
print
(
"真实uid插入序号:"
,
str
(this_count) )
break
elif
this_count > main_index
-
1
:
print
(
"超出了范围了"
,
str
(this_count) )
break
if
this_count
=
=
main_index
-
1
:
print
(
"第二次验证 该插入真实id了"
,
str
(this_count) )
this_count
=
inst_user_data(main_uid)
print
(
"真实uid插入序号:"
,
str
(this_count) )
now
=
datetime.now()
current_timestamp
=
now.timestamp()
timestamp
=
int
(current_timestamp)
print
(
"timestamp 时间戳:"
, timestamp)
p_timestamp
=
str
(timestamp)
+
"|"
print
(
"校验数据:"
, p_timestamp)
verify_code
=
get_verify_code_new(p_timestamp)
print
(
"verify_code 校验结果:"
, verify_code )
this_count
=
get_count()
cha
=
main_count
-
this_count
for
i
in
range
(cha):
if
this_count >
=
main_count :
print
(
"后,当前人数为"
,
str
(this_count) )
print
(
"后,计划人数为"
,
str
(main_count) )
print
(
"停止"
)
sys.exit(
0
)
temp_uid
=
zeros
+
"0200"
+
str
(i)
jh_uid
=
this_count
+
1
this_count
=
inst_user_data(temp_uid)
print
(
"后 计划插入"
,
str
(jh_uid) )
print
(
"后 实际插入为"
,
str
(this_count) )
get_count()
print
(
"执行结束 "
)