//////////////////////////////////
//时间:2011/07/08
//作者:gaollxu
//原理:
// 微软提供了Protected Storage服务,并同时将Outlook Express密码、IE自动保存密码、MSNExplorer浏览器登陆账户密码、IE自动完成的资料这些隐私信息
//分门别类地保存在了Protected Storage中。但同时又提供了IPStore接口可以访问这些信息,如是乎,便有了这个程序,用来读取Outlook Express密码。
//////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
#import "pstorec.dll" no_namespace har
typedef struct tagOutLookUserData_t
{
char POPuser[ 200 ]; //POP3 User Name
char POPpassword[ 200 ]; //POP3 Password2
char POPserver[ 200 ]; //POP3 Server
char password[200]; //Decoded password
} OutLookUserData_t;
BOOL EnumOutlookUserSum(
long* plUserSum //OUT
);
BOOL EnumOutlookUserData(
long lCount, //IN
OutLookUserData_t* pUserDataList //OUT
);
BOOL EnumOutlookAccounts(
long* plCount, //OUT
OutLookUserData_t** ppUserDataList //OUT
);
BOOL EnumPStorage(
long lCount, //OUT
OutLookUserData_t* pUserDataList //OUT
);
int main()
{
long lCount = 0;
OutLookUserData_t* pUserDataList = NULL;
BOOL bResult = EnumOutlookAccounts( &lCount, &pUserDataList );
if( TRUE != bResult )
{
return -1;
}
bResult = EnumPStorage( lCount, pUserDataList );
if( TRUE != bResult )
{
return -1;
}
{
printf( "%20s", "[POP3 Server]" );
printf( "%20s", "[POP3 User Name]" );
printf( "%20s", "[POP3 Password]" );
printf( "\r\n" );
}
for( int i = 0; i < lCount; ++i )
{
printf( "%20s", pUserDataList[i].POPserver );
printf( "%20s", pUserDataList[i].POPuser );
printf( "%20s", pUserDataList[i].password );
printf( "\r\n" );
}
system( "pause" );
return 0;
}
BOOL EnumOutlookUserSum(
long* plUserSum //OUT
)
{
if( NULL == plUserSum )
{
return false;
}
*plUserSum = 0;
HKEY hKey;
char skey[200] = { 0 };
lstrcpy( skey,"Software\\Microsoft\\Internet Account Manager\\Accounts" );
LONG lResult = ::RegOpenKeyEx( HKEY_CURRENT_USER, ( LPCTSTR ) skey, 0, KEY_ALL_ACCESS, &hKey );
if( ERROR_SUCCESS != lResult )
{
return false;
}
HKEY hSubkey;
long lIndexItem = 0;
BOOL bResult = TRUE;
while( true )
{
char name[200] = { 0 };
DWORD dwSize = 200;
FILETIME f;
lResult = ::RegEnumKeyEx( hKey, lIndexItem++, name, &dwSize, NULL, NULL, NULL, &f );
if( ERROR_NO_MORE_ITEMS == lResult )
{
break;
}
else if( ERROR_SUCCESS != lResult )
{
bResult = FALSE;
break;
}
lstrcpy( skey, "Software\\Microsoft\\Internet Account Manager\\Accounts" );
lstrcat( skey, "\\" );
lstrcat( skey, name );
lResult = ::RegOpenKeyEx( HKEY_CURRENT_USER, ( LPCTSTR )skey , 0, KEY_ALL_ACCESS, &hSubkey );
if( ERROR_SUCCESS != lResult )
{
bResult = FALSE;
break;
}
BYTE contens[150] = {0};
DWORD contenSize = 150;
DWORD type = REG_BINARY;
if( ERROR_SUCCESS == ::RegQueryValueEx ( hSubkey, ( LPCTSTR )"POP3 User Name" , 0, &type, contens, &contenSize ) )
{
*plUserSum += 1;
}
if( NULL != hSubkey)
{
::RegCloseKey( hSubkey );
hSubkey = NULL;
}
}
if( NULL != hSubkey)
{
::RegCloseKey( hSubkey );
hSubkey = NULL;
}
if( NULL != hSubkey)
{
::RegCloseKey( hSubkey );
hSubkey = NULL;
}
return bResult;
}
BOOL EnumOutlookUserData(
long lCount, //IN
OutLookUserData_t* pUserData //OUT
)
{
if( NULL == pUserData )
{
return FALSE;
}
memset( pUserData, 0, sizeof(OutLookUserData_t) );
BOOL bRet = TRUE;
HKEY hKey;
char skey[200] = { 0 };
lstrcpy( skey,"Software\\Microsoft\\Internet Account Manager\\Accounts" );
LONG lResult = ::RegOpenKeyEx( HKEY_CURRENT_USER, ( LPCTSTR ) skey, 0, KEY_ALL_ACCESS, &hKey );
if( ERROR_SUCCESS != lResult )
{
return false;
}
HKEY hSubkey;
long lIndexItem = 0;
BOOL bResult = TRUE;
long lUserIndex = 0;
while( true )
{
char name[200] = { 0 };
DWORD dwSize = 200;
FILETIME f;
lResult = ::RegEnumKeyEx( hKey, lIndexItem++, name, &dwSize, NULL, NULL, NULL, &f );
if( ERROR_NO_MORE_ITEMS == lResult )
{
break;
}
else if( ERROR_SUCCESS != lResult )
{
bResult = FALSE;
break;
}
lstrcpy( skey, "Software\\Microsoft\\Internet Account Manager\\Accounts" );
lstrcat( skey, "\\" );
lstrcat( skey, name );
lResult = ::RegOpenKeyEx( HKEY_CURRENT_USER, ( LPCTSTR )skey , 0, KEY_ALL_ACCESS, &hSubkey );
if( ERROR_SUCCESS != lResult )
{
bResult = FALSE;
break;
}
BYTE contens[150] = {0};
DWORD contenSize = 150;
DWORD type = REG_SZ;
memset( contens, 0, 150 );
if( ERROR_SUCCESS == ::RegQueryValueEx ( hSubkey, ( LPCTSTR )"POP3 User Name" , 0, &type, contens, &contenSize ) )
{
lstrcpy( pUserData[lUserIndex].POPuser,(char*) contens );
}
else
{
continue;
}
type = REG_BINARY;
memset( contens, 0, 150 );
contenSize = 150;
if( ERROR_SUCCESS == ::RegQueryValueEx ( hSubkey, ( LPCTSTR )"POP3 Password2" , 0, &type, contens, &contenSize ) )
{
int totnopass = 0;
for( DWORD i = 2; i < contenSize; i++ )
{
if( IsCharAlphaNumeric(contens[i])
||(contens[i]=='(')
||(contens[i]==')')
||(contens[i]=='.')
||(contens[i]==' ')
||(contens[i]=='-')
)
{
pUserData[lUserIndex].POPpassword[totnopass] = contens[i];
totnopass++;
}
pUserData[lUserIndex].POPpassword[totnopass] = 0;
}
}
else
{
continue;
}
type = REG_SZ;
memset( contens, 0, 150 );
contenSize = 150;
if( ERROR_SUCCESS == ::RegQueryValueEx ( hSubkey, ( LPCTSTR )"POP3 Server" , 0, &type, contens, &contenSize ) )
{
lstrcpy( pUserData[lUserIndex].POPserver,(char*) contens );
}
else
{
continue;
}
if( NULL != hSubkey)
{
::RegCloseKey( hSubkey );
hSubkey = NULL;
}
lUserIndex += 1;
if( lUserIndex == lCount )
{
bRet = TRUE;
break;
}
}
if( NULL != hSubkey)
{
::RegCloseKey( hSubkey );
hSubkey = NULL;
}
if( NULL != hSubkey)
{
::RegCloseKey( hSubkey );
hSubkey = NULL;
}
return bRet;
}
BOOL EnumOutlookAccounts(
long* plCount, //OUT
OutLookUserData_t** ppUserDataList //OUT
)
{
if( NULL == plCount || NULL == ppUserDataList )
{
return false;
}
*plCount = 0;
*ppUserDataList = NULL;
BOOL bRet = EnumOutlookUserSum( plCount );
if( TRUE != bRet )
{
return FALSE;
}
if( *plCount == 0 )
{
return TRUE;
}
bRet = TRUE;
do
{
*ppUserDataList = (OutLookUserData_t*)new OutLookUserData_t[*plCount];
if( NULL == *ppUserDataList )
{
bRet = FALSE;
break;
}
bRet = EnumOutlookUserData( *plCount, *ppUserDataList );
if( TRUE != bRet )
{
break;
}
} while ( false );
if( TRUE != bRet )
{
if( NULL != *ppUserDataList )
{
delete [] *ppUserDataList;
*ppUserDataList = NULL;
}
}
return bRet;
}
BOOL EnumPStorage(
long lCount, //OUT
OutLookUserData_t* pUserDataList //OUT
)
{
if( NULL == pUserDataList )
{
return FALSE;
}
//获得PStoreCreateInstance函数指针
typedef HRESULT (WINAPI *tPStoreCreateInstance)( IPStore **, DWORD, DWORD, DWORD );
tPStoreCreateInstance pPStoreCreateInstance = NULL;
HMODULE hpsDLL = ::LoadLibrary("pstorec.dll");
pPStoreCreateInstance = (tPStoreCreateInstance)::GetProcAddress( hpsDLL, "PStoreCreateInstance" );
if( NULL == pPStoreCreateInstance )
{
return FALSE;
}
//获得IPStore接口
IPStorePtr PStore;
HRESULT hRes = pPStoreCreateInstance( &PStore, 0, 0, 0 );
if( FAILED( hRes ) )
{
return FALSE;
}
//获得IEnumPStoreTypes接口
IEnumPStoreTypesPtr EnumPStoreTypes;
ToBeroOTer
- 粉丝: 1
- 资源: 3
最新资源
- 基于javaweb的网上拍卖系统,采用Spring + SpringMvc+Mysql + Hibernate+ JSP技术
- polygon-mumbai
- Chrome代理 switchyOmega
- GVC-全球价值链参与地位指数,基于ICIO表,(Wang等 2017a)计算方法
- 易语言ADS指纹浏览器管理工具
- 易语言奇易模块5.3.6
- cad定制家具平面图工具-(FG)门板覆盖柜体
- asp.net 原生js代码及HTML实现多文件分片上传功能(自定义上传文件大小、文件上传类型)
- whl@pip install pyaudio ERROR: Failed building wheel for pyaudio
- Constantsfd密钥和权限集合.kt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页