<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joon Yoo</title>
    <description>The latest articles on DEV Community by Joon Yoo (@joonhyoo).</description>
    <link>https://dev.to/joonhyoo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1197943%2F859417a1-a820-4a0d-8b76-75ef855a5c3c.png</url>
      <title>DEV Community: Joon Yoo</title>
      <link>https://dev.to/joonhyoo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joonhyoo"/>
    <language>en</language>
    <item>
      <title>Solving Natas 15-17</title>
      <dc:creator>Joon Yoo</dc:creator>
      <pubDate>Tue, 31 Oct 2023 14:09:00 +0000</pubDate>
      <link>https://dev.to/joonhyoo/solving-natas-15-17-44ip</link>
      <guid>https://dev.to/joonhyoo/solving-natas-15-17-44ip</guid>
      <description>&lt;h2&gt;
  
  
  Natas Level 15
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P3n-WksU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svx0nexi3sliuutj4ofo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P3n-WksU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svx0nexi3sliuutj4ofo.png" alt="Image description" width="631" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This time, we see a little login-esque box which checks if a username exists in the database or not.&lt;br&gt;
Again, in the source code a query is being run&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$query = "SELECT * from users where username=\"".$_REQUEST["username"]."\"";&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once the quotations are expanded it becomes:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * from users where username=”input”;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
From what we can gather, it’s possible to use sql injection, and we could definitely brute force the password by checking each character and matching it to the username via a query that would look something like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * from users where username=”input” and password like binary “%A%”;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;However, we can use a tool called SQLmap which can do this for us automatically.&lt;br&gt;
Like most web accessing scripts we need to give the tool some information so it knows what to do:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RQ8ItCXw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53iyicllaa9vjuv5eu2c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RQ8ItCXw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53iyicllaa9vjuv5eu2c.png" alt="Image description" width="715" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The complete call of the script is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqlmap --auth-type=basic --auth-cred=natas15:TTkaI7AWG4iDERztBcEyKV7kRXH1EZRB -u http://natas15.natas.labs.overthewire.org/index.php --data="username=something" -p username --string=doesn --level=5 --user-agent=Mozilla --dbms=MySQL --threads 4 -D natas15 -T users --dump

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This takes a while to run and tries to find all the vulnerabilites of the site. It is capable of doing many things, such as time delay sql injections, regular sql injections, and many other fun pen testing operations! In this case, I've used it as I was too lazy to write a brute force algorithm and kind of wanted to try the tool out.&lt;/p&gt;

&lt;p&gt;Once the tool is done running, it left us with these results from the sql injection attacks:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hY5sbw4z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwrokqw7tkvl8g9yqk7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hY5sbw4z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwrokqw7tkvl8g9yqk7a.png" alt="Image description" width="430" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pass for next level: &lt;strong&gt;TRD7iZrd5gATjj9PkPEuaOlfEjHqj32V&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Natas Level 16
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7HgvfjKv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjc30btuvntqtojgs01v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7HgvfjKv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjc30btuvntqtojgs01v.png" alt="Image description" width="639" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This level is similar to Natas 9 &amp;amp; 10 but with even more restrictions on the input.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H8Jjz0Hh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ne1f8hmkm1oaikrhgudt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H8Jjz0Hh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ne1f8hmkm1oaikrhgudt.png" alt="Image description" width="435" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Natas 9 we exploited the use of ; to cat the password file, and in Natas 10 we exploited greps built in multi search ability, but in this case this isn’t possible. The key is double quoted, and so anything we put as the key will be used as one input - thus eliminating the grep vulnerability.&lt;br&gt;
However, if you’re familiar with shell you’ll know that $() can be used for command substitution, and while it can’t give us the password directly in this case - we can use it to determine certain things.&lt;/p&gt;

&lt;p&gt;Reading the source code, we can see that our input should return a case insensitive match of our input if it’s valid.&lt;br&gt;
Using command substitution, we should be able to test all the inputs for the password and have a final valid password for level 17. The key idea here is that if we use &lt;br&gt;
&lt;code&gt;$(grep somecharacters thepasswordfilefornatas17)&lt;/code&gt;&lt;br&gt;
in our input, if -somecharacters- appears in the natas17 password, then the command substitution will return it’s result. This works in our favour, as we can use a regular input, and then add the command substitution. If the command works, the input gets mangled, if it doesn’t then we get a result from the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0KwwHI5T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u23tr18wwpi1b2donv4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0KwwHI5T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u23tr18wwpi1b2donv4x.png" alt="Image description" width="624" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jnzP-zap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1tsunpnih70ps8beufh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jnzP-zap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1tsunpnih70ps8beufh.png" alt="Image description" width="632" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the output still shows zooms, we know that “a” is not in the password.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pPczXL8c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wq1rw8kwwogancqz0151.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pPczXL8c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wq1rw8kwwogancqz0151.png" alt="Image description" width="631" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the output shows nothing, we know that x is in the password.&lt;br&gt;
We brute force all the possible combinations of numbers and letters and then go through all of those to try and find the password by testing strings and not just single characters. We find all the possible characters first to reduce the time complexity of the solution as testing all the characters would take a lot longer than a smaller subset.&lt;br&gt;
This is the python script I wrote for this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PVCkKbfy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f9xhiuu68g70pwbs4bbx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PVCkKbfy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f9xhiuu68g70pwbs4bbx.png" alt="Image description" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result of running the script was this:&lt;br&gt;
(It took around 30 minutes, I went to eat some food while the script ran)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UUy518OM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/24mzj12wlecmepbbts1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UUy518OM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/24mzj12wlecmepbbts1l.png" alt="Image description" width="456" height="931"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pass for next level: &lt;strong&gt;XkEuChE0SbnKBvH1RU7ksIb9uuLmI7sd&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Natas Level 17
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5AvjqPNA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i40g4xzxg6921gbvj84m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5AvjqPNA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i40g4xzxg6921gbvj84m.png" alt="Image description" width="670" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This level is similar in appearance to level 15. Level 15 was exploitable via brute forcing sql injections to figure out the password. However, in this level we don’t have the ability to check text output as all the outputs have been commented out, and so checking usernames results in an empty result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vs3pDynl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dubrpnp152s4w6q35ty2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vs3pDynl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dubrpnp152s4w6q35ty2.png" alt="Image description" width="646" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Typically we would use a time delay sql injection attack, where we use an sql query combined with a sleep function. When the sql returns a query, we &amp;amp;&amp;amp; a delay function and then we test the time taken for our queries to return.&lt;/p&gt;

&lt;p&gt;The query returns a result before our expected time =&amp;gt; it didn’t work&lt;/p&gt;

&lt;p&gt;The query returns a result after our expected time =&amp;gt; it did work&lt;/p&gt;

&lt;p&gt;This is the philosophy of how the time delay sqli works. There are some drawbacks, like network delays and things that could cause issues, but these can be overcome by simply increasing the time delay that is used (with the obvious drawback being a slower attack).&lt;br&gt;
I decided to use the sqlmap tool again in a similar way to level 15 to get myself familiar with using pen testing tools, but it is entirely possible to write a python script which does the same thing I’m doing and probably faster as well. This is because sqlmap detects the vulnerability in the website and then performs multiple attacks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqlmap --auth-type=basic --auth-cred=natas17:XkEuChE0SbnKBvH1RU7ksIb9uuLmI7sd -u http://natas17.natas.labs.overthewire.org/index.php --data="username=something" -p username --level=5 --user-agent=Mozilla --dbms=MySQL --threads 1 -D natas17 -T users --dump
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this query, we removed the string to check for as nothing gets returned, and we ensure that only 1 thread is used, as multiple threads can increase false positives/negatives as it’s hard to account for thread switching in the time count. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WjODF8Qd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11cl2a6ta9f5do23t1wz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WjODF8Qd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11cl2a6ta9f5do23t1wz.png" alt="Image description" width="433" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After 2 hours, we get the results for the passwords. As sqlmap goes through all the passwords/usernames it can take a long time if all the passwords are long strings like in this example.&lt;/p&gt;

&lt;p&gt;Pass for next level: &lt;strong&gt;8NEDUUxg8kFgPV84uLwvZkGn6okJQ6aq&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I learnt&lt;/strong&gt;&lt;br&gt;
These levels were quite difficult to do. However it was great fun to learn about time delay basde sql attacks and how time consuming they can be due to network interruptions.  Many of these solutions involved brute force attacks, and writing up my own script for level 16 was fun as it has been a while since I used python for anything.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Solving Natas Levels 11-14</title>
      <dc:creator>Joon Yoo</dc:creator>
      <pubDate>Tue, 31 Oct 2023 13:49:18 +0000</pubDate>
      <link>https://dev.to/joonhyoo/solving-natas-levels-11-14-1ah2</link>
      <guid>https://dev.to/joonhyoo/solving-natas-levels-11-14-1ah2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Natas Level 11&lt;/strong&gt;&lt;br&gt;
This level opens up with a simple background color changing application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--skFSDTvg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gkf7yq2r2lx8i93ledb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--skFSDTvg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gkf7yq2r2lx8i93ledb1.png" alt="Image description" width="645" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have access to the source code again, so upon reading it we see that default data is loaded using a loadData function.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$defaultdata = array( "showpassword"=&amp;gt;"no", "bgcolor"=&amp;gt;"#ffffff");&lt;br&gt;
$data = loadData($defaultdata);&lt;/code&gt;&lt;br&gt;
The load data function accesses the cookie, loads it into the mydata variable and checks if the cookie has the key "data".&lt;br&gt;
If it does, it stores a base64 decoded, custom xor encrypted, json decoded version of the cookie data in the variable temp data. Then it checks if the tempdata variable is an array with key "showpassword" and "bgcolor". If it does, it checks if the bgcolor matches the format of a hexcode (#123456) and if it does, then it moves the information in the tempdata to the mydata variable and returns it.&lt;/p&gt;

&lt;p&gt;For us to return an altered version of the mydata variable, a couple things must be true:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The cookie has the "data" key in it&lt;/li&gt;
&lt;li&gt;The 3 function encrypt/decode of the cookie "data" must be an array&lt;/li&gt;
&lt;li&gt;The array must have a key showpassword and bgcolor&lt;/li&gt;
&lt;li&gt;The bgcolor value must match the format of a hexcode&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It appears that what we need to do is change the cookie in such a way that once it comes out of the three function enrypt/decode, it results in an array that has a key “showpassword” set to true, and a bgcolor key that is set to some hexcode.&lt;br&gt;
Luckily for us, json_decode and base64_decode have their respective encode functions built into php so we just need to use the associated function. So let’s take a deeper look into how we can decrypt the xor function.&lt;br&gt;
xor functions are associative and transitive, this means that if:&lt;/p&gt;

&lt;p&gt;A xor B = C, then&lt;br&gt;
A xor C = B, and&lt;br&gt;
C xor A = B, and so on.&lt;/p&gt;

&lt;p&gt;In this case, we have a key, text and an output text. We can apply similar principles here to find the key that the xor function is using so we can manipulate the output text in our favor.&lt;br&gt;
IN xor KEY = OUTPUT, then&lt;br&gt;
IN xor OUTPUT = KEY&lt;br&gt;
Since we know that the input will be the base64 decoded cookie, and our output will be the json encoded array. To get the cookie from our site, we go to the dev tools and enter document.cookie into the console and copy the data we get.&lt;br&gt;
&lt;code&gt;Cookie = MGw7JCQ5OC04PT8jOSpqdmkgJ25nbCorKCEkIzlscm5oKC4qLSgubjY&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--frkGCk0_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08bvzjtps701x3knl2iv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--frkGCk0_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08bvzjtps701x3knl2iv.png" alt="Image description" width="775" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After running this function, it returns:&lt;br&gt;
KNHLKNHLKNHLKNHLKNHLKNHLKNHLKNHLKNHLKNHLK&lt;br&gt;
With xor functions, if one value is shorter than the other it begins to repeat the key and - so we can determine that our key is ‘KNHL’. Now using this information, we want to have an array with key showpassword set to yes and a valid bgcolor hexcode. Applying the principle we learnt about earlier, we can assume:&lt;br&gt;
ARRAY xor KEY = COOKIE&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KTjEBURQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nyl0jhj5wqqa3n4tic9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KTjEBURQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nyl0jhj5wqqa3n4tic9j.png" alt="Image description" width="691" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As explained earlier, we reverse what happens to the cookie data to get a valid cookie holding our required information. Now we just need to set our cookie to the cookie that comes out of this function:&lt;br&gt;
&lt;code&gt;MGw7JCQ5OC04PT8jOSpqdmk3LT9pYmouLC0nICQ8anZpbS4qLSguKmkz&lt;/code&gt;&lt;br&gt;
We can do this by going to the dev tools again and typing&lt;br&gt;
&lt;code&gt;document.cookie=”data=thecookieyougot”&lt;/code&gt;&lt;br&gt;
Upon refreshing the page with our new cookie:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rYcIELts--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x4l4lsq3vmnlwxlvu9w7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rYcIELts--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x4l4lsq3vmnlwxlvu9w7.png" alt="Image description" width="649" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pass for next level: &lt;strong&gt;YWqo0pjpcXzSIl5NMAVxg12QxeC1w9QG&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 12&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YTRDNR-R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xzrgfu7bxjsd8m750e48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YTRDNR-R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xzrgfu7bxjsd8m750e48.png" alt="Image description" width="652" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are presented with a simple page to choose and upload a file. Reading the source code, we can see that it lets us upload jpeg files to the site and then does a couple things to it.&lt;br&gt;
The important thing to note is that once it's there, it generates a link to the image and displays it on the site. This probably means that if we get php code and pretend it's a jpeg file, we will be able to run it when the link displays.&lt;/p&gt;

&lt;p&gt;First, we’ll create a fake jpg that will echo the password for the next level as we have done in previous levels by peeking into the webpass folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_IWC3Y7i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14gs4mr3b4l4a0dfgngs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_IWC3Y7i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14gs4mr3b4l4a0dfgngs.png" alt="Image description" width="672" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This creates a jpg which contains php code that reads out the password file.&lt;br&gt;
Uploading this to the website results in a clickable link that doesn’t do much.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cGRk0ByI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4otxbd9j41bpyrqor2zt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cGRk0ByI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4otxbd9j41bpyrqor2zt.png" alt="Image description" width="648" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make this link do something, we can probably change the extension of our file to .php so that the browser runs our code! We can do this by editing the file extension in the dev tools then uploading it which gives us a link that prints out the password stored for the next level&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0anx6SiF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tinwmwl683eagfurwxve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0anx6SiF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tinwmwl683eagfurwxve.png" alt="Image description" width="640" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pass for next level: &lt;strong&gt;lW3jYRI02ZKDBb8VtQBU1f6eDRo6WEj9&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 13&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RY885P4x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lu6pmhpnfa19vrztt3j9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RY885P4x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lu6pmhpnfa19vrztt3j9.png" alt="Image description" width="654" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the site checks if the file uploaded is actually an image using the exif_imagetype function. Reading the documentation, this function reads the first bytes of an image and checks its signature. A value of 2 signifies a jpeg type, so we just need to prepend some bytes of information into our file to bypass the function. I did this using hexedit, but any tool to modify the bytes of a file will work here.&lt;br&gt;
After a quick search I found that I needed to edit the first 4 bytes to&lt;br&gt;
FF D8 FF DB as this is the bytes used for raw jpeg files.&lt;br&gt;
I added 4 characters to my image file so I can change them using hexedit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KOYEJd0---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/liqkfvmd86mi6h9ug6i4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KOYEJd0---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/liqkfvmd86mi6h9ug6i4.png" alt="Image description" width="720" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sx2l3UIS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxv4xp5z508wq1pk2gsw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sx2l3UIS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxv4xp5z508wq1pk2gsw.png" alt="Image description" width="785" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I uploaded the image, changed its extension and received the password for the next level!&lt;br&gt;
Pass for next level: &lt;strong&gt;qPazSJBmrmU7UQJv17MHk1PGC4DxZMEP&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 14&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SYadGk-w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dk5k83giiqcml49rsl87.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SYadGk-w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dk5k83giiqcml49rsl87.png" alt="Image description" width="647" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We open up to a login screen. In the source code it’s made apparent that there is a mysql database.&lt;br&gt;
The query that is called looks like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * from users where username=”input” and password=”input”;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The code then checks if any rows have been returned from the database. We can do a simple sql injection which will ensure that a row will always return like so:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * from users where username=”” or “”=”” and password=”” or””=””;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This works because the query or “”=”” is always true. As the regular query already includes double quotations for us, we need to add " or ""=" to get the query we want.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EAsx8HvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3owqqn60qu5clt5y1lk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EAsx8HvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3owqqn60qu5clt5y1lk.png" alt="Image description" width="640" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon clicking login, we are through to the next level.&lt;br&gt;
Pass for next level: &lt;strong&gt;TTkaI7AWG4iDERztBcEyKV7kRXH1EZRB&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I learnt&lt;/strong&gt;&lt;br&gt;
It was really fun getting to do some of the sql injections, as I've always heard about it - but never had the chance to do them. I learnt about how some verification methods work, like the exif_image checking bytes of a file. I also learnt that since code can be run on websites, many languages run on the web like: javascript, php and java can be exploited.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Solving Natas Levels 7-10</title>
      <dc:creator>Joon Yoo</dc:creator>
      <pubDate>Tue, 31 Oct 2023 13:29:29 +0000</pubDate>
      <link>https://dev.to/joonhyoo/solving-natas-levels-7-10-2k73</link>
      <guid>https://dev.to/joonhyoo/solving-natas-levels-7-10-2k73</guid>
      <description>&lt;p&gt;&lt;strong&gt;Natas Level 7&lt;/strong&gt;&lt;br&gt;
The level opens up with two buttons, Home and About. Upon my previous readings about php, I've been made aware that php injections exist. Simply by changing the url, you can access different php pages, functions, etc. In this case there was a clue left in the comments that accessing /etc/natas_webpass/natas8 would return a password, so I just entered that into the ?page= query and boom&lt;br&gt;
pass for next level: &lt;strong&gt;a6bZCNYwdKqN5cGP11ZdtPg0iImQQhAB&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 8&lt;/strong&gt;&lt;br&gt;
Similarly, this level opens up with an input secret screen. This time, as I read about before, the secret is encoded via a function written in the php script.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KzTIjGsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28y98uwzbtl8iql63bhh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KzTIjGsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28y98uwzbtl8iql63bhh.png" alt="Image description" width="539" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reading the encodeSecret function, I can just reverse what it’s doing to decode the secret.&lt;/p&gt;

&lt;p&gt;Steps to decode:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hex2bin&lt;/li&gt;
&lt;li&gt;Reverse string&lt;/li&gt;
&lt;li&gt;Base64_decode&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Following those steps and putting the result into the input box worked!&lt;br&gt;
pass for the next level: &lt;strong&gt;Sda6t0vkOPkM8YeOZkAGVhFoaplvlJFd&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 9&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lUnnibYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpqdgjkuhi8q3ehn3acz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lUnnibYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpqdgjkuhi8q3ehn3acz.png" alt="Image description" width="659" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking into the source code we see that there is another php function that we can exploit!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zzBq2Apz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7uw2zqz3q5t71h2psni1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zzBq2Apz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7uw2zqz3q5t71h2psni1.png" alt="Image description" width="358" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wasn’t sure if it would sanitize the input, so I tried a bunch of things. At the end of it I remembered back to when I solved Narnia 0 (a different overthewire wargame) and I used ; to send multiple commands in, noticing that it was using shell commands, I considered trying something a bit more useful than grep.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XaAcQJb8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dk31oyf160teqkck0lv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XaAcQJb8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dk31oyf160teqkck0lv.png" alt="Image description" width="544" height="676"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bingo, now from what I remember from previous levels - the passwords are stored in a particular folder, so I used cat to try and find it by entering: ; cat /etc/natas_webpass/natas10&lt;br&gt;
pass for next level: &lt;strong&gt;D44EcsFkLxPIkAAKLosx8z3hxX1Z4MCE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 10&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ftm1fYhC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osxggn8ehr2jlb69roog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ftm1fYhC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osxggn8ehr2jlb69roog.png" alt="Image description" width="645" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon reading the sourcecode, it seems that they are checking the input using preg_match - a simple regex matching function for php.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UYKftqes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wns4v1bhzdymsybcayvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UYKftqes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wns4v1bhzdymsybcayvq.png" alt="Image description" width="439" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I won’t be able to use command injection anymore to just cat the file containing the password. Now we can try to attack the weakest thing there which is the part that lets us use user input! The key changes depending on what we input, for example, when using the search term ‘africa’ - grep searches for words that contain africa, and does it while ignoring cases due to the -i flag.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FriehZxm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s768fy3koamo8t52ozrr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FriehZxm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s768fy3koamo8t52ozrr.png" alt="Image description" width="408" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reading the grep man page, we can see that multiple files can be searched at once!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jwb4ZB7g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ekkk4fpjz7xfz5yn4u00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jwb4ZB7g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ekkk4fpjz7xfz5yn4u00.png" alt="Image description" width="711" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This means we can likely use grep to expose the password for us again by searching the /etc/natas_webpass/level11. However, since we’re using grep, we’ll need to use our input to try and guess letters in the password for it to spit it out. We’ll guess using a, so our input should look like&lt;br&gt;
Input:  a /etc/natas_webpass/level11&lt;br&gt;
We know that the grep input worked, as it is now specifying the files from which grep is pulling text from.&lt;br&gt;
Luckily, the password contained the letter ‘a’ so we are in!&lt;br&gt;
Pass for next level: &lt;strong&gt;1KFqoJXi6hRaPluAmk8ESDW4fSysRoIg&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I learnt&lt;/strong&gt;&lt;br&gt;
I have previously learnt about shell from one of my classes in university, but it was never used in an exploitative manner. Seeing these tools be used in this way taught me that even things designed to help people can be used in damaging ways. Something that has been taught to me in class is that developers should whitelist and not blacklist. Alot of these levels involve some form of blacklisting, and the vulnerability is in exploiting something that wasn't included in the blacklist.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Solving Natas Levels 4-6</title>
      <dc:creator>Joon Yoo</dc:creator>
      <pubDate>Tue, 31 Oct 2023 07:34:51 +0000</pubDate>
      <link>https://dev.to/joonhyoo/solving-natas-4-6-5e52</link>
      <guid>https://dev.to/joonhyoo/solving-natas-4-6-5e52</guid>
      <description>&lt;p&gt;&lt;strong&gt;Natas Level 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6rSbwzun--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bd1wkix9zwhupffmbjgm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6rSbwzun--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bd1wkix9zwhupffmbjgm.png" alt="Image description" width="643" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon opening the level, you see this. I was initially confused and refreshed the page, giving me a big hint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hznzBhQT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj3njdr894fipz8p95z0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hznzBhQT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj3njdr894fipz8p95z0.png" alt="Image description" width="653" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I thought for a bit, and wondered if there was some information being sent to the site that could inform it of my "previous website". I tried things like visiting google.com and then entering in the natas4 site which didn't work, and so that brought the idea that possibly some information is being directly sent to natas4. I did some googling and came across 'http refering' which made a lot of sense. I tried to figure out ways I could "give" natas4 a http referer, and I knew of curl which could help transfer data to the site and back without me having to download any extra tools. After a bit of googling and documentation reading, I learnt that the http referer could be sent in the request to a page like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--trVRlsCw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plefs61z9pxl1j1xqpdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--trVRlsCw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plefs61z9pxl1j1xqpdo.png" alt="Image description" width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After realising this worked, actually getting the password just required me to trial and error a bit to actually type in the natas5 link in properly.&lt;br&gt;
pass for next level: &lt;strong&gt;Z0NsrtIkJoKALBCLi5eqFfcRN82Au2oD&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When logging into natas 5, I was greeted with an "access denied, user not logged in" which was funny since I just had to enter in a password. But considering this was a puzzle, I got to thinking and considered what that message could possibly mean. Maybe I needed to log in somewhere, or maybe I needed to use different login credentials for this site which could be hidden in the page?? After going through a couple things, it almost felt like Jesus spoke to me "COOKIES, THE ANSWER IS COOKIES". I pondered it a bit, and then realised that cookies was likely part of the solution. I had never dealt with cookies properly before besides always pressing the reject all button, so as with almost every level before this: I went to google and seached some stuff up. Basically I wanted to know how I could see the cookies that were being sent to the page, and how I could send my own to the page (hopefully) using curl. Funnily enough, searching something along those lines basically gave me the answer as curl is quite a powerful tool. The -c and -b flags came in useful, -c showing me the cookies, and -b letting me send my own cookies.&lt;br&gt;
Using the -c flag, I found that the cookie name was "loggedin" and was set to a value of "0"&lt;br&gt;
&lt;code&gt;curl --user natas5:Z0NsrtIkJoKALBCLi5eqFfcRN82Au2oD -c - 'http://natas5.natas.labs.overthewire.org'&lt;br&gt;
&lt;/code&gt;Using the -b flag I set this value to 1 and sent it to the site&lt;br&gt;
&lt;code&gt;curl --user natas5:Z0NsrtIkJoKALBCLi5eqFfcRN82Au2oD -b "loggedin=1" 'http://natas5.natas.labs.overthewire.org'&lt;br&gt;
&lt;/code&gt;After sending in my very own cookie, curl basically just spat out the password&lt;br&gt;
pass for next level: &lt;strong&gt;fOIvE0MDtPTgRhqmmvvAOt2EfXR6uQgR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 6&lt;/strong&gt;&lt;br&gt;
This level was interesting, it opens up to a page with a new format. An input secret button. After clicking the button to open the source code I saw some html and this mystery langauge. The actual solution wasn't complex, &lt;br&gt;
but I did scratch my head trying to figure out what language the input secret button was written in, turns out the html tag &lt;code&gt;&amp;lt;? ?&amp;gt;&lt;/code&gt; was for php and I went into a rabbit hole trying to determine what that meant, but as it turns out - it was a red herring and I needed to look at the include statement, which I seem to always forget means that there is a filesystem available.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ag50uDo7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1z9md5tt9gw5y5lfby42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ag50uDo7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1z9md5tt9gw5y5lfby42.png" alt="Image description" width="574" height="192"&gt;&lt;/a&gt;&lt;br&gt;
Upon accessing the includes/secret.inc path, it spits out a secret that I can enter on the home page and get the password to the next level!&lt;br&gt;
pass for next level: &lt;strong&gt;jmxSiH3SP6Sonf8dv66ng8v1cIEdjXWr&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I Learnt&lt;/strong&gt;&lt;br&gt;
I'm kind of shocked at how much a "game" can teach me about the web. Before I did these levels, I only had vague ideas of cookies and curl as a cli. Now, although I wouldn't say I'm a pro by any means, I have more confidence in searching/reading documentation on how to use tools and understanding simple web structure. Once I was in the groove of thinking like an attacker and trying to "abuse" the site, I found it easier to keep trying different things and found a hunger for information that could help me solve the puzzle.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Solving Natas Levels 0-3</title>
      <dc:creator>Joon Yoo</dc:creator>
      <pubDate>Tue, 31 Oct 2023 06:59:55 +0000</pubDate>
      <link>https://dev.to/joonhyoo/solving-natas-level-0-3-3310</link>
      <guid>https://dev.to/joonhyoo/solving-natas-level-0-3-3310</guid>
      <description>&lt;p&gt;Hello all! This is a series of blog posts outlining my solutions to the "OverTheWire" wargame Natas. I'll also be adding my thoughts/things I learnt after each level, so hopefully there's more to learn than just how to capture the flag :D&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 0&lt;/strong&gt;&lt;br&gt;
This was an introductory problem and solving it just requires you "inspect element" the page. The password is hidden as a html comment.&lt;br&gt;
pass for next level: &lt;strong&gt;g9D9cREhslqBKtcA2uocGHPfMZVzeFK6&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 1&lt;/strong&gt;&lt;br&gt;
Following similar ideas, except now right clicking was blocked. Using the F12 shortcut to open the dev tools revealed the password as a html comment like last time.&lt;br&gt;
pass for next level: &lt;strong&gt;h4ubbcXrWqsTo7GGnnUMLppXbOogfBZ7&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 2&lt;/strong&gt;&lt;br&gt;
This level is a bit trickier than the last two, but all you need to know is that the image is a big hint. It reveals that there is a file system that can be routed to. The path of the image was from /files, so by accessing the /files route, a text document is revealed containing the password to the next level.&lt;br&gt;
pass for next level: &lt;strong&gt;G6ctbMJ5Nb4cbFwhpMPSvxGHhQ7I6W8Q&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Natas Level 3&lt;/strong&gt;&lt;br&gt;
This level hints at how the site might be hidden from a search engine. After some research, I learnt about robot meta tags which could instruct search engines to not show the page, but as mentioned previously: "Header info isn't part of the solution". Flowing off this tangent, I searched about robot meta tags and came across robots.txt files which store user agents and can enforce certain user rules. In this case there was a wild card user agent dissallowing the /s3cr3ts route. Upon visiting this route, the password is made available.&lt;br&gt;
pass for next level: &lt;strong&gt;tKOcJIbzM4lTs8hbCmzn5Zr4434fGZQm&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I learnt&lt;/strong&gt;&lt;br&gt;
These were the introductory problems, so I didn't have too much issue solving them - though I did learn about file systems and the robot meta tag/txt files! It was interesting to see how simple things can become vulnerabilities.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
