STAPLER:1 Walkthrough
Reconnaissance
Host Discovery
1
2
3
4
5
6
7
$netdiscover
Currently scanning: 192.168.84.0/16 | Screen View: Unique Hosts
3 Captured ARP Req/Rep packets, from 3 hosts. Total size: 180
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.56.102 08:00:27:c4:4e:1e 1 60 PCS Systemtechnik GmbH
Port Scanning
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
$ nmap -p- -A -sV -sC 192.168.56.102 | tee stapler.txt
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-22 05:36 EDT
Nmap scan report for 192.168.56.102
Host is up (0.0017s latency).
Not shown: 65523 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
20/tcp closed ftp-data
21/tcp open ftp vsftpd 2.0.8 or later
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 192.168.56.101
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 1
| vsFTPd 3.0.3 - secure, fast, stable
|_End of status
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_Can't get directory listing: PASV failed: 550 Permission denied.
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 81:21:ce:a1:1a:05:b1:69:4f:4d:ed:80:28:e8:99:05 (RSA)
| 256 5b:a5:bb:67:91:1a:51:c2:d3:21:da:c0:ca:f0:db:9e (ECDSA)
|_ 256 6d:01:b7:73:ac:b0:93:6f:fa:b9:89:e6:ae:3c:ab:d3 (ED25519)
53/tcp open domain dnsmasq 2.75
| dns-nsid:
|_ bind.version: dnsmasq-2.75
80/tcp open http PHP cli server 5.5 or later
|_http-title: 404 Not Found
123/tcp closed ntp
137/tcp closed netbios-ns
138/tcp closed netbios-dgm
139/tcp open netbios-ssn Samba smbd 4.3.9-Ubuntu (workgroup: WORKGROUP)
666/tcp open doom?
| fingerprint-strings:
| NULL:
| message2.jpgUT
| QWux
| "DL[E
| #;3[
| \xf6
| u([r
| qYQq
| Y_?n2
| 3&M~{
| 9-a)T
| L}AJ
|_ .npy.9
3306/tcp open mysql MySQL 5.7.12-0ubuntu1
| mysql-info:
| Protocol: 10
| Version: 5.7.12-0ubuntu1
| Thread ID: 19
| Capabilities flags: 63487
| Some Capabilities: SupportsLoadDataLocal, InteractiveClient, FoundRows, ODBCClient, Support41Auth, Speaks41ProtocolOld, LongPassword, SupportsTransactions, SupportsCompression, LongColumnFlag, Speaks41ProtocolNew, ConnectWithDatabase, IgnoreSpaceBeforeParenthesis, IgnoreSigpipes, DontAllowDatabaseTableColumn, SupportsMultipleStatments, SupportsAuthPlugins, SupportsMultipleResults
| Status: Autocommit
| Salt: _Z\x05Ab0aF \x0D\x028\x03H@=\x01\KF
|_ Auth Plugin Name: mysql_native_password
12380/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Tim, we need to-do better next year for Initech
|_http-server-header: Apache/2.4.18 (Ubuntu)
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port666-TCP:V=7.94SVN%I=7%D=6/22%Time=66769BA0%P=x86_64-pc-linux-gnu%r(
SF:NULL,2D58,"PK\x03\x04\x14\0\x02\0\x08\0d\x80\xc3Hp\xdf\x15\x81\xaa,\0\0
SF:\x152\0\0\x0c\0\x1c\0message2\.jpgUT\t\0\x03\+\x9cQWJ\x9cQWux\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xcfC\x
SF:cd\x88\x8e}\xac\x15\xf6~\xc4R\x8e`wT\x96\xa8KT\x1cam\xdb\x99f\xfb\n\xbc
SF:\xbcL}AJ\xe5H\x912\x88\(O\0k\xc9\xa9\x1a\x93\xb8\x84\x8fdN\xbf\x17\xf5\
SF:xf0\.npy\.9\x04\xcf\x14\x1d\x89Rr9\xe4\xd2\xae\x91#\xfbOg\xed\xf6\x15\x
SF:04\xf6~\xf1\]V\xdcBGu\xeb\xaa=\x8e\xef\xa4HU\x1e\x8f\x9f\x9bI\xf4\xb6GT
SF:Q\xf3\xe9\xe5\x8e\x0b\x14L\xb2\xda\x92\x12\xf3\x95\xa2\x1c\xb3\x13\*P\x
SF:11\?\xfb\xf3\xda\xcaDfv\x89`\xa9\xe4k\xc4S\x0e\xd6P0");
Service Info: Host: RED; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
|_nbstat: NetBIOS name: RED, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb-os-discovery:
| OS: Windows 6.1 (Samba 4.3.9-Ubuntu)
| Computer name: red
| NetBIOS computer name: RED\x00
| Domain name: \x00
| FQDN: red
|_ System time: 2024-06-22T18:38:52+01:00
| smb2-time:
| date: 2024-06-22T17:38:52
|_ start_date: N/A
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled but not required
|_clock-skew: mean: 7h40m00s, deviation: 34m37s, median: 7h59m59s
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 159.77 seconds
Enumeration
FTP Enumeration (port 21)
使用anonymous
用户名,随意密码登陆后,发现一条Harry
给的提示信息,并且查看到根目录下存在note
文件,使用get
下载到本地,发现是一条John
给Elly
的留言。
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
┌──(root㉿kali)-[~]
└─$ ftp 192.168.56.102
Connected to 192.168.56.102.
220-
220-|-----------------------------------------------------------------------------------------|
220-| Harry, make sure to update the banner when you get a chance to show who has access here |
220-|-----------------------------------------------------------------------------------------|
220-
220
Name (192.168.56.102:kali): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
550 Permission denied.
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 107 Jun 03 2016 note
226 Directory send OK.
ftp> get note
local: note remote: note
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for note (107 bytes).
100% |********************************************************************************| 107 24.96 KiB/s 00:00 ETA
226 Transfer complete.
107 bytes received in 00:00 (22.40 KiB/s)
ftp> exit
221 Goodbye.
┌──(root㉿kali)-[~]
└─$ cat note
Elly, make sure you update the payload information. Leave it in your FTP account once your are done, John.
将上述信息中出现的三个人名,作为FTP的用户名,通过hydra
进行爆破查看是否存在空口令,同名口令等。
结果显示,elly
用户名存在同名逆向口令ylle
。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
┌──(root㉿kali)-[~]
└─$ cat username
John
JOHN
john
Elly
ELLY
elly
Harry
HARRY
harry
┌──(root㉿kali)-[~]
└─$ hydra -L username -e nsr ftp://192.168.56.102
Hydra v9.5 (c) 2023 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 2024-06-25 01:29:54
[DATA] max 16 tasks per 1 server, overall 16 tasks, 27 login tries (l:9/p:3), ~2 tries per task
[DATA] attacking ftp://192.168.56.102:21/
[21][ftp] host: 192.168.56.102 login: elly password: ylle
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2024-06-25 01:30:02
尝试使用爆破到的用户名进行登陆,发现其根目录挂载位于/etc/
下,通过查看文件发现一个名为passwd
的文件,我们下载到本地对其进行查看,发现很多自定义的个人用户。
将其中具有可登录 shell 的用户筛选出来
SSH Enumeration (port 22)
这里再次使用hydra
使用刚刚筛选的用户名对其进行爆破,是否存在空口令,同名口令,同名逆向口令等。根据结果 SHayslett
用户名存在同名口令 SHayslett
。
接着使用ssh
对其进行登陆,发现其存在存在一条Barry
的提示
SMB Enumeration (port 139)
这里使用enum4linux
对SMB进行扫描
在共享服务扫描结果中,发现存在有效共享服务名tmp
kathy
其中这里的用户列表,与我们之前获取的功能一样,所以同样也可以进行FTP
和SSH
爆破
使用 smbclient
连接到主机上的共享目录 /kathy
和/tmp
,并使用空指令(-N
选项)登录。
然后并将所有文件下载到本地对其进行查看
文件内容如下:
ls
像是 root 用户某目录下的文件列举信息,其中还包含一个时间同步服务的相关文件
todo-list.txt
包含一条给Kathy
的留言,确保帮Initech
备份了重要数据
vsftpd.conf
为本地FTP服务配置文件,与之前elly
挂载的/etc
目录下vsftpd.conf
内容相同
wordpress-4.tar.gz
为4.2.1版本的WordPress服务原始代码。
Unknown Enumeration (port 666)
使用nc
对其进行探测,结果显示为乱码,其中有张图片名为message2.jpg
接着将数据流重定向至本地文件 666
,并使用 file 工具查看,结果显示为 Zip 压缩包
接着使用unzip
对其进行解压,得到一张图片,打开后发现是给Scott
的留言。
HTTP Enumeration (port 80)
使用浏览器对其进行访问,提示在网站根目录没有找到主页
使用nikto
进行扫描,发现根目录存在.bashrc
和.profile
文件,说明根目录可能位于某个用户的主目录下,接着将文件下载到本地,并没有什么敏感的信息。
1
$ wget -P 80_port http://192.168.56.102/.bashrc ; wget -P 80_port http://192.168.56.102/.profile
WordPress Enumeration (port 12380)
在浏览器使用HTTP协议范文12380端口,出现一个页面,并没有发现什么异常
接着查看源代码,在最下面发现一条注释,HR给Zoe
的留言,值得注意的是,在我们之前的获取到的信息中,/etc/passwd
系统文件和SMB扫描结果中,同样存在zoe
这个用户。
我们先使用nikto
进行初步的扫描,发现存在/phpmyadmin
,/admin112233
,/blogblog
三个目录,和/robots.txt
,/icons/README
等两个文件
接着我们尝试访问所有文件和目录。
robots.txt
文件,发现Disallow的目录为/admin112233
和/blogblog
,于nikto
扫描结果一致。
icons/README
文件,发现只是Apache图标目录下的默认文档,无敏感信息
/admin112233
目录,弹框提示这可能是一个 BeEF-XSS 钩子 ;)
,很可能是一个彩蛋 :(
/blogblog
,发现是一个名为INITECH的博客(曾在todo-list.txt
中提到过)
查看其源码发现由WordPress 4.2.1
搭建的(该版本出现在之前kathy
的ftp目录下)
这里我们使用wpscan
工具进行针对性扫描,这个工具详情请看官网
我们需要创建一个账号,然后在Kali Linux 当前目录下,创建~/.wpscan/scan.yml
配置文件,写入以下内容
1
2
cli_options:
api_token: YOUR_API_TOKEN
接下来对其进行使用
1
wpscan --url https://192.168.2.212:12380/blogblog/ --enumerate u1-100 --disable-tls-checks
--enumerate
u1-100
表示将尝试枚举从用户 ID 1 到用户 ID 100 的所有用户。
--disable-tls-checks
这意味着将不会验证目标网站的 TLS/SSL 证书的有效性,不会由于证书问题而中止扫描
结果显示,共有 17 个用户名,大部分与之前收集的相同
1
wpscan --url https://192.168.2.212:12380/blogblog/ --enumerate ap --plugins-detection aggressive --disable-tls-checks
--enumerate ap
指定扫描所有插件
--plugins-detection aggressive
参数指定主动扫描模式,结果显示,共有 4 个插件:
Exportation
WordPress (Advanced Video plugin)
这里我们先使用searchsploit
成功查询到插件存在的漏洞,并将其脚本拷贝到当前目录中
我们编辑脚本,将url
地址改为我们需要的,这里需要使用python2执行,在靶机的环境中会报错,根据查询结果,我们需要在脚本中插入一行代码,用来忽略SSL的证书校验方可执行。
执行后发现并没有输出wp-config.php
文件其内容
这里我们使用dirb
对其目录进行爆破,目录包括 /wp-admin/
/wp-content/
/wp-includes/
等三个目录,与 WordPress 的默认目录结构相同
经过对所有目录的遍历,我们发现了一张图片,与我们执行脚本的时间基本吻合,我们对其进行下载
发现该图片内容是wp-config.php
文件的内容,其中包含了数据库的账号root
密码plbkac
MySQL Exportation
根据配置文件得知,WordPress服务是已root用户连接的MySQL,至此意味着已完全掌控了MySQL控制权,这是极其有利于进一步的信息收集与后渗透利用。我们使用刚刚得到的数据库账号密码对其进行登陆。
wp_users
表中存储了 WordPress 的用户相关信息
user_login
列为登录用户名
user_pass
列为登录口令散列值
截取以上16个用户的user_login和user_pass列,按<key>:<value>
格式排列
接下来我们需要使用john
配合系统自带的字典,对其进行爆破,如果没有解压字典,需要自行解压。
经过爆破我们成功拿到了12个用户的弱口令密码
Persistent Control
File Upload PHP Reverse Shell
访问/blogblog/wp-login.php
文件,出现WordPress
控制台登陆页面
我们使用刚刚爆破到的任意一个用户密码,进入到控制台页面,发现并没有管理员权限,接着尝试每个用户。
最终我们登陆了John
发现其有用管理员权限,并查看到了其他拥有管理员权限的账号
接着点击Plugins导航栏,对其进行文件上传漏洞测试,这里使用脚本 php-reverse-shell.php 更改其中用于监听设备的IP,这时候需要监听设备使用netcat
工具进行监听,然后访问其已经上传的php
文件,成功将shell
反弹
Privilege Escalation
Method 1
我们先查看系统的所有信息
我们使用searchsploit
查看有关于这个版本的内核提权漏洞 CVE-2016-4457
这里我们使用39772.txt
,查看其文件内容,得知我们需要从 Exploit-DB Mirror 下载其文件,解压后将exploit.tar
上传至服务器,将其解压后,进入到ebpf_mapfd_doubleput_exploit/
目录下,依次执行compile.sh
和doubleput
,成功拿到ROOT权限。
Method 2
由于该系统存在众多的用户,我们可以查询所有用户的 .bash_history 操作日志,查询是否存在敏感信息。
其中发现两个用户的账号密码,JKanode
和peter
我们通过SSH对其进行登陆,出现一个zsh配置页面,这里直接按q
退出,通过sudo -l
查询得知peter
的sudo
权限为(ALL:ALL) ALL,这说明peter
可以在任何主机上,以任意用户的身份执行任意命令,最后使用sudo su - root
拿到root用户权限。