extract变量覆盖
源码
<?php
$flag='xxx';
extract($_GET);
if(isset($shiyan)){
$content=trim(file_get_contents($flag));
if($shiyan==$content){
echo'flag{xxx}';
}
else{
echo'Oh.no';
}
}
?>
输入一个值shiyan,要求与flag相同,但是又不知道flag的值,还用了extract函数和file_get_contents函数,进行绕过
flag get√
strcmp比较字符串
源码
<?php
$flag = "flag{xxxxx}";
if (isset($_GET['a'])) {
if (strcmp($_GET['a'], $flag) == 0) //如果 str1 小于 str2 返回 < 0; 如果 str1大于 str2返回 > 0;如果两者相等,返回 0。
//比较两个字符串(区分大小写)
die('Flag: '.$flag);
else
print 'No';
}
?>
这里利用strcmp不能比较数组的漏洞
flag get√
urldecode二次编码绕过
源码
<?php
if(eregi("hackerDJ",$_GET[id])) {
echo("not allowed!");
exit();
}
$_GET[id] = urldecode($_GET[id]);
if($_GET[id] == "hackerDJ"){
echo "Access granted!";
echo "flag";
}
?>
可以看到代码对id进行了一次url解码,这里有个知识点就是,当我们发送数据的时候,浏览器会自动对字符进行url编码,后台接收到数据又会自动解码,因为源码对hackerDJ进行了查找,为了绕过他,首先对url编码以后的hackerDJ进行又一次编码,然后就刚好让程序对其解码通过判断
payload
?id=%25%36%38%25%36%31%25%36%33%25%36%62%25%36%35%25%37%32%25%34%34%25%34%61
flag get√
md5()函数
源码
<?php
error_reporting(0);
$flag = 'flag{test}';
if (isset($_GET['username']) and isset($_GET['password'])) {
if ($_GET['username'] == $_GET['password'])
print 'Your password can not be your username.';
else if (md5($_GET['username']) === md5($_GET['password']))
die('Flag: '.$flag);
else
print 'Invalid password';
}
?>
又是典型的md5函数漏洞,不过这里有个坑就是它的md5的判断是三个等号,所以0e开头不能绕过了,只能用数组
flag get√
数组返回NULL绕过
源码
<?php
$flag = "flag";
if (isset ($_GET['password'])){
if (ereg ("^[a-zA-Z0-9]+$", $_GET['password']) === FALSE)
echo 'You password must be alphanumeric';
else if (strpos ($_GET['password'], '--') !== FALSE)
die('Flag: ' . $flag);
else
echo 'Invalid password';
}
?>
用数组绕过ereg函数,后面再继续加减号
flag get√
弱类型整数大小比较绕过
源码
$temp = $_GET['password'];
is_numeric($temp)?die("no numeric"):NULL;
if($temp>1336){
echo $flag;
这题先判断是不是数字,是的话退出,不是的话继续下一步,用%00跟在数字后会判断为非数字,用%20也行,不过只能跟在数字后面
flag get√
sha()函数比较绕过
源码
<?php
$flag = "flag";
if (isset($_GET['name']) and isset($_GET['password'])){
var_dump($_GET['name']);
echo " ";
var_dump($_GET['password']);
var_dump(sha1($_GET['name']));
var_dump(sha1($_GET['password']));
if ($_GET['name'] == $_GET['password'])
echo 'Your password can not be your name!';
else if (sha1($_GET['name']) === sha1($_GET['password']))
die('Flag: '.$flag);
else
echo 'Invalid password.';
}
else
echo 'Login first!';
?>
emmm,经典的sha函数漏洞
flag get√
md5加密相等绕过
源码
<?php
$md51 = md5('QNKCDZO');
$a = @$_GET['a'];
$md52 = @md5($a);
if(isset($a)){
if ($a != 'QNKCDZO' && $md51 == $md52) {
echo "flag{*}";
} else {
echo "false!!!";
}
}
else{echo "please input a";}
?>
emmm,0e开头的函数漏洞
flag get√
十六进制与数字比较
源码
<?php
error_reporting(0);
function noother_says_correct($temp){
$flag = 'flag{test}';
$one = ord('1'); //ord — 返回字符的 ASCII 码值
$nine = ord('9'); //ord — 返回字符的 ASCII 码值
$number = '3735929054';
// Check all the input characters!
for ($i = 0; $i < strlen($number); $i++){
// Disallow all the digits!
$digit = ord($temp{$i});
if ( ($digit >= $one) && ($digit <= $nine) ){
// Aha, digit not allowed!
return "flase";
}
}
if($number == $temp)
return $flag;
}
$temp = $_GET['password'];
echo noother_says_correct($temp);
?>
又不能是数字,又要与3735929054相等,用十六进制绕过
flag get√
变量覆盖
题目
真的是魔性的表情包(捂脸
变量覆盖过去改了b的值就行了
flag get√
ereg正则%00截断
源码
<?php
$flag = "xxx";
if (isset ($_GET['password'])){
if (ereg ("^[a-zA-Z0-9]+$", $_GET['password']) === FALSE){
echo 'You password must be alphanumeric';
}
else if (strlen($_GET['password']) < 8 && $_GET['password'] > 9999999){
if (strpos ($_GET['password'], '-') !== FALSE) //strpos — 查找字符串首次出现的位置{
die('Flag: ' . $flag);
}
else{
echo('- have not been found');
}
}
else{
echo 'Invalid password';
}
}
?>
ereg函数用%00去截断
flag get√
strpos数组绕过
源码
<?php
$flag = "flag";
if (isset ($_GET['ctf'])) {
if (@ereg ("^[1-9]+$", $_GET['ctf']) === FALSE)
echo '必须输入数字才行';
else if (strpos ($_GET['ctf'], '#biubiubiu') !== FALSE)
die('Flag: '.$flag);
else
echo '骚年,继续努力吧啊~';
}
?>
ereg函数处理输入返回null,刚好绕过。strpos函数给他匹配到就行了
flag get√
数字验证正则绕过
源码
<?php
error_reporting(0);
$flag = 'flag{test}';
if ("POST" == $_SERVER['REQUEST_METHOD']){
$password = $_POST['password'];
if (0 >= preg_match('/^[[:graph:]]{12,}$/', $password)){ //preg_match — 执行一个正则表达式匹配
echo 'flag';
exit;
}
while (TRUE){
$reg = '/([[:punct:]]+|[[:digit:]]+|[[:upper:]]+|[[:lower:]]+)/';
if (6 > preg_match_all($reg, $password, $arr))
break;
$c = 0;
$ps = array('punct', 'digit', 'upper', 'lower'); //[[:punct:]] 任何标点符号 [[:digit:]] 任何数字 [[:upper:]] 任何大写字母 [[:lower:]] 任何小写字母
foreach ($ps as $pt){
if (preg_match("/[[:$pt:]]+/", $password))
$c += 1;
}
if ($c < 3) break;
//>=3,必须包含四种类型三种与三种以上
if ("42" == $password) echo $flag;
else echo 'Wrong password';
exit;
}
}
?>
post一个值,位数小于12就行了
flag get√
简单的waf
进去看到you are not admin,找到源码看见
$a=isset($_GET["a"])?$_GET["a"]:'';
$b=isset($_GET["b"])?$_GET["b"]:'';
$c=isset($_GET["c"])?$_GET["c"]:'';
$d=isset($_GET["d"])?$_GET["d"]:'';
$e=isset($_GET['e'])?$_GET['e']:'';
if(preg_match('/php/i', $a)){
die("This not allow pseudo protocol!");
}
if(preg_match('/\.\./', $a)){
die("This also not allow!");
}
if((file_get_contents($a,'r')===$b)&&(file_get_contents($e,'r')==="I'm Administrator!")){
echo "hello admin!<br>";
if(preg_match("/flag/",$c)){
echo "不能现在就给你flag哦";
exit();
}else{
include($c);
if(preg_match('/base64/', $d)){
die("No! you can't use it!");
}
$d = unserialize($d);
echo $d;
}
}else{
echo "you are not admin ! <br>";
}
首先要求a和b相同,e是I'm Administrator!,因为有两个地方有file_get_contets函数,而且a过滤了php
所以我现在服务器放个1.txt文件,内容写1,然后这个就能让a和b相等了,e用php://filter伪协议,c也可以用伪协议
可以看到,现在已经是可以绕过a和b的限制了,但是剩下的后台应该是有点问题,c没有触发waf,却没有回显,无法继续下去了