首页
社区
课程
招聘
[旧帖] [求助]大家帮我看下这个算法 0.00雪花
发表于: 2008-3-12 02:42 2739

[旧帖] [求助]大家帮我看下这个算法 0.00雪花

2008-3-12 02:42
2739
session.Timeout=120
function torot13(str_rot13) '将ASCII码转换为ROT13码(包括阿拉伯数字)
dim str_ascii

for i=len(str_rot13) to 1 step -1
If Asc(right(str_rot13 ,i)) > 64 And Asc(right(str_rot13 ,i)) < 91 Then
   newAsc = Asc(right(str_rot13 ,i)) + 13
   If newAsc > 90 Then newAsc = newAsc - 26
ElseIf Asc(right(str_rot13 ,i)) > 96 And Asc(right(str_rot13 ,i)) < 123 Then
   newAsc = Asc(right(str_rot13 ,i)) + 13
   If newAsc > 122 Then newAsc = newAsc - 26
Elseif Asc(right(str_rot13 ,i)) > 47 And Asc(right(str_rot13 ,i)) < 58 Then
  newAsc = Asc(right(str_rot13 ,i)) + 5
   If newAsc > 57 Then newAsc = newAsc - 10
Else
   newAsc = Asc(right(str_rot13 ,i))
End If
str_ascii = str_ascii + chr(newAsc)
next

torot13 = str_ascii
End function

Function TenturnTwo(varNum ,varsit) '返回第一个参数的二进制形式,第二个参数决定返回字符串的位数
    Dim returnString
    Dim ModNum
    Do While varNum > 0
      ModNum = varNum Mod 2
      varNum = varNum \ 2
      returnString = Cstr(ModNum) & returnString
    Loop
        for i = 1 to varsit - len(returnstring)
          returnString = "0" & returnString
        next
    TenturnTwo = returnString
End Function

Function TwoturnTen(varString) '返回参数的十进制形式
    Dim SLen
    Dim I
    Dim returnNum

    SLen = Len(varString)
    For I=1 To SLen
           int_power = SLen - I
       returnNum = returnNum + (Cint(Mid(varString,I,1)) * (2^(int_power)))
    Next
    TwoturnTen = returnNum
End Function

function tobase64(str_ascii) '对输入参数进行加密,并返回加密后的字符串
    dim int_array_count
    dim str_rot13

        str_rot13 = torot13(str_ascii)
        if (len(str_rot13) mod 3 ) = 0 then
           int_array_count = len(str_rot13) \ 3
        else
             int_array_count = (len(str_rot13) \ 3) + 1
    end if
    for i = 0 to int_array_count - 1
           array_temp0 = mid(str_rot13 ,(i * 3 + 1) ,3) '从参数中一次取三个字符出来赋值到0变量中
           for j = 1 to len(array_temp0) '此循环将0变量中的字符转换为位数为8倍数的二进制字符,并赋值到1变量
              array_temp1 = array_temp1 & TenturnTwo(Asc(Mid(array_temp0 ,j ,1)) ,8)
       next
           for k = 1 to 24 - len(array_temp1)
           '此循环将1变量的位数补满至24
              array_temp1 = array_temp1 & "0"
           next
           for m = 0 to 3
           '此循环将长度为24的变量1分割为四段,并生成一个四个字符的加密后的字符,添加至变量3末尾
              array_temp2 = cint(TwoTurnTen(mid(array_temp1 ,(m * 6 + 1) ,6)))

                     if array_temp2>=0 and array_temp2<26 then
                             array_temp3 = array_temp3 & chr(array_temp2 + 97)
                     elseif array_temp2>25 and array_temp2<52 then
                             array_temp3 = array_temp3 & chr(array_temp2 + 39)
                         elseif array_temp2>51 and array_temp2<62 then
                             array_temp3 = array_temp3 & chr(array_temp2 - 4)
                         elseif array_temp2 = 62 then
                             array_temp3 = array_temp3 & "#"
                         elseif array_temp2 = 63 then
                             array_temp3 = array_temp3 & "^"
                         else
                             array_temp3 = array_temp3 & "!"
                  end if
           next
           array_temp1 = ""
        next
        tobase64 = array_temp3
end function

Function toAscii(str_base64) '对输入参数进行解密,并返回解密后的字符串,即用户的密码原型
    dim int_array_count

        int_array_count = len(trim(str_base64)) / 4
        for i = 0 to int_array_count - 1
            array_temp0 = mid(str_base64 ,(i * 4 + 1) ,4)
           for j = 1 to len(array_temp0) '此循环将0变量中的字符转换为位数为8倍数的二进制字符,并赋值到1变量
              array_temp2 = Asc(Mid(array_temp0 ,j ,1))
                  if array_temp2 < 123 and array_temp2 > 96 then
                      array_temp1 = array_temp1 & TenturnTwo((array_temp2 - 97) ,6)
                  elseif array_temp2 < 91 and array_temp2 > 64 then
                      array_temp1 = array_temp1 & TenturnTwo((array_temp2 - 39) ,6)
          elseif array_temp2 < 58 and array_temp2 > 47 then
                      array_temp1 = array_temp1 & TenturnTwo((array_temp2 + 4) ,6)
                  elseif array_temp2 = 35 then
                      array_temp1 = array_temp1 & TenturnTwo(62 ,6)
                  elseif array_temp2 = 36 then
                      array_temp1 = array_temp1 & TenturnTwo(63 ,6)
                  end if
       next
       for k = 0 to 2
              if mid(array_temp1 ,(k * 8 + 1) ,8) <> "00000000" then
              array_temp3 = array_temp3 & chr(cint(TwoTurnTen(mid(array_temp1 ,(k * 8 + 1) ,8))))
                  end if
           next
           array_temp1 = ""
        next
    toascii = torot13(trim(array_temp3))
End Function

哪位大哥哥能帮我破解这个算法啊! 给我一个明文 和密文 好吗?

[培训]科锐逆向工程师培训第53期2025年7月8日开班!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 65
活跃值: (811)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
2
这个好像用的是base64……
一般我要是遇到自己看不明白的代码,我就把它改一下,放到你的开发环境中调试单步跟一下!
建议LZ你把程序改一下放到VB里跟一下,应该就可以弄明白了!
2008-3-12 09:01
0
游客
登录 | 注册 方可回帖
返回