<?php
$sums = 0;
for ($i=1;$i<=20;$i++){
$headers = null;
$page = $i;
$time = get_total_millisecond();
$str = 'xialuo'.$time;
$md5 = md5($str);
$x = hash('sha256', $md5.'xxoo');
$headers[] = 'Cookie:Hm_lvt_0d2227abf9548feda3b9cb6fddee26c0=1753794156; HMACCOUNT=8CFCE68853DBDF9C; sessionid=acnti2em752v7l48qa9av21r69td509r; Hm_lpvt_0d2227abf9548feda3b9cb6fddee26c0=1753794360';
$headers[] = 'User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0';
$headers[] = 'Referer:https://mashangpa.com/problem-detail/7/';
$headers[] = "m:{$md5}";
$headers[] = "ts:{$time}";
$url = "https://mashangpa.com/api/problem-detail/7/data/?page={$page}&x={$x}";
$code = get_curl_contents($url,$headers);
$json = json_decode($code,true);
$code = decrypt($json['r']);
$json = json_decode($code,true);
//var_dump($json);exit;
$sum = 0;
foreach($json['current_array'] as $v){
$sum +=$v;
}
$sums += $sum;
}
echo $sums;
function decrypt($hexCiphertext){
$hexKey = '78787878787878786f6f6f6f6f6f6f6f'; // 16 字节
$hexIV = '30313233343536373839414243444546'; // 16 字节
// 1. 把十六进制转成二进制
$ciphertext = hex2bin($hexCiphertext);
$key = hex2bin($hexKey);
$iv = hex2bin($hexIV);
// 2. 解密
$plaintext = openssl_decrypt(
$ciphertext,
'AES-128-CBC',
$key,
OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, // 保持原始填充
$iv
);
// 3. 去掉 PKCS#7 填充
$pad = ord($plaintext[strlen($plaintext) - 1]);
$plaintext = substr($plaintext, 0, -$pad);
return $plaintext;
}
function get_curl_contents($bstrURL, $headers = null, $post = null) {
$ch = curl_init($bstrURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
if ($headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
$data = curl_exec($ch);
// 关闭CURL会话
curl_close($ch);
return $data;
}
function get_total_millisecond() {
$time = explode(" ", microtime());
$time = ($time[1] + $time[0]) * 1000;
$time = round($time) . '';
return $time;
}
function padPkcs7($data, $blocksize = 16){
$pad = $blocksize - (strlen($data) % $blocksize);
return $data . str_repeat(chr($pad), $pad);
}