IDF实验室之天罗地网简单的js解密

给了一个页面,老样子,看网页源码

<script>
/**
 * Pseudo md5 hash function
 * @param {string} string
 * @param {string} method The function method, can be 'ENCRYPT' or 'DECRYPT'
 * @return {string}
 */
function pseudoHash(string, method) {
  // Default method is encryption
  if (!('ENCRYPT' == method || 'DECRYPT' == method)) {
    method = 'ENCRYPT';
  }
  // Run algorithm with the right method
  if ('ENCRYPT' == method) {
    // Variable for output string
    var output = '';
    // Algorithm to encrypt
    for (var x = 0, y = string.length, charCode, hexCode; x < y; ++x) {
      charCode = string.charCodeAt(x);
      if (128 > charCode) {
        charCode += 128;
      } else if (127 < charCode) {
        charCode -= 128;
      }
      charCode = 255 - charCode;
      hexCode = charCode.toString(16);
      if (2 > hexCode.length) {
        hexCode = '0' + hexCode;
      }
      
      output += hexCode;
    }
    // Return output
    return output;
  } else if ('DECRYPT' == method) {
    // DECODE MISS
    // Return ASCII value of character
    return string;
  }
}
document.getElementById('password').value = pseudoHash('47491e4d194c4a4c1a4e1a4949464d1c4f4a191a474c1b49191c48461c19461b', 'DECRYPT');
</script>
js就是看着不舒服,翻译成C#

        public string pseudoHash(string str, string method)
        {
            // Default method is encryption
            if (!("ENCRYPT" == method || "DECRYPT" == method))
            {
                method = "ENCRYPT";
            }
            // Run algorithm with the right method
            if ("ENCRYPT" == method)
            {
                // Variable for output string
                string output = "";
                // Algorithm to encrypt
                char[] ch = str.ToCharArray();
                char charCode;
                string hexCode;
                for (int x = 0, y = str.Length; x < y; ++x)
                {
                    charCode = ch[x];
                    if (charCode < 128)
                    {
                        charCode = (char)(charCode + 128);
                    }
                    else if (charCode > 127)
                    {
                        charCode = (char)(charCode - 128);
                    }
                    charCode = (char)(255 - charCode);
                    hexCode = Convert.ToString(charCode,16);
                    if (hexCode.Length < 2)
                    {
                        hexCode = '0' + hexCode;
                    }
                    output += hexCode;
                }
                // Return output
                return output;
            }
            else if ("DECRYPT" == method)
            {
                return str;
            }
            return "";
        }
写个逆函数就是

        public string getIt(string str)
        {
            char[] ch = str.ToCharArray();
            string s = "";
            for(int i = 0; i < str.Length - 1; i+=2)
            {
                s += (char)(255-Convert.ToInt32(ch[i] + "" + ch[i + 1], 16)-128) + "";
            }
            return s;
        }
然后结果就出来了,86a2f353e1e6692c05fe83d6fc79cf9d

看样子是个md5码,去解了一下,是4914的md5码,提交,坑爹,不对,然后提交md5码,出来了!!!wctf{jS_decRypt__Eaaasy},。。。

提交,通过!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值