实战|对某一网站的渗透测试

技术

        
            

          转载自:http://diego.team
        
      

对网站的渗透,还挺有意思的,注入->getshell->提权->破解php加密(网站防护做的。。)

端口扫描

picture.image

存在mysql,ftp,ssh,http,ajp,tomcat 多个服务

ajp 存在漏洞 2020-10487 Tomcat apj

存在任意文件读 ,但没啥用

WEB-INF/web.xml 里没有任何东西

picture.image

app上抓了个包,发现了比较可以的api

picture.image

name进行注入, 输入"||1||" 返回正常数据 ,但无法注释后面的内容,只能布尔注入

picture.image

sqlmap 一把梭

python .\sqlmap.py -r res --tamper=space2comment --level 5 --dbs --random-agent

picture.image

存在读文件

picture.image

不知道nginxweb目录,默认路径不存在

picture.image

读到mysql的目录,根据大佬的猜测,同目录下存在nginx 服务,于是读取 ***/nginx/conf/nignx.conf

成功读到配置文件, 存在多个应用 以及对应的路径


        
        location /** {  
                autoindex on;  
               root /***/***/******;  
               index index.html index.htm index.php;  
                if (!-e $request_filename) {  
                        rewrite ^/xx/(.*)$ /xxxx/admin.php/$1 last;  
  
        break;  
                }  
        }  
  
        location = /xxx {  
               #autoindex on;  
               root /xxx/xxx/xxxx;  
               index index.html index.htm index.php;  
                if (!-e $request_filename) {  
                        rewrite ^/xx /xx/index.php last;  
                        break;  
                }  
        }  

    

两个后台(其中一个还挂了),和一个应用

picture.image

暴露了 框架和绝对路径

picture.image

存在目录遍历,发现了个比较有意思的页面mysql.inc.php,读取获取了 mysql 的账号密码

picture.image

企图直接连接,但失败了,

看了看数据库,只能本地登录和指定ip登录

picture.image

然后发现是 tp3.0 的远古框架 ,根据框架读了一下配置文件(也就是入可文件index.php)

picture.image

按照这个配置文件本搭建了一下,目录结构清晰可见


        
├─caches  
│  ├─cache  
│  ├─data  
│  ├─logs  
│  └─temp  
├─common  
├─Conf  
├─language  
├─library  
│  ├─Action  
│  ├─****  
│  ├─Model  
│  └─****  
└─themes  

    

根据手册 tp3的编程风格,确定 项目的文件为IndexAction.class.php,通过sql注入读取发现乱码。。。

然后尝试 tp3.0 的RCE

poc如下


        
http://**/index.php/Index/index/name/$%7B@phpinfo%28%29%7D  

    

直接打不行

仔细看了一下 发现必须为精简模式下才可以使用,即index.php得包含如下


        
define('MODE\_NAME','Lite');  

    

未果 想起还有管理的账号密码

通过之前注入拿到数据库,找到管理员的账号密码,然后登入(后台有点东西

picture.image

后台同样存在注入漏洞(随便一个地方就有),并存在 联合注入,并且具有写文件权限


        
0 union select tohex('webshell'),1,2 into outfile '/**/**/**/shell.php'  

    

蚁剑连接上

picture.image

但自己是 www用户

picture.image

查看进程

picture.image

发现root启动的 tomcat

尝试往tomcat 写 jsp马

picture.image

但是没有写权限

在检索可操作文件时,存在所有服务的一个日志文件夹

发现tomcat日志可读(心想 tomcat不是个空壳来着,怎么还有日志

picture.image

picture.image

看日志才发现还运行服务

检索对应文件

发现在tomcat外的目录 部署了服务并运行在8080上,且属性位777,写个jsp马

picture.image

picture.image

看了看源码 (蒙🖊 怪不得是乱码

picture.image

根据PM9SCREW 检索了一下 是screw 加密

根据教程先获取 编译好的 php_screw.so 文件

picture.image

下载下来拖到 IDA

找到 _pm9screw_ext_fopen 加密函数

picture.image

f5

picture.image

跟进

picture.image

进入红色部分发现 key (打码部分

picture.image

导出

picture.image

然后用

https://github.com/firebroo/screw_decode 进行解密

克隆下来 修改 screwdecode.c

picture.image

然后编译 make

./decode ./xx.php

picture.image

解密完成

picture.image

声明:本公众号所分享内容仅用于网安爱好者之间的技术讨论,禁止用于违法途径, 所有渗透都需获取授权 !否则需自行承担,本公众号及原作者不承担相应的后果。

如有侵权,请联系删除

推荐阅读

实战|记一次奇妙的文件上传getshell

「 超详细 | 分享 」手把手教你如何进行内网渗透

神兵利器 | siusiu-渗透工具管理套件

一款功能全面的XSS扫描器

实战 | 一次利用哥斯拉马绕过宝塔waf

BurpCrypto: 万能网站密码爆破测试工具

快速筛选真实IP并整理为C段 -- 棱眼

自动探测端口顺便爆破工具t14m4t

渗透工具|无状态子域名爆破工具(1秒扫160万个子域)

查看更多精彩内容,还请关注 橘猫学安全:

每日坚持学习与分享,觉得文章对你有帮助可在底部给点个“ 再看

0
0
0
0
关于作者

文章

0

获赞

0

收藏

0

相关资源
火山引擎HTTPDNS边缘云原生技术实践
《火山引擎HTTPDNS边缘云原生技术实践》 赵彦奇 | 火山引擎边缘云网络研发工程师
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论