Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/documentation/modules/exploit/linux/local/bpf_priv_esc.md
Views: 11788
Notes
Linux kernel 4.4 < 4.5.5 extended Berkeley Packet Filter (eBPF) does not properly reference count file descriptors, resulting in a use-after-free, which can be abused to escalate privileges.
The target system must be compiled with CONFIG_BPF_SYSCALL
and must not have kernel.unprivileged_bpf_disabled
set to 1.
Note, this module will overwrite the first few lines of /etc/crontab
with a new cron job. The job will need to be manually removed.
Vulnerable Application
This module has been tested successfully on:
Ubuntu 16.04 (x64) kernel 4.4.0-21-generic (default kernel)
This module was not tested against, but may work against:
Fedora 24 < kernel-4.5.4-300.fc24
Fedora 23 < kernel-4.5.5-201.fc23
Fedora 22 < kernel-4.4.10-200.fc22
Debian >= 4.4~rc4-1~exp1, < Fixed in version [4.5.3-1](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=82
Ubuntu 14.04.1 <= 4.4.0-22.39
Creating A Testing Environment
There are a few requirements for this module to work:
CONFIG_BPF_SYSCALL=y
must be set in the kernel (default on Ubuntu 16.04)kernel.unprivileged_bpf_disabled
can't be set to1
(default on Ubuntu 16.04)fuse needs to be installed (non-default on Ubuntu 16.04)
Using Ubuntu 16.04, simply sudo apt-get install fuse
and you're all set!
The libfuse-dev
package must be installed to test live-compiling on the target:
apt-get install libfuse-dev=2.9.4-1ubuntu3.1
Verification Steps
Start msfconsole
Exploit a box via whatever method
Do: `use exploit/linux/local/bpf_priv_esc
Do:
set session #
Do:
set verbose true
Do:
exploit
Options
MAXWAIT
The first stage of this priv esc can take ~35 seconds to execute. This is the timer on how long we should wait till we give up on the first stage finishing. Defaults to 120
(seconds)
WritableDir
A folder we can write files to. Defaults to /tmp
COMPILE
If we should live compile on the system, or drop pre-created binaries. Auto will determine if gcc/libs are installed to compile live on the system. Defaults to Auto
Scenarios
Ubuntu 16.04 (with Linux 4.4.0-21-generic)
In this scenario, gcc and libfuse-dev are both installed so we can live compile on the system.