diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-24 15:00:33 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-24 15:00:33 +0300 |
commit | 1f2d549010819a62aa322b31cfa6c86d78288802 (patch) | |
tree | 73b6002da1d02f36a88d7bba64557af146d2b751 | |
parent | 972fa306badc2e072d65cec43c37496aa952eee0 (diff) |
icq: login succeeded
-rw-r--r-- | protocols/Icq10/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Icq10/src/server.cpp | 32 |
2 files changed, 17 insertions, 17 deletions
diff --git a/protocols/Icq10/src/proto.h b/protocols/Icq10/src/proto.h index 45fb20f845..d1e701bbe3 100644 --- a/protocols/Icq10/src/proto.h +++ b/protocols/Icq10/src/proto.h @@ -46,7 +46,7 @@ class CIcqProto : public PROTO<CIcqProto> void OnStartSession(NETLIBHTTPREQUEST*, AsyncHttpRequest*); HNETLIBCONN m_hAPIConnection; - CMStringA m_szSessionSecret; + CMStringA m_szSessionKey; CMStringA m_szAToken; ////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Icq10/src/server.cpp b/protocols/Icq10/src/server.cpp index 0a8f8e9e98..841706258a 100644 --- a/protocols/Icq10/src/server.cpp +++ b/protocols/Icq10/src/server.cpp @@ -90,14 +90,22 @@ void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) return; } + BYTE hashOut[MIR_SHA256_HASH_SIZE]; + unsigned int len; + JSONNode response = (*root)["response"]; switch (response["statusCode"].as_int()) { case 200: { JSONNode data = response["data"]; - m_szAToken = ptrA(mir_urlDecode(data["token"]["a"].as_string().c_str())); - m_szSessionSecret = data["sessionSecret"].as_mstring(); - + m_szAToken = data["token"]["a"].as_mstring(); + m_szAToken = ptrA(mir_urlDecode(m_szAToken)); + CMStringA m_szSessionSecret = data["sessionSecret"].as_mstring(); + + ptrA szPassword(getStringA("Password")); + HMAC(EVP_sha256(), szPassword.get(), (int)mir_strlen(szPassword), (BYTE*)m_szSessionSecret.c_str(), m_szSessionSecret.GetLength(), hashOut, &len); + m_szSessionKey = ptrA(mir_base64_encode(hashOut, sizeof(hashOut))); + CMStringA szUin = data["loginId"].as_mstring(); if (szUin) setDword("UIN", atoi(szUin)); @@ -133,22 +141,14 @@ void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) UuidToStringA(&pReq->m_reqId, &szId); pReq << CHAR_PARAM("a", m_szAToken) << INT_PARAM("activeTimeout", 180) << CHAR_PARAM("assertCaps", CAPS) - << INT_PARAM("buildNumber", __BUILD_NUM) << CHAR_PARAM("clientName", "Miranda NG") << INT_PARAM("clientVersion", 5000) - << CHAR_PARAM("deviceId", szDeviceId) << CHAR_PARAM("events", EVENTS) << CHAR_PARAM("f", "json") << CHAR_PARAM("imf", "plain") - << CHAR_PARAM("inactiveView", "offline") << CHAR_PARAM("includePresenceFields", FIELDS) << CHAR_PARAM("invisible", "false") - << CHAR_PARAM("k", "ic1nmMjqg7Yu-0hL") << INT_PARAM("majorVersion", __MAJOR_VERSION) << INT_PARAM("minorVersion", __MINOR_VERSION) - << INT_PARAM("mobile", 0) << CHAR_PARAM("nonce", nonce) << INT_PARAM("pointVersion", 0) << CHAR_PARAM("r", (char*)szId) + << INT_PARAM("buildNumber", __BUILD_NUM) << CHAR_PARAM("deviceId", szDeviceId) << CHAR_PARAM("events", EVENTS) + << CHAR_PARAM("f", "json") << CHAR_PARAM("imf", "plain") << CHAR_PARAM("inactiveView", "offline") + << CHAR_PARAM("includePresenceFields", FIELDS) << CHAR_PARAM("invisible", "false") + << CHAR_PARAM("k", "ic1nmMjqg7Yu-0hL") << INT_PARAM("mobile", 0) << CHAR_PARAM("nonce", nonce) << CHAR_PARAM("r", (char*)szId) << INT_PARAM("rawMsg", 0) << INT_PARAM("sessionTimeout", 7776000) << INT_PARAM("ts", ts) << CHAR_PARAM("view", "online"); - ptrA szPassword(getStringA("Password")); - - BYTE hashOut[MIR_SHA256_HASH_SIZE]; - unsigned int len = 0; - HMAC(EVP_sha256(), szPassword.get(), (int)mir_strlen(szPassword), (BYTE*)m_szSessionSecret.c_str(), m_szSessionSecret.GetLength(), hashOut, &len); - ptrA szSessionKey(mir_base64_encode(hashOut, sizeof(hashOut))); - CMStringA hashData(FORMAT, "POST&%s&%s", ptrA(mir_urlEncode(pReq->m_szUrl)), ptrA(mir_urlEncode(pReq->m_szParam))); - HMAC(EVP_sha256(), szSessionKey.get(), (int)mir_strlen(szSessionKey), (BYTE*)hashData.c_str(), hashData.GetLength(), hashOut, &len); + HMAC(EVP_sha256(), m_szSessionKey, m_szSessionKey.GetLength(), (BYTE*)hashData.c_str(), hashData.GetLength(), hashOut, &len); pReq << CHAR_PARAM("sig_sha256", ptrA(mir_base64_encode(hashOut, sizeof(hashOut)))); Push(pReq); |