大家都知道,屏幕保護(hù)密碼最多為16個(gè)字符。微軟內(nèi)置了16字節(jié)的密鑰:48 EE 76 1D 67 69 A1 1B 7A 8C 47 F8 54 95 97 5F。Windows便用上述密鑰加密你輸入的密碼。其加密過(guò)程為:首先將你輸入的密碼字符逐位轉(zhuǎn)換為其16進(jìn)制的ASCⅡ碼值(小寫(xiě)字母先轉(zhuǎn)為大寫(xiě)字母),再依次與對(duì)應(yīng)密鑰逐位進(jìn)行異或運(yùn)算,把所得16進(jìn)制值的每一位當(dāng)作字符,轉(zhuǎn)換為其16進(jìn)制ASCII碼,并在其尾加上00作為結(jié)束標(biāo)志,存入注冊(cè)表HKEY_CURRENT_USERControl Paneldesktop下的二進(jìn)制鍵ScreenSave_Data中。
懂得其加密原理后,便不難編程*我的屏幕保護(hù)密碼(即上網(wǎng)密碼)了。本人用VB6.0編制了一讀取注冊(cè)表中ScrrenSave_Data值的函數(shù)GetBinaryValue(Entry As String),讀出其值為31 43 41 33 33 43 35 35 33 34 32 31 00,去掉其結(jié)束標(biāo)志00,把余下字節(jié)轉(zhuǎn)換為對(duì)應(yīng)的ASCII字符,并把每?jī)蓚€(gè)字符組成一16進(jìn)制數(shù):1C A3 3C 55 34 21,顯然,密碼為6位,將其與前6字節(jié)密鑰逐一異或后便得出密碼的ASCII碼(16進(jìn)制值):54 4D 4A 48 53 48,對(duì)應(yīng)的密碼明文為T(mén)MJHSH,*成功!用它拔號(hào)一試,呵,立刻傳來(lái)Modem歡快的叫聲。
附VB源程序:(程序中使用了窗體Form1,文本框Text1,命令按鈕Command1)
窗體代碼:
Option Explicit
Dim Cryptograph As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim CryptographStr(32) As Integer
Dim PWstr As String
Dim PassWord As String
Private Sub Command1_Click()
PWstr = ""
PassWord = ""
Text1.Text =""
Cryptograph = GetBinaryValue("ScreenSave_Data")
k = Len(Cryptograph)
For j = 1 To k - 1
For i = 32 To 126
If Mid(Cryptograph, j, 1) = Chr(i) Then
CryptographStr(j) = i
End If
Next i
Next j
i = (k - 1) / 2 ‘密碼位數(shù)為(h-1)/2,根據(jù)位數(shù)選擇解密過(guò)程。
Select Case i
Case 16
GoTo 16
Case 15
GoTo 15
Case 14
GoTo 14
Case 13
GoTo 13
Case 12
GoTo 12
Case 11
GoTo 11
Case 10
GoTo 10
Case 9
GoTo 9
Case 8
GoTo 8
Case 7
GoTo 7
Case 6
GoTo 6
Case 5
GoTo 5
Case 4
GoTo 4
Case 3
GoTo 3
Case 2
GoTo 2
Case 1
GoTo 1
Case Else
End
End Select
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)
For i = i To 1 Step -1 ‘所得PWstr的值為密碼的倒序列,將其倒置便得出密碼。
PassWord = PassWord & Mid(PWstr, i, 1)
Next i
Text1.Text = PassWord ‘在文本框內(nèi)顯示密碼。
End Sub
懂得其加密原理后,便不難編程*我的屏幕保護(hù)密碼(即上網(wǎng)密碼)了。本人用VB6.0編制了一讀取注冊(cè)表中ScrrenSave_Data值的函數(shù)GetBinaryValue(Entry As String),讀出其值為31 43 41 33 33 43 35 35 33 34 32 31 00,去掉其結(jié)束標(biāo)志00,把余下字節(jié)轉(zhuǎn)換為對(duì)應(yīng)的ASCII字符,并把每?jī)蓚€(gè)字符組成一16進(jìn)制數(shù):1C A3 3C 55 34 21,顯然,密碼為6位,將其與前6字節(jié)密鑰逐一異或后便得出密碼的ASCII碼(16進(jìn)制值):54 4D 4A 48 53 48,對(duì)應(yīng)的密碼明文為T(mén)MJHSH,*成功!用它拔號(hào)一試,呵,立刻傳來(lái)Modem歡快的叫聲。
附VB源程序:(程序中使用了窗體Form1,文本框Text1,命令按鈕Command1)
窗體代碼:
Option Explicit
Dim Cryptograph As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim CryptographStr(32) As Integer
Dim PWstr As String
Dim PassWord As String
Private Sub Command1_Click()
PWstr = ""
PassWord = ""
Text1.Text =""
Cryptograph = GetBinaryValue("ScreenSave_Data")
k = Len(Cryptograph)
For j = 1 To k - 1
For i = 32 To 126
If Mid(Cryptograph, j, 1) = Chr(i) Then
CryptographStr(j) = i
End If
Next i
Next j
i = (k - 1) / 2 ‘密碼位數(shù)為(h-1)/2,根據(jù)位數(shù)選擇解密過(guò)程。
Select Case i
Case 16
GoTo 16
Case 15
GoTo 15
Case 14
GoTo 14
Case 13
GoTo 13
Case 12
GoTo 12
Case 11
GoTo 11
Case 10
GoTo 10
Case 9
GoTo 9
Case 8
GoTo 8
Case 7
GoTo 7
Case 6
GoTo 6
Case 5
GoTo 5
Case 4
GoTo 4
Case 3
GoTo 3
Case 2
GoTo 2
Case 1
GoTo 1
Case Else
End
End Select
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)
For i = i To 1 Step -1 ‘所得PWstr的值為密碼的倒序列,將其倒置便得出密碼。
PassWord = PassWord & Mid(PWstr, i, 1)
Next i
Text1.Text = PassWord ‘在文本框內(nèi)顯示密碼。
End Sub