diff options
author | ikeblaster <ike@thez.info> | 2020-08-20 17:10:14 +0200 |
---|---|---|
committer | ikeblaster <ike@thez.info> | 2020-08-20 17:11:28 +0200 |
commit | f672145138af24d238bc763001f5625da9525d88 (patch) | |
tree | 1fb17695a6646c05e9ce61fcda88a2cc07292b9c /protocols/SkypeWeb | |
parent | aae73c3fa0472a29a5ca76f4c1ed65be67167ea1 (diff) |
fixes #2549 (SkypeWeb cannot connect)
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r-- | protocols/SkypeWeb/src/requests/oauth.h | 17 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_oauth.cpp | 47 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 3 |
3 files changed, 65 insertions, 2 deletions
diff --git a/protocols/SkypeWeb/src/requests/oauth.h b/protocols/SkypeWeb/src/requests/oauth.h index f5bf8afd1b..32cee1ec76 100644 --- a/protocols/SkypeWeb/src/requests/oauth.h +++ b/protocols/SkypeWeb/src/requests/oauth.h @@ -31,7 +31,7 @@ struct OAuthRequest : public AsyncHttpRequest } OAuthRequest(const char *login, const char *password, const char *cookies, const char *ppft) : - AsyncHttpRequest(REQUEST_POST, HOST_OTHER, "https://login.live.com/ppsecure/post.srf", &CSkypeProto::OnOAuthAuthorize) + AsyncHttpRequest(REQUEST_POST, HOST_OTHER, "https://login.live.com/ppsecure/post.srf", &CSkypeProto::OnOAuthConfirm) { this << CHAR_PARAM("wa", "wsignin1.0") << CHAR_PARAM("wp", "MBI_SSL") << CHAR_PARAM("wreply", "https://lw.skype.com/login/oauth/proxy?site_name=lw.skype.com") @@ -44,6 +44,21 @@ struct OAuthRequest : public AsyncHttpRequest this << CHAR_PARAM("login", login) << CHAR_PARAM("passwd", password) << CHAR_PARAM("PPFT", ppft); } + OAuthRequest(const char *cookies, const char* ppft, const char* opid) : + AsyncHttpRequest(REQUEST_POST, HOST_OTHER, "https://login.live.com/ppsecure/post.srf", &CSkypeProto::OnOAuthAuthorize) + { + this << CHAR_PARAM("wa", "wsignin1.0") << CHAR_PARAM("wp", "MBI_SSL") + << CHAR_PARAM("wreply", "https://lw.skype.com/login/oauth/proxy?site_name=lw.skype.com") + << CHAR_PARAM("cobrandid", "90010") + << CHAR_PARAM("opid", opid); + m_szUrl.AppendFormat("?%s", m_szParam.c_str()); + m_szParam.Empty(); + + AddHeader("Cookie", cookies); + + this << CHAR_PARAM("type", "28") << CHAR_PARAM("PPFT", ppft); + } + OAuthRequest(const char *t) : AsyncHttpRequest(REQUEST_POST, HOST_LOGIN, "/login/microsoft", &CSkypeProto::OnOAuthEnd) { diff --git a/protocols/SkypeWeb/src/skype_oauth.cpp b/protocols/SkypeWeb/src/skype_oauth.cpp index 8a202bdf09..1e6737b5cf 100644 --- a/protocols/SkypeWeb/src/skype_oauth.cpp +++ b/protocols/SkypeWeb/src/skype_oauth.cpp @@ -53,9 +53,56 @@ void CSkypeProto::OnOAuthStart(NETLIBHTTPREQUEST *response, AsyncHttpRequest*) ptrA password(getStringA(SKYPE_SETTINGS_PASSWORD)); CMStringA mscookies(FORMAT, "MSPRequ=%s;MSPOK=%s;CkTst=G%lld;", scookies["MSPRequ"].c_str(), scookies["MSPOK"].c_str(), time(NULL)); + cookies["MSPRequ"] = scookies["MSPRequ"]; + PushRequest(new OAuthRequest(login, password, mscookies.c_str(), PPTF.c_str())); } +void CSkypeProto::OnOAuthConfirm(NETLIBHTTPREQUEST* response, AsyncHttpRequest*) { + if (response == nullptr || response->pData == nullptr) { + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); + SetStatus(ID_STATUS_OFFLINE); + return; + } + + std::regex regex; + std::smatch match; + std::string content = response->pData; + std::map<std::string, std::string> scookies; + std::string PPTF; + std::string opid; + + regex = "sFT:'(.+?)'"; + if (!std::regex_search(content, match, regex)) { + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); + SetStatus(ID_STATUS_OFFLINE); + return; + } + PPTF = match[1]; + + regex = "&opid=(.+?)'"; + if (!std::regex_search(content, match, regex)) { + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); + SetStatus(ID_STATUS_OFFLINE); + return; + } + opid = match[1]; + + for (int i = 0; i < response->headersCount; i++) { + if (mir_strcmpi(response->headers[i].szName, "Set-Cookie")) + continue; + + content = response->headers[i].szValue; + regex = "^(.+?)=(.+?);"; + if (std::regex_search(content, match, regex)) + scookies[match[1]] = match[2]; + } + + CMStringA mscookies(FORMAT, "MSPRequ=%s;MSPOK=%s;PPAuth=%s;OParams=%s;", cookies["MSPRequ"].c_str(), scookies["MSPOK"].c_str(), scookies["PPAuth"].c_str(), scookies["OParams"].c_str()); + + PushRequest(new OAuthRequest(mscookies.c_str(), PPTF.c_str(), opid.c_str())); +} + void CSkypeProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *response, AsyncHttpRequest*) { if (response == nullptr || response->pData == nullptr) { diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 2760c47f39..d16b8f55d3 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -122,7 +122,8 @@ public: // oauth
void OnOAuthStart(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
- void OnOAuthAuthorize(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
+ void OnOAuthConfirm(NETLIBHTTPREQUEST* response, AsyncHttpRequest* pRequest);
+ void OnOAuthAuthorize(NETLIBHTTPREQUEST* response, AsyncHttpRequest* pRequest);
void OnOAuthEnd(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnASMObjectCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
|