Clean up some incosistent verbosity

Modules should use `vprint_*` instead of `print... if
datastore["VERBOSE"]` or similar constructs
unstable
James Lee 2012-03-06 12:01:20 -07:00
parent 003fa3e22c
commit 2b9acb61ad
31 changed files with 41 additions and 105 deletions

View File

@ -33,21 +33,6 @@ def initialize(info = {})
@nmap_bin = nmap_binary_path
end
def vprint_status(msg='')
return if not datastore['VERBOSE']
print_status(msg)
end
def vprint_error(msg='')
return if not datastore['VERBOSE']
print_error(msg)
end
def vprint_good(msg='')
return if not datastore['VERBOSE']
print_good(msg)
end
def rports
datastore['RPORTS']
end

View File

@ -37,7 +37,7 @@ class Metasploit3 < Msf::Auxiliary
add_socket(udp_sock)
# get the external address first
print_status "#{host} - NATPMP - Probing for external address" if (datastore['VERBOSE'])
vprint_status "#{host} - NATPMP - Probing for external address"
req = Rex::Proto::NATPMP.external_address_request
udp_sock.sendto(req, host, datastore['NATPMPPORT'], 0)
external_address = nil
@ -45,7 +45,7 @@ class Metasploit3 < Msf::Auxiliary
(ver, op, result, epoch, external_address) = Rex::Proto::NATPMP.parse_external_address_response(r[0])
end
print_status "#{host} - NATPMP - Sending mapping request" if (datastore['VERBOSE'])
vprint_status "#{host} - NATPMP - Sending mapping request"
# build the mapping request
req = Rex::Proto::NATPMP.map_port_request(
datastore['LPORT'].to_i, datastore['RPORT'].to_i,

View File

@ -52,7 +52,6 @@ class Metasploit3 < Msf::Auxiliary
def run
ret = postgres_read_textfile(datastore['RFILE'])
verbose = datastore['VERBOSE']
case ret.keys[0]
when :conn_error
print_error "#{rhost}:#{rport} Postgres - Authentication failure, could not connect."
@ -60,15 +59,15 @@ class Metasploit3 < Msf::Auxiliary
case ret[:sql_error]
when /^C58P01/
print_error "#{rhost}:#{rport} Postgres - No such file or directory."
print_status "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}" if verbose
vprint_status "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}"
when /^C42501/
print_error "#{rhost}:#{rport} Postgres - Insufficent file permissions."
print_status "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}" if verbose
vprint_status "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}"
else
print_error "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}"
end
when :complete
print_good "#{rhost}:#{rport} Postgres - Command complete." if verbose
vprint_good "#{rhost}:#{rport} Postgres - Command complete."
end
postgres_logout if self.postgres_conn
end

View File

@ -32,7 +32,7 @@ class Metasploit3 < Msf::Auxiliary
'Version' => '$Revision$'
))
register_options( [ ], self.class) # None needed.
#register_options( [ ], self.class) # None needed.
end
def rhost
@ -45,14 +45,13 @@ class Metasploit3 < Msf::Auxiliary
def run
ret = postgres_query(datastore['SQL'],datastore['RETURN_ROWSET'])
verbose = datastore['VERBOSE']
case ret.keys[0]
when :conn_error
print_error "#{rhost}:#{rport} Postgres - Authentication failure, could not connect."
when :sql_error
print_error "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}"
when :complete
print_good "#{rhost}:#{rport} Postgres - Command complete." if verbose
vprint_good "#{rhost}:#{rport} Postgres - Command complete."
end
postgres_logout if self.postgres_conn
end

View File

@ -56,58 +56,38 @@ class Metasploit3 < Msf::Auxiliary
def run_host(ip)
if (datastore['VERBOSE'])
print_status("Connecting to the server...")
end
vprint_status("Connecting to the server...")
begin
connect()
smb_login()
if (datastore['VERBOSE'])
print_status("Mounting the remote share \\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}'...")
end
vprint_status("Mounting the remote share \\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}'...")
self.simple.connect("\\\\#{rhost}\\#{datastore['SMBSHARE']}")
if (datastore['VERBOSE'])
print_status("Checking for file/folder #{datastore['RPATH']}...")
end
vprint_status("Checking for file/folder #{datastore['RPATH']}...")
if (fd = simple.open("\\#{datastore['RPATH']}", 'o')) # mode is open only - do not create/append/write etc
print_good("File FOUND: \\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['RPATH']}")
fd.close
end
rescue ::Rex::HostUnreachable
if (datastore['VERBOSE'])
print_error("Host #{rhost} offline.")
end
vprint_error("Host #{rhost} offline.")
rescue ::Rex::Proto::SMB::Exceptions::LoginError
if (datastore['VERBOSE'])
print_error("Host #{rhost} login error.")
end
vprint_error("Host #{rhost} login error.")
rescue ::Rex::Proto::SMB::Exceptions::ErrorCode => e
if e.get_error(e.error_code) == "STATUS_FILE_IS_A_DIRECTORY"
print_good("Directory FOUND: \\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['RPATH']}")
elsif e.get_error(e.error_code) == "STATUS_OBJECT_NAME_NOT_FOUND"
if (datastore['VERBOSE'])
print_error("Object \\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['RPATH']} NOT found!")
end
vprint_error("Object \\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['RPATH']} NOT found!")
elsif e.get_error(e.error_code) == "STATUS_OBJECT_PATH_NOT_FOUND"
if (datastore['VERBOSE'])
print_error("Object PATH \\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['RPATH']} NOT found!")
end
vprint_error("Object PATH \\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['RPATH']} NOT found!")
elsif e.get_error(e.error_code) == "STATUS_ACCESS_DENIED"
if (datastore['VERBOSE'])
print_error("Host #{rhost} reports access denied.")
end
vprint_error("Host #{rhost} reports access denied.")
elsif e.get_error(e.error_code) == "STATUS_BAD_NETWORK_NAME"
if (datastore['VERBOSE'])
print_error("Host #{rhost} is NOT connected to #{datastore['SMBDomain']}!")
end
vprint_error("Host #{rhost} is NOT connected to #{datastore['SMBDomain']}!")
elsif e.get_error(e.error_code) == "STATUS_INSUFF_SERVER_RESOURCES"
if (datastore['VERBOSE'])
print_error("Host #{rhost} rejected with insufficient resources!")
end
vprint_error("Host #{rhost} rejected with insufficient resources!")
else
raise e
end

View File

@ -30,7 +30,7 @@ class Metasploit3 < Msf::Auxiliary
'Context' => {'Msf' => framework, 'MsfExploit' => self}
})
add_socket(udp_sock)
print_status "#{host}:#{datastore['RPORT']} - NATPMP - Probing for external address" if (datastore['VERBOSE'])
vprint_status "#{host}:#{datastore['RPORT']} - NATPMP - Probing for external address"
udp_sock.sendto(Rex::Proto::NATPMP.external_address_request, host, datastore['RPORT'].to_i, 0)
while (r = udp_sock.recvfrom(12, 1.0) and r[1])

View File

@ -53,7 +53,6 @@ class Metasploit3 < Msf::Auxiliary
end
def do_login(user=nil,pass=nil,db=nil)
verbose = datastore['VERBOSE']
datastore['USERNAME'] = user
datastore['PASSWORD'] = pass
vprint_status("#{rhost}:#{rport} - DB2 - Trying username:'#{user}' with password:'#{pass}'")

View File

@ -41,7 +41,6 @@ class Metasploit3 < Msf::Auxiliary
end
def run_host(ip)
verbose = datastore['VERBOSE']
begin
info = db2_probe(to)

View File

@ -138,7 +138,6 @@ class Metasploit3 < Msf::Auxiliary
end
def do_login(user='admin', pass='admin')
verbose = datastore['VERBOSE']
vprint_status("#{target_url} - Trying username:'#{user}' with password:'#{pass}'")
success = false
proof = ""

View File

@ -62,7 +62,6 @@ class Metasploit3 < Msf::Auxiliary
end
def enum_user(user='administrator', pass='pass')
verbose = datastore['VERBOSE']
vprint_status("#{rhost}:#{rport} - Trying username:'#{user}' password:'#{pass}'")
success = false
soapenv='http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -58,7 +58,6 @@ class Metasploit3 < Msf::Auxiliary
end
def enum_user(user, pass)
verbose = datastore['VERBOSE']
vprint_status("#{rhost}:#{rport} - Trying username:'#{user}' password: '#{pass}'")
success = false
data = 'isFromLogonPage=true&cms=127.0.1%3A6400'

View File

@ -64,7 +64,6 @@ class Metasploit3 < Msf::Auxiliary
end
def enum_user(user='administrator', pass='invalid-sap-password-0d03b389-b7a1-4ecc-8898-e62d1836b72a')
verbose = datastore['VERBOSE']
vprint_status("#{rhost}:#{rport} - Enumerating username:'#{user}'")
success = false
soapenv='http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -61,7 +61,6 @@ class Metasploit3 < Msf::Auxiliary
end
def enum_version(rhost)
verbose = datastore['VERBOSE']
print_status("Identifying SAP BusinessObjects on #{rhost}:#{rport}")
success = false
soapenv='http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -151,9 +151,7 @@ class Metasploit3 < Msf::Auxiliary
data_parts << nil
data = data_parts.join("\r\n")
if (datastore['VERBOSE'])
print_status("Sending request #{datastore['PATH']}/#{v}#{n} to #{wmap_target_host}:#{datastore['RPORT']}")
end
vprint_status("Sending request #{datastore['PATH']}/#{v}#{n} to #{wmap_target_host}:#{datastore['RPORT']}")
res = send_request_raw({
'uri' => datastore['PATH'] + '/' + v + n,

View File

@ -97,7 +97,7 @@ class Metasploit3 < Msf::Auxiliary
if (datastore['VERBOSE'])
if (res and res.code = 403 and res.body and res.body =~ /You do not have permission to access <i>(\w+)<\/i>/)
print_status("#{target_url}?a=#{asset} - Trying Asset: '#{asset}' title '#{$1}'")
else
else
print_status("#{target_url}?a=#{asset} - Trying Asset: '#{asset}'")
end
end

View File

@ -102,7 +102,6 @@ class Metasploit3 < Msf::Auxiliary
end
def do_login(user='tomcat', pass='tomcat')
verbose = datastore['VERBOSE']
vprint_status("#{rhost}:#{rport} - Trying username:'#{user}' with password:'#{pass}'")
success = false
srvhdr = '?'

View File

@ -32,7 +32,7 @@ class Metasploit3 < Msf::Auxiliary
'Context' => {'Msf' => framework, 'MsfExploit' => self} }
)
add_socket(udp_sock)
print_status "Scanning #{datastore['PROTOCOL']} ports #{datastore['PORTS']} on #{host} using NATPMP" if (datastore['VERBOSE'])
vprint_status "Scanning #{datastore['PROTOCOL']} ports #{datastore['PORTS']} on #{host} using NATPMP"
# first, send a request to get the external address
udp_sock.sendto(Rex::Proto::NATPMP.external_address_request, host, datastore['RPORT'].to_i, 0)

View File

@ -44,7 +44,7 @@ class Metasploit3 < Msf::Auxiliary
def run_host(ip)
user = datastore['USERNAME']
pass = postgres_password
do_fingerprint(user,pass,datastore['DATABASE'],datastore['VERBOSE'])
do_fingerprint(user,pass,datastore['DATABASE'])
end
# Alias for RHOST
@ -57,18 +57,18 @@ class Metasploit3 < Msf::Auxiliary
datastore['RPORT']
end
def do_fingerprint(user=nil,pass=nil,database=nil,verbose=false)
def do_fingerprint(user=nil,pass=nil,database=nil)
begin
msg = "#{rhost}:#{rport} Postgres -"
password = pass || postgres_password
print_status("#{msg} Trying username:'#{user}' with password:'#{password}' against #{rhost}:#{rport} on database '#{database}'") if verbose
vprint_status("#{msg} Trying username:'#{user}' with password:'#{password}' against #{rhost}:#{rport} on database '#{database}'")
result = postgres_fingerprint(
:db => database,
:username => user,
:password => password
)
if result[:auth]
print_good "#{rhost}:#{rport} Postgres - Logged in to '#{database}' with '#{user}':'#{password}'" if verbose
vprint_good "#{rhost}:#{rport} Postgres - Logged in to '#{database}' with '#{user}':'#{password}'"
print_status "#{rhost}:#{rport} Postgres - Version #{result[:auth]} (Post-Auth)"
elsif result[:preauth]
print_status "#{rhost}:#{rport} Postgres - Version #{result[:preauth]} (Pre-Auth)"

View File

@ -60,7 +60,6 @@ class Metasploit4 < Msf::Auxiliary
end
def extractabap(rhost)
verbose = datastore['VERBOSE']
print_status("#{rhost}:#{rport} [SAP] Connecting to SAP Management Console SOAP Interface")
success = false

View File

@ -89,7 +89,6 @@ class Metasploit4 < Msf::Auxiliary
pass = pass.gsub("<SAPSID>", datastore["SAP_SID"])
end
verbose = datastore['VERBOSE']
print_status("#{rhost}:#{rport} - Trying username:'#{user}' password:'#{pass}'")
success = false

View File

@ -67,7 +67,6 @@ class Metasploit4 < Msf::Auxiliary
end
def extractusers(rhost)
verbose = datastore['VERBOSE']
print_status("#{rhost}:#{rport} [SAP] Connecting to SAP Management Console SOAP Interface")
success = false

View File

@ -66,7 +66,6 @@ class Metasploit4 < Msf::Auxiliary
end
def getacesspoints(rhost)
verbose = datastore['VERBOSE']
print_status("[SAP] Connecting to SAP Management Console SOAP Interface on #{rhost}:#{rport}")
success = false
soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -66,7 +66,6 @@ class Metasploit4 < Msf::Auxiliary
end
def getEnvironment(rhost)
verbose = datastore['VERBOSE']
print_status("#{rhost}:#{rport} [SAP] Connecting to SAP Management Console SOAP Interface ")
success = false

View File

@ -70,7 +70,6 @@ class Metasploit4 < Msf::Auxiliary
end
def gettfiles(rhost)
verbose = datastore['VERBOSE']
print_status("#{rhost}:#{rport} [SAP] Connecting to SAP Management Console SOAP Interface")
success = false

View File

@ -67,7 +67,6 @@ class Metasploit4 < Msf::Auxiliary
end
def getprocparam(rhost)
verbose = datastore['VERBOSE']
print_status("[SAP] Connecting to SAP Management Console SOAP Interface on #{rhost}:#{rport}")
success = false
soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -66,7 +66,6 @@ class Metasploit4 < Msf::Auxiliary
end
def enum_instance(rhost)
verbose = datastore['VERBOSE']
print_status("#{rhost}:#{rport} [SAP] Connecting to SAP Management Console SOAP Interface")
success = false
soapenv='http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -68,7 +68,6 @@ class Metasploit4 < Msf::Auxiliary
end
def listfiles(rhost)
verbose = datastore['VERBOSE']
print_status("[SAP] Connecting to SAP Management Console SOAP Interface on #{rhost}:#{rport}")
success = false
soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -65,7 +65,6 @@ class Metasploit4 < Msf::Auxiliary
end
def getStartProfile(rhost)
verbose = datastore['VERBOSE']
print_status("#{rhost}:#{rport} [SAP] Connecting to SAP Management Console SOAP Interface")
success = false
soapenv ='http://schemas.xmlsoap.org/soap/envelope/'

View File

@ -65,7 +65,6 @@ class Metasploit4 < Msf::Auxiliary
end
def enum_version(rhost)
verbose = datastore['VERBOSE']
print_status("[SAP] Connecting to SAP Management Console SOAP Interface on #{rhost}:#{rport}")
success = false
soapenv='http://schemas.xmlsoap.org/soap/envelope/'
@ -75,7 +74,7 @@ class Metasploit4 < Msf::Auxiliary
ns1='ns1:GetVersionInfo'
data = '<?xml version="1.0" encoding="utf-8"?>' + "\r\n"
data << '<SOAP-ENV:Envelope xmlns:SOAP-ENV="' + soapenv + '" xmlns:xsi="' + xsi + '" xmlns:xs="' + xs + '">' + "\r\n"
data << '<SOAP-ENV:Envelope xmlns:SOAP-ENV="' + soapenv + '" xmlns:xsi="' + xsi + '" xmlns:xs="' + xs + '">' + "\r\n"
data << '<SOAP-ENV:Header>' + "\r\n"
data << '<sapsess:Session xlmns:sapsess="' + sapsess + '">' + "\r\n"
data << '<enableSession>true</enableSession>' + "\r\n"

View File

@ -151,10 +151,8 @@ class Metasploit3 < Msf::Exploit::Remote
print_status("Sending Write packets...")
w_packets.each do |packet|
if datastore['VERBOSE']
print_status("Sending packet #{counter.to_s}/#{w_packets_count}")
counter += 1
end
vprint_status("Sending packet #{counter}/#{w_packets_count}")
counter += 1
sock.put(packet)
res = sock.get_once() #Wait before we do the next sock.put again
end

View File

@ -175,16 +175,14 @@ class Metasploit3 < Msf::Post
perm['dircreate'], perm['dirdelete'], perm['dirlist'], perm['dirsubdirs'], perm['autocreate']]
end
if datastore['VERBOSE']
print_status(" Collected the following configuration details:")
print_status(" FTP Port: %s" % config['ftp_port'])
print_status(" FTP Bind IP: %s" % config['ftp_bindip'])
print_status(" SSL: %s" % config['ssl'])
print_status(" Admin Port: %s" % config['admin_port'])
print_status(" Admin Bind IP: %s" % config['admin_bindip'])
print_status(" Admin Pass: %s" % config['admin_pass'])
print_line("")
end
vprint_status(" Collected the following configuration details:")
vprint_status(" FTP Port: %s" % config['ftp_port'])
vprint_status(" FTP Bind IP: %s" % config['ftp_bindip'])
vprint_status(" SSL: %s" % config['ssl'])
vprint_status(" Admin Port: %s" % config['admin_port'])
vprint_status(" Admin Bind IP: %s" % config['admin_bindip'])
vprint_status(" Admin Pass: %s" % config['admin_pass'])
vprint_line("")
configuration << [config['ftp_port'], config['ftp_bindip'], config['admin_port'], config['admin_bindip'], config['admin_pass'],
config['ssl'], config['ssl_certfile'], config['ssl_keypass']]
@ -337,13 +335,11 @@ class Metasploit3 < Msf::Post
account['ssl'] = settings['ssl']
creds << account
if datastore['VERBOSE']
print_status(" Collected the following credentials:")
print_status(" Username: %s" % account['user'])
print_status(" Password: %s" % account['password'])
print_status(" Group: %s" % account['group'])
print_line("")
end
vprint_status(" Collected the following credentials:")
vprint_status(" Username: %s" % account['user'])
vprint_status(" Password: %s" % account['password'])
vprint_status(" Group: %s" % account['group'])
vprint_line("")
end
groups = groups.uniq unless groups.uniq.nil?