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

所属分类: 网络安全 / 加密解密 阅读数: 188
收藏 0 赞 0 分享
/* 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);
}
更多精彩内容其他人还在看

破解Oracle数据库的密码

要连接远程的 Oracle 数据库,需要知道 SID,用户名, 密码,当然还有最重要的 IP 地址。SID 如果被管理 员修改的话,可以利用 sidguess 来进行破解,速度非常的快,至于成功与否,就要看你的字典配置了。破解 效果如图 1。   图 1
收藏 0 赞 0 分享

破解CMOS密码的四种方法

1.简单的DOS下DEBUG破解程序:   用软盘启动进入DOS下,执行Debug程序(你没有,那得去拷贝一个啊)   1)debug   o 70 2e (回车)   o 71 00 (回车)   o 70 2f (回车)
收藏 0 赞 0 分享

轻松破解无线网络WEP密码下篇

上期为各位介绍了将自己的网卡重新安装驱动,以便使用无线网络检测及WEP解密工具。当我们把网卡驱动更新完毕后,我们再来看看如何找出已经禁用了SSID号广播的无线网络以及进行WEP解密工作。   一、使用airodump抓取无线网络数据包并破解SSID名称:   
收藏 0 赞 0 分享

简单破解“高强度文件夹加密大师”

今天我们社团学弟拿了一个高强度文件夹加密大师给社长试试,说是一个这加密文件夹很好的东西,可以把私藏的物品放在文件夹然后加密文件夹。我处于好奇也跟了上去看看。他又说,这是他花了好长时间才找到的一个不错的东西,还说网络上没有比这个还好的加密文件夹软件了
收藏 0 赞 0 分享

在KDE环境下安装GnuPG加密软件

大多数人以前没有使用过加密技术,我记录了在Mandrake 10.0发行版中KDE环境下创建我的公/私钥的过程,我将这些步骤记录下来了,没有使用到命令行,其linux发行版可能更容易安装。   首先你得在纸上创建你的密码,密码的长度没有限制,你应该小心选择,你可以使用空
收藏 0 赞 0 分享

轻松破解无线网络WEP密码上篇

近些年无线技术发展迅速,越来越多的用户使用无线设备在自己家建立起无线网络,通过搭建无线网络可以在家里的每个角落使用笔记本和无线网卡访问internet。有很多文章都向大家介绍了无线安全之中的通过设置WEP加密来保证其他计算机以及非法用户无法连接我们建立的无线
收藏 0 赞 0 分享

简述加密和数字签名的区别

什么是加密?   用非常基本的词汇说,加密是一种以密码方式发送信息的方法。只有拥有正确密钥的人才能解开这个信息的密码。对于其他人来说,这个信息看起来就像是一系列随机的字母、数字和符号。如果你要发送不应该让其他人看的敏感信息时,加密是特别重要的。由于
收藏 0 赞 0 分享

介绍几款“加密”软件的破解方法

现在网络上流行很多文件夹加密和文件加密的所谓加密软件,很多都是个人根据开源代码编写的程序,多数都是利用windows技巧实现的(最常见的就是将文件隐藏到回收站,万一你不小心删除了回收站或者重装了系统,那就只有哭了),最受不了的就是他们还都号称自己是什么“
收藏 0 赞 0 分享

加密全接触

经过陈冠希的艳照门事件之后,相信各位网友都对自己电脑里的一些隐私文件的保存问题有了更高的安全要求(不吃亏不知道补牢)。无论是黑客入侵、电脑丢失、电脑送修等都可能会导致自己的隐私文件泄露。为了避免这些问题,最方便快捷的方法就是对我们的隐私文件进行加密处理
收藏 0 赞 0 分享

破解Rar加密文件的方法

(1)了解破解rar加密文件方面的相关知识 (2)使用工具软件Advanced RAR Password Recovery 1.11破解rar加密文件 对于一些安全意识比较强的人来说,一般都会对文件进行加密,例如使用rar自带的加密功能进行加密,如果偶然获取了
收藏 0 赞 0 分享
查看更多