Metasploit mailing list archives

[PATCH] cleanup with $DEBUG=true


From: john-metasploit at ofjj.net (Yoann Guillot)
Date: Thu, 25 Jun 2009 19:45:53 +0200

Hi,

Another patch, this one is more cosmetic: it is intended to reduce the messages
printed by ruby -d -r msf/base -e Msf::Simple::Framework.create

Mostly it changes the code to use less rescue Exceptions when simpler workarounds
are available.

-- 
Yoann Guillot



diff -r b71036428911 lib/msf/core/module_manager.rb
--- a/lib/msf/core/module_manager.rb    Wed Jun 24 22:02:29 2009 +0200
+++ b/lib/msf/core/module_manager.rb    Thu Jun 25 19:16:23 2009 +0200
@@ -54,11 +54,7 @@
        # throwing an exception.
        #
        def get_hash_val(name)
-               begin
-                       return self.fetch(name)
-               rescue IndexError
-                       return nil
-               end
+               fetch(name) if has_key?(name)
        end
 
        #
@@ -902,10 +898,7 @@
                usable = false
 
                begin
-                       usable = added.is_usable
-               # If no method is defined, assume that this module is usable.
-               rescue NoMethodError
-                       usable = true
+                       usable = respond_to?(:is_usable) ? added.is_usable : true
                rescue
                        elog("Exception caught during is_usable check: #{$!}")
                end
diff -r b71036428911 lib/msf/core/payload.rb
--- a/lib/msf/core/payload.rb   Wed Jun 24 22:02:29 2009 +0200
+++ b/lib/msf/core/payload.rb   Thu Jun 25 19:16:23 2009 +0200
@@ -78,6 +78,8 @@
                        end
 
                        @staged = true
+               else
+                       @staged = false
                end
 
                # Update the module info hash with the connection type
diff -r b71036428911 lib/rex/sync/event.rb
--- a/lib/rex/sync/event.rb     Wed Jun 24 22:02:29 2009 +0200
+++ b/lib/rex/sync/event.rb     Thu Jun 25 19:16:23 2009 +0200
@@ -64,7 +64,7 @@
        begin
                # XXX: we need to replace this code
                #      continuations slow down YARV
-               require "continuation"
+               require "continuation" if not defined? callcc
        rescue ::LoadError
        end
        
diff -r b71036428911 modules/payloads/stagers/netware/reverse_tcp.rb
--- a/modules/payloads/stagers/netware/reverse_tcp.rb   Wed Jun 24 22:02:29 2009 +0200
+++ b/modules/payloads/stagers/netware/reverse_tcp.rb   Thu Jun 25 19:16:23 2009 +0200
@@ -127,9 +127,9 @@
         ; remove CIFS lock
         call [edi-4]          ; NSS.NLM|NSSMPK_UnlockNss
         
-        ; allocate heap buffer to remove the code from the stack (if on the stack)
-        ; network functions will give back control to the kernel and we don't want
-        ; the driver to erase our shellcode
+        // allocate heap buffer to remove the code from the stack (if on the stack)
+        // network functions will give back control to the kernel and we don't want
+        // the driver to erase our shellcode
 
         push 65535
         call [edi-8]          ; AFPTCP.NLM|LB_malloc
diff -r b71036428911 lib/rex/peparsey/pebase.rb
--- a/lib/rex/peparsey/pebase.rb        Wed Jun 24 22:02:29 2009 +0200
+++ b/lib/rex/peparsey/pebase.rb        Thu Jun 25 19:20:26 2009 +0200
@@ -928,7 +928,6 @@
                end
 
                attr_reader :code_offset, :unwind_op, :op_info, :frame_offset
-       private
                attr_writer :code_offset, :unwind_op, :op_info, :frame_offset
 
        end
@@ -973,9 +972,6 @@
 
                attr_reader :begin_address, :end_address, :unwind_info_address
                attr_reader :unwind_info
-
-       private
-
                attr_writer :unwind_info
 
        end


Current thread: