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/lib/metasploit/framework/login_scanner/jupyter.rb
Views: 11623
require 'metasploit/framework/login_scanner/http'12module Metasploit3module Framework4module LoginScanner56# Jupyter login scanner7class Jupyter < HTTP89# Inherit LIKELY_PORTS,LIKELY_SERVICE_NAMES, and REALM_KEY from HTTP10CAN_GET_SESSION = true11DEFAULT_PORT = 888812PRIVATE_TYPES = [ :password ]1314# (see Base#set_sane_defaults)15def set_sane_defaults16self.uri = '/login' if self.uri.nil?17self.method = 'POST' if self.method.nil?1819super20end2122def attempt_login(credential)23result_opts = {24credential: credential,25host: host,26port: port,27protocol: 'tcp',28service_name: ssl ? 'https' : 'http'29}3031begin32res = send_request({'method'=> 'GET', 'uri' => uri})33vars_post = {'password' => credential.private }3435# versions < 4.3.1 do not use this field36unless (node = res.get_html_document.xpath('//form//input[@name="_xsrf"]')).empty?37vars_post['_xsrf'] = node.first['value']38end3940res = send_request({41'method' => 'POST',42'uri' => uri,43'cookie' => res.get_cookies,44'vars_post' => vars_post45})4647if res&.code == 302 && res.headers['Location']48result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: res.headers)49else50result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res)51end52rescue ::EOFError, Errno::ETIMEDOUT, Errno::ECONNRESET, Rex::ConnectionError, OpenSSL::SSL::SSLError, ::Timeout::Error => e53result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)54end55Result.new(result_opts)56end57end58end59end60end616263