飞信聊天记录文件解密

前段时间,财务部的同事突然说飞信登录不了,经查发现飞信已经下线

而和飞信既无聊天记录导入,也无导出功能,联系中国移动未解决

建议不再使用此平台发送短信,然而数据还是要恢复的,因此...

 

注意:数据无价,执行代码前先对消息记录文件备份(位置:我的文档)

 

代码如下:


// szKeyName 为密码, 微信账号(文件夹名称)
int __stdcall FectionHistoryDecode(const char *srcFileName, const char *dstFileName, const char *szKeyName)
{
	HCRYPTPROV hProv = NULL;
	BOOL status = CryptAcquireContextA(&hProv, 0, "Microsoft Enhanced Cryptographic Provider v1.0", 1, 0xF0000000);
	if (status != FALSE)
	{
		HCRYPTHASH hHash = NULL;
		status = CryptCreateHash(hProv, 0x8004, 0, 0, &hHash);
		if (status != FALSE)
		{
			status = CryptHashData(hHash, (const BYTE *)szKeyName, strlen(szKeyName), 0);
			if (status != FALSE)
			{
				HCRYPTKEY hKey = NULL;
				status = CryptDeriveKey(hProv, 0x6801, hHash, 0, &hKey);
				if (status != FALSE)
				{
					status = FALSE;
					HANDLE hInput = CreateFileA(srcFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_READONLY, NULL);
					if (hInput != INVALID_HANDLE_VALUE)
					{
						HANDLE hOutput = CreateFileA(dstFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
						if (hOutput != INVALID_HANDLE_VALUE)
						{
							unsigned char buffer[1025] = { 0 };
							unsigned long length = 1024;
							DWORD dwReadBytes = 0;
							status = ReadFile(hInput, buffer, length, &dwReadBytes, NULL);
							while (status != FALSE)
							{
								status = CryptDecrypt(hKey, 0, TRUE, 0, buffer, (dwReadBytes > length ? &length : &dwReadBytes));
								if (status == FALSE)
								{
									break;
								}
								DWORD dwWriteBytes = 0;
								status = WriteFile(hOutput, buffer, dwReadBytes, &dwWriteBytes, NULL);
								if (status == FALSE || dwReadBytes < length)
								{
									break;
								}
								memset(buffer, 0, sizeof(buffer));
								status = ReadFile(hInput, buffer, length, &dwReadBytes, NULL);
							}
							CloseHandle(hOutput);
						}
						CloseHandle(hInput);
					}
					CryptDestroyKey(hKey);
				}
				// endif
			}
			CryptDestroyHash(hHash);
		}
		CryptReleaseContext(hProv, 0);
	}
	
	return status;
}

 

注意:数据无价,执行代码前先对消息记录文件备份(位置:我的文档)

 

doc end!

你可能感兴趣的:(黑客技术,Visual,C++,Windows,API)