{"id":4591,"date":"2022-09-22T22:50:00","date_gmt":"2022-09-23T03:50:00","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4591"},"modified":"2022-09-22T23:50:40","modified_gmt":"2022-09-23T04:50:40","slug":"directory-traversal-burp-suite","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/directory-traversal-burp-suite\/","title":{"rendered":"Directory Traversal &#8211; Burp Suite"},"content":{"rendered":"\n<p>Here are a couple different ways to do directory traversal.<\/p>\n\n\n\n<p><em>More detailed information is available at the following site.<\/em><br><a href=\"https:\/\/portswigger.net\/web-security\/file-path-traversal\">https:\/\/portswigger.net\/web-security\/file-path-traversal<\/a><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Normal directory traversal<\/li><li>URL Encoding<\/li><li>Getting around applications that strip directory traversal sequences<\/li><li>Using a null byte<\/li><\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Directory Traversal<\/h2>\n\n\n\n<p>What exactly is directory traversal anyway?  Well, it is pretty much exactly what it sounds like.  We traverse directories by manipulate the file path, for something like an image, to get something more valuable like the passwd file.<\/p>\n\n\n\n<p>In it&#8217;s most basic form, we can add ..\/..\/..\/..\/..\/etc\/passwd to a file path and instead of pulling an image, we get the passwd file.<\/p>\n\n\n\n<p>For instance, if we load an image on a website, it&#8217;s file path on the server may be something like \/var\/www\/html\/image.png.  If we right click on an image and open in a new tab and inspect the URL, we can see this path.  &#8220;Note: Web servers have a root directory for all the website files.  Generally web files&#8217; root starts there not \/ root of the machine.&#8221;<\/p>\n\n\n\n<p>Now if we remove image.png and replace it with ..\/ (..\/ on Linux\/macOS or ..\\ on Windows) we&#8217;ll go backwards one directory.  String them together and we can go back to the root of the drive.  Then we can add \/etc\/passwd (Or replace with whatever file we want) and load the contents of that file.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Most web applications should have some sort of protections in place to guard against directory traversal.  Let&#8217;s go over a few ways to get around it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">URL Encoding<\/h2>\n\n\n\n<p>URL encoding sometimes can work and is simple to do.  In Burp, select the file path, right click, Convert selection -&gt; URL -&gt; URL-encode all characters.<\/p>\n\n\n\n<p>You can also try double encoding.  Encode once, select the encoded text and encode again.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"605\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1024x605.png\" alt=\"\" class=\"wp-image-4592\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1024x605.png 1024w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-300x177.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-768x454.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1536x908.png 1536w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-500x296.png 500w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image.png 1817w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"762\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1-1024x762.png\" alt=\"\" class=\"wp-image-4593\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1-1024x762.png 1024w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1-300x223.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1-768x572.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1-403x300.png 403w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-1.png 1436w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"604\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2-1024x604.png\" alt=\"\" class=\"wp-image-4594\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2-1024x604.png 1024w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2-300x177.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2-768x453.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2-1536x906.png 1536w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2-500x295.png 500w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/09\/image-2.png 1819w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>In the above screenshots, ..\/..\/etc\/passwd becomes &#8220;%25%32%65%25%32%65%25%32%66%25%32%65%25%32%65%25%32%66%25%36%35%25%37%34%25%36%33%25%32%66%25%37%30%25%36%31%25%37%33%25%37%33%25%37%37%25%36%34&#8221;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting around applications that strip directory traversal sequences<\/h2>\n\n\n\n<p>Sometimes the web app can strip out text that it knows is directory traversal characters\/sequences.  For instance, it sees ..\/ in the requested url and just strips it out.<\/p>\n\n\n\n<p>We can do something like the following sequence to get around it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">..<strong>..\/<\/strong>\/..<strong>..\/<\/strong>\/etc\/passwd<\/pre>\n\n\n\n<p>That is 4 periods, followed by 2 slashes.  What happens is the web app reads the URL, goes hey ..\/ is not allowed, bye bye!  Removes the two instances of ..\/ and forwards the URL on.  Which ends up being<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">..\/..\/etc\/passwd<\/pre>\n\n\n\n<p>Which is just perfect for our use case.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using a Null Byte<\/h2>\n\n\n\n<p>If the application is using the file extension to validate that an image or other file is loaded, instead of say passwd, we can try using a null byte.  A null byte is used to terminate a string.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">..\/..\/etc\/passwd%00.png<\/pre>\n\n\n\n<p>What can end up happening is the web application sees the .png or .jpg at the end and goes &#8220;oh that is a valid extension, carry on&#8221; and then the system reads the line and sees the null byte and says &#8220;Oh null byte! end of file path, here is your file.&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are a couple different ways to do directory traversal. More detailed information is available at the following site.https:\/\/portswigger.net\/web-security\/file-path-traversal Normal directory traversal URL Encoding Getting around applications that strip directory traversal sequences Using a null byte Directory Traversal What exactly &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/directory-traversal-burp-suite\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[420,573],"tags":[1337,1339,1338,421,503,1340],"class_list":["post-4591","post","type-post","status-publish","format-standard","hentry","category-hacking","category-security","tag-burp-suite","tag-directory","tag-directory-traversal","tag-hacking","tag-security","tag-web-application"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4591"}],"version-history":[{"count":3,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4591\/revisions"}],"predecessor-version":[{"id":4597,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4591\/revisions\/4597"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}