目录:
1.漏洞描述
2.环境搭建
3.漏洞复现
4.漏洞分析
4.1:代码分析
4.2:流量分析
5.poc代码:
1.漏洞描述
漏洞编号:CVE-2020-10987
漏洞名称:Tenda AC9 远程代码执行漏洞
威胁等级:严重
漏洞详情:Tenda AC9 的goform/setUsbUnload端点允许远程攻击者通过deviceName POST参数执行任意系统命令。
影响范围:V15.03.05.19(6318)_CN
2.环境搭建
qemu-sys模拟debian-armhf系统:
1.移动文件:mv.sh
#!/bin/bash
# 复制 squashfs-root 目录并压缩
cp -r _*/squashfs-root /root/ && tar czf /root/squashfs-root.tar.gz -C /root squashfs-root && rm -rf /root/squashfs-root
2.使用 expect 脚本自动化 QEMU 启动和配置:run.sh
#!/bin/bash
# 启动 ssh 服务
#systemctl start ssh
# 配置网卡
tunctl -t tap0
ifconfig tap0 192.168.2.1/24
ifconfig tap0 up
# 启动 http 服务
nohup python3 -m http.server 8000 1>/dev/null &
# 进入 qemu 镜像目录
cd debain
# 使用 expect 脚本自动化 QEMU 启动和配置
/usr/bin/expect <<EOF
set timeout 10000
spawn qemu-system-arm -M vexpress-a9 -kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.img-3.2.0-4-vexpress -drive if=sd,file=debian_wheezy_armhf_standard.qcow2 -append "root=/dev/mmcblk0p2" -net nic -net tap,ifname=tap0,script=no,downscript=no -nographic
expect "debian-armhf login:"
send "root\r"
expect "Password:"
send "root\r"
expect "root@debian-armhf:~# "
send "ifconfig eth0 192.168.2.2/24\r"
expect "root@debian-armhf:~# "
send "scp root@192.168.2.1:/root/squashfs-root.tar.gz /root/squashfs-root.tar.gz\r"
expect {
"(yes/no)? " { send "yes\r"; exp_continue }
"password: " { send "root\r" }
}
expect "root@debian-armhf:~# "
send "tar xzf squashfs-root.tar.gz && rm squashfs-root.tar.gz\r"
expect "root@debian-armhf:~# "
send "mount -o bind /dev ./squashfs-root/dev && mount -t proc /proc ./squashfs-root/proc\r"
expect "root@debian-armhf:~# "
send "chroot squashfs-root/ sh\r"
expect "# "
send "brctl addbr br0 && ifconfig br0 192.168.2.2/24 up\r"
expect "# "
send "/bin/httpd\r"
expect eof
EOF
3.漏洞复现
在/home/CVE-2018-10987目录下,用qemu-sys模式模拟,把固件模拟运行起来。
1.首先在CVE-2018.10987py同级目录下,binwalk -eM 解压文件。
2.然后对binwalk解包后的固件中的任何二进制文件执行 file 命令,查看下设备的cpu 架构。
命令:file ./bin/httpd
我们可知Tenda AC15路由器的httpd是基于ARM架构的 32 位小端序可执行文件
3.创建diban目录,下载模拟qemu-system需要的阉割debian(debian-armhf)系统:
https://people.debian.org/~aurel32/qemu/armhf/debian_wheezy_armhf_standard.qcow2
https://people.debian.org/~aurel32/qemu/armhf/initrd.img-3.2.0-4-vexpress
https://people.debian.org/~aurel32/qemu/armhf/vmlinuz-3.2.0-4-vexpres
4.给httpd文件可执行权限,命令:chmod +x httpd
5.复制squashfs-root目录下的webroot_ro文件到webroot中
命令:
rm -rf webroot
ln -s webroot_ro/ webroot
6.执行模拟命令
./mv.sh
./run.sh