Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/misc/ib_service_mgr_info.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp78# Scanner mixin should be near last9include Msf::Auxiliary::Scanner10include Msf::Auxiliary::Report1112def initialize13super(14'Name' => 'Borland InterBase Services Manager Information',15'Description' => %q{16This module retrieves version of the services manager, version17and implementation of the InterBase server from InterBase18Services Manager.19},20'Author' =>21[22'Ramon de C Valle',23'Adriano Lima <adriano[at]risesecurity.org>',24],25'License' => MSF_LICENSE26)2728register_options(29[30Opt::RPORT(3050)31],32self.class33)3435end3637# Create service parameter block38def spb_create39isc_dpb_user_name = 2840isc_dpb_password = 294142isc_spb_user_name = isc_dpb_user_name43isc_spb_password = isc_dpb_password4445isc_spb_current_version = 246isc_spb_version = isc_spb_current_version4748user = 'SYSDBA'49pass = 'masterkey'5051spb = ''5253spb << [isc_spb_version].pack('c')54spb << [isc_spb_current_version].pack('c')5556spb << [isc_spb_user_name].pack('c')57spb << [user.length].pack('c')58spb << user5960spb << [isc_spb_password].pack('c')61spb << [pass.length].pack('c')62spb << pass6364spb65end6667# Create receive buffer68def recv_spb_create69# Retrieves the version of the services manager70isc_info_svc_version = 547172# Retrieves the version of the InterBase server73isc_info_svc_server_version = 557475# Retrieves the implementation of the InterBase server76isc_info_svc_implementation = 567778recv_spb = ''7980recv_spb << [isc_info_svc_version].pack('c')81recv_spb << [isc_info_svc_server_version].pack('c')82recv_spb << [isc_info_svc_implementation].pack('c')8384recv_spb85end8687# Calculate buffer padding88def buf_padding(length = '')89remainder = length.remainder(4)90padding = 09192if remainder > 093padding = (4 - remainder)94end9596padding97end9899def run_host(ip)100101#102# Using the InterBase Services Manager103# http://dn.codegear.com/article/27002104#105106begin107108print_status("Trying #{ip}")109110connect111112# isc_service_attach113114# Service name115svc_name = 'service_mgr'116117# Service attach118op_service_attach = 82119120buf = ''121122# Operation/packet type123buf << [op_service_attach].pack('N')124125# Id126buf << [0].pack('N')127128# Length129buf << [svc_name.length].pack('N')130131# Service name132buf << svc_name133134# Padding135buf << "\x00" * buf_padding(svc_name.length)136137# Create service parameter block138spb = spb_create139140# Service parameter block length141buf << [spb.length].pack('N')142143# Service parameter block144buf << spb145146# Padding147buf << "\x00" * buf_padding(spb.length)148149sock.put(buf)150151response = sock.get_once || ''152153# print(Rex::Text.to_hex_dump(response))154155156# isc_service_query157158# Response buffer length159response_buffer_length = 64160161# Service info162op_service_info = 84163164buf = ''165166# Operation/packet type167buf << [op_service_info].pack('N')168169# Id170buf << [0].pack('N')171172# ?173buf << [0].pack('N')174175# ?176buf << [0].pack('N')177178# Create receive buffer179recv_spb = recv_spb_create180181# Receive buffer length182buf << [recv_spb.length].pack('N')183184# Receive buffer185buf << recv_spb186187# Padding188buf << "\x00" * buf_padding(recv_spb.length)189190# Response buffer length191buf << [response_buffer_length].pack('N')192193sock.put(buf)194195response = sock.get_once || ''196197res = response.unpack('x28Z*Z*')198199info_svc_server_version = res[0].chop.chop200info_svc_implementation = res[1].chop201202print("IP Address: #{ip}\n")203# print("Version of the services manager: #{info_svc_version}\n")204print("Version of the InterBase server: #{info_svc_server_version}\n")205print("Implementation of the InterBase server: #{info_svc_implementation}\n\n")206207#print(Rex::Text.to_hex_dump(response))208209# Add Report210report_note(211:host => ip,212:sname => 'ib',213:proto => 'tcp',214:port => rport,215:type => 'Version of the InterBase server',216:data => "Version of the InterBase server: #{info_svc_server_version}"217)218219# Add Report220report_note(221:host => ip,222:sname => 'ib',223:proto => 'tcp',224:port => rport,225:type => 'Implementation of the InterBase server',226:data => "Implementation of the InterBase server: #{info_svc_implementation}"227)228229rescue ::Rex::ConnectionError230rescue ::Errno::EPIPE231232end233234end235end236237238