Skip to content

Commit

Permalink
crypt8 cli
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-mausch committed Dec 25, 2014
1 parent 6c30239 commit 0f2e483
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion source/CLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
#include "CLI.h"
#include "WhatsApp/Crypt5.h"
#include "WhatsApp/Crypt7.h"
#include "WhatsApp/Crypt8.h"

void displayUsage()
{
const WCHAR *usage = L"Supported commands:\n\n"
L"-decrypt5 [input database] [account name] [output filename]\n"
L"example: -decrypt5 msgstore.db.crypt5 andreas.mausch@gmail.com msgstore.decrypted.db\n\n"
L"-decrypt7 [input database] [key filename] [output filename]\n"
L"example: -decrypt7 msgstore.db.crypt7 key msgstore.decrypted.db";
L"example: -decrypt7 msgstore.db.crypt7 key msgstore.decrypted.db\n\n"
L"-decrypt8 [input database] [key filename] [output filename]\n"
L"example: -decrypt8 msgstore.db.crypt8 key msgstore.decrypted.db";

MessageBox(NULL, usage, L"WhatsApp Viewer", MB_OK | MB_ICONINFORMATION);
}
Expand Down Expand Up @@ -46,6 +49,20 @@ void decrypt7(const std::vector<std::string *> arguments)
decryptWhatsappDatabase7(databaseFilename, outputFilename, keyFilename);
}

void decrypt8(const std::vector<std::string *> arguments)
{
if (arguments.size() != 5)
{
displayUsage();
return;
}

std::string &databaseFilename = *arguments[2];
std::string &keyFilename = *arguments[3];
std::string &outputFilename = *arguments[4];
decryptWhatsappDatabase8(databaseFilename, outputFilename, keyFilename);
}

bool handleCommandLineArguments(const std::vector<std::string *> arguments)
{
if (arguments.size() > 1)
Expand All @@ -61,6 +78,11 @@ bool handleCommandLineArguments(const std::vector<std::string *> arguments)
decrypt7(arguments);
return true;
}
else if (command == "-decrypt8")
{
decrypt8(arguments);
return true;
}
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion source/WhatsApp/Crypt8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void uncompressGzipBuffer(unsigned char *compressedBytes, int size, std::vector<
int ret = inflateInit2(&stream, 16 + MAX_WBITS);
if (ret != Z_OK)
{
throw Exception("Decryption failed. Error during unzipping (inflateInit).");
throw Exception("Decryption failed. Error during unzipping (inflateInit). Invalid key?");
}

unsigned char *currentPosition = compressedBytes;
Expand Down

0 comments on commit 0f2e483

Please sign in to comment.