[HTB] Popcorn Writeup

admin 2022年7月5日19:59:45评论39 views字数 2925阅读9分45秒阅读模式

概述 (Overview)

[HTB] Popcorn Writeup

时间: 2021-09-04
机器作者: ch4p
困难程度: MEDIUM
MACHINE TAGS:
* External
* Network
* Apache
* Penetration Tester Level 3
* Unrestricted File Upload
* CVE-2010-0832
* Kernel Exploitation
* Public Vulnerabilities
* CVE Exploitation
* OSCP
* OSWE

攻击链 (Kiillchain)

通过对 Web 服务进行目录枚举成功找到隐藏站点,根据指纹信息在 exploit 中找到公开攻击方式,随后复现攻击步骤成功获取到目标服务器的交互会话。

根据系统版本信息和内核信息过低,判断存在内核提权的可能性,最终使用编译的提权脚本完成本地权限提升。

枚举(Enumeration)

老规矩,开局依然使用 Nmap 对目标信息进行开放端口信息枚举:

$ nmap -p- --Pn -sC --min-rate 2000 -oA portscan -10.10.10.6
PORT   STATE SERVICE
22/tcp open  ssh
| ssh-hostkey:
|   1024 3e:c8:1b:15:21:15:50:ec:6e:63:bc:c5:6b:80:7b:38 (DSA)
|_  2048 aa:1f:79:21:b8:42:f4:8a:38:bd:b8:05:ef:1a:07:4d (RSA)
80/tcp open  http
| http-methods:
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-title: Site doesn't have a title (text/html).

从扫描结果中可以得知攻击面很少,仅有两个服务对外暴漏。

Port 80 - HTTP

使用浏览器访问一下:

[HTB] Popcorn Writeup

从提示信息中看不出来什么,尝试使用 Web 路径扫描工具枚举下看看。

# Dirsearch started Sat Sep  4 15:02:09 2021 as: dirsearch.py -u http://10.10.10.6 -w /home/kali/tools/DictionaryTools/IntruderPayloads/Repositories/SecLists/Discovery/Web-Content/common.txt -e php,html,txt -o /home/kali/hackthebox/dirsearch.txt

403   286B   http://10.10.10.6:80/cgi-bin/
200   177B   http://10.10.10.6:80/index
200   177B   http://10.10.10.6:80/index.html
301   310B   http://10.10.10.6:80/torrent    -> REDIRECTS TO: http://10.10.10.6/torrent/
200    47KB  http://10.10.10.6:80/test

从扫描结果中得知可以访问 /torrent/ 路径,而在 /test 路径中可以看到 phpinfo 函数信息显示。

[HTB] Popcorn Writeup

这让我们知道了目标服务的信息为Apache/2.2.12+php5.2.10-2ubuntu6.10 ,方便我们后续攻击的决策面。

立足点(Foothold)

访问 /torrent/ 路径,显示为种子文件资源站:

[HTB] Popcorn Writeup

尝试通过站点指纹中寻找脆弱面,发现通过 title 信息 “Torrent Hoster“ 从 exploit-db 中找到了一个上传 shell 的信息。

Torrent Hoster - Remount Upload Path:php/webapps/11746.txt

找到对应路径页面,尝试上传 php webshell 脚本会提示失败,提示信息是并不是有效的 torrent 文件:

[HTB] Popcorn Writeup

随后从网上随便找了个 torrent 文件并上传,提示成功。

[HTB] Popcorn Writeup

OK,此时我们查看刚创建的详情页,并选择编辑种子资源就可以触发上传 php webshell 了:

[HTB] Popcorn Writeup

image

[HTB] Popcorn Writeup

image

通过 burp 抓包,将上传的文本信息改为 webshell 脚本:

[HTB] Popcorn Writeup

访问 webshell 脚本页面,成功触发连接 NC 获得一个 www-data 用户会话 shell。

[HTB] Popcorn Writeup

随后在 george 用户中找到了 user flag。

[HTB] Popcorn Writeup

权限提升(Privilege Escalation)

对 george 用户下的 torrenthoster.zip 文件进行解压,发现为站点备份文件,通过了解目录结构在,目标 Web 站点服务的 config.php 文件中找到一组数据库连接信息:

  $CFG->host = "localhost";
  $CFG->dbName = "torrenthoster";       //db name
  $CFG->dbUserName = "torrent";    //db username
  $CFG->dbPassword = "SuperSecret!!";   //db password

随后通过命令行执行 mysql 查询语句,从 users 表中找到管理员 MD5 密码,并尝试解密。

[HTB] Popcorn Writeup

         id: 3
   userName: Admin
   password: d5bfedcee289e5e05b86daad8ee3e2e2
  privilege: admin
      email: admin@yourdomain.com
     joined: 2007-01-06 21:12:46
lastconnect: 2007-01-06 21:12:46

字典跑完也没没解出来,尝试其他思路,留意到服务版本和内核版本都比较低,尝试进行内核提权。

Linux version 2.6.31-14-generic-pae (buildd@rothera) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #48-Ubuntu SMP Fri Oct 16 15:22:42 UTC 2009
Distributor ID: Ubuntu
Description:    Ubuntu 9.10

使用 linux-exploit-suggester 工具进行扫描,并将结果通过 NC 传递至 kali 进行查看:

[HTB] Popcorn Writeup

存在一个 CVE 组合的本地提权漏洞,随后将提权代码传递至目标服务器,并进行 gcc 编译,执行后成功拿到 root 权限。

[HTB] Popcorn Writeup

参考

  • • https://www.exploit-db.com/exploits/11746

  • • https://github.com/mzet-/linux-exploit-suggester

  • • https://www.exploit-db.com/exploits/15704

原文始发于微信公众号(一个人的安全笔记):[HTB] Popcorn Writeup

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年7月5日19:59:45
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   [HTB] Popcorn Writeuphttp://cn-sec.com/archives/1158912.html

发表评论

匿名网友 填写信息