Skip to content

Commit

Permalink
Merge pull request #7 from ywmoyue/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ywmoyue authored Jan 19, 2023
2 parents b8969ae + e8aac76 commit 33f190e
Show file tree
Hide file tree
Showing 12 changed files with 802 additions and 217 deletions.
88 changes: 80 additions & 8 deletions src/BiliLite.UWP/Api/AccountApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ public ApiModel GetKey()
{
ApiModel api = new ApiModel()
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/api/oauth2/getKey",
body = ApiHelper.MustParameter(ApiHelper.AndroidKey)
method = RestSharp.Method.Get,
baseUrl = "https://passport.bilibili.com/x/passport-login/web/key"
};
api.body += ApiHelper.GetSign(api.body, ApiHelper.AndroidKey);
return api;
}

Expand Down Expand Up @@ -47,13 +45,13 @@ public ApiModel LoginV2(string username, string password, string captcha = "")
/// <param name="password">密码</param>
/// <param name="gee_type"></param>
/// <returns></returns>
public ApiModel LoginV3(string username, string password,string seesionId="",string seccode="",string validate="",string challenge="",string recaptcha_token="", int gee_type = 10)
public ApiModel LoginV3(string username, string password)
{
ApiModel api = new ApiModel()
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/x/passport-login/oauth2/login",
body = $"username={Uri.EscapeDataString(username)}&password={Uri.EscapeDataString(password)}&login_session_id={seesionId}&gee_type={gee_type}&gee_seccode={seccode}&gee_validate={validate}&gee_challenge={challenge}&recaptcha_token={recaptcha_token}&" + ApiHelper.MustParameter(ApiHelper.LoginKey)
body = $"actionKey=appkey&channel=bili&device=phone&permission=ALL&subid=1&username={Uri.EscapeDataString(username)}&password={Uri.EscapeDataString(password)}&" + ApiHelper.MustParameter(ApiHelper.LoginKey)
};
api.body += ApiHelper.GetSign(api.body, ApiHelper.LoginKey);
return api;
Expand Down Expand Up @@ -125,12 +123,12 @@ public ApiModel SSO(string access_key)
api.parameter += ApiHelper.GetSign(api.parameter,ApiHelper.AndroidKey);
return api;
}

/// <summary>
/// 读取验证码
/// </summary>
/// <returns></returns>
public ApiModel Captcha()
public ApiModel Captcha()
{
ApiModel api = new ApiModel()
{
Expand All @@ -140,8 +138,82 @@ public ApiModel Captcha()
parameter = $"ts={Utils.GetTimestampS()}"
};
return api;
}

/// <summary>
/// 读取极验验证码
/// </summary>
/// <returns></returns>
public ApiModel GeetestCaptcha()
{
ApiModel api = new ApiModel()
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/x/safecenter/captcha/pre"
};
return api;
}

/// <summary>
/// 获取带星号的手机号
/// </summary>
/// <returns></returns>
public ApiModel FetchHideTel(string tmp_token)
{
ApiModel api = new ApiModel()
{
method = RestSharp.Method.Get,
baseUrl = "https://api.bilibili.com/x/safecenter/user/info",
parameter = $"tmp_code={tmp_token}"
};
return api;
}

/// <summary>
/// 发送验证短信
/// </summary>
/// <returns></returns>
public ApiModel SendVerifySMS(string tmp_token, string recaptcha_token, string gee_challenge, string gee_gt, string geetest_validate, string geetest_seccode)
{
ApiModel api = new ApiModel()
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/x/safecenter/common/sms/send",
body = $"sms_type=loginTelCheck&tmp_code={tmp_token}&recaptcha_token={recaptcha_token}&gee_challenge={gee_challenge}&gee_gt={gee_gt}&gee_validate={geetest_validate}&gee_seccode={geetest_seccode}"
};
return api;
}

/// <summary>
/// 提交短信验证码
/// </summary>
/// <returns></returns>
public ApiModel SubmitPwdLoginSMSCheck(string code, string tmp_token, string request_id, string captcha_key)
{
ApiModel api = new ApiModel()
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/x/safecenter/login/tel/verify",
body = $"type=loginTelCheck&code={code}&tmp_code={tmp_token}&request_id={request_id}&captcha_key={captcha_key}"
};
return api;
}

/// <summary>
/// 交换获取cookie
/// </summary>
/// <returns></returns>
public ApiModel PwdLoginExchangeCookie(string code)
{
ApiModel api = new ApiModel()
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/x/passport-login/web/exchange_cookie",
body = $"code={code}"
};
return api;
}

/// <summary>
/// 个人资料
/// </summary>
Expand Down
61 changes: 61 additions & 0 deletions src/BiliLite.UWP/Assets/GeeTest/bili_gt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>

<head>
<title>极验</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
<div id="captcha">
<p>完成验证后继续登录</p>
</div>
</body>
<script type="text/javascript" src="gt.js"></script>
<script>

window.onload = function () {

let appType=getQueryVariable("app");
initGeetest({
gt: getQueryVariable("gee_gt"),
challenge: getQueryVariable("gee_challenge"),
offline: false,
new_captcha: true,
product: "popup",
width: "300px",
https: true
}, function (captchaObj) {

captchaObj.appendTo('#captcha');
captchaObj.onSuccess(function () {
var result = captchaObj.getValidate();
window.location.href=`http://geetest.result/?success=1&recaptcha_token=${getQueryVariable("recaptcha_token")}&geetest_challenge=${result.geetest_challenge}&geetest_validate=${result.geetest_validate}&geetest_seccode=${result.geetest_seccode}&app=uwp`
console.log({
geetest_challenge: result.geetest_challenge,
geetest_validate: result.geetest_validate,
geetest_seccode: result.geetest_seccode,
recaptcha_token:getQueryVariable("recaptcha_token")
});
});
captchaObj.onError(function (error) {
window.location.href=`http://geetest.result/?success=0&msg=${error.msg}&app=uwp`
});
captchaObj.onClose(function () {
window.location.href=`http://geetest.result/?success=2&app=uwp`
});
})
}
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) { return pair[1]; }
}
return (false);
}
</script>

</html>
Loading

0 comments on commit 33f190e

Please sign in to comment.