From e7a545c483822b8986fa51e36d24a083bae38a41 Mon Sep 17 00:00:00 2001 From: James Lee Date: Sun, 20 Nov 2011 12:10:08 +1100 Subject: [PATCH] spaces at EOL in core stuff --- lib/msf/core/data_store.rb | 2 +- lib/msf/core/db.rb | 10 ++-- lib/msf/core/db_export.rb | 76 +++++++++++++------------- lib/msf/core/db_manager.rb | 4 +- lib/msf/core/event_dispatcher.rb | 10 ++-- lib/msf/core/exceptions.rb | 4 +- lib/msf/core/module_manager.rb | 2 +- lib/msf/core/nop.rb | 4 +- lib/msf/core/option_container.rb | 2 +- lib/msf/core/option_container.rb.ut.rb | 16 +++--- lib/msf/core/payload.rb | 2 +- lib/msf/core/plugin.rb | 4 +- lib/msf/core/post.rb | 6 +- lib/msf/core/session_manager.rb | 52 +++++++++--------- lib/msf/core/thread_manager.rb | 30 +++++----- 15 files changed, 112 insertions(+), 112 deletions(-) diff --git a/lib/msf/core/data_store.rb b/lib/msf/core/data_store.rb index 17027abc3c..489b468e24 100644 --- a/lib/msf/core/data_store.rb +++ b/lib/msf/core/data_store.rb @@ -223,7 +223,7 @@ class DataStore < Hash end list.each(&block) end - + protected # diff --git a/lib/msf/core/db.rb b/lib/msf/core/db.rb index f92604a2ca..31538e7697 100644 --- a/lib/msf/core/db.rb +++ b/lib/msf/core/db.rb @@ -2264,7 +2264,7 @@ class DBManager next if port.to_i == 0 uri = URI.parse(host.attributes['sitename']) rescue nil next unless uri and uri.scheme - # Collect and report scan descriptions. + # Collect and report scan descriptions. host.elements.each do |item| if item.elements['description'] desc_text = item.elements['description'].text @@ -2286,16 +2286,16 @@ class DBManager if item.attributes['osvdbid'].to_i != 0 desc_data[:refs] = ["OSVDB-#{item.attributes['osvdbid']}"] desc_data[:name] = "NIKTO-#{item.attributes['id']}" - desc_data.delete(:data) + desc_data.delete(:data) desc_data.delete(:type) desc_data.delete(:update) report_vuln(desc_data) end end - end + end end end - end + end def import_libpcap_file(args={}) filename = args[:filename] @@ -4231,7 +4231,7 @@ class DBManager when "http-proxy"; "http" when "iiimsf"; "db2" when "oracle-tns"; "oracle" - when "quickbooksrds"; "metasploit" + when "quickbooksrds"; "metasploit" when /^dns-(udp|tcp)$/; "dns" when /^dce[\s+]rpc$/; "dcerpc" else diff --git a/lib/msf/core/db_export.rb b/lib/msf/core/db_export.rb index cb2aa3c519..8a6f8cbe1d 100644 --- a/lib/msf/core/db_export.rb +++ b/lib/msf/core/db_export.rb @@ -16,8 +16,8 @@ class Export def myworkspace self.workspace - end - + end + def myusername @username ||= (ENV['LOGNAME'] || ENV['USERNAME'] || ENV['USER'] || "unknown").to_s.strip.gsub(/[^A-Za-z0-9\x20]/,"_") end @@ -72,7 +72,7 @@ class Export report_file.flush report_file.close - yield(:status, "complete", "password dump") if block_given? + yield(:status, "complete", "password dump") if block_given? true end @@ -93,19 +93,19 @@ class Export report_file.write "# #{svc}\n" case ptype when "smb_hash" - data.each do |c| + data.each do |c| user = (c.user.nil? || c.user.empty?) ? "" : c.user pass = (c.pass.nil? || c.pass.empty?) ? "" : c.pass report_file.write "%s:%d:%s:::\n" % [user,c.id,pass] end when "smb_netv1_hash" - data.each do |c| + data.each do |c| user = (c.user.nil? || c.user.empty?) ? "" : c.user pass = (c.pass.nil? || c.pass.empty?) ? "" : c.pass report_file.write "%s::%s\n" % [user,pass] end when "smb_netv2_hash" - data.each do |c| + data.each do |c| user = (c.user.nil? || c.user.empty?) ? "" : c.user pass = (c.pass.nil? || c.pass.empty?) ? "" : c.pass if pass != "" @@ -143,8 +143,8 @@ class Export report_file.puts "Warning: could not read the private key '#{c.pass}'." end end - else "text" - data.each do |c| + else "text" + data.each do |c| user = (c.user.nil? || c.user.empty?) ? "" : Rex::Text.ascii_safe_hex(c.user, true) pass = (c.pass.nil? || c.pass.empty?) ? "" : Rex::Text.ascii_safe_hex(c.pass, true) report_file.write "%s %s\n" % [user,pass] @@ -191,7 +191,7 @@ class Export return creds end - + def to_xml_file(path, &block) yield(:status, "start", "report") if block_given? @@ -237,25 +237,25 @@ class Export report_file.flush extract_web_page_info(report_file) report_file.write %Q|\n| - + yield(:status, "start", "web forms") if block_given? report_file.write %Q|\n| report_file.flush extract_web_form_info(report_file) - report_file.write %Q|\n| + report_file.write %Q|\n| yield(:status, "start", "web vulns") if block_given? report_file.write %Q|\n| report_file.flush extract_web_vuln_info(report_file) report_file.write %Q|\n| - + report_file.write %Q|\n| report_file.flush report_file.close - - yield(:status, "complete", "report") if block_given? - + + yield(:status, "complete", "report") if block_given? + true end @@ -310,7 +310,7 @@ class Export # Extract all web entries, storing them in instance variables def extract_web_entries @web_sites = myworkspace.web_sites - @web_pages = myworkspace.web_pages + @web_pages = myworkspace.web_pages @web_forms = myworkspace.web_forms @web_vulns = myworkspace.web_vulns end @@ -411,7 +411,7 @@ class Export report_file.write(" \n") end - report_file.flush + report_file.flush end # Extract event data from @events @@ -441,7 +441,7 @@ class Export end report_file.flush end - + # Extract credential data from @creds def extract_credential_info(report_file) @creds.each do |c| @@ -478,63 +478,63 @@ class Export el = create_xml_element(k,v) report_file.write(" #{el}\n") end - + site = e el = create_xml_element("host", site.service.host.address) report_file.write(" #{el}\n") - - el = create_xml_element("port", site.service.port) + + el = create_xml_element("port", site.service.port) + report_file.write(" #{el}\n") + + el = create_xml_element("ssl", site.service.name == "https") report_file.write(" #{el}\n") - el = create_xml_element("ssl", site.service.name == "https") - report_file.write(" #{el}\n") - report_file.write(" \n") end report_file.flush end - - # Extract web pages, forms, and vulns + + # Extract web pages, forms, and vulns def extract_web_info(report_file, tag, entries) entries.each do |e| report_file.write(" <#{tag}>\n") e.attributes.each_pair do |k,v| el = create_xml_element(k,v) report_file.write(" #{el}\n") - end - + end + site = e.web_site el = create_xml_element("vhost", site.vhost) report_file.write(" #{el}\n") - + el = create_xml_element("host", site.service.host.address) report_file.write(" #{el}\n") - - el = create_xml_element("port", site.service.port) + + el = create_xml_element("port", site.service.port) + report_file.write(" #{el}\n") + + el = create_xml_element("ssl", site.service.name == "https") report_file.write(" #{el}\n") - el = create_xml_element("ssl", site.service.name == "https") - report_file.write(" #{el}\n") - report_file.write(" \n") end report_file.flush end - + # Extract web pages def extract_web_page_info(report_file) extract_web_info(report_file, "web_page", @web_pages) end - + # Extract web forms def extract_web_form_info(report_file) extract_web_info(report_file, "web_form", @web_forms) end - + # Extract web vulns def extract_web_vuln_info(report_file) extract_web_info(report_file, "web_vuln", @web_vulns) - end + end end end diff --git a/lib/msf/core/db_manager.rb b/lib/msf/core/db_manager.rb index cfc20eb89c..e76cab0c6c 100644 --- a/lib/msf/core/db_manager.rb +++ b/lib/msf/core/db_manager.rb @@ -36,7 +36,7 @@ class DBManager # Stores a TaskManager for serializing database events attr_accessor :sink - + # Flag to indicate database migration has completed attr_accessor :migrated @@ -159,7 +159,7 @@ class DBManager # Set the default workspace framework.db.workspace = framework.db.default_workspace - + # Flag that migration has completed self.migrated = true rescue ::Exception => e diff --git a/lib/msf/core/event_dispatcher.rb b/lib/msf/core/event_dispatcher.rb index c50cb9e7f1..7e6379948a 100644 --- a/lib/msf/core/event_dispatcher.rb +++ b/lib/msf/core/event_dispatcher.rb @@ -82,7 +82,7 @@ class EventDispatcher # Removes a general subscriber. # def remove_general_subscriber(subscriber) - remove_event_subscriber(general_event_subscribers, subscriber) + remove_event_subscriber(general_event_subscribers, subscriber) end # @@ -203,8 +203,8 @@ class EventDispatcher end return found end - - + + protected # @@ -224,8 +224,8 @@ protected attr_accessor :general_event_subscribers # :nodoc: attr_accessor :exploit_event_subscribers # :nodoc: attr_accessor :session_event_subscribers # :nodoc: - attr_accessor :db_event_subscribers # :nodoc: - attr_accessor :ui_event_subscribers # :nodoc: + attr_accessor :db_event_subscribers # :nodoc: + attr_accessor :ui_event_subscribers # :nodoc: end diff --git a/lib/msf/core/exceptions.rb b/lib/msf/core/exceptions.rb index 5b78901ef4..5cdb6583e2 100644 --- a/lib/msf/core/exceptions.rb +++ b/lib/msf/core/exceptions.rb @@ -105,7 +105,7 @@ class BadcharError < EncodingError # Integer in ruby 1.9. if (char.respond_to? :ord) c = char.ord - else + else c = char end if (c) @@ -289,7 +289,7 @@ class PluginLoadError < RuntimeError self.reason = reason super end - + def to_s "This plugin failed to load: #{reason}" end diff --git a/lib/msf/core/module_manager.rb b/lib/msf/core/module_manager.rb index 258e4eb549..b23ad8a8d8 100644 --- a/lib/msf/core/module_manager.rb +++ b/lib/msf/core/module_manager.rb @@ -683,7 +683,7 @@ class ModuleManager < ModuleSet save_module_cache end - + # # Reloads the module specified in mod. This can either be an instance of a # module or a module class. diff --git a/lib/msf/core/nop.rb b/lib/msf/core/nop.rb index bb0d51d7f8..40836b2511 100644 --- a/lib/msf/core/nop.rb +++ b/lib/msf/core/nop.rb @@ -44,7 +44,7 @@ class Nop < Msf::Module # The list of registers that should not be clobbered by the NOP # generator. # - BadChars (string) - # The list of characters that should be avoided by the NOP + # The list of characters that should be avoided by the NOP # generator. # def generate_sled(length, opts) @@ -60,4 +60,4 @@ class Nop < Msf::Module end -end \ No newline at end of file +end diff --git a/lib/msf/core/option_container.rb b/lib/msf/core/option_container.rb index 1b37a64465..abfe958e9b 100644 --- a/lib/msf/core/option_container.rb +++ b/lib/msf/core/option_container.rb @@ -406,7 +406,7 @@ class OptPath < OptBase return false unless self.class.const_defined?(:ObjectSpace) obj = ObjectSpace._id2ref(id.to_i) rescue nil return false unless obj.respond_to? :acts_as_file? - return false unless obj.acts_as_file? # redundant? + return false unless obj.acts_as_file? # redundant? return !!obj end diff --git a/lib/msf/core/option_container.rb.ut.rb b/lib/msf/core/option_container.rb.ut.rb index 323315bb6f..641c8ef837 100644 --- a/lib/msf/core/option_container.rb.ut.rb +++ b/lib/msf/core/option_container.rb.ut.rb @@ -42,11 +42,11 @@ class OptionContainer::UnitTest < Test::Unit::TestCase options = OptionContainer.new( 'rport' => [ OptPort, true, nil, 1234 ]) - assert_equal(1234, options.get('rport').default, + assert_equal(1234, options.get('rport').default, "option default does not match") - assert_equal(true, options.get('rport').required?, + assert_equal(true, options.get('rport').required?, "option required does not match") - assert_equal('rport', options['rport'].name, + assert_equal('rport', options['rport'].name, "option name does not match") end @@ -90,8 +90,8 @@ class OptionContainer::UnitTest < Test::Unit::TestCase options.add_advanced_options( 'DONKEY' => [ OptString, false ]) - - assert_equal(true, options.get('DONKEY').advanced?, + + assert_equal(true, options.get('DONKEY').advanced?, "advanced option failed") end @@ -117,13 +117,13 @@ class OptionContainer::UnitTest < Test::Unit::TestCase options = OptionContainer.new( 'testenum' => [ OptEnum, true, 'desc', nil, ['none','one','done']] ) - + ds = DataStore.new assert_raise(OptionValidateError, "enum required") { options.validate(ds) } - + ds['testenum'] = 'done' assert_equal(true, options.validate(ds), "enum valid") @@ -136,4 +136,4 @@ class OptionContainer::UnitTest < Test::Unit::TestCase end end -end \ No newline at end of file +end diff --git a/lib/msf/core/payload.rb b/lib/msf/core/payload.rb index df48388c33..7610cc2164 100644 --- a/lib/msf/core/payload.rb +++ b/lib/msf/core/payload.rb @@ -450,7 +450,7 @@ class Payload < Msf::Module begin assoc_exploit.on_new_session(session) rescue ::Exception => e - dlog("#{assoc_exploit.refname}: on_new_session handler triggered exception: #{e.class} #{e} #{e.backtrace}", 'core', LEV_1) rescue nil + dlog("#{assoc_exploit.refname}: on_new_session handler triggered exception: #{e.class} #{e} #{e.backtrace}", 'core', LEV_1) rescue nil end # Set the abort sockets flag only if the exploit is not passive diff --git a/lib/msf/core/plugin.rb b/lib/msf/core/plugin.rb index ce221848a1..f63e75acad 100644 --- a/lib/msf/core/plugin.rb +++ b/lib/msf/core/plugin.rb @@ -10,12 +10,12 @@ module Msf # them during the course of a framework's lifetime. For instance, a plugin # could be loaded to alter the default behavior of new sessions, such as by # scripting meterpreter sessions that are created. The possiblities are -# endless! +# endless! # # All plugins must exist under the Msf::Plugin namespace. Plugins are # reference counted to allow them to be loaded more than once if they're a # singleton. -# +# ### class Plugin diff --git a/lib/msf/core/post.rb b/lib/msf/core/post.rb index 91497feae7..02d3fd6cca 100644 --- a/lib/msf/core/post.rb +++ b/lib/msf/core/post.rb @@ -40,7 +40,7 @@ class Post < Msf::Module @session.init_ui(self.user_input, self.user_output) end - # Meterpreter sometimes needs a little bit of extra time to + # Meterpreter sometimes needs a little bit of extra time to # actually be responsive for post modules. Default tries # and retries for 5 seconds. def check_for_session_readiness(tries=10) @@ -79,7 +79,7 @@ class Post < Msf::Module alias :client :session - # + # # Cached sysinfo, returns nil for non-meterpreter sessions # def sysinfo @@ -112,7 +112,7 @@ class Post < Msf::Module end sessions end - + # # Create an anonymous module not tied to a file. Only useful for IRB. # diff --git a/lib/msf/core/session_manager.rb b/lib/msf/core/session_manager.rb index d3073f34b7..55a49850d3 100644 --- a/lib/msf/core/session_manager.rb +++ b/lib/msf/core/session_manager.rb @@ -21,34 +21,34 @@ class SessionManager < Hash LAST_SEEN_INTERVAL = 60 * 2.5 SCHEDULER_THREAD_COUNT = 5 - + def initialize(framework) self.framework = framework self.sid_pool = 0 - self.mutex = Mutex.new + self.mutex = Mutex.new self.scheduler_queue = ::Queue.new self.initialize_scheduler_threads - + self.monitor_thread = framework.threads.spawn("SessionManager", true) do last_seen_timer = Time.now.utc - + respawn_max = 30 respawn_cnt = 0 - + begin while true # # Process incoming data from all stream-based sessions and queue the # data into the associated ring buffers. - # + # rings = values.select{|s| s.respond_to?(:ring) and s.ring and s.rstream } ready = ::IO.select(rings.map{|s| s.rstream}, nil, nil, 0.5) || [[],[],[]] ready[0].each do |fd| s = rings.select{|s| s.rstream == fd}.first next if not s - + begin buff = fd.get_once(-1) if buff @@ -67,13 +67,13 @@ class SessionManager < Hash # normal EOF dlog("Call Stack\n#{e.backtrace.join("\n")}", 'core', LEV_3) end - + # Flush any ring data in the queue s.ring.clear_data rescue nil - + # Shut down the socket itself s.rstream.close rescue nil - + # Deregister the session deregister(s, "Died from #{e.class}") end @@ -84,8 +84,8 @@ class SessionManager < Hash # TODO: Call the dispatch entry point of each Meterpreter thread instead of # dedicating specific processing threads to each session # - - + + # # Check for closed / dead / terminated sessions # @@ -96,20 +96,20 @@ class SessionManager < Hash next end end - + # # Mark all open session as alive every LAST_SEEN_INTERVAL # - if (Time.now.utc - last_seen_timer) >= LAST_SEEN_INTERVAL - + if (Time.now.utc - last_seen_timer) >= LAST_SEEN_INTERVAL + # Update this timer BEFORE processing the session list, this will prevent # processing time for large session lists from skewing our update interval. - + last_seen_timer = Time.now.utc values.each do |s| # Update the database entry on a regular basis, marking alive threads # as recently seen. This notifies other framework instances that this - # session is being maintained. + # session is being maintained. if framework.db.active and s.db_record s.db_record.last_seen = Time.now.utc s.db_record.save @@ -122,7 +122,7 @@ class SessionManager < Hash # Skip the database cleanup code below if there is no database # next if not (framework.db and framework.db.active) - + # # Clean out any stale sessions that have been orphaned by a dead # framework instance. @@ -133,9 +133,9 @@ class SessionManager < Hash db_session.close_reason = "Orphaned" db_session.save end - end + end end - + # # All session management falls apart when any exception is raised to this point. Log it. # @@ -149,7 +149,7 @@ class SessionManager < Hash end end end - + # # Dedicated worker threads for pulling data out of new sessions # @@ -169,7 +169,7 @@ class SessionManager < Hash end end end - + # # Add a new task to the loader thread queue. Task is assumed to be # a Proc or another object that responds to call() @@ -210,7 +210,7 @@ class SessionManager < Hash end next_sid = allocate_sid - + # Initialize the session's sid and framework instance pointer session.sid = next_sid session.framework = framework @@ -219,7 +219,7 @@ class SessionManager < Hash if session.register? # Insert the session into the session hash table self[next_sid.to_i] = session - + # Notify the framework that we have a new session opening up... # Don't let errant event handlers kill our session begin @@ -273,7 +273,7 @@ class SessionManager < Hash def get(sid) return self[sid.to_i] end - + # # Allocates the next Session ID # @@ -289,7 +289,7 @@ protected attr_accessor :monitor_thread # :nodoc: attr_accessor :scheduler_threads # :nodoc: attr_accessor :scheduler_queue # :nodoc: - attr_accessor :mutex # :nodoc: + attr_accessor :mutex # :nodoc: end diff --git a/lib/msf/core/thread_manager.rb b/lib/msf/core/thread_manager.rb index 8b3f8a6499..569f78b2c0 100644 --- a/lib/msf/core/thread_manager.rb +++ b/lib/msf/core/thread_manager.rb @@ -13,7 +13,7 @@ class ThreadManager < Array include Framework::Offspring attr_accessor :monitor - + # # Initializes the thread manager. # @@ -21,14 +21,14 @@ class ThreadManager < Array self.framework = framework self.monitor = spawn_monitor end - + # # Spawns a monitor thread for removing dead threads # def spawn_monitor ::Thread.new do begin - + ::Thread.current[:tm_name] = "Thread Monitor" ::Thread.current[:tm_crit] = true @@ -39,8 +39,8 @@ class ThreadManager < Array self[i] = nil if not state end self.delete(nil) - end - + end + rescue ::Exception => e elog("thread monitor: #{e} #{e.backtrace} source:#{self[:tm_call].inspect}") end @@ -52,14 +52,14 @@ class ThreadManager < Array # def spawn(name, crit, *args, &block) t = nil - + if block t = ::Thread.new(name, crit, caller, block, *args) do |*argv| ::Thread.current[:tm_name] = argv.shift.to_s ::Thread.current[:tm_crit] = argv.shift ::Thread.current[:tm_call] = argv.shift - ::Thread.current[:tm_time] = Time.now - + ::Thread.current[:tm_time] = Time.now + begin argv.shift.call(*argv) rescue ::Exception => e @@ -74,13 +74,13 @@ class ThreadManager < Array ::Thread.current[:tm_crit] = argv.shift ::Thread.current[:tm_call] = argv.shift ::Thread.current[:tm_time] = Time.now - end + end end self << t t end - + # # Registers an existing thread # @@ -88,11 +88,11 @@ class ThreadManager < Array t[:tm_name] = name t[:tm_crit] = crit t[:tm_call] = caller - t[:tm_time] = Time.now + t[:tm_time] = Time.now self << t t end - + # # Updates an existing thread # @@ -106,7 +106,7 @@ class ThreadManager < Array break end end - + t = self[ti] if not t raise RuntimeError, "Thread not found" @@ -115,7 +115,7 @@ class ThreadManager < Array t[:tm_name] = name t[:tm_crit] = crit t - end + end # # Kills a thread by index @@ -123,7 +123,7 @@ class ThreadManager < Array def kill(idx) self[idx].kill rescue false end - + end end