summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/WhatsAppWeb/src/noise.cpp1
-rw-r--r--protocols/WhatsAppWeb/src/proto.h1
-rw-r--r--protocols/WhatsAppWeb/src/server.cpp44
-rw-r--r--protocols/WhatsAppWeb/src/utils.cpp8
-rw-r--r--protocols/WhatsAppWeb/src/utils.h2
5 files changed, 38 insertions, 18 deletions
diff --git a/protocols/WhatsAppWeb/src/noise.cpp b/protocols/WhatsAppWeb/src/noise.cpp
index c773eba105..0ff9ac2ab5 100644
--- a/protocols/WhatsAppWeb/src/noise.cpp
+++ b/protocols/WhatsAppWeb/src/noise.cpp
@@ -215,6 +215,7 @@ bool WANoise::decodeFrame(const void *pData, size_t cbLen)
MBinBuffer encryptedPub = encrypt(noiseKeys.pub.data(), noiseKeys.pub.length());
mixIntoKey(noiseKeys.priv.data(), ephemeral_.c_str());
+ ppro->ProcessHandshake(encryptedPub);
}
return true;
}
diff --git a/protocols/WhatsAppWeb/src/proto.h b/protocols/WhatsAppWeb/src/proto.h
index 19a2f41add..7d5263952c 100644
--- a/protocols/WhatsAppWeb/src/proto.h
+++ b/protocols/WhatsAppWeb/src/proto.h
@@ -9,6 +9,7 @@ Copyright © 2019-22 George Hazan
#define PROTO_H
#define APP_VERSION "2.2230.15"
+#define KEY_BUNDLE_TYPE "\x05"
class WhatsAppProto;
typedef void (WhatsAppProto:: *WA_PKT_HANDLER)(const JSONNode &node, void*);
diff --git a/protocols/WhatsAppWeb/src/server.cpp b/protocols/WhatsAppWeb/src/server.cpp
index ac2ef6c6c0..3677ca7176 100644
--- a/protocols/WhatsAppWeb/src/server.cpp
+++ b/protocols/WhatsAppWeb/src/server.cpp
@@ -71,7 +71,7 @@ bool WhatsAppProto::ProcessHandshake(const MBinBuffer &keyEnc)
pAppVersion->set_quaternary(v[3]);
proto::DeviceProps pCompanion;
- pCompanion.set_os("Miranda");
+ pCompanion.set_os("Chrome");
pCompanion.set_allocated_version(pAppVersion);
pCompanion.set_platformtype(proto::DeviceProps_PlatformType_DESKTOP);
pCompanion.set_requirefullsync(true);
@@ -82,11 +82,15 @@ bool WhatsAppProto::ProcessHandshake(const MBinBuffer &keyEnc)
auto *pPairingData = new proto::ClientPayload_DevicePairingRegistrationData();
pPairingData->set_deviceprops(buf.data(), buf.length());
pPairingData->set_buildhash(appVersion, sizeof(appVersion));
-
- MBinBuffer tmp = encodeBigEndian(getDword(DBKEY_REG_ID));
- pPairingData->set_eregid(tmp.data(), tmp.length());
-
+ pPairingData->set_eregid(encodeBigEndian(getDword(DBKEY_REG_ID)));
+ pPairingData->set_ekeytype(KEY_BUNDLE_TYPE);
+ pPairingData->set_eident(m_noise->signedIdentity.pub.data(), m_noise->signedIdentity.pub.length());
+ pPairingData->set_eskeyid(encodeBigEndian(m_noise->preKey.keyid));
+ pPairingData->set_eskeyval(m_noise->preKey.pub.data(), m_noise->preKey.pub.length());
+ pPairingData->set_eskeysig(m_noise->preKey.signature.data(), m_noise->preKey.signature.length());
node.set_allocated_devicepairingdata(pPairingData);
+
+ node.set_passive(false);
}
// generate login packet
else {
@@ -94,31 +98,45 @@ bool WhatsAppProto::ProcessHandshake(const MBinBuffer &keyEnc)
}
auto *pUserVersion = new proto::ClientPayload_UserAgent_AppVersion();
- pUserVersion->set_primary(v[0]);
- pUserVersion->set_secondary(v[1]);
- pUserVersion->set_tertiary(v[2]);
- pUserVersion->set_quaternary(v[3]);
+ pUserVersion->set_primary(2);
+ pUserVersion->set_secondary(2230);
+ pUserVersion->set_tertiary(15);
auto *pUserAgent = new proto::ClientPayload_UserAgent();
pUserAgent->set_allocated_appversion(pUserVersion);
- pUserAgent->set_platform(proto::ClientPayload_UserAgent_Platform_WINDOWS);
+ pUserAgent->set_platform(proto::ClientPayload_UserAgent_Platform_WEB);
pUserAgent->set_releasechannel(proto::ClientPayload_UserAgent_ReleaseChannel_RELEASE);
pUserAgent->set_mcc("000");
pUserAgent->set_mnc("000");
- pUserAgent->set_osversion("10.0");
- pUserAgent->set_osbuildnumber("10.0");
+ pUserAgent->set_osversion("0.1");
+ pUserAgent->set_osbuildnumber("0.1");
pUserAgent->set_manufacturer("");
pUserAgent->set_device("Desktop");
pUserAgent->set_localelanguageiso6391("en");
pUserAgent->set_localecountryiso31661alpha2("US");
auto *pWebInfo = new proto::ClientPayload_WebInfo();
- pWebInfo->set_websubplatform(proto::ClientPayload_WebInfo_WebSubPlatform_WINDA);
+ pWebInfo->set_websubplatform(proto::ClientPayload_WebInfo_WebSubPlatform_WEB_BROWSER);
node.set_connecttype(proto::ClientPayload_ConnectType_WIFI_UNKNOWN);
node.set_connectreason(proto::ClientPayload_ConnectReason_USER_ACTIVATED);
node.set_allocated_useragent(pUserAgent);
node.set_allocated_webinfo(pWebInfo);
+
+ MBinBuffer payload(node.ByteSize());
+ node.SerializeToArray(payload.data(), (int)payload.length());
+
+ MBinBuffer payloadEnc = m_noise->encrypt(payload.data(), payload.length());
+
+ auto *pFinish = new proto::HandshakeMessage_ClientFinish();
+ pFinish->set_payload(payloadEnc.data(), payloadEnc.length());
+ pFinish->set_static_(keyEnc.data(), keyEnc.length());
+
+ proto::HandshakeMessage handshake;
+ handshake.set_allocated_clientfinish(pFinish);
+ WSSend(handshake);
+
+ m_noise->finish();
return true;
}
diff --git a/protocols/WhatsAppWeb/src/utils.cpp b/protocols/WhatsAppWeb/src/utils.cpp
index e8c9a3b170..9f687d0368 100644
--- a/protocols/WhatsAppWeb/src/utils.cpp
+++ b/protocols/WhatsAppWeb/src/utils.cpp
@@ -629,12 +629,12 @@ void WAWriter::writePacked(const CMStringA &str)
/////////////////////////////////////////////////////////////////////////////////////////
-MBinBuffer encodeBigEndian(uint32_t num, size_t len)
+std::string encodeBigEndian(uint32_t num, size_t len)
{
- MBinBuffer res;
+ std::string res;
for (int i = 0; i < len; i++) {
- uint8_t c = num & 0xFF;
- res.append(&c, 1);
+ char c = num & 0xFF;
+ res = c + res;
num >>= 8;
}
return res;
diff --git a/protocols/WhatsAppWeb/src/utils.h b/protocols/WhatsAppWeb/src/utils.h
index d2a2311e91..aa8f220292 100644
--- a/protocols/WhatsAppWeb/src/utils.h
+++ b/protocols/WhatsAppWeb/src/utils.h
@@ -102,4 +102,4 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
-MBinBuffer encodeBigEndian(uint32_t num, size_t len = sizeof(uint32_t));
+std::string encodeBigEndian(uint32_t num, size_t len = sizeof(uint32_t));