当前位置: 代码网 > 服务器>网络安全>加密解密 > 演示从注册表中还原MSNMessenger口令

演示从注册表中还原MSNMessenger口令

2008年10月08日 加密解密 我要评论
演示从注册表中还原MSNMessenger口令 /* MSNMessenger的口令是经过DPAPI加密后保存在注册表中的 * 这个程序演示解码过程 * tombkeeper[0x40]nsfocus[0x2e]com * tombkeeper[0x40]xfocus[0x2e]net * 2004.... 08-10-08
/* msnmessenger的口令是经过dpapi加密后保存在注册表中的
* 这个程序演示解码过程
* tombkeeper[0x40]nsfocus[0x2e]com
* tombkeeper[0x40]xfocus[0x2e]net
* 2004.08.11
*/ #include <windows.h> #pragma comment(lib, "advapi32.lib")
#define fchk(a) if (!(a)) {printf(#a " failed\n"); return 0;}
typedef struct _cryptoapi_blob {
dword cbdata;
byte* pbdata;
} data_blob;
typedef struct _cryptprotect_promptstruct {
dword cbsize;
dword dwpromptflags;
hwnd hwndapp;
lpcwstr szprompt;
} cryptprotect_promptstruct, *pcryptprotect_promptstruct;
typedef bool (winapi *pcryptunprotectdata)(
data_blob* pdatain,
lpwstr* ppszdatadescr,
data_blob* poptionalentropy,
pvoid pvreserved,
cryptprotect_promptstruct* ppromptstruct,
dword dwflags,
data_blob* pdataout
);
pcryptunprotectdata cryptunprotectdata = null; int main(void)
{
int ret;
hmodule hntdll;
hkey hkey;
dword dwtype;
char data[0x100] = {0};
dword dwsize;
data_blob datain;
data_blob dataout;
ret = regopenkeyex
(
hkey_current_user,
"software\\microsoft\\msnmessenger",
0,
key_read,
&hkey
);
if( ret != error_success ) return 1;
ret = regqueryvalueex
(
hkey,
"password.net messenger service",
null,
&dwtype,
data,
&dwsize
);
if( ret != error_success ) return 1;
fchk ((hntdll = loadlibrary ("crypt32.dll")) != null);
fchk ((cryptunprotectdata = (pcryptunprotectdata)
getprocaddress (hntdll, "cryptunprotectdata")) != null);
datain.pbdata = data 2; //口令密文从第二位开始
datain.cbdata = dwsize-2;
cryptunprotectdata
(
&datain,
null,
null,
null,
null,
1,
&dataout
);
base64_decode (dataout.pbdata, data, strlen(dataout.pbdata));
printf ( "msn password: %s\n", data);
return 0;
}
//copied from gnu libc - libc/resolv/base64.c
int base64_decode (char const *src, char *target, size_t targsize)
{
static const char base64[] =
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 /";
static const char pad64 = ’=’;
int tarindex, state, ch;
char *pos;
state = 0;
tarindex = 0;
while ((ch = *src ) != ’\0’)
{
if (isspace (ch)) /* skip whitespace anywhere. */
continue;
if (ch == pad64)
break;
pos = strchr (base64, ch);
if (pos == 0) /* a non-base64 character. */
return (-1);
switch (state)
{
case 0:
if (target)
{
if ((size_t) tarindex >= targsize)
return (-1);
target[tarindex] = (pos - base64) << 2;
}
state = 1;
break;
case 1:
if (target)
{
if ((size_t) tarindex 1 >= targsize)
return (-1);
target[tarindex] |= (pos - base64) >> 4;
target[tarindex 1] = ((pos - base64) & 0x0f) << 4;
}
tarindex ;
state = 2;
break;
case 2:
if (target)
{
if ((size_t) tarindex 1 >= targsize)
return (-1);
target[tarindex] |= (pos - base64) >> 2;
target[tarindex 1] = ((pos - base64) & 0x03) << 6;
}
tarindex ;
state = 3;
break;
case 3:
if (target)
{
if ((size_t) tarindex >= targsize)
return (-1);
target[tarindex] |= (pos - base64);
}
tarindex ;
state = 0;
break;
default:
abort ();
}
}
/*
* we are done decoding base-64 chars. let’s see if we ended
* on a byte boundary, and/or with erroneous trailing characters.
*/
if (ch == pad64)
{ /* we got a pad char. */
ch = *src ; /* skip it, get next. */
switch (state)
{
case 0: /* invalid = in first position */
case 1: /* invalid = in second position */
return (-1);
case 2: /* valid, means one byte of info */
/* skip any number of spaces. */
for ((void) null; ch != ’\0’; ch = *src )
if (!isspace (ch))
break;
/* make sure there is another trailing = sign. */
if (ch != pad64)
return (-1);
ch = *src ; /* skip the = */
/* fall through to "single trailing =" case. */
/* fallthrough */
case 3: /* valid, means two bytes of info */
/*
* we know this char is an =. is there anything but
* whitespace after it?
*/
for ((void) null; ch != ’\0’; ch = *src )
if (!isspace (ch))
return (-1);
/*
* now make sure for cases 2 and 3 that the "extra"
* bits that slopped past the last full byte were
* zeros. if we don’t check them, they become a
* subliminal channel.
*/
if (target && target[tarindex] != 0)
return (-1);
}
}
else
{
/*
* we ended by seeing the end of the string. make sure we
* have no partial bytes lying around.
*/
if (state != 0)
return (-1);
}
return (tarindex);
}
(0)

相关文章:

  • 强!1分钟破解Windows系统开机密码

    强!1分钟破解Windows系统开机密码 Windows系统开机密码从Windows 98开始就被人津津乐道,最早的密码保护可以用形同虚设来形容。直到后来的Windows 200…

    2008年10月08日 网络安全
  • DB2中的数据值加密

    DB2中的数据值加密

    DB2中的数据值加密 多年来,数据库已经能够阻止未经授权的人看到其中的数据,这通常是通过数据库管理器中的特权和权限来实现的。在当前的环境下,对存储数据的保密的... [阅读全文]
  • PECompact.v1.80.b2解密详解

    PECompact.v1.80.b2解密详解

    PECompact.v1.80.b2解密详解 ////////////////////////////////////////////////////////... [阅读全文]
  • 加密解密有高招

    加密解密有高招

    加密解密有高招 加密和解密是一个永久的热点话题,什么样的加密才是安全的?怎样才能解开常用的密码?你是否已经意识到,在你每日朝夕相处的密码和保护中,已经有太多的... [阅读全文]
  • 取密钥生成算法(图)

    取密钥生成算法(图) 从拷贝保护产品中剥取(ripping)算法通常是创建密钥生成程序的一种简单而行之有效的方法。其思路非常简单:定位受保护程序内计算合法序列号的函数(可能不止一…

    2008年10月08日 网络安全
  • 高级破解Defender教程(图)

    高级破解Defender教程(图) Defender与底层操作系统紧密集成在一起,且它是专为在基于NT的Windows系统中运行设计的。它可以在当前所有基于NT的系统中运行,包括…

    2008年10月08日 网络安全

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com