Paste: dfdfdf
Author: | pluvet |
Mode: | php |
Date: | Mon, 1 Mar 2021 08:51:41 |
Plain Text |
<?php
include "./vendor/autoload.php";
$loginUrl = "https://vpn.ccmu.edu.cn/users/sign_in";
use GuzzleHttp\Client;
$domain = 'szsyweb-443.vpn.ccmu.edu.cn';
$values = [
'CASTGC' => 'TGT-291282-MWq2YeWDlH7Sh3wyg20JBYMXzKZtl4VyLAiOuAHYa37hTZN14P-cas',
'CASPRIVACY' => ''
];
$cookieJar = GuzzleHttp\Cookie\CookieJar::fromArray($values, $domain);
$cookieJar->fromArray([
'UUkey' => '05829f7a39f050646ac7f40b75dcf213',
'eai-sess' => 'kh9ueg0hifa1fk8rhpga357i9djun364v4q2j6i1krn1dhr5rlnhna714vqc7pc6jntehd5ss44jd'
], 'app-443.vpn.ccmu.edu.cn');
$client = new GuzzleHttp\Client(['cookies' => $cookieJar, 'allow_redirects' => ['max' => 10]]);
function getToken($client, $url)
{
$response = $client->get($url);
$re = '/name="authenticity_token" value="([^"]*)"/m';
$str = (string)($response->getBody());
preg_match($re, $str, $matches);
$token = $matches[1];
echo "Token: $token\n";
return $token;
}
function login($client, $url, $token, $username, $password)
{
$response = $client->request('POST', $url, [
'form_params' => [
'utf8' => '✓',
'authenticity_token' => $token,
'user[login]' => $username,
'user[password]' => $password,
'user[dymatice_code]' => 'unknown',
'user[otp_with_capcha]' => 'false',
'commit' => '登录 Login'
]
]);
$str = (string)($response->getBody());
$code = $response->getStatusCode();
var_dump($response->getHeaders());
echo "Login StatusCode: $code\n";
$re = '/name="csrf-token" content="([^"]*)"/m';
preg_match($re, $str, $matches);
$token = $matches[1];
echo "Token: $token\n";
return $token;
}
function logout($client, $url, $token)
{
$response = $client->request('POST', $url, [
'form_params' => [
'_method' => 'delete',
'authenticity_token' => $token
]
]);
return $response->getStatusCode();
}
$token = getToken($client, $loginUrl);
$username = "1611112";
$password = "KKK318318";
$token = login($client, $loginUrl, $token, $username, $password);
$logoutUrl = "https://vpn.ccmu.edu.cn/users/sign_out";
$getInfoUrl = "https://app-443.vpn.ccmu.edu.cn/ncov/wap/normal/get-info";
$reportUrl = "https://app-443.vpn.ccmu.edu.cn/ncov/wap/default/save";
function printCookie($client)
{
$cookieJar = $client->getConfig('cookies');
var_dump($cookieJar->toArray());
}
function loadInfo($client, $getInfoUrl)
{
$response = $client->get($getInfoUrl);
$str = (string)($response->getBody());
$json = json_decode($str, true);
if (!$json) {
echo "错误!";
printCookie($client);
exit(1);
}
echo "info: ";
return $json["d"]["info"];
}
$info = loadInfo($client, $getInfoUrl);
$info['geo_api_info'] = '{"type":"complete","info":"SUCCESS","status":1,"position":{"Q":25.06328,"R":102.71485000000001,"lng":102.71485,"lat":25.06328},"message":"Get ipLocation success.Get address success.","location_type":"ip","accuracy":null,"isConverted":true,"addressComponent":{"citycode":"010","adcode":"110102","businessAreas":[{"name":"复兴门","id":"110102","location":{"Q":39.906008,"R":116.35317900000001,"lng":116.353179,"lat":39.906008}},{"name":"西便门","id":"110102","location":{"Q":39.90008,"R":116.35494499999999,"lng":116.354945,"lat":39.90008}},{"name":"月坛","id":"110102","location":{"Q":39.913242,"R":116.345663,"lng":116.345663,"lat":39.913242}}],"neighborhoodType":"","neighborhood":"","building":"北京市西城区卫生局卫生监督所","buildingType":"政府机构及社会团体;政府机关;区县级政府及事业单位","street":"白云观街北里","streetNumber":"2区","country":"中国","province":"北京市","city":"","district":"西城区","township":"月坛街道"},"formattedAddress":"北京市西城区月坛街道北京市西城区卫生局卫生监督所白云观街北里小区","roads":[],"crosses":[],"pois":[]}';
$info['address'] = '北京市西城区月坛街道北京市西城区卫生局卫生监督所白云观街北里小区';
function report($client, $info, $reportUrl)
{
$response = $client->request('POST', $reportUrl, [
'form_params' => $info
]);
echo "=========POST=========";
foreach ($info as $key => $value) {
echo "$key: $value\n";
}
$str = (string)($response->getBody());
$code = $response->getStatusCode();
echo "Report StatusCode: $code\n";
echo "resp: $str \n";
}
$result = report($client, $info, $reportUrl);
$code = logout($client, $logoutUrl, $token);
echo "Logout StatusCode: $code\n";
New Annotation