IDF实验室Writeup之Web

0x00 一种编码而已

Jsfuck代码,本质就是js,直接运行即可,也可以在线转换:JsFuck在线转换

flag:WCTF{H3110_J0t4er}

0x01 你关注最新的漏洞吗

每个人都会梦想手头有一把0day,不过0day可遇不可求,我们还是关注最新的漏洞吧:http://pan.baidu.com/s/1hqf5YZE。答案格式:wctf{***}

解答:

这个题目是一个wireshark的数据包,用wireshark打开没什么异常,不过里面的信息跟kerberos相关,一开始并不知道是什么,上网去搜了一下kerberos,这是个漏洞,试图提交wctf{kerberos}不对,又试了下漏洞的编号MS14-068,好吧,居然对了
flag:wctf{MS14-068}

0x02 简单的js解密

题目连接 http://ctf.idf.cn/game/web/43/index.php

网页中有一段js脚本

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('4e1d494d19194d4d1a484f1e484e4648191e4e194c194c4b191e4d1d4819494a', 'DECRYPT');

根据代码的意思就是对这段字符串解密(题目会有变化,每个人做的题字符串应该不一样)

4e1d494d19194d4d1a484f1e484e4648191e4e194c194c4b191e4d1d4819494a

写了一个Python脚本

import sys
a="4e1d494d19194d4d1a484f1e484e4648191e4e194c194c4b191e4d1d4819494a"
for i in range(0,len(a)-1,2):
    b = 255-int((a[i]+a[(i+1)]),16)
    #print b,
    if b>128:
        b=b-128
    else:
        b=b+128
    print chr(b),
    sys.stdout.softspace=0

得出解密后的结果,提交1b62ff22e70a7197fa1f3f34fa2b7f65

flag:wctf{jS_decRypt__Eaaasy}

0x03 超简单的js题

题目链接  http://ctf.idf.cn/game/web/42/index.php

还是关于js的,加一个alert()直接在浏览器控制台里运行,会弹出一个窗口

var p1 = '%66%75%6e%63%74%69%6f%6e%20%63%68%65%63%6b%53%75%62%6d%69%74%28%29%7b%76%61%72%20%61%3d%64%6f%63%75%6d%65%6e%74%2e%67%65%74%45%6c%65%6d%65%6e%74%42%79%49%64%28%22%70%61%73%73%77%6f%72%64%22%29%3b%69%66%28%22%75%6e%64%65%66%69%6e%65%64%22%21%3d%74%79%70%65%6f%66%20%61%29%7b%69%66%28%22%66%36%65%32%65%65%63%32%36';
var p2 = '%65%65%35%37%62%64%63%37%32%63%64%62%32%33%33%35%37%37%32%38%34%22%3d%3d%61%2e%76%61%6c%75%65%29%72%65%74%75%72%6e%21%30%3b%61%6c%65%72%74%28%22%45%72%72%6f%72%22%29%3b%61%2e%66%6f%63%75%73%28%29%3b%72%65%74%75%72%6e%21%31%7d%7d%64%6f%63%75%6d%65%6e%74%2e%67%65%74%45%6c%65%6d%65%6e%74%42%79%49%64%28%22%6c%65%76%65%6c%51%75%65%73%74%22%29%2e%6f%6e%73%75%62%6d%69%74%3d%63%68%65%63%6b%53%75%62%6d%69%74%3b';
alert(eval(unescape(p1) + unescape('%39%65' + p2)));

内容为解码后的代码

function checkSubmit(){var a=document.getElementById("password");if("undefined"!=typeof a){if("f6e2eec269eee57bdc72cdb233577284"==a.value)return!0;alert("Error");a.focus();return!1}}

根据代码意思,输入f6e2eec269eee57bdc72cdb233577284得答案

flag:wctf{webclieNt_c0py}

0x04  古老的邮件编码

MR,O)^KNYU>;*Q[*[P_?#Q+”AHZS6QG,LKNYNZ.LR;;2LK*[N^&CK+/VN/;,

MXK:TJJ]RKZAQ-36K:&CH:,*M/.XQ;3PL+B^S<K’U>+1^;#)=V-T9GMU=75U

*=65N8V]D95]??0“

直接在线UUencode解密即可:http://web.chacuo.net/charsetuuencode

flag:wctf{uuuuuencode__}

0x05 COOKIE欺骗

题目连接  http://ctf.idf.cn/game/web/40/index.php

一开始给了一段奇怪的字符串cd67918e02086c10d************1eb9a2987ff0b3c4ca6009a   并没有什么思路,n多时间后看了下提示,然后注意到url上file参数的编码好像base64,于是尝试解码,结果是flag.txt的编码。这样看来file参数可以读取文件,尝试(base64编码尝试)几个后发现index.php会返回<?php,修改另一个参数line返回不同的php语句,于是决定写个程序跑。

#-*- coding:utf-8 -*-
import urllib2

url1="http://ctf.idf.cn/game/web/40/index.php?line="
url2="&file=aW5kZXgucGhw"
html=1
i=0
while html:
    page=urllib2.urlopen(url1+str(i)+url2)
    html=page.read()
    print html
    i=i+1

得出如下php脚本

<?php
    error_reporting(0);
    $file=base64_decode(isset($_GET['file'])?$_GET['file']:"");
    $line=isset($_GET['line'])?intval($_GET['line']):0;
    if($file=='') header("location:index.php?line=&file=ZmxhZy50eHQ");
    $file_list = array(
        '0' =>'flag.txt', 
        '1' =>'index.php',
    );
    if(isset($_COOKIE['key']) && $_COOKIE['key']=='idf'){
        $file_list[2]='flag.php';
    }
    if(in_array($file, $file_list)){
        $fa = file($file);
        echo $fa[$line];
    }
?>

根据php代码的意思,会判断COOKIE中是否有key,如果有并且key=idf则将flag.php添加到file_list中并且如果file参数是flag.php则返回flag.php,所以构造
url      :   http://ctf.idf.cn/game/web/40/index.php?line=&file=ZmxhZy5waHA=
cookie:   key=idf

然后查看源代码

<?php $flag='wctf{idf_c00kie}'; ?>

flag:wctf{idf_c00kie}

0x06不难不易的js加密

题目连接  http://ctf.idf.cn/game/web/28

本地js加密,先对js去混淆http://tool.chinaz.com/js.aspx

然后将部分解释加在注释中

var a = prompt("输入你的flag吧,少年!", "");
var b = "f3373e36c677750779f5d04ff7885b3e";
var c = /.+_.+_.+/gi;
var d = 0;
var e = a.substr(8,5);
if ($.md5(e) == b.replace(/7/ig, ++d).replace(/8/ig, d * 2)) {     //确定8-13位是jiami
    var f = a.substr(0 / d,7);
    if (f.substr(5,2) =="js" && $.md5(f.substr(0x0 / d, d + 3)) ==   //确定5-7位是js
    "d0154d5048b5a5eb10ef1646400719f1") {   //确定0到34位是wctf
        r = a.substr(0xd);
        if (r.charCodeAt(d) - 25 == r.charCodeAt(++d) - 25 && r.charCodeAt(--d) - 25 == r.charCodeAt(--d)) {   //确定13-14位是xx
            var g = String.fromCharCode(79);
            g = g.toLowerCase() + g.toLowerCase();  //确定15-16位是oo
            if (r.substr((++d) * 3,6) == g.concat("easy") && c.test(a)) {  //确定后几位为easy,以及其余空白处为_
                d = String(1) + String(a.length)
            }
        }
    }
};
if (a.substr(4, 1) != String.fromCharCode(d) || a.substr(4,1) == "z") {  //确定第四位是{
    alert("额,再去想想。。")
} else {
    alert("恭喜恭喜!")
}

flag:wctf{js_jiami_xxooeasy}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注