Skip to content

Commit

Permalink
Removed trailling whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
darkoperator committed Jul 15, 2012
1 parent eec9f1b commit 1fb4316
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 79 deletions.
38 changes: 19 additions & 19 deletions auto_exploit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ def cmd_vuln_exploit(*args)

when "-s"
limit_sessions = false

when "-m"
show_matched = true

when "-j"
maxjobs = val.to_i

when "-h"
print_line(opts.usage)
return

end
end

Expand All @@ -111,7 +111,7 @@ def cmd_vuln_exploit(*args)
filter << i
end
end

exploits =[]
print_status("Generating List for Matching...")
framework.exploits.each_module do |n,e|
Expand All @@ -129,7 +129,7 @@ def cmd_vuln_exploit(*args)
exploits << exploit
end
end

print_status("Matching Exploits (This will take a while depending on number of hosts)...")
framework.db.workspace.hosts.each do |h|
# Check that host has vulnerabilities associated in the DB
Expand All @@ -138,15 +138,15 @@ def cmd_vuln_exploit(*args)
#payload = chose_pay(h.os_name)
exploits.each do |e|
found = false

next if not e[:rank] >= min_rank
if e[:platforms].downcase =~ /#{os_type}/ or e[:platforms].downcase == ""
# lets get the proper references
e_refs = parse_references(e[:references])
h.vulns.each do |v|
v.refs.each do |f|
# Filter out Nessus notes
next if f.name =~ /^NSS|^CWE/
next if f.name =~ /^NSS|^CWE/
if e_refs.include?(f.name) and not found
# Skip those hosts that are filtered
next if filter.include?(h.address)
Expand All @@ -165,13 +165,13 @@ def cmd_vuln_exploit(*args)
end
end
end

end

if matched_exploits.length > 0
# Sort by rank with highest ranked exploits first
matched_exploits.sort! { |x, y| y[:rank] <=> x[:rank] }

print_good("Matched Exploits:")
matched_exploits.each do |e|
print_good("\t#{e[:target]} #{e[:exploit]} #{e[:port]} #{e[:rank]}")
Expand All @@ -182,11 +182,11 @@ def cmd_vuln_exploit(*args)

# Track LPORTs used
known_lports = []

# Make sure that existing jobs do not affect the limit
current_jobs = framework.jobs.keys.length
maxjobs = current_jobs + maxjobs

# Start launching exploits that matched sorted by best ranking first
print_status("Running Exploits:")
matched_exploits.each do |e|
Expand Down Expand Up @@ -235,7 +235,7 @@ def cmd_vuln_exploit(*args)
end
# Show client side exploits
def cmd_show_client_side(*args)

# Define options
opts = Rex::Parser::Arguments.new(
"-r" => [ true, "Minimum Rank for exploits (low, average,normal,good,great and excellent) good is the default."],
Expand Down Expand Up @@ -278,7 +278,7 @@ def cmd_show_client_side(*args)
print_error("No vulnerabilities are present in the database.")
return
end

print_status("Generating List for Matching...")
framework.exploits.each_module do |n,e|
exploit = {}
Expand Down Expand Up @@ -420,7 +420,7 @@ def create_payload(name, lhost, lport, opts = "")
end
# Validate the options for the module
if pay.options.validate(pay.datastore)
print_good("Payload option validation passed")
print_good("Payload option validation passed")
end
return pay

Expand All @@ -430,7 +430,7 @@ def get_current_sessions()
session_hosts = framework.sessions.map { |s,r| r.tunnel_peer.split(":")[0] }
return session_hosts
end

# Method to write string to file
def file_write(file2wrt, data2wrt)
if not ::File.exists?(file2wrt)
Expand All @@ -442,15 +442,15 @@ def file_write(file2wrt, data2wrt)
end
output.close
end
def jobwaiting(maxjobs)

def jobwaiting(maxjobs)
while(framework.jobs.keys.length >= maxjobs)
::IO.select(nil, nil, nil, 2.5)
print_status("waiting for finishing some modules... active jobs: #{framework.jobs.keys.length} / threads: #{framework.threads.length}")
end
end
end

def initialize(framework, opts)
super
add_console_dispatcher(AutoExploit)
Expand Down
54 changes: 27 additions & 27 deletions growl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@

require 'ruby-growl'
module Msf

class Plugin::Growl < Msf::Plugin
include Msf::SessionEvent
if not defined?(Growl_yaml)
Growl_yaml = "#{Msf::Config.get_config_root}/growl.yaml"
end

# Initialize the Plug-In
def initialize(framework, opts)
super
add_console_dispatcher(GrowlCommandDispatcher)
end

# Cleanup when the Plug-In unloads
def cleanup
self.framework.events.remove_session_subscriber(self)
Expand All @@ -43,48 +43,48 @@ def cleanup
def name
"growl"
end

# Sets the description of the Plug-In
def desc
"Automatically send Twitter Direct Message when sessions are created and closed"
end

# CommandDispacher Class for the Plug-In
class GrowlCommandDispatcher
include Msf::Ui::Console::CommandDispatcher

@host = nil
@password = nil
@source = nil
@sticky = true

# Sets what is done when a session is opened
def on_session_open(session)
print_status("Session received Sending Message to #{@host}")
send_message("Source: #{@source} Session: #{session.sid} IP: #{session.tunnel_peer} Platform:#{session.platform} Type: #{session.type}")
return
end

# Sets what is done when a session is closed
def on_session_close(session,reason = "")

print_status("Session: #{session.sid} Type: #{session.type} is shutting down")
send_message("Source: #{@source} Session: #{session.sid} Type: #{session.type} is shutting down")

return
end

# Sets the name of the Plug-In
def name
"growl"
end

# Method for sending a message
def send_message(message)
@g.notify("Session Notification","Metasploit", message,0,@sticky)
return
end

# Method for reading the YAML File
def read_settings
read = nil
Expand All @@ -94,7 +94,7 @@ def read_settings
@password = ldconfig['password']
@source = ldconfig['source']
@sticky = ldconfig['sticky']

read = true
else
print_error("You must create a YAML File with the options")
Expand All @@ -103,7 +103,7 @@ def read_settings
end
return read
end

# Method that defines the commands of the plugin
def commands
{
Expand All @@ -115,27 +115,27 @@ def commands
'growl_set_source' => "Sets the source name shown in the messages.",
'growl_set_sticky' => "Sets true or false if the message will be sticky.",
'growl_show_parms' => "Shows currently set parameters."

}
end

# Help Command
def cmd_growl_help
puts "Help"
end

# Re-Read YAML file and set Growl Configuration
def cmd_growl_start
print_status "Starting to monitor sessions to Growl on"
if read_settings()
self.framework.events.add_session_subscriber(self)
@g = Growl.new(@host,@source,["Session Notification"],nil,@password)
print_good("Growl Plugin Started, Monitoring Sessions")
else
else
print_error("Could not set Growl settings.")
end
end

# Save Parameters to text file
def cmd_growl_save
print_status("Saving paramters to config file")
Expand All @@ -151,7 +151,7 @@ def cmd_growl_save
print_error("You have not provided all the parameters!")
end
end

# Set Host to send message to
def cmd_growl_set_host(*args)
if args.length > 0
Expand All @@ -161,7 +161,7 @@ def cmd_growl_set_host(*args)
print_error("Please provide a value")
end
end

# Set Growl Password
def cmd_growl_set_password(*args)
if args.length > 0
Expand All @@ -171,7 +171,7 @@ def cmd_growl_set_password(*args)
print_error("Please provide a value")
end
end

# Set if message will be sticky or not
def cmd_growl_set_sticky(*args)
if args.length > 0
Expand All @@ -188,7 +188,7 @@ def cmd_growl_set_sticky(*args)
print_error("Please provide a value")
end
end


# Show parameters that will be used
def cmd_growl_show_parms
Expand All @@ -198,7 +198,7 @@ def cmd_growl_show_parms
print_good("sticky #{@sticky}")
print_good("source #{@source}")
end

# Set the source name that will be shown in the messages
def cmd_growl_set_source(*args)
if args.length > 0
Expand All @@ -208,9 +208,9 @@ def cmd_growl_set_source(*args)
print_error("Please provide a value")
end
end

end

end
end

4 changes: 2 additions & 2 deletions pentest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ def cmd_pivot_network_discover(*args)
smb_user = nil
smb_pass = nil
smb_dom = "WORKGROUP"

opts = Rex::Parser::Arguments.new(
"-s" => [ true, "Session to do discovery of networks and hosts."],
"-p" => [ false, "Perform port scan of hosts discovered."],
Expand Down Expand Up @@ -1353,7 +1353,7 @@ def cmd_network_discover(*args)
# Collect current set of hosts and services before the scan
current_hosts = framework.db.workspace.hosts.find_all_by_state("alive")
current_services = framework.db.workspace.services.find_all_by_state("open")

# Run the nmap scan, this will populate the database with the hosts and services that will be processed by the discovery modules
if scan_type =~ /-A/
cmd_str = "#{scan_type} -T4 -p #{ports * ","} --max-rtt-timeout=500ms --initial-rtt-timeout=200ms --min-rtt-timeout=200ms --open --stats-every 5s #{range}"
Expand Down
4 changes: 2 additions & 2 deletions post_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def cmd_multi_cmd(*args)
else
sessions = val.split(",")
end

when "-c"
command = val
when "-p"
Expand Down Expand Up @@ -142,7 +142,7 @@ def cmd_app_creds(*args)

# Parse options
sessions = ""

opts.parse(args) do |opt, idx, val|
case opt
when "-s"
Expand Down
Loading

0 comments on commit 1fb4316

Please sign in to comment.