Changeset 5505

Show
Ignore:
Timestamp:
05/17/08 00:29:32 (5 months ago)
Author:
egypt
Message:

"set foo" prints the value of foo if it exists

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/lib/msf/ui/console/command_dispatcher/core.rb

    r5403 r5505  
    802802                                        datastore) + "\n") 
    803803                        return true 
    804                 elsif (args.length < 2) 
    805                         print( 
    806                                 "Usage: set name value\n\n" + 
    807                                 "Sets an arbitrary name to an arbitrary value.\n") 
    808                         return false 
     804                elsif (args.length == 1) 
     805                        if (not datastore[args[0]].nil?) 
     806                                print_line("#{args[0]} => #{datastore[args[0]]}") 
     807                                return true 
     808                        else 
     809                                print( 
     810                                        "Usage: set name value\n\n" + 
     811                                        "Sets an arbitrary name to an arbitrary value.\n") 
     812                                return false 
     813                        end 
    809814                end 
    810815 
  • framework3/trunk/lib/rex/exploitation/obfuscatejs.rb

    r4641 r5505  
    66# 
    77class ObfuscateJS 
     8        STRINGS_SINGLE_QUOTES = 0 
     9        STRINGS_DOUBLE_QUOTES = 1 
    810 
    911        # 
     
    4042        # 
    4143        def sym(name) 
    42                 @dynsym[name] 
     44                if (@dynsym[name]) 
     45                        @dynsym[name] 
     46                else  
     47                        name 
     48                end 
    4349        end 
    4450 
     
    5258                # Globally replace symbols 
    5359                replace_symbols(opts['Symbols']) if opts['Symbols'] 
     60 
     61                if (opts['Strings']) 
     62                        obfuscate_strings(opts['Strings']) 
     63                        # since there shouldn't be spaces in strings after the call to 
     64                        # obfuscate_strings, we can safely randomize the spaces as well 
     65                        @js = Rex::Text.compress(@js) 
     66                        @js = Rex::Text.randomize_space(@js) 
     67                end 
     68 
    5469 
    5570                @js 
     
    99114        end 
    100115 
     116        def obfuscate_strings(type=STRINGS_SINGLE_QUOTES) 
     117                if type == STRINGS_SINGLE_QUOTES 
     118                        regex = /'.*?[^\\]'/ 
     119                else  
     120                        regex = /".*?[^\\]"/  
     121                end 
     122                return @js.gsub!(regex) { |str| 
     123                        str = str[1,str.length-2] 
    101124 
     125                        case (rand(3)) 
     126                        when 0 
     127                                buf = '"' + Rex::Text.to_hex(str) + '"' 
     128                        when 1 
     129                                buf = "unescape(\"" + Rex::Text.to_hex(str, "%") + "\")" 
     130                        else  
     131                                buf = "String.fromCharCode(" 
     132                                str.each_byte { |c| 
     133                                        if (0 == rand(2)) 
     134                                                buf << "%i,"%(c) 
     135                                        else 
     136                                                buf << "0x%0.2x,"%(c) 
     137                                        end 
     138                                } 
     139                                buf = buf[0,buf.length-1] + ")" 
     140                        end 
     141                        buf 
     142                } 
     143        end 
    102144end 
    103145 
  • framework3/trunk/lib/rex/text.rb

    r5494 r5505  
    176176                return buff      
    177177        end 
     178        def self.from_unescape(data, endian=ENDIAN_LITTLE) 
     179                buf =  
     180                        if (data =~ /%u/) 
     181                                data.split("%u").collect { |b|  
     182                                        next if b == "" 
     183                                        if (endian == ENDIAN_LITTLE) 
     184                                                "#{(b[2,2].to_i 16).chr}#{(b[0,2].to_i 16).chr}"  
     185                                        else 
     186                                                "#{(b[0,2].to_i 16).chr}#{(b[2,2].to_i 16).chr}"  
     187                                        end 
     188                                }.join('') 
     189                        else 
     190                                data.split("%").collect { |b| 
     191                                        next if b == "" 
     192                                        "#{(b.to_i 16).chr}" 
     193                                }.join('') 
     194                        end 
     195                return buf 
     196        end 
    178197 
    179198        #