Breaking the Windows Server 2003 SP2 Stack

本文介绍了一种特殊的技术来绕过Windows Server 2003 SP2的堆栈保护机制。该技术通过调整堆栈布局使攻击者能够在不依赖JMP ESP指令的情况下执行代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. ============================================================================
  2.   Breaking the Windows Server 2003 SP2 Stack
  3.   by Nikolaos Rangos aka kcope/eliteb0y in 2008 / kcope2(at)googlemail.com
  4. ============================================================================
  5. In this tutorial you can learn how to circumvent the 
  6. stack protection of Windows Server 2003.
  7. It has to be said that the technique presented in this paper
  8. works on Service Pack 2 of the Windows Server 2003 Operating System.
  9. I don't claim that the information in this paper is something new.
  10. The described technique has been documented in the paper entitled
  11. "Advanced exploitation in exec-shield (Fedora Core case study)"
  12. by "dong-hun you" [1]. This paper describes circumventing the
  13. exec-shield protections of Linux systems but can also be applied
  14. to Windows Server systems.
  15. Normal exploitation of Windows stack based overflows is done by
  16. either redirecting EIP (the instruction pointer) to an attacker
  17. defined return address jumping onto the stack or through the 
  18. SEH handler (Structured Exception Handler) method where the
  19. SEH chain is overwritten. 
  20. Both exploitation methods only seem to work on Windows (Server) 2000 
  21. systems or even older Windows Operating systems.
  22. The exploitation method I want to present is a special return-into-libc
  23. technique.
  24. An example exploit using this technique is the "Bea Weblogic -- Apache 
  25. Connector Remote Exploit" [2]. In this exploit the described technique 
  26. is implemented.
  27. The first thing to do is to redirect EIP to 0x41414141 (Here we
  28. have to be careful to not overwrite the SEH chain).
  29. Now normally one would search for an address which allows to jump 
  30. on the stack and execute the shellcode which is on the stack. 
  31. Now for this new technique we will NOT search for a JMP ESP in memory 
  32. space. 
  33. When the executable is loaded into the OllDbg [3] debugger and the
  34. access violation kicks in because 0x41414141 is not an executable
  35. address the stack layout may look like the following:
  36. -overwritten addresses-
  37. -overwritten addresses-
  38. .......................
  39. .......................
  40. .......................
  41. .......................
  42. .......................
  43. .......................
  44. Pointer to our buffer
  45. .......................
  46. .......................
  47. The goal is to shift the "Pointer to our buffer" upwards in the stack
  48. layout just below a call to WinExec().
  49. Ideally the stack layout would look like the following:
  50. -overwritten addresses-
  51. -overwritten addresses-
  52. Call to WinExec()
  53. Pointer to our buffer (can be "cmd.exe /c ...")
  54. .......................
  55. .......................
  56. If there is a call to WinExec() with the parameter "Pointer to our
  57. buffer" we have our code execution.
  58. Now how can we shift our buffer just below a call to WinExec() ?
  59. This is quite easy to do. We search the memory space of our process
  60. for POP+ret instructions.
  61. As an example there would be POP+POP+POP+RET instructions at 0x10020EBF:
  62. (Such instruction sets are very easy to find in the processes address 
  63. space. The addresses used here are just examples)
  64. 10020EBF   5F               POP EDI
  65. 10020EC0   5D               POP EBP
  66. 10020EC1   5E               POP ESI
  67. 10020EC2   C3               RETN
  68. If we now set our return address to 0x10020EBF instead of 0x41414141
  69. the process will jump to that address and shift the stack.
  70. The RET instruction will return to the next bytes in our attack buffer:
  71. The address right after 0x10020EBF (which was 0x41414141 before).
  72. To illustrate that we can look at the Bea Weblogic exploit and it's
  73. attack buffer:
  74. --- snip ---
  75. #### STACKBREAKING WITH WINEXEC() ON WINDOWS
  76. my $c = "C" x 97 . pack("L", 0x10013930) x 3 . pack("L", 0x10013930) . 
  77.     pack("L", 0x10013931) . pack("L",0x77EA411E);
  78. my $a = $cmds . "A" x (4000-length($cmds)) . $c;
  79. ---snip---
  80. There we have four times called the address at 0x10013930 and
  81. once the address at 0x10013931. These addresses are pointing to POP+RET 
  82. instructions. After those instructions are called there is a call
  83. to WinExec(). It's address is at 0x77EA411E as seen in the attack
  84. string.
  85. When we call the POP+RET instructions at 0x10013930 and RETurn from
  86. that address there is a direct call to 0x10013930 again because this
  87. is the place the epilog (POP+RET instructions) will return, namely
  88. returning to our string again.
  89. So the described technique is nothing but shifting/adjusting the 
  90. stack frame and when the "Pointer to our buffer" is reached 
  91. a call to WinExec() (or ShellExecute/CreateProcess) to execute 
  92. our commands.
  93. That's it - nothing more to say - it's pretty straightforward.
  94. References
  95. [1] Advanced exploitation in exec-shield (Fedora Core case study) by
  96.     "dong-hun you", http://www.milw0rm.com/papers/151
  97. [2] Bea Weblogic Remote Exploit, http://www.milw0rm.com/exploits/6089
  98. [3] OllyDbg, http://www.ollydbg.de

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值