IOT入门CVE复现
写在前面
- 复现这些很老的cve就不用追求细节了,把整体过程过一遍就行了
华为HG532系列路由器命令注入漏洞复现CVE-2017-17215
除了binwalk还要记得下载 sasquatch安装:https://github.com/devttys0/sasquatch
因为这个cve很旧,我用的u20虚拟机firefox支持的协议版本还比较高,所以不支持访问,询问GPT得到结果
你遇到的错误是因为浏览器和服务器之间使用的加密协议不兼容。根据错误信息,服务器可能不支持现代的安全协议,如 TLS 1.2 或更高版本,而 Firefox 强制使用 TLS 1.2 及以上的协议。
尝试降低浏览器的 TLS 版本要求(不推荐长期使用,只作临时排查):
在 Firefox 的地址栏中输入 about:config,并按回车键。
你会看到警告页面,点击“我接受风险!”。
搜索 security.tls.version.min。
将该值设置为 1,这意味着最低支持的协议将是 TLS 1.0。
尝试重新访问该页面。
注意:降低 TLS 版本可能带来安全风险,因为旧版本的协议已被发现存在漏洞,因此建议仅作为临时解决方案。
ROPing Routers from scratch: Step-by-step Tenda Ac8v4 Mips 0day Flow-control ROP -> RCE
第一个问题,卡在这个循环,直接patch掉即可
Well, if you search for string ‘welcome’ in IDA, you cross-reference the string which will takes you to main()! and the cause of this is located at ifaddrs_get_ifip() (You should see something similar to this):
puts("\n\nYes:\n\n ****** WeLoveLinux****** \n\n ****** Welcome to ******");
setup_signals();
while ( 1 )
{
lan_ifname = ifaddrs_get_lan_ifname();
if ( ifaddrs_get_ifip(lan_ifname, v10) >= 0 )
break;
sleep(1u);
}
第二个问题,执行httpd后监听端口不太对
the script should continue, but other issues will start to manifest; when assigning the listening address for httpd, httpd might say ‘unable to assign address’ or listened on 255.255.255.255! How did this happen? If you search for ‘httpd listen ip’ as a string; it will take you to socketOpenConnection() and back to main()
v4 = ifaddrs_get_lan_ifname();
if ( ifaddrs_get_ifip(v4, v11) < 0 )
{
GetValue("lan.ip", v8);
strcpy(g_lan_ip, v8);
memset(v12, 0, 0x5E4u);
if ( !file_lan_dhcpc_get_ipinfo_and_status(v12) && v12[0x8C] )
strcpy(g_lan_ip, &v12[0x8C]);
}
which the lan.ip comes from global variable g_lan_ip, which generally obtain the ip at interface br0; in our case, we don’t have br0 bridge interface in the QEMU (we have it in Ubuntu VMware indeed), thus we will have to create one using similar to the pre-qemu setup, using brctl and ifconfig; we can try to assign the address manually ourselves instead of using dhclient:
可以这样解决
brctl show
brctl delbr br0
brctl addbr br0
ifconfig br0 192.168.50.100 up
第三个问题,网页无法打开,应该是httpd会自动找webroot这个文件,所以需要这样复制
这一步也很重要,原本./webroot/是个符号连接文件,可以先把它删了,再重新执行
rm webroot
mkdir webroot
cp -rf ./webroot_ro/* ./webroot/
sudo qemu-mipsel-static -L . ./bin/httpd_fixed
利用gdbserver调试,在作者的指导下,用了如下方式,发现应该在chroot squashfs-root sh之前就该把gdbserver拷贝进去最好
- 首先在网上下载 gdbserver-7.7.1-mipsel-mips32-v1
- scp gdbserver root@192.168.50.53 :~/squashfs-root/ 把对应的gdbserver传到qemu虚拟机中
- 在qemu虚拟机中,chmod +x gdbserver
- 在qemu虚拟机中./gdbserver 0.0.0.0:7777 ./bin/httpd
- 在linux虚拟机中,gdb-multiarch -q ./bin/httpd ; target remote 192.168.50.100:7777 连接上后注意要用c
- 之后就可以用exp进行攻击了,然后可以gdb查看
在这里做以下解释 在你的环境中,httpd 服务和 gdbserver 服务使用了相同的 IP 地址,但端口不同。让我们分别解释 httpd 和 gdbserver 运行时的情况:
httpd 服务: httpd 是一个 Web 服务器,它的主要功能是监听 HTTP 请求。在你的例子中,它监听的是 IP 192.168.50.100,端口是 80。 端口 80 是 HTTP 的默认端口,所以客户端(例如浏览器)可以通过访问 http://192.168.50.100 与这个服务进行交互。
gdbserver 调试器: gdbserver 是一个用于远程调试的工具,它允许你从另一台机器上用 GDB 连接并调试目标程序。 在你的命令中,gdbserver 被配置为监听 0.0.0.0:7777,这意味着它会监听所有网络接口上的 7777 端口(包括 192.168.50.100 这个 IP)。 端口 7777 用于 gdbserver 和远程 GDB 客户端之间的通信,通常是调试器专用的端口。
解释为何 IP 相同但端口不同: IP 地址相同:这是因为 httpd 和 gdbserver 都运行在同一台设备上(该设备的 IP 地址为 192.168.50.100)。 端口不同:网络服务通过端口号区分不同的应用程序和服务。例如,httpd 监听端口 80 来处理 HTTP 请求,而 gdbserver 监听端口 7777 来处理远程调试请求。虽然两者使用相同的 IP 地址,但它们通过不同的端口来互不干扰地提供服务。
简单类比: 可以把 IP 地址看作是设备的“地址”,而端口号相当于“门牌号”。同一栋建筑(同一台设备)可能有多个不同的门(不同的端口),通往不同的服务。
mipsrop
- 这里主要是通过已经有的溢出找gadget,有以下技巧,没用成功注意有没有中文的(
misrop.system() 可以找到控制$a0,$ra寄存器的gadget,这样的话就可以直接任意命令执行
mipsrop.find('move $t9') 这种可以看是否能通过一个寄存器进而控制目的寄存器
mipsrop.find('.* $s4')
反弹shell
todo