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

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

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

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

工具目录

分类

查看所有分类
Loading categories
af_packet.c — Proof-Of-Concept to check privileges of af_packet.c for validating the privileges acquired by any hacker upon successful exploitation of CVE-2021-22600 | Kitploit
工具/GitHubGitHub/chinmay1743/af_packet.c
Privilege EscalationVulnerability AnalysisExploitationPenetration TestingBinary AnalysisLearning & Education
GitHubchinmay1743/af_packet.c

af_packet.c

Proof-Of-Concept to check privileges of af_packet.c for validating the privileges acquired by any hacker upon successful exploitation of CVE-2021-22600

查看仓库
1111个月前尚未审核

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

af_packet.c

用于检查 af_packet.c 权限的概念验证,以验证任何黑客在成功利用 CVE-2021-22600 后获得的权限。


这只是一个由 LLM 生成的示例概念验证,并未涵盖所有情况。 此概念验证的基本思想是检查目标代码以何种权限运行(例如用户空间还是内核空间),以了解利用围绕 CVE-2021-22600 构建的任何漏洞利用所带来的影响。 此代码绝非上述 CVE 的漏洞利用程序。我在虚拟机内的 Ubuntu 上进行了测试。您的结果可能因环境而异。


编译并运行代码的步骤:

root@kitploit:~
gcc program.c -o runme
chmod +x runme
./runme
sudo ./runme

以普通用户身份运行时的示例输出:

root@kitploit:~
<..SNIP..>
=== AF_PACKET privilege probe ===
UID=1000  EUID=1000

WARNING: couldn't read CapEff from /proc/self/status. Continuing anyway.
Stage 1: try AF_PACKET + SOCK_DGRAM (no CAP_NET_RAW required by kernel check)
socket(AF_PACKET, SOCK_DGRAM, ETH_P_ALL) => FAILED: Operation not permitted (errno=1)

Stage 2: try AF_PACKET + SOCK_RAW (kernel checks CAP_NET_RAW for SOCK_RAW)
socket(AF_PACKET, SOCK_RAW, ETH_P_ALL) => FAILED: Operation not permitted (errno=1)
RAW socket creation failed: you cannot reach packet_set_ring() from user-land without CAP_NET_RAW.
Common results:
 - errno=EPERM (Operation not permitted) : you lack CAP_NET_RAW
 - errno=EACCES : sometimes indicates policy or network namespace restrictions

Notes:
 - The kernel enforces CAP_NET_RAW at socket creation: look for a check like
     if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) return -EPERM;
   in net/packet/af_packet.c (this is why PACKET_RX_RING is unreachable without that socket).
 - If you run this program as root or with CAP_NET_RAW, the RAW socket will succeed and
   setsockopt(PACKET_RX_RING) will attempt to configure the ring (it may still fail with EINVAL
   if your parameters are invalid, but you will have invoked packet_set_ring()).

=== Done ===
<..SNIP..>

以 sudo / root 用户身份运行时的示例输出:

root@kitploit:~
<..SNIP..>
=== AF_PACKET privilege probe ===
UID=0  EUID=0

CapEff (hex) = 0x000001ffffffffff
 -> CAP_NET_RAW (bit 12) = YES

Stage 1: try AF_PACKET + SOCK_DGRAM (no CAP_NET_RAW required by kernel check)
socket(AF_PACKET, SOCK_DGRAM, ETH_P_ALL) => OK (fd=3)

Stage 2: try AF_PACKET + SOCK_RAW (kernel checks CAP_NET_RAW for SOCK_RAW)
socket(AF_PACKET, SOCK_RAW, ETH_P_ALL) => OK (fd=3)
Since RAW socket creation succeeded, we likely have CAP_NET_RAW (or are root).

Stage 3: try setsockopt PACKET_RX_RING (this invokes packet_set_ring in kernel)
setsockopt(PACKET_RX_RING) => OK

Notes:
 - The kernel enforces CAP_NET_RAW at socket creation: look for a check like
     if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) return -EPERM;
   in net/packet/af_packet.c (this is why PACKET_RX_RING is unreachable without that socket).
 - If you run this program as root or with CAP_NET_RAW, the RAW socket will succeed and
   setsockopt(PACKET_RX_RING) will attempt to configure the ring (it may still fail with EINVAL
   if your parameters are invalid, but you will have invoked packet_set_ring()).

=== Done ===
<..SNIP..>

下载工具