Linux提权工具分享

LES:Linux 提权审计工具

快速下载:

wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh -O les.sh

有关 LES 使用和内部工作原理的详细信息:

https://mzet-.github.io/2019/05/10/les-paper.html

LES 的其他资源:

https://github.com/mzet-/les-res

目的

LES 工具旨在帮助检测给定 Linux 内核/基于 Linux 的机器的安全缺陷。它提供以下功能:

评估公开已知漏洞的内核暴露

工具评估(使用此处详细讨论的启发式方法)给定内核在每个公开的 Linux 内核漏洞利用中的暴露情况。工具输出示例:

$ ./linux-exploit-suggester.sh
...
[+] [CVE-2017-16995] eBPF_verifier

   Details: https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html
   Exposure: highly probable
   Tags: debian=9.0{kernel:4.9.0-3-amd64},fedora=25|26|27,[ ubuntu=14.04 ]{kernel:4.4.0-89-generic},ubuntu=(16.04|17.04){kernel:4.(8|10).0-(19|28|45)-generic}
   Download URL: https://www.exploit-db.com/download/45010
   Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1

[+] [CVE-2017-1000112] NETIF_F_UFO

   Details: http://www.openwall.com/lists/oss-security/2017/08/13/1
   Exposure: probable
   Tags: [ ubuntu=14.04{kernel:4.4.0-*} ],ubuntu=16.04{kernel:4.8.0-*}
   Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-1000112/poc.c
   ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/cve-2017-1000112/CVE-2017-1000112/poc.c
   Comments: CAP_NET_ADMIN cap or CONFIG_USER_NS=y needed. SMEP/KASLR bypass included. Modified version at 'ext-url' adds support for additional distros/kernels

[+] [CVE-2016-8655] chocobo_root

   Details: http://www.openwall.com/lists/oss-security/2016/12/06/1
   Exposure: probable
   Tags: [ ubuntu=(14.04|16.04){kernel:4.4.0-(21|22|24|28|31|34|36|38|42|43|45|47|51)-generic} ]
   Download URL: https://www.exploit-db.com/download/40871
   Comments: CAP_NET_RAW capability is needed OR CONFIG_USER_NS=y needs to be enabled
...

对于每个漏洞,都会计算暴露。以下“暴露”状态是可能的:

  • 极有可能– 评估的内核最有可能受到影响,并且 PoC 漏洞利用很有可能无需任何重大修改即可开箱即用。
  • 可能– 漏洞利用可能会起作用,但很可能需要对 PoC 漏洞利用进行自定义以适合您的目标。
  • 不太可能– 需要额外的手动分析来验证内核是否受到影响。
  • 不可能– 内核受到影响的可能性很小(工具的输出中不显示漏洞利用)

验证内核强化安全措施的状态

LES 可以检查您的 Linux 内核可用的大多数安全设置。它不仅验证内核编译时配置 (CONFIG),还验证运行时设置 (sysctl),从而更全面地了解运行内核的安全状况。此功能是Tobias Klein--kernelchecksec.sh工具切换的现代延续。工具输出示例:

$ ./linux-exploit-suggester.sh --checksec

Mainline kernel protection mechanisms:

 [ Disabled ] GCC stack protector support (CONFIG_HAVE_STACKPROTECTOR)
              https://github.com/mzet-/les-res/blob/master/features/stackprotector-regular.md

 [ Disabled ] GCC stack protector STRONG support (CONFIG_STACKPROTECTOR_STRONG)
              https://github.com/mzet-/les-res/blob/master/features/stackprotector-strong.md

 [ Enabled  ] Low address space to protect from user allocation (CONFIG_DEFAULT_MMAP_MIN_ADDR)
              https://github.com/mzet-/les-res/blob/master/features/mmap_min_addr.md

 [ Disabled ] Restrict unprivileged access to kernel syslog (CONFIG_SECURITY_DMESG_RESTRICT)
              https://github.com/mzet-/les-res/blob/master/features/dmesg_restrict.md

 [ Enabled  ] Randomize the address of the kernel image (KASLR) (CONFIG_RANDOMIZE_BASE)
              https://github.com/mzet-/les-res/blob/master/features/kaslr.md

 [ Disabled ] Hardened user copy support (CONFIG_HARDENED_USERCOPY)
              https://github.com/mzet-/les-res/blob/master/features/hardened_usercopy.md

...

用法

评估 Linux box 在公开漏洞上的暴露程度:

$ ./linux-exploit-suggester.sh

在 Linux 机器上显示安全功能的状态:

$ ./linux-exploit-suggester.sh --checksec

根据提供的“uname”字符串(即uname -a命令的输出)评估 Linux 内核在已知漏洞中的暴露情况:

$ ./linux-exploit-suggester.sh --uname <uname-string>

有关更多使用示例,请参见此处

请登录后发表评论