大家都知道,屏幕保护密码最多为16个字符。微软内置了16字节的密钥:48EE761D6769A11B7A8C47F85495975F。Windows便用上述密钥加密你输入的密码。其加密过程为:首先将你输入的密码字符逐位转换为其16进制的ASCⅡ码值(小写字母先转为大写字母),再依次与对应密钥逐位进行异或运算,把所得16进制值的每一位当作字符,转换为其16进制ASCII码,并在其尾加上00作为结束标志,存入注册表HKEY_CURRENT_USER\ControlPanel\desktop下的二进制键ScreenSave_Data中。
懂得其加密原理后,便不难编程破解我的屏幕保护密码(即上网密码)了。本人用VB6.0编制了一读取注册表中ScrrenSave_Data值的函数GetBinaryValue(EntryAsString),读出其值为31434133334335353334323100,去掉其结束标志00,把余下字节转换为对应的ASCII字符,并把每两个字符组成一16进制数:1CA33C553421,显然,密码为6位,将其与前6字节密钥逐一异或后便得出密码的ASCII码(16进制值):544D4A485348,对应的密码明文为TMJHSH,破解成功!用它拔号一试,呵,立刻传来Modem欢快的叫声。
附VB源程序:(程序中使用了窗体Form1,文本框Text1,命令按钮Command1)
1、窗体代码:
OptionExplicit
DimCryptographAsString
DimiAsInteger
DimjAsInteger
DimkAsInteger
DimCryptographStr(32)AsInteger
DimPWstrAsString
DimPassWordAsString
PrivateSubCommand1_Click()
PWstr=“”
PassWord=“”
Text1.Text=“”
Cryptograph=GetBinaryValue(“ScreenSave_Data”)
k=Len(Cryptograph)
Forj=1Tok-1
Fori=32To126
IfMid(Cryptograph,j,1)=Chr(i)Then
CryptographStr(j)=i
EndIf
Nexti
Nextj
i=(k-1)/2密码位数为(h-1)/2,根据位数选择解密过程。
SelectCasei
Case16
GoTo16
Case15
GoTo15
Case14
GoTo14
Case13
GoTo13
Case12
GoTo12
Case11
GoTo11
Case10
GoTo10
Case9
GoTo9
Case8
GoTo8
Case7
GoTo7
Case6
GoTo6
Case5
GoTo5
Case4
GoTo4
Case3
GoTo3
Case2
GoTo2
Case1
GoTo1
CaseElse
End
EndSelect
16:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(31))&Chr(CryptographStr(32)))Xor&H5F)
15:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(29))&Chr(CryptographStr(30)))Xor&H97)
14:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(27))&Chr(CryptographStr(28)))Xor&H95)
13:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(25))&Chr(CryptographStr(26)))Xor&H54)
12:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(23))&Chr(CryptographStr(24)))Xor&HF8)
11:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(21))&Chr(CryptographStr(22)))Xor&H47)
10:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(19))&Chr(CryptographStr(20)))Xor&H8C)
9:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(17))&Chr(CryptographStr(18)))Xor&H7A)
8:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(15))&Chr(CryptographStr(16)))Xor&H1B)
7:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(13))&Chr(CryptographStr(14)))Xor&HA1)
6:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(11))&Chr(CryptographStr(12)))Xor&H69)
5:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(9))&Chr(CryptographStr(10)))Xor&H67)
4:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(7))&Chr(CryptographStr(8)))Xor&H1D)
3:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(5))&Chr(CryptographStr(6)))Xor&H76)
2:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(3))&Chr(CryptographStr(4)))Xor&HEE)
1:PWstr=PWstr&Chr((“&H”&Chr(CryptographStr(1))&Chr(CryptographStr(2)))Xor&H48)
Fori=iTo1Step-1所得PWstr的值为密码的倒序列,将其倒置便得出密码。
PassWord=PassWord&Mid(PWstr,i,1)
Nexti
Text1.Text=PassWord在文本框内显示密码。
EndSub
2、模块代码:
OptionExplicit
ConstERROR_SUCCESS=0&
ConstERROR_BADDB=1009&
ConstERROR_BADKEY=1010&
ConstREG_EXPAND_SZ=2&
ConstREG_BINARY=3&
ConstKEY_QUERY_VALUE=&H1&
ConstKEY_ENUMERATE_SUB_KEYS=&H8&
ConstKEY_NOTIFY=&H10&
ConstREAD_CONTROL=&H20000
ConstSTANDARD_RIGHTS_READ=READ_CONTROL
ConstKEY_READ=STANDARD_RIGHTS_READOrKEY_QUERY_VALUEOrKEY_ENUMERATE_SUB_KEYSOrKEY_NOTIFY
ConstHKEY_CURRENT_USER=&H80000001
DimhKeyAsLong,MainKeyHandleAsLong
DimrtnAsLong,lBufferAsLong,sBufferAsString,SubKeyAsString
DimlBufferSizeAsLong
DeclareFunctionRegOpenKeyExLib“advapi32.dll”Alias“RegOpenKeyExA”(ByValhKeyAsLong,ByVallpSubKeyAsString,ByValulOptionsAsLong,ByValsamDesiredAsLong,phkResultAsLong)AsLong
DeclareFunctionRegCloseKeyLib“advapi32.dll”(ByValhKeyAsLong)AsLong
DeclareFunctionRegQueryValueExLib“advapi32.dll”Alias“RegQueryValueExA”(ByValhKeyAsLong,ByVallpValueNameAsString,ByVallpReservedAsLong,lpTypeAsLong,ByVallpDataAsString,lpcbDataAsLong)AsLong
FunctionGetBinaryValue(EntryAsString)
MainKeyHandle=HKEY_CURRENT_USER
SubKey=“ControlPanel\desktop\”
rtn=RegOpenKeyEx(MainKeyHandle,SubKey,0,KEY_READ,hKey)
Ifrtn=ERROR_SUCCESSThen如果HKEY_CURRENT_USER\ControlPanel\desktop键被成功打开
lBufferSize=1
rtn=RegQueryValueEx(hKey,Entry,0,REG_BINARY,0,lBufferSize)读取ScreenSave_Data的值
sBuffer=Space(lBufferSize)
rtn=RegQueryValueEx(hKey,Entry,0,REG_BINARY,sBuffer,lBufferSize)
Ifrtn=ERROR_SUCCESSThen如果读取ScreenSave_Data的值成功
rtn=RegCloseKey(hKey)
GetBinaryValue=sBuffer函数返回ScreenSave_Data的值
Else如果读取ScreenSave_Data的值不成功
CallErrorMsg
End
EndIf
Else如果HKEY_CURRENT_USER\ControlPanel\desktop键不能打开
CallErrorMsg调用ErrorMsg()过程
End
EndIf
EndFunction
PrivateSubErrorMsg()显示错误信息过程
SelectCasertn
CaseERROR_BADDB
MsgBox(“您的计算机注册表有错误!”)
CaseERROR_BADKEY,REG_EXPAND_SZ
MsgBox(“您的计算机未设屏保密码!”)
CaseElse
MsgBox(“破解过程中遇到未知错误,错误号:”&Str$(rtn))
EndSelect
EndSub->