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/msf/core/auxiliary/rservices.rb
Views: 11784
# -*- coding: binary -*-12##3#4# This Auxiliary Mixin provides functionality for dealing with BSD R*Services5#6##78module Msf9module Auxiliary::RServices1011def initialize(info = {})12super1314register_options(15[16OptString.new('FROMUSER', [ false, 'The username to login from' ]),17OptPath.new( 'FROMUSER_FILE', [ false, 'File containing from usernames, one per line',18File.join(Msf::Config.data_directory, "wordlists", "rservices_from_users.txt") ])19], Msf::Auxiliary::RServices)2021register_advanced_options(22[23OptBool.new('REMOVE_FROMUSER_FILE', [ true, "Automatically delete the FROMUSER_FILE on module completion", false])24], Msf::Auxiliary::RServices)25end262728def connect_from_privileged_port(start_port = 1023)29cport = start_port30sd = nil31while cport > 51232#vprint_status("Trying to connect from port #{cport} ...")33sd = nil34begin35sd = connect(true, { 'CPORT' => cport })3637rescue Rex::BindFailed38# Ignore and try again39#vprint_error("Unable to connect: #{$!}")4041rescue Rex::ConnectionError => e42vprint_error("Unable to connect: #{$!}")43return :refused if e.class == Rex::ConnectionRefused44return :connection_error4546end4748break if sd49cport -= 150end5152if not sd53print_error("#{target_host}:#{rport} - Unable to bind to privileged port")54return :bind_error55end5657#vprint_status("Connected from #{cport}")58return :connected59end606162def load_fromuser_vars63fromusers = extract_words(datastore['FROMUSER_FILE'])64if datastore['FROMUSER']65fromusers.unshift datastore['FROMUSER']66end67fromusers68end697071def cleanup_files72super7374path = datastore['FROMUSER_FILE']75if path and datastore['REMOVE_FROMUSER_FILE']76::File.unlink(path) rescue nil77end78end7980end81end828384