{"id":6421,"date":"2019-02-20T20:11:51","date_gmt":"2019-02-20T20:11:51","guid":{"rendered":"https:\/\/hackmethod.com\/?p=6421"},"modified":"2022-06-03T05:36:42","modified_gmt":"2022-06-03T05:36:42","slug":"overthewire-narnia-1","status":"publish","type":"post","link":"https:\/\/hackmethod.com\/overthewire-narnia-1\/","title":{"rendered":"OverTheWire \u2013 Narnia 1"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Introduction<\/h3>\n\n\n\n<p>Narnia a  series of reverse engineering puzzles developed by OverTheWire and is an introduction to reverse engineering.  Below is the methodology used to solve these puzzles. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Login and Execution<\/h3>\n\n\n\n<p>In the previous level, <a href=\"https:\/\/hackmethod.com\/overthewire-narnia-0\/\">Narnia 0<\/a>, we covered the difference between Source Code and Executable Code.  All Narnia binaries and source files are located in <code>\/narnia\/<\/code>.  Using the password we obtained in Narnia 0, we can now login as user <code>narnia1<\/code> and change to the narnia directory. Then reviewing the source code and the binary, we can determine how to exploit this particular level.  Let&#8217;s get started. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"878\" height=\"700\" data-attachment-id=\"6429\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-login\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?fit=878%2C700&amp;ssl=1\" data-orig-size=\"878,700\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-login\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?fit=300%2C239&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?fit=878%2C700&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?resize=878%2C700&#038;ssl=1\" alt=\"\" class=\"wp-image-6429\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?w=878&amp;ssl=1 878w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?resize=300%2C239&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?resize=768%2C612&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-login.png?resize=600%2C478&amp;ssl=1 600w\" sizes=\"(max-width: 878px) 100vw, 878px\" \/><\/figure>\n\n\n\n<p>When listing the directory we can see all levels of Narnia. The concern of this walkthrough is <code>narnia1.c<\/code> and <code>narnia1<\/code>. Viewing this directory listing we can see that <code>narnia1<\/code> when executed runs as the user narnia2 and is executable by the user narnia1.  Running <code>.\/narnia1<\/code>we see the response &#8220;Give me something to execute at the env-variable EGG&#8221;. With this we can gleam some information from it&#8217;s output. <a href=\"https:\/\/en.wikipedia.org\/wiki\/Environment_variable\">Env-Variable<\/a> is expecting the environment variable <code>EGG<\/code> to contain data. Let&#8217;s break down the source code.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"121\" data-attachment-id=\"6430\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-execute\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?fit=852%2C121&amp;ssl=1\" data-orig-size=\"852,121\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-execute\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?fit=300%2C43&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?fit=852%2C121&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?resize=852%2C121&#038;ssl=1\" alt=\"\" class=\"wp-image-6430\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?w=852&amp;ssl=1 852w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?resize=300%2C43&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?resize=768%2C109&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute.png?resize=600%2C85&amp;ssl=1 600w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Source code and breakdown<\/h3>\n\n\n\n<p><code>cat<\/code> is an essential tool for any Linux distribution and can assist users in reading files.  This in turn allows us to read the <code>narnia1.c<\/code> source file.  Running the command <code>cat narnia1.c<\/code> from the <code>\/narnia\/<\/code> directory we get the following source code.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"503\" data-attachment-id=\"6431\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-source_code-no_comment\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?fit=977%2C503&amp;ssl=1\" data-orig-size=\"977,503\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-source_code-no_comment\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?fit=300%2C154&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?fit=977%2C503&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?resize=977%2C503&#038;ssl=1\" alt=\"\" class=\"wp-image-6431\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?w=977&amp;ssl=1 977w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?resize=300%2C154&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?resize=768%2C395&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-source_code-no_comment.png?resize=600%2C309&amp;ssl=1 600w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><figcaption><code>cat \/narnia\/narnia1.c -<\/code>Source code minus the narnia comments.<\/figcaption><\/figure>\n\n\n\n<p>If you&#8217;ve never seen the C programming language before it might be a little foreign to you. Let&#8217;s break it down line by line and hopefully get an idea of what&#8217;s happening in our binary. I have copied the code to <a href=\"https:\/\/code.visualstudio.com\/\">VSCode<\/a> for ease of commenting.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"39\" data-attachment-id=\"6447\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/image-15\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?fit=852%2C39&amp;ssl=1\" data-orig-size=\"852,39\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?fit=300%2C14&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?fit=852%2C39&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?resize=852%2C39&#038;ssl=1\" alt=\"\" class=\"wp-image-6447\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?w=852&amp;ssl=1 852w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?resize=300%2C14&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?resize=768%2C35&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-14.png?resize=600%2C27&amp;ssl=1 600w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><figcaption>Lines 1-2<\/figcaption><\/figure>\n\n\n\n<p>The <code>#include &lt;stdio.h&gt;<\/code> is used to import all standard input and output functions defined in the stdio header file, such as <code>printf<\/code>and <code>NULL<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"21\" data-attachment-id=\"6443\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/image-12\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?fit=852%2C21&amp;ssl=1\" data-orig-size=\"852,21\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?fit=300%2C7&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?fit=852%2C21&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?resize=852%2C21&#038;ssl=1\" alt=\"\" class=\"wp-image-6443\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?w=852&amp;ssl=1 852w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?resize=300%2C7&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?resize=768%2C19&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-11.png?resize=600%2C15&amp;ssl=1 600w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><figcaption>Line 3<\/figcaption><\/figure>\n\n\n\n<p>Every C program has a <code>main()<\/code> function and is the entry point of the binary once the source code has been compiled. Within <code>main<\/code> is where we get to the real meat of the program.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"42\" data-attachment-id=\"6448\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/image-16\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?fit=852%2C42&amp;ssl=1\" data-orig-size=\"852,42\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?fit=300%2C15&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?fit=852%2C42&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?resize=852%2C42&#038;ssl=1\" alt=\"\" class=\"wp-image-6448\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?w=852&amp;ssl=1 852w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?resize=300%2C15&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?resize=768%2C38&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-15.png?resize=600%2C30&amp;ssl=1 600w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><figcaption>Lines 3-4<\/figcaption><\/figure>\n\n\n\n<p>Within <code>main()<\/code> we see the above code which declares the <code>ret()<\/code>function as a prototype to use further down in the code.   Because C programming is procedural, defining it first will save us from an error upon compilation. Now let&#8217;s visit the <code>if<\/code> statement.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"78\" data-attachment-id=\"6449\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/image-17\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?fit=852%2C78&amp;ssl=1\" data-orig-size=\"852,78\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?fit=300%2C27&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?fit=852%2C78&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?resize=852%2C78&#038;ssl=1\" alt=\"\" class=\"wp-image-6449\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?w=852&amp;ssl=1 852w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?resize=300%2C27&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?resize=768%2C70&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-16.png?resize=600%2C55&amp;ssl=1 600w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><figcaption>Lines 6-9<\/figcaption><\/figure>\n\n\n\n<p>The above 4 lines of code are a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conditional_(computer_programming)\">conditional statement<\/a> and will execute a specific set of instructions in the code. This case it is pulling in the environment variable &#8220;EGG&#8221;, if it is empty, or rather <code>NULL<\/code> in this case, it will print &#8220;Give me something to execute at the env-variable EGG&#8221; and <code>exit(1)<\/code> will then exit the program.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"134\" data-attachment-id=\"6450\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/image-18\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?fit=852%2C134&amp;ssl=1\" data-orig-size=\"852,134\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?fit=300%2C47&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?fit=852%2C134&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?resize=852%2C134&#038;ssl=1\" alt=\"\" class=\"wp-image-6450\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?w=852&amp;ssl=1 852w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?resize=300%2C47&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?resize=768%2C121&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-17.png?resize=600%2C94&amp;ssl=1 600w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><figcaption>Lines 10-16<\/figcaption><\/figure>\n\n\n\n<p>If the environment variable &#8220;EGG&#8221; has data, the conditional statement covered in lines 6-9 will be skipped and will then print &#8220;Trying to execute EGG!&#8221;.  The program will assign the data in the environment variable &#8220;EGG&#8221; into <code>ret<\/code>, then execute the data, and then exit.<\/p>\n\n\n\n<p>Hopefully with all that explained above we can start diving into exploiting the <code>narnia1<\/code> binary using what we&#8217;ve gathered from the code breakdown.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Debugging and Analysis<\/h3>\n\n\n\n<p>Leaving the &#8220;EGG&#8221; environment variable empty we receive the expected output based on the code review.  But what happens when we give it something to execute.  To set an environment variable in Linux we can run the simple command <code>export EGG=cd<\/code>.  To view the env variable we just set, run <code>echo $EGG<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"574\" height=\"133\" data-attachment-id=\"6453\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-envvar-cd\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-envvar-cd.png?fit=574%2C133&amp;ssl=1\" data-orig-size=\"574,133\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-envvar-cd\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-envvar-cd.png?fit=300%2C70&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-envvar-cd.png?fit=574%2C133&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-envvar-cd.png?resize=574%2C133&#038;ssl=1\" alt=\"\" class=\"wp-image-6453\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-envvar-cd.png?w=574&amp;ssl=1 574w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-envvar-cd.png?resize=300%2C70&amp;ssl=1 300w\" sizes=\"(max-width: 574px) 100vw, 574px\" \/><figcaption>Setting &#8216;cd&#8217; as our env variable for EGG<\/figcaption><\/figure>\n\n\n\n<p>With data now set on variable &#8220;EGG&#8221;, we can now run <code>.\/narnia1<\/code> and see what happens.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"492\" height=\"125\" data-attachment-id=\"6454\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-execute-cd\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute-cd.png?fit=492%2C125&amp;ssl=1\" data-orig-size=\"492,125\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-execute-cd\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute-cd.png?fit=300%2C76&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute-cd.png?fit=492%2C125&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute-cd.png?resize=492%2C125&#038;ssl=1\" alt=\"\" class=\"wp-image-6454\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute-cd.png?w=492&amp;ssl=1 492w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-execute-cd.png?resize=300%2C76&amp;ssl=1 300w\" sizes=\"(max-width: 492px) 100vw, 492px\" \/><\/figure>\n\n\n\n<p>Look at that, we have a &#8220;Segmentation fault&#8221;.  This means we have an abnormal condition that caused the program to exit.  Lucky for us, GDB is on the narnia host, loading the binary into gdb using <code>gdb narnia1<\/code> we can start looking at what the binary is doing.  Once gdb has loaded, we can run the command <code>disassemble main<\/code> which is going to print the memory addresses and assembly code for everything happening in the <code>main()<\/code> function we saw above. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1199\" height=\"1388\" data-attachment-id=\"6456\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/image-20\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?fit=1199%2C1388&amp;ssl=1\" data-orig-size=\"1199,1388\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?fit=259%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?fit=885%2C1024&amp;ssl=1\" src=\"https:\/\/i1.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?fit=750%2C868&amp;ssl=1\" alt=\"\" class=\"wp-image-6456\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?w=1199&amp;ssl=1 1199w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?resize=259%2C300&amp;ssl=1 259w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?resize=768%2C889&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?resize=885%2C1024&amp;ssl=1 885w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/image-19.png?resize=600%2C695&amp;ssl=1 600w\" sizes=\"(max-width: 1080px) 100vw, 1080px\" \/><figcaption><code>(gdb) disassemble main<\/code><\/figcaption><\/figure>\n\n\n\n<p>Your memory addresses will differ so refer to the image above for the rest of the article.  From memory address <code>0x08048476<\/code> to <code>0x0804848f<\/code> this is the conditional statement discussed previously that prints a msg to the screen and exits the program if &#8220;EGG&#8221; has no data.  Since we have data in the &#8220;EGG&#8221; variable it will be skipped and move to the <code>0x0804849b<\/code> memory location where it will print &#8220;Trying to execute EGG!&#8221; to the console. Moving down to memory address <code>0x080484a8<\/code> through <code>0x080484b3<\/code>, this is where the program calls getenv(&#8220;EGG&#8221;) in the program, makes space on the stack, and assigns the data in &#8220;EGG&#8221; to the <a href=\"https:\/\/en.wikipedia.org\/wiki\/X86#32-bit\">EAX<\/a> register.  Looking at the <code>0x080484b6<\/code> memory address we see the program calling <code>*%eax<\/code> which is the ret() function being executed.  Our first stop to see whats happening is to set a break point on that call and see what is on the stack.<\/p>\n\n\n\n<p>Using the memory address of eax, we set a breakpoint.  This will allow us to stop program execution as the environment variable &#8220;EGG&#8221; is put on the stack.  Set your breakpoint on the (gdb) prompt using <code>break *0x080484b6<\/code>.  Then proceed to run the command by simply typing <code>run<\/code>at the (gdb) prompt.  The program should stop at the set breakpoint.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"243\" data-attachment-id=\"6459\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-gdb-run\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-run.png?fit=752%2C243&amp;ssl=1\" data-orig-size=\"752,243\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-gdb-run\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-run.png?fit=300%2C97&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-run.png?fit=752%2C243&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-run.png?resize=752%2C243&#038;ssl=1\" alt=\"\" class=\"wp-image-6459\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-run.png?w=752&amp;ssl=1 752w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-run.png?resize=300%2C97&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-run.png?resize=600%2C194&amp;ssl=1 600w\" sizes=\"(max-width: 752px) 100vw, 752px\" \/><figcaption><code>(gdb) run<\/code><\/figcaption><\/figure>\n\n\n\n<p>This allows some analysis of the stack.  While we are stopped on the <code>0x080484b6<\/code>memory address, let&#8217;s view what&#8217;s on the stack at that address.  Using the <code>x\/25x $eax<\/code> command we can see (in hex) the next 25 values that are set for the eax register.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1064\" height=\"276\" data-attachment-id=\"6462\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-gdb-x25x_eax\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?fit=1064%2C276&amp;ssl=1\" data-orig-size=\"1064,276\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-gdb-x25x_eax\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?fit=300%2C78&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?fit=1024%2C266&amp;ssl=1\" src=\"https:\/\/i1.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?fit=750%2C195&amp;ssl=1\" alt=\"\" class=\"wp-image-6462\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?w=1064&amp;ssl=1 1064w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?resize=300%2C78&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?resize=768%2C199&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?resize=1024%2C266&amp;ssl=1 1024w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-gdb-x25x_eax.png?resize=600%2C156&amp;ssl=1 600w\" sizes=\"(max-width: 1064px) 100vw, 1064px\" \/><figcaption><code>(gdb) x\/25x $eax<\/code><\/figcaption><\/figure>\n\n\n\n<p>Looking at the first address on the left (<code>0xffffdea7<\/code>), we see the first value <code>0x5f006463<\/code>.  If we convert this from hex to ascii, we can see the last two bytes <code>64<\/code> and <code>63<\/code> convert to <code>d<\/code> and <code>c<\/code> respectively. If you recall from earlier, we made our &#8220;EGGS&#8221; variable equal to <code>cd<\/code>, with memory being in little-endian format this matches our environment variable data. Knowing that <code>.\/narnia1<\/code> is executable by user narnia1 and runs as user narnia2, let&#8217;s use this ability to put data on the stack to get a shell as user narnia2.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Exploit<\/h3>\n\n\n\n<p>We know that shellcode is what we are after since we want to spawn a shell as user narnia2.  The site <a href=\"http:\/\/shell-storm.org\/shellcode\/\">shell-storm.org<\/a> has a plethora of different OS shellcodes available. Running <code>uname -a<\/code> we can see the host is an x86_64 bit based OS so any x86 or x86_64 shells are possibly usable.  After a few frustrating shellcode tests and failures later, I found <a href=\"http:\/\/shell-storm.org\/shellcode\/files\/shellcode-607.php\">shellcode-607<\/a> worked wonderfully.  Within this page is the hex code we are after.  Copying the shellcode value and removing any quotes in the value, we end up with something like <code>\\xeb\\x11\\x5e\\x31\\...\\x8a\\xe2\\xce\\x81<\/code>.  Using this information we can now prepare our exploit.  To place our shellcode into the &#8220;EGG&#8221; variable we use python to get the hexcode in an acceptable format.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1123\" height=\"122\" data-attachment-id=\"6465\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-shellcode-python\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?fit=1123%2C122&amp;ssl=1\" data-orig-size=\"1123,122\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-shellcode-python\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?fit=300%2C33&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?fit=1024%2C111&amp;ssl=1\" src=\"https:\/\/i2.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?fit=750%2C81&amp;ssl=1\" alt=\"\" class=\"wp-image-6465\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?w=1123&amp;ssl=1 1123w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?resize=300%2C33&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?resize=768%2C83&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?resize=1024%2C111&amp;ssl=1 1024w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shellcode-python.png?resize=600%2C65&amp;ssl=1 600w\" sizes=\"(max-width: 1080px) 100vw, 1080px\" \/><\/figure>\n\n\n\n<p>With our environment variable set, we can now execute the <code>.\/narnia1<\/code> binary and get the password for user narnia2.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1122\" height=\"216\" data-attachment-id=\"6467\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-narnia-1\/narnia1-shell-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?fit=1122%2C216&amp;ssl=1\" data-orig-size=\"1122,216\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"narnia1-shell\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?fit=300%2C58&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?fit=1024%2C197&amp;ssl=1\" src=\"https:\/\/i2.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?fit=750%2C144&amp;ssl=1\" alt=\"\" class=\"wp-image-6467\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?w=1122&amp;ssl=1 1122w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?resize=300%2C58&amp;ssl=1 300w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?resize=768%2C148&amp;ssl=1 768w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?resize=1024%2C197&amp;ssl=1 1024w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2019\/02\/narnia1-shell-1.png?resize=600%2C116&amp;ssl=1 600w\" sizes=\"(max-width: 1080px) 100vw, 1080px\" \/><\/figure>\n\n\n\n<p>If you missed out on Narnia Level 0 click the button on the left to  check it out.  If you&#8217;re all caught up and want to see more, check out  the Narnia Level 2 by clicking the button on the right. <\/p>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-button aligncenter\"><a class=\"wp-block-button__link\" href=\"https:\/\/hackmethod.com\/overthewire-narnia-0\/\">Narnia Level 0<br><\/a><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-button aligncenter\"><a class=\"wp-block-button__link\" href=\"https:\/\/hackmethod.com\/overthewire-narnia-2\/\">Narnia Level 2<br><\/a><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Narnia a series of reverse engineering puzzles developed by OverTheWire and is an introduction to reverse engineering. Below is the methodology used to solve these puzzles. Login and Execution In the previous level, Narnia 0, we covered the difference between Source Code and Executable Code. All Narnia binaries and source files are located in [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":1842,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","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":""},"categories":[52,49],"tags":[165,166,162,45,50,46,164],"class_list":["post-6421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hacking","category-tutorials","tag-buffer-overflow","tag-level-2","tag-narnia","tag-overthewire","tag-tutorial","tag-tutorials","tag-walkthrough"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2016\/01\/NarniaImage.jpeg?fit=600%2C400&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5zY4D-1Fz","_links":{"self":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/6421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/comments?post=6421"}],"version-history":[{"count":15,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/6421\/revisions"}],"predecessor-version":[{"id":27851,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/6421\/revisions\/27851"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/media\/1842"}],"wp:attachment":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/media?parent=6421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/categories?post=6421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/tags?post=6421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}