-
-
[求助]找来一个算法,请问可否求逆?以及求逆的难度
-
发表于: 2008-7-23 19:46 3416
-
为了描述简单,用vbscript编写,请保存为a.vbs,即可运行
dim crctable(255)
initcrc
sub initcrc
dim i,j,crc
for i=0 to 255
crc=cdbl(i)
for j=0 to 7
if (crc and 1)=1 then
crc=crc and &hFFFFFFFE
crc=crc/2
crc=crc and &h7fffffff
crc=crc xor &HEDB88320
else
crc=crc/2
crc=crc and &h7fffffff
end if
next
crctable(i)=crc
next
end sub
function crc(arr)
dim i,c
crc=&HFFFFFFFF
for i=ubound(arr) to 0 step -1
crc=(((crc and &hffffff00)/&h100) and &hffffff) xor crctable((crc xor arr(i)) and &hff)
next
end function
function str2arr(text)
dim i,l
l=len(text)
redim out(l-1)
for i=1 to l
out(i-1)=asc(mid(text,i,1))
next
str2arr=out
end function
function myhash(txt)
dim cnt,tmp,arr,l,i,m,a(5),b,c,t,k,tt,out(15),x
arr=str2arr(txt)
cnt=128
redim h(cnt)
l=ubound(arr)
b=2^8-1
c=0
a(0)=&h12
a(1)=&h34
a(2)=&H56
a(3)=&h78
a(4)=&h90
a(5)=&hab
h(0)=&h21436587
x=0
for i=1 to cnt
tmp=str2arr(right("0000000" & hex(h(i-1)),8))
l=l+8
redim preserve arr(l)
for j=0 to 7
arr(l-j)=tmp(j)
next
for j=0 to l
t=arr(j) and 7
for m=0 to t
tt=a(0)-a(1)-c
if tt<0 then
tt=tt+b
c=1
else
c=0
end if
a(5)=tt
for k=0 to 4
a(k)=a(k+1)
next
next
arr(j)=(arr(j) xor tt) xor x
x=arr(j)
next
h(i)=crc(arr)
next
for i=0 to 15
out(i)=right("0000000" & hex(h(cnt)),8)
cnt=cnt-1
next
myhash=join(out,"")
end function
msgbox myhash("a")
问题,已知 myhash(x)="E893F781C8349229ACB3D499798A6D226D3D912B781EA81149380ED2FB151EABD0FCB4306D890A1B46FF3264722E399E4A3956025693241B1611C226A7C6F626"
求 x
dim crctable(255)
initcrc
sub initcrc
dim i,j,crc
for i=0 to 255
crc=cdbl(i)
for j=0 to 7
if (crc and 1)=1 then
crc=crc and &hFFFFFFFE
crc=crc/2
crc=crc and &h7fffffff
crc=crc xor &HEDB88320
else
crc=crc/2
crc=crc and &h7fffffff
end if
next
crctable(i)=crc
next
end sub
function crc(arr)
dim i,c
crc=&HFFFFFFFF
for i=ubound(arr) to 0 step -1
crc=(((crc and &hffffff00)/&h100) and &hffffff) xor crctable((crc xor arr(i)) and &hff)
next
end function
function str2arr(text)
dim i,l
l=len(text)
redim out(l-1)
for i=1 to l
out(i-1)=asc(mid(text,i,1))
next
str2arr=out
end function
function myhash(txt)
dim cnt,tmp,arr,l,i,m,a(5),b,c,t,k,tt,out(15),x
arr=str2arr(txt)
cnt=128
redim h(cnt)
l=ubound(arr)
b=2^8-1
c=0
a(0)=&h12
a(1)=&h34
a(2)=&H56
a(3)=&h78
a(4)=&h90
a(5)=&hab
h(0)=&h21436587
x=0
for i=1 to cnt
tmp=str2arr(right("0000000" & hex(h(i-1)),8))
l=l+8
redim preserve arr(l)
for j=0 to 7
arr(l-j)=tmp(j)
next
for j=0 to l
t=arr(j) and 7
for m=0 to t
tt=a(0)-a(1)-c
if tt<0 then
tt=tt+b
c=1
else
c=0
end if
a(5)=tt
for k=0 to 4
a(k)=a(k+1)
next
next
arr(j)=(arr(j) xor tt) xor x
x=arr(j)
next
h(i)=crc(arr)
next
for i=0 to 15
out(i)=right("0000000" & hex(h(cnt)),8)
cnt=cnt-1
next
myhash=join(out,"")
end function
msgbox myhash("a")
问题,已知 myhash(x)="E893F781C8349229ACB3D499798A6D226D3D912B781EA81149380ED2FB151EABD0FCB4306D890A1B46FF3264722E399E4A3956025693241B1611C226A7C6F626"
求 x
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)
赞赏
看原图
赞赏
雪币:
留言: