summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/WhatsAppWeb/WhatsAppWeb.vcxproj3
-rw-r--r--protocols/WhatsAppWeb/src/pmsg.pb.h2
-rw-r--r--protocols/WhatsAppWeb/src/proto.h3
-rw-r--r--protocols/WhatsAppWeb/src/server.cpp5
-rw-r--r--protocols/WhatsAppWeb/src/stdafx.h2
-rw-r--r--protocols/WhatsAppWeb/src/utils.cpp34
6 files changed, 46 insertions, 3 deletions
diff --git a/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj b/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj
index 4929d9f266..a10c683edb 100644
--- a/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj
+++ b/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj
@@ -28,6 +28,9 @@
<ProjectReference Include="..\..\libs\libsodium\libsodium.vcxproj">
<Project>{a185b162-6cb6-4502-b03f-b56f7699a8d9}</Project>
</ProjectReference>
+ <ProjectReference Include="..\..\libs\zlib\zlib.vcxproj">
+ <Project>{e2a369cd-eda3-414f-8ad0-e732cd7ee68c}</Project>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<Image Include="res\whatsapp.ico" />
diff --git a/protocols/WhatsAppWeb/src/pmsg.pb.h b/protocols/WhatsAppWeb/src/pmsg.pb.h
index eb2dc778b6..5402ec1abf 100644
--- a/protocols/WhatsAppWeb/src/pmsg.pb.h
+++ b/protocols/WhatsAppWeb/src/pmsg.pb.h
@@ -6590,7 +6590,7 @@ class ClientPayload_UserAgent final :
ClientPayload_UserAgent_Platform_KAIOS;
static constexpr Platform SMB_IOS =
ClientPayload_UserAgent_Platform_SMB_IOS;
- static constexpr Platform WINDOWS =
+ static constexpr Platform WINDA =
ClientPayload_UserAgent_Platform_WINDOWS;
static constexpr Platform WEB =
ClientPayload_UserAgent_Platform_WEB;
diff --git a/protocols/WhatsAppWeb/src/proto.h b/protocols/WhatsAppWeb/src/proto.h
index fdafe61568..137c42e60e 100644
--- a/protocols/WhatsAppWeb/src/proto.h
+++ b/protocols/WhatsAppWeb/src/proto.h
@@ -226,6 +226,9 @@ class WhatsAppProto : public PROTO<WhatsAppProto>
// Binary packets
void ProcessBinaryPacket(const void *pData, size_t cbLen);
+ // unzip operations
+ MBinBuffer unzip(const MBinBuffer &src);
+
/// Avatars ////////////////////////////////////////////////////////////////////////////
CMStringW GetAvatarFileName(MCONTACT hContact);
diff --git a/protocols/WhatsAppWeb/src/server.cpp b/protocols/WhatsAppWeb/src/server.cpp
index 663a10901f..f6ca1ef948 100644
--- a/protocols/WhatsAppWeb/src/server.cpp
+++ b/protocols/WhatsAppWeb/src/server.cpp
@@ -196,8 +196,9 @@ void WhatsAppProto::ProcessBinaryPacket(const void *pData, size_t cbDataLen)
WAReader rdr(buf.data(), buf.length());
auto b = rdr.readInt8();
if (b & 2) {
- debugLogA("zipped nodes are not supported");
- return;
+ buf.remove(1);
+ buf = unzip(buf);
+ rdr = WAReader(buf.data(), buf.length());
}
if (WANode *pNode = rdr.readNode()) {
diff --git a/protocols/WhatsAppWeb/src/stdafx.h b/protocols/WhatsAppWeb/src/stdafx.h
index 17ab137be9..a463e5ea64 100644
--- a/protocols/WhatsAppWeb/src/stdafx.h
+++ b/protocols/WhatsAppWeb/src/stdafx.h
@@ -59,6 +59,8 @@ Copyright © 2019-22 George Hazan
#include "../../libs/libsodium/src/include/sodium.h"
+#include "../../libs/zlib/src/zlib.h"
+
/////////////////////////////////////////////////////////////////////////////////////////
// to obtain protobuf library do the following
// - install vcpkg (https://github.com/microsoft/vcpkg);
diff --git a/protocols/WhatsAppWeb/src/utils.cpp b/protocols/WhatsAppWeb/src/utils.cpp
index 4c8fb5d8ca..509f277f49 100644
--- a/protocols/WhatsAppWeb/src/utils.cpp
+++ b/protocols/WhatsAppWeb/src/utils.cpp
@@ -344,3 +344,37 @@ void WhatsAppProto::Popup(MCONTACT hContact, const wchar_t *szMsg, const wchar_t
ppd.hContact = hContact;
Popup_AddClass(&ppd);
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MBinBuffer WhatsAppProto::unzip(const MBinBuffer &src)
+{
+ z_stream strm = {};
+ inflateInit(&strm);
+
+ strm.avail_in = src.length();
+ strm.next_in = (Bytef *)src.data();
+
+ MBinBuffer res;
+ Bytef buf[2048];
+
+ while (strm.avail_in > 0) {
+ strm.avail_out = sizeof(buf);
+ strm.next_out = buf;
+
+ int ret = inflate(&strm, Z_NO_FLUSH);
+ switch (ret) {
+ case Z_NEED_DICT:
+ ret = Z_DATA_ERROR; /* and fall through */
+ case Z_DATA_ERROR:
+ case Z_MEM_ERROR:
+ inflateEnd(&strm);
+ return ret;
+ }
+
+ res.append(buf, sizeof(buf) - strm.avail_out);
+ }
+
+ inflateEnd(&strm);
+ return res;
+} \ No newline at end of file