01 环境搭建
- 靶机环境下载:https://www.vulnhub.com/entry/me-and-my-girlfriend-1,409/
- 题目信息如下,难度入门级,需要获取俩个flag
Description: This VM tells us that there are a couple of lovers namely Alice and Bob, where the couple was originally very romantic, but since Alice worked at a private company, "Ceban Corp", something has changed from Alice's attitude towards Bob like something is "hidden", And Bob asks for your help to get what Alice is hiding and get full access to the company!
Difficulty Level: Beginner
Notes: there are 2 flag files
Learning: Web Application | Simple Privilege Escalation
02 信息收集
将靶机环境恢复到virtualbox
之后,开始第一步信息收集工作。
发现靶机
查看攻击机Kali的ip为192.168.56.1
(环境恢复时采用Host-Only Adapter)
使用nmap
扫描网段内的ip地址
nmap -sP 192.168.56.0/24
扫描发现的192.168.56.101
就是目标靶机的ip地址。
端口扫描
使用nmap
对目标靶机开放的端口进行扫描
nmap -Pn -n -sV 192.168.56.101
发现目标靶机仅开放了两个tcp端口,22和80。
03 查询Alice账户
访问80端口,发现无法访问正常网页功能。查看网页源码,发现注释处有提示使用x-forwarded-for
使用burpsuite
将拦截的请求都添加一条x-forwarded-for: 127.0.0.1
后,发现可以访问正常的网页功能。
有登录,注册等页面。在登录页面尝试使用SQL注入绕过校验,失败。
进入注册页面,注册一个合法用户,然后登录。登录后可以查看用户信息。
查看用户信息页面的url发现其中携带有用户id,http://192.168.56.101/index.php?page=profile&user_id=12
。尝试更改用户id,能查询其他用户的信息。通过遍历用户id,找到Alice的账户信息。
查看页面源码发现,Alice的密码明文显示。
获取flag1
使用该账户可以正常登录web,且能登录SSH。在home目录下存在flag1
04 提权
搜索带有SUID
的程序,查看是否可以被利用提权的。
find / -user root -perm -4000 -print 2>/dev/null
发现没有什么特殊的程序可以被利用来进行提权。
查看sudo
配置
sudo -l
发现alice用户可以用sudo
执行php
命令,且不需要输入密码。
在本地创建一个读取flag的php文件
<?php
$filename = "/root/flag2.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize ($filename));
echo $contents;
fclose($handle);
?>
执行sudo php a.php
就可以获取flag2