Changeset 3820

Show
Ignore:
Timestamp:
08/12/06 03:31:38 (2 years ago)
Author:
hdm
Message:

Major reworking of the recon stuff, there is a new mixin called Auxiliary::Scanner that
supports per-range, per-host, and per-batch requests. The reporting stuff has been moved
into a new mixin for it. The old recon stuff was pulled out and sample modules for the
scanner mixin were added. Almost time to re-import skape's old recon foo using Scanner :-)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/lib/msf/base/simple/auxiliary.rb

    r3589 r3820  
    4747                 
    4848                # Verify the ACTION 
    49                 if (not mod.action) 
     49                if (mod.actions.length > 0 and not mod.action) 
    5050                        raise MissingActionError, "You must specify a valid Action", caller 
    5151                end 
  • framework3/trunk/lib/msf/core/auxiliary.rb

    r3666 r3820  
    1717        # Auxiliary mixins 
    1818        # 
    19         require 'msf/core/auxiliary/recon' 
     19        require 'msf/core/auxiliary/scanner' 
     20        require 'msf/core/auxiliary/report' 
    2021        require 'msf/core/auxiliary/dos' 
    2122         
  • framework3/trunk/lib/msf/core/option_container.rb

    r3453 r3820  
    11require 'resolv' 
    22require 'msf/core' 
     3require 'rex/socket' 
    34 
    45module Msf 
     
    134135# OptInt     - An integer value 
    135136# OptEnum    - Select from a set of valid values 
     137# OptAddressRange - A subnet or range of addresses 
    136138# 
    137139### 
     
    277279                        begin 
    278280                                Resolv.getaddress(value) 
     281                        rescue 
     282                                return false 
     283                        end 
     284                end 
     285 
     286                return super 
     287        end 
     288end 
     289 
     290### 
     291# 
     292# Network address range option. 
     293# 
     294### 
     295class OptAddressRange < OptBase 
     296        def type  
     297                return 'addressrange'  
     298        end 
     299 
     300        def normalize(value) 
     301 
     302                sets   = [] 
     303                return '' if not value 
     304 
     305                ranges = value.split(',')                
     306                ranges.each do |range| 
     307                        begin 
     308                        case range 
     309                        when /-/ 
     310                                tmp = range.split('-') 
     311                                next if tmp.length != 2 
     312 
     313                                if (Rex::Socket.addr_atoi(tmp[0]) < Rex::Socket.addr_atoi(tmp[1])) 
     314                                        sets << tmp 
     315                                end 
     316         
     317                        when /\// 
     318                                sets << Rex::Socket.cidr_crack(range) 
     319                        else 
     320                                tmp = Rex::Socket.addr_itoa(Rex::Socket.addr_atoi(range)) 
     321                                sets << [tmp, tmp] 
     322                        end 
     323                        rescue 
     324                        end 
     325                end 
     326 
     327                return sets.map{|i| i[0]+'-'+i[1]}.join(',') 
     328        end 
     329         
     330        def valid?(value) 
     331                if (value != nil and value.empty? == false) 
     332                        begin 
     333                                return (normalize(value).length > 0 ? true : false) 
    279334                        rescue 
    280335                                return false 
  • framework3/trunk/lib/msf/ui/console/command_dispatcher/core.rb

    r3803 r3820  
    700700                # A value needs to be specified 
    701701                if(words[1]) 
    702                         return tab_complete_option(words[1]
     702                        return tab_complete_option(str, words
    703703                end 
    704704                 
     
    10431043        # Provide tab completion for option values 
    10441044        # 
    1045         def tab_complete_option(opt)     
     1045        def tab_complete_option(str, words) 
     1046                opt = words[1] 
    10461047                res = [] 
    10471048                mod = active_module 
     
    10711072                # Is this option used by the active module? 
    10721073                if (mod.options.include?(opt)) 
    1073                         res.concat(option_values_dispatch(mod.options[opt])) 
     1074                        res.concat(option_values_dispatch(mod.options[opt], str, words)) 
    10741075                end 
    10751076                 
     
    10781079                        p = framework.modules.create(mod.datastore['PAYLOAD']) 
    10791080                        if (p and p.options.include?(opt)) 
    1080                                 res.concat(option_values_dispatch(p.options[opt])) 
     1081                                res.concat(option_values_dispatch(p.options[opt], str, words)) 
    10811082                        end 
    10821083                end 
     
    10881089        # Provide possible option values based on type 
    10891090        # 
    1090         def option_values_dispatch(o)    
     1091        def option_values_dispatch(o, str, words)        
     1092 
    10911093                res = [] 
    10921094                res << o.default.to_s if o.default 
     
    11041106                                        else 
    11051107                                end 
    1106                                  
     1108                         
     1109                        when 'Msf::OptAddressRange' 
     1110 
     1111                                case str 
     1112                                        when /\/$/ 
     1113                                                res << str+'32' 
     1114                                                res << str+'24' 
     1115                                                res << str+'16' 
     1116                                        when /\-$/ 
     1117                                                res << str+str[0, str.length - 1] 
     1118                                        else 
     1119                                                option_values_target_addrs().each do |addr| 
     1120                                                        res << addr+'/32' 
     1121                                                        res << addr+'/24' 
     1122                                                        res << addr+'/16' 
     1123                                                end 
     1124                                end 
     1125                         
    11071126                        when 'Msf::OptPort' 
    11081127                                case o.name 
  • framework3/trunk/lib/rex/pescan/scanner.rb

    r3617 r3820  
    2222                                hits.each do |hit| 
    2323                                        vma  = pe.rva_to_vma(hit[0]) 
    24                                         msg  = hit[1] 
     24                                        msg  = hit[1].is_a?(Array) ? hit[1].join(" ") : hit[1] 
    2525                                        $stdout.puts pe.ptr_s(vma) + " " + msg 
    2626                                end 
  • framework3/trunk/lib/rex/socket.rb

    r3796 r3820  
    2424        require 'rex/socket/switch_board' 
    2525        require 'rex/socket/subnet_walker' 
     26        require 'rex/socket/range_walker' 
     27         
     28        # Handle systems without AF_INET6 defined 
     29        if (! ::Socket.constants.include?('AF_INET6')) 
     30                ::Socket.const_set('AF_INET6', 10) 
     31        end 
    2632 
    2733        ## 
     
    207213 
    208214        # 
     215        # Converts a dotted-quad address into an integer 
     216        # 
     217        def self.addr_atoi(addr) 
     218                addr.split('.').map{|i| i.to_i }.pack('C4').unpack('N')[0] 
     219        end 
     220 
     221        # 
     222        # Converts an integer into a dotted-quad 
     223        # 
     224        def self.addr_itoa(addr) 
     225                [addr].pack('N').unpack('C4').join('.') 
     226        end 
     227         
     228        # 
     229        # Converts a CIDR subnet into an array (base, bcast) 
     230        # 
     231        def self.cidr_crack(cidr) 
     232                tmp = cidr.split('/') 
     233                addr = self.addr_atoi(tmp[0]) 
     234                mask = (2 ** 32) - (2 ** (32 - tmp[1].to_i)) 
     235                base = addr & mask 
     236                stop = base + (2 ** (32 - tmp[1].to_i)) - 1 
     237                return [self.addr_itoa(base), self.addr_itoa(stop)]      
     238        end 
     239         
     240         
     241        # 
    209242        # Converts a bitmask (28) into a netmask (255.255.255.240) 
    210243        #