主题:  做找回密码的程序,可是密码加密了。怎么办?

楚楚

职务:普通成员
等级:1
金币:1.0
发贴:187
#12003/10/25 11:49:21
做找回密码的程序,可是密码加密了。怎么办?

找回的密码是加密过的。不能用。

原来的程序中有这样一个包含文件:

这是处理加密的。
我在找回密码的程序中也包含这个文件,但密码还是没有揭开。

有什么办法吗?



楚楚

职务:普通成员
等级:1
金币:1.0
发贴:187
#22003/10/25 12:37:55
不是MD5。那个encrypt.asp 加密代码如下:

<%

sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
sBASE_64_CHARACTERS = strUnicode2Ansi(sBASE_64_CHARACTERS)

Function strUnicodeLen(asContents)
'计算unicode字符串的Ansi编码的长度
asContents1="a"&asContents
len1=len(asContents1)
k=0
for i=1 to len1
asc1=asc(mid(asContents1,i,1))
if asc1<0 then asc1=65536+asc1
if asc1>255 then
k=k+2
else
k=k+1
end if
next
strUnicodeLen=k-1
End Function

Function strUnicode2Ansi(asContents)
'将Unicode编码的字符串,转换成Ansi编码的字符串
strUnicode2Ansi=""
len1=len(asContents)
for i=1 to len1
varchar=mid(asContents,i,1)
varasc=asc(varchar)
if varasc<0 then varasc=varasc+65536
if varasc>255 then
varHex=Hex(varasc)
varlow=left(varHex,2)
varhigh=right(varHex,2)
strUnicode2Ansi=strUnicode2Ansi & chrb("&H" & varlow ) & chrb("&H" & varhigh )
else
strUnicode2Ansi=strUnicode2Ansi & chrb(varasc)
end if
next
End function

Function strAnsi2Unicode(asContents)
'将Ansi编码的字符串,转换成Unicode编码的字符串
strAnsi2Unicode = ""
len1=lenb(asContents)
if len1=0 then exit function
for i=1 to len1
varchar=midb(asContents,i,1)
varasc=ascb(varchar)
if varasc > 127 then
strAnsi2Unicode = strAnsi2Unicode & chr(ascw(midb(asContents,i+1,1) & varchar))
i=i+1
else
strAnsi2Unicode = strAnsi2Unicode & chr(varasc)
end if
next
End function

Function Base64encode(asContents)
'将Ansi编码的字符串进行Base64编码
'asContents应当是ANSI编码的字符串(二进制的字符串也可以)
Dim lnPosition
Dim lsResult
Dim Char1
Dim Char2
Dim Char3
Dim Char4
Dim Byte1
Dim Byte2
Dim Byte3
Dim SaveBits1
Dim SaveBits2
Dim lsGroupBinary
Dim lsGroup64
Dim m4,len1,len2

len1=Lenb(asContents)
if len1<1 then
Base64encode=""
exit Function
end if

m3=Len1 Mod 3
If M3 > 0 Then asContents = asContents & String(3-M3, chrb(0))

IF m3 > 0 THEN
len1=len1+(3-m3)
len2=len1-3
else
len2=len1
end if

lsResult = ""

For lnPosition = 1 To len2 Step 3
lsGroup64 = ""
lsGroupBinary = Midb(asContents, lnPosition, 3)

Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
Byte3 = Ascb(Midb(lsGroupBinary, 3, 1))

Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1)
Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1)
Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1)
Char4 = Midb(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1)
lsGroup64 = Char1 & Char2 & Char3 & Char4

lsResult = lsResult & lsGroup64
Next

if M3 > 0 then
lsGroup64 = ""
lsGroupBinary = Midb(asContents, len2+1, 3)

Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
Byte3 = Ascb(Midb(lsGroupBinary, 3, 1))

Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1)
Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1)
Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1)

if M3=1 then
lsGroup64 = Char1 & Char2 & ChrB(61) & ChrB(61)
else
lsGroup64 = Char1 & Char2 & Char3 & ChrB(61)
end if

lsResult = lsResult & lsGroup64
end if

Base64encode = lsResult

End Function


Function Base64decode(asContents)
'将Base64编码字符串转换成Ansi编码的字符串
'asContents应当也是ANSI编码的字符串(二进制的字符串也可以)
Dim lsResult
Dim lnPosition
Dim lsGroup64, lsGroupBinary
Dim Char1, Char2, Char3, Char4
Dim Byte1, Byte2, Byte3
Dim M4,len1,len2

len1= Lenb(asContents)
M4 = len1 Mod 4

if len1 < 1 or M4 > 0 then
Base64decode = ""
exit Function
end if

if midb(asContents, len1, 1) = chrb(61) then m4=3
if midb(asContents, len1-1, 1) = chrb(61) then m4=2

if m4 = 0 then
len2=len1
else
len2=len1-4
end if

For lnPosition = 1 To Len2 Step 4
lsGroupBinary = ""
lsGroup64 = Midb(asContents, lnPosition, 4)
Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1
Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1
Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1
Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1
Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF)
Byte2 = lsGroupBinary & Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF)
Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63))
lsGroupBinary = Byte1 & Byte2 & Byte3

lsResult = lsResult & lsGroupBinary
Next

'处理最后剩余的几个字符
if M4 > 0 then
lsGroupBinary = ""
lsGroup64 = Midb(asContents, len2+1, m4) & chrB(65) 'chr(65)=A,转换成值为0
if M4=2 then '补足4位,是为了便于计算
lsGroup64 = lsGroup64 & chrB(65)
end if
Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1
Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1
Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1
Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1
Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF)
Byte2 = lsGroupBinary & Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF)
Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63))

if M4=2 then
lsGroupBinary = Byte1
elseif M4=3 then
lsGroupBinary = Byte1 & Byte2
end if

lsResult = lsResult & lsGroupBinary
end if

Base64decode = lsResult

End Function

'=============================================
Function Encode(passwd)
Encode=strAnsi2Unicode(Base64encode(strUnicode2Ansi(passwd)))
End Function

Function Decode(passwd)
Decode=strAnsi2Unicode(Base64decode(strUnicode2Ansi(passwd)))
End Function
%>



raynube

职务:普通成员
等级:1
金币:0.0
发贴:34
#32003/10/25 22:06:29
MD5怎么逆啊,要死人的……

还是将密码改成一些随机数,然后告诉用户来的轻松

或者叫用户自己重新输入就好



janlay

职务:管理员
等级:7
金币:28.0
发贴:7244
#42003/10/25 22:16:07
不是有decode函数吗,应该是可以反编码的。试试将密码decode



raynube

职务:普通成员
等级:1
金币:0.0
发贴:34
#52003/10/25 22:38:56
引用:
不是有decode函数吗,应该是可以反编码的。试试将密码decode


应该可以,但是这个要多久啊,呵呵,几个月?几年?



janlay

职务:管理员
等级:7
金币:28.0
发贴:7244
#62003/10/25 23:22:18
既然提供了反编码函数,就应该不存在执行效率的问题。剩下的不用我说了吧,别告诉我你不会调用这个函数哦



null

职务:普通成员
等级:1
金币:0.0
发贴:15
#72003/10/28 12:20:56
看看这两个function:

Function Encode(passwd)
Encode=strAnsi2Unicode(Base64encode(strUnicode2Ansi(passwd)))
End Function

Function Decode(passwd)
Decode=strAnsi2Unicode(Base64decode(strUnicode2Ansi(passwd)))
End Function


有什么差别吗?
如何去decode?
而且,既然是加密程序,如果能有反编码,那还加密干什么啊,那就一点用都没有了啊……




janlay

职务:管理员
等级:7
金币:28.0
发贴:7244
#82003/10/29 9:53:53
如果仅仅只是数据库被盗而 encrypt.asp 没有的话,想破解还是要花点心思的



{ 在指尖上绽放的花朵 }

职务:普通成员
等级:5
金币:14.0
发贴:3209
#92003/10/31 22:48:31
null在上个帖子中说
引用:
看看这两个function:
Function Encode(passwd)
Encode=strAnsi2Unicode(Base64encode(strUnicode2Ansi(passwd)))
End Function

Function Decode(passwd)
Decode=strAnsi2Unicode(Base64decode(strUnicode2Ansi(passwd)))
End Function

有什么差别吗?
如何去decode?
而且,既然是加密程序,如果能有反编码,那还加密干什么啊,那就一点用都没有了啊……





我同意null
兄的说法呢。

编辑历史:[此帖被lemontree编辑过(编辑时间2003-11-01 06:30:45)]