这一篇复现跟第一篇复现同样遇到了环境问题,导致最后poc无法成功验证
记录一下这次不成功的复现过程,算是加深了固定流程的印象
概述:
totolink outdoor CP900 V6.3c.566_B20171026在cgi-bin/cstecgi.cgi
中的setWebWlanIdx
函数的webWlanIdx
参数存在命令注入漏洞
漏洞:
和前几个洞不一样,这次cstecgi.cgi
没有直接包含漏洞函数,而是通过下面的动态链接库global.so
引用
$grep -rnl "setWebWlanIdx"
lib/cste_modules/global.so #vuln
usr/lib/lighttpd/web/js/forbidView.js
可以看forbidView.js
中相关函数的实现
可以看到topicurl
值为setting/setWebWlanIdx
时可以实现相关函数接口调用
global.so
中漏洞函数通过读取webWlanIdx
参数值传递给变量Var
接着通过sprintf
将变量格式化进入给定字符串,最后将格式化后的字符串传入CsteSystem
该函数底层实现为execve
,最后可导致任意命令执行
int __fastcall setWebWlanIdx(int a1, int a2, int a3)
{
const char *Var; // $v0
char v7[64]; // [sp+1Ch] [-48h] BYREF
Var = (const char *)websGetVar(a2, "webWlanIdx", "0");
sprintf(v7, "echo %s > /tmp/webWlanIdx", Var);
CsteSystem(v7, 0);
websSetCfgResponse(a1, a3, "0", "reserv");
return 0;
}
复现:
先配置网络:
sudo brctl addbr virbr2 # 创建网桥
sudo ifconfig virbr2 192.168.122.1/24 up # 配置网桥IP
sudo tunctl -t tap2 # 添加虚拟网卡tap2
sudo ifconfig tap2 192.168.122.11/24 up # 配置虚拟网卡IP
sudo brctl addif virbr2 tap2 # 配置虚拟网卡与网桥连接
binwalk -Me
提取后判断固件架构相关信息
$readelf -h busybox
ELF 头:
Magic: 7f 45 4c 46 01 02 01 00 01 00 00 00 00 00 00 00
类别: ELF32
数据: 2 补码,大端序 (big endian)
Version: 1 (current)
OS/ABI: UNIX - System V
ABI 版本: 1
类型: EXEC (可执行文件)
系统架构: MIPS R3000
版本: 0x1
入口点地址: 0x404e60
程序头起点: 52 (bytes into file)
Start of section headers: 0 (bytes into file)
标志: 0x70001005, noreorder, cpic, o32, mips32r2
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 7
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
确定为32位mips(大端序),提前下载好所需镜像和虚拟磁盘,然后开启创建虚拟机
sudo qemu-system-mips \
-M malta \
-cpu 74Kf \
-m 2G \
-object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0 \
-kernel vmlinux-3.2.0-4-4kc-malta \
-hda debian_wheezy_mips_standard.qcow2 \
-append "root=/dev/sda1 console=tty0" \
-netdev tap,id=tapnet,ifname=tap2,script=no \
-device rtl8139,netdev=tapnet \
-nographic
root/root登录后配置虚拟机ip
root@debian-mips:~# ifconfig eth0 192.168.122.15 up
host通过scp将提取的文件系统传输到虚拟机上
scp -r squashfs-root/ root@192.168.122.15:/root/
然后挂载并启动服务
root@debian-mips:~# ls
squashfs-root
root@debian-mips:~# chroot ./squashfs-root/ /bin/sh
BusyBox v1.19.4 (2017-10-25 18:14:12 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
/ # ls
bin etc mnt proc root sys usr www
dev lib overlay rom sbin tmp var
/ # /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -m /lib
/ # 2023-08-09 13:53:09: (log.c.166) server started
启动服务后第一次POC打出来回显{"error" : "data is null"}
尝试使用同固件的登陆验证绕过漏洞结果访问失败
使用admin/admin登录路由器后台也返回{"error" : "data is null"}
判定为环境出问题,使用grep -rnl "data is null"
锁定cstecgi.cgi
文件
ftext
函数中,通过web_getData
函数执行网络请求,如果网络请求成功,并且返回的数据内容为空(即"data is null"),那么会输出"data is null"
到libmosquitto.so.1
里也未明白为什么最后返回数据为空
感觉还是得真机,真机环境不会出这么多岔子...