好文推荐 | 记一次项目中如何快速定位.net漏洞点

2022-04-18 4,593

文章来源:先知社区(am0s)

原文地址:https://xz.aliyun.com/t/11185




最近项目比较多,一个教育局的测试项目,主要目标为一个在线教育平台,经过信息搜集发现是一个开源的代码搭建的平台。能找到源码就离拿下权限不远了。这篇文章在代码审计方面没啥亮点,因为太菜了,不会.net,主要是总结一些.net快速定位漏洞的小技巧。


0x01 寻找源码

通过询问管理员知道是个开源的系统,但是管理员并不确定具体的信息,就需要我们自己去寻找版权


首页信息查看源代码,根据页面关键字去某fa搜索,确定"/templates/web/netschool/corescripts/verify.js"


搜出来的相同站点比较多,根据案例里的连接挨个访问,在某个站底部发现版权为某厦商学院学习平台,知道版权就很容易找到源码了。


0x02 快速审计技巧

由于我不懂.net 所以审计只能靠一些简单技巧泛泛的寻找


0x01 确定路由结构

先打开aspx文件


class为song.site.Manage.Console 在bin目录下用illspy打开song.site.dll

song.site.Manage.Console 对应的url为:

http://www.xxx.com/Manage/console.aspx


这样基本就确定了路由访问,审计起来就比较方便了


0x02 确定路由结构

发现后台部分页面存在未授权访问,对比了一下有验证和没验证的代码,但并没有发现验证信息,主要还是太菜了,不知道从哪里做的认证,只能挨个访问去判断是否为未授权,但页面太多,为了找到一个未授权的切入点,于是采用了最无脑的方法-扫目录,由于已经有了代码,所以把页面路径全部列出来做成专用字典进行跑,然后根据返回页面大小来判断是否未授权,说干就干


先用命令导出所有脚本结构

C:\Users\Administrator\Desktop\wxqysxy-a5>dir /a /s /b *.aspx
C:\Users\Administrator\Desktop\wxqysxy-a5\Pay\Weixin\NativePayPage.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Pay\Weixin\OrderQueryPage.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Pay\Weixin\ProductPage.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Pay\Weixin\PublicPay.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Pay\Weixin\RefundPage.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Pay\Weixin\RefundQueryPage.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Pay\Weixin\ResultNotifyPage.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Utility\CodeImg.aspxC:\Users\Administrator\Desktop\wxqysxy-a5\Utility\Default.aspx

把路径处理一下做成字典,然后用burp跑,页面响应比较大,说明存在未授权


页面响应为197,返回为空,说明有验证或需要构造传参


这样就找到了所有的未授权页面,然后挨个测试就可以了


0x03 任意文件上传

客户要求以拿权限为主,经过漫长的轮一遍未授权,并没有发现有上传的地方,只能接着去看代码找上传点了,在目录下或ilspy里搜索upload等关键字找到的页面全部都有权限验证,为了找到全部的上传功能点,我们可以直接搜SaveAs等上传函数,但iLspy对代码内容搜索功能比较鸡肋,搜索加强版也不是很好用,经过百度,把代码全部导出,然后用cmd查找关键字


这样便导出了所有的项目代码文件,然后用cmd命令查找SaveAs

C:UsersAdministratorDesktopshop>findstr /msi /c:"saveas" *.*
Song.Site.Manage.AdminSetup_Qrcode.cs
Song.Site.Manage.AdminSetup_Stamp.cs
Song.Site.Manage.PanelAuthorization.cs
Song.Site.Manage.TemplateList_Edit.cs
Song.Site.Manage.UtilityExcelInput.cs
Song.Site.Manage.Utility.UploadPathUploading.cs
Song.Site.UtilityExamFileUp.cs


最终在Song.Site.Manage.TemplateList_Edit.cs源码里发现了上传代码没有验证,根据代码构造上传数据包

<form id="LoginForm" action="http://x:8084/Manage/Template/List_Edit.aspx" method="post" enctype="multipart/form-data">
<div class="aspNetHidden">
<input type="text" name="org">
<input type="text" name="NSRSBH">
<input type="file" name="org">
<input type="submit" name="btn_Click" id="btn_Click">

成功上传aspx文件拿到权限。



本文作者:HACK_Learn

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/177238.html

Tags:
评论  (0)
快来写下你的想法吧!

HACK_Learn

文章数:142 积分: 323

微信公众号:HACK学习呀

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号