<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Henry Lonborg on Medium]]></title>
        <description><![CDATA[Stories by Henry Lonborg on Medium]]></description>
        <link>https://medium.com/@henlon30?source=rss-2b20cc7dee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jSeqCeONHh-VAhNA.</url>
            <title>Stories by Henry Lonborg on Medium</title>
            <link>https://medium.com/@henlon30?source=rss-2b20cc7dee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 01:00:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@henlon30/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Clients, Servers, and Sockets]]></title>
            <link>https://medium.com/@henlon30/clients-servers-and-sockets-6a4ea50e3eb7?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a4ea50e3eb7</guid>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Mon, 02 Apr 2018 12:10:58 GMT</pubDate>
            <atom:updated>2018-04-02T12:10:58.691Z</atom:updated>
            <content:encoded><![CDATA[<p>This week we learned about sockets, hosting servers, and connecting to them through Python, with the use of the socket library. The socket library allows you to host servers, connect to them, and transfer data through them, all in Python. To begin with — what even is a socket? A socket is the endpoint of a connection between a client a server — essentially, where both machines (or threads from one machine) go to mingle and interact. A socket is located at a specific IP and port, which you <strong><em>bind </em></strong>to it. Therefore, in order to <strong><em>connect</em></strong> to that same socket, you need to specify that the IP and port you’re connecting to are the same as the ones you initially bound that socket to. To get a better idea of how they interact, we can create a basic server &amp; client combination.</p><p>In order to do so, you’ll want to create 2 separate documents, server.py and client.py, and open 2 separate terminal windows.</p><p>Now, in each of the files, you’ll want to import the socket library. In addition, we’ll want to use the randint function later on, so we’ll import that as well</p><pre>import socket<br>from random import randint</pre><p>This comes with several basic functionalities in regards to sockets — creating a socket object, binding the socket to an ip &amp; port, listening for incoming traffic, sending traffic, and recieving traffic, among others.</p><p>We’l start with server.py:</p><p>To begin with, we’ll need to create a socket object using</p><pre>socketName = socket.socket()</pre><p>and bind it to an IP and port using</p><pre>socketName.bind((&#39;127.0.0.1&#39;, 9999))</pre><p>You can replace the IP and port with your own numbers — the only thing to note is that 127.0.0.1 is your localhost, so if you want to create a socket on your own machine that’s the IP you’ll want to use.</p><p>After binding our socket to an ip an port, we need to listen for incoming connections, so we use</p><pre>socketName.listen()</pre><p>This sets our socket to listen for incoming connections. Inside the parentheses you can specify a backlog — a number of unaccepted connections to allow through before disregarding new connections altogether — but it is not required.</p><p>From here, we can move on into the meat of our code — our loop. This loop will continue to run and allow incoming connections until we give it a specific condition to stop.</p><p>Our loop, after we’re done, will look like this:</p><pre>while True:<br>   connection, addr = socketName.accept()<br>   print(&quot;Connection from: %s&quot; % str(addr))<br>   dataIn = connection.recv(1024)<br>   stringIn = dataIn.decode()<br>   print(&quot;User&#39;s question: %s&quot; % stringIn)<br>   answers = [&quot;Definitely Yes.&quot;, &quot;Maybe?&quot;, &quot;Probably No.&quot;]<br>   selector = randint(0, 2)<br>   stringOut = answers[selector]<br>   print(&quot;Answering: %s&quot; % stringOut)<br>   dataOut = stringOut.encode()<br>   connection.send(dataOut)<br>   connection.close()</pre><p>This while loop will continue to run until an error is thrown, as we haven’t set a condition where it will end. As such, it will continue to run until there is an error or you close the program. If you want there to be a condition where you’ll exit the loop, you can add one by using an if statement with break inside of it to break out of the loop when a condition is met.</p><p>Now let’s break it down line by line:</p><pre>   connection, addr = socketName.accept()</pre><p>will attempt to accept a connection, and store the connection under 2 separate variables: connection, and addr. connection stores the connection itself, and addr stores who the connection is from.</p><pre>   print(&quot;Connection from: %s&quot; % str(addr))</pre><p>prints who the connection is from.</p><pre>   dataIn = connection.recv(1024)</pre><p>recieves data from the connection you’ve made, up to a maximum size of 1024 bytes. The flag under connection.recv() is known as bufsize, and is used to specify the maximum size of incoming data in bytes. It’s generally kept as a power of 2, and due to hardware limitations it’s usually capped out at 4096 at max.</p><pre>   stringIn = dataIn.decode()</pre><p>because the incoming data is in the form of bytes, we need to convert it to a string in order to make it human readable.</p><pre>   print(&quot;User&#39;s question: %s&quot; % stringIn)</pre><p>This prints out on the server’s side what the user’s question was.</p><pre>   answers = [&quot;Definitely Yes.&quot;, &quot;Maybe?&quot;, &quot;Probably No.&quot;]</pre><p>This creates a set of 3 different possible answers that the magic 8 ball will choose from, using</p><pre>   selector = randint(0, 2)</pre><p>to create an index value to call, storing it with</p><pre>   stringOut = answers[selector]</pre><p>We then print out on the server’s side what the response is:</p><pre>   print(&quot;Answering: %s&quot; % stringOut)</pre><p>Then, we encode our response, packaging it to be sent on its merry way, with</p><pre>dataOut = stringOut.encode()</pre><p>Finally, we send it off using</p><pre>connection.send(dataOut)</pre><p>before closing the connection with</p><pre>connection.close()</pre><p>As stated earlier, this loop will continue to run forever until you close the program, so you can ask it as many questions as you like.</p><p>In total, the code for server.py is</p><pre>import socket<br>from random import randint</pre><pre>socketName = socket.socket()<br>socketName.bind((&#39;127.0.0.1&#39;, 9999))<br>socketName.listen()</pre><pre>while True:<br>   connection, addr = socketName.accept()<br>   print(&quot;Connection from: %s&quot; % str(addr))<br>   dataIn = connection.recv(1024)<br>   stringIn = dataIn.decode()<br>   print(&quot;User&#39;s question: %s&quot; % stringIn)<br>   answers = [&quot;Definitely Yes.&quot;, &quot;Maybe?&quot;, &quot;Probably No.&quot;]<br>   selector = randint(0, 2)<br>   stringOut = answers[selector]<br>   print(&quot;Answering: %s&quot; % stringOut)<br>   dataOut = stringOut.encode()<br>   connection.send(dataOut)<br>   connection.close()</pre><p>However, this is just the server side. Now we need to write the code for the client side! This code is simpler, but still worth showing in its own right.</p><p>Here’s the code for client.py:</p><pre>import socket<br>while True:<br>   socketName = socket.socket()<br>   socketName.connect((&#39;127.0.0.1&#39;, 9999))<br>   userQuestion = input(&quot;Ask the magic 8 ball a question: &quot;)<br>   dataOut = userQuestion.encode()<br>   socketName.send(dataOut)<br>   dataReply = socketName.recv(1024)<br>   stringReply = dataReply.decode()<br>   print(&quot;Your answer is: %s&quot; % stringReply)<br>   socketName.close()</pre><p>Again, there’s no end condition, so the only way out is to manually stop it from running. This will continue to allow you to ask questions until you want to stop.</p><p>To run them, first run server.py, and then client.py</p><p>Now you have a magic 8 ball that you can ask questions of until it bores you! No need to worry about it quitting first.</p><p>This is among the most basic of servers that you could make — the practical applications are endless. Everything on the internet is based off of the interactions between clients and servers, which in turn means that everything is based off of sockets. The possibilities are limitless! IRCs, music streaming services, social media sites, everything is based off of sockets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a4ea50e3eb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hawaii Computer Science Walk-Around]]></title>
            <link>https://medium.com/@henlon30/hawaii-computer-science-walk-around-5b2c90755620?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b2c90755620</guid>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Wed, 28 Mar 2018 22:46:39 GMT</pubDate>
            <atom:updated>2018-03-28T22:46:39.469Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we went around the offices of various legislators to discuss bills HB 2607 HD1 SD1 and SB 2507 SD2. These bills are intended to create a computer science education sector of the Hawaii DOE and mandate that all public high schools offer at least one computer science course per year, in addition to creating a method for current teachers to get certification to teach computer science and appropriating some funds to fund these efforts as well as already existing computer science programs.</p><p>For my part, I rather enjoyed the experience — it was interesting meeting the various legislators and learning more about the people who keep Hawaii’s government running while helping to lobby for a bill that I’d be glad to see passed. I wouldn’t actively seek out opportunities to go lobby for bills, but if there’s future bills that I’m interested in seeing passed I certainly wouldn’t shy from a repeat of today’s events.</p><p>To me, much as this process seems very bureaucratic, I can’t think of a more efficient way to show support for a bill that you’d like passed than to go and talk to the legislators and show them that the bill is needed. Representative Woodson in particular said that with so many bills flying around the capitol, it’s easy for a particular one to get lost in the noise, especially if no one puts a face to the bill. Many of the other legislators said similar things, and it’s shown me that if you’re trying to pass anything through the government, or any other organization with a lot of bureaucracy, you need to strongly show support and do your best to attach faces to whatever you’re trying to push — when someone’s job is to deal with a constant flow of similar information and requests, one can only imagine that they eventually start to blend together, and that you will be lost and invisible to them if you don’t distinguish yourself from the crowd and make them care about you.</p><p>The bill won’t affect me, as I’m a senior and by the time this bill is effective (should it be passed) I’ll already be out of high school, however I still care about this bill being passed. I enjoy computer science, and I feel like many students currently are missing out on something that could become a lifelong passion for them, or open the door to a brighter future. To me, that’s a bit saddening. I’m no saint, but I have no ill will towards my peers, and it makes me happy to know that I’ve helped open doors for those who will come after me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b2c90755620" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nebula Level 06]]></title>
            <link>https://medium.com/@henlon30/nebula-level-06-369a834449b7?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/369a834449b7</guid>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Fri, 16 Feb 2018 22:17:15 GMT</pubDate>
            <atom:updated>2018-02-21T19:14:48.705Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description:</h4><p>The <strong>flag06</strong> account credentials came from a legacy unix system.</p><p>To do this level, log in as the <strong>level06</strong> account with the password <strong>level06</strong>. Files for this level can be found in /home/flag06.</p><h4>Solutions:</h4><p>The flag06 account’s credentials came from an outdated system, which had encrypted passwords stored under /etc/passwd. In modern systems, encrypted passwords are stored under /etc/shadow, which, unlike /etc/passwd, doesn’t allow users to access it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*RMYadVHakZXVcrJIZSWAuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*65r08NQeZ3oe25kAy8WFjg.png" /></figure><p>This shows us that the encrypted password is ueqwOCnSGdsuM. Now we need to decrypt it using a tool such as johntheripper. You can install johntheripper on ubuntu, or alternatively it comes as a default tool on kali. This will show how to use it with kali.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*ABsRfSpImy3izWYk0lYNyw.png" /></figure><p>Echo the whole line with the encrypted password into a txt file, and then run john --show yourtxt.txt</p><p>upon running john, we can now see that the password was hello.</p><p>Now we can take that information, return back to our nebula system, and ssh into flag06.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*ifCY_qofuFQHCYO7yAHe6w.png" /></figure><p>Now run getflag, and you’re done with the level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=369a834449b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nebula Level 05]]></title>
            <link>https://medium.com/@henlon30/nebula-level-05-8457f96e1c1b?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/8457f96e1c1b</guid>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Wed, 14 Feb 2018 22:53:53 GMT</pubDate>
            <atom:updated>2018-02-14T22:53:53.210Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description:</h4><p>Check the <strong>flag05</strong> home directory. You are looking for weak directory permissions</p><p>To do this level, log in as the <strong>level05</strong> account with the password <strong>level05</strong>. Files for this level can be found in /home/flag05.</p><h4>Solution:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*IaJRBCAAiIdELVZBGY0HTw.png" /></figure><p>We start by changing directory to /home/flag05 like directed. Then, we take an ls -la. As you can see, all of the files are hidden, so we want to use -a, and since we want to see the directory permissions we use -l. There are only 2 folders here that are actually unique — .ssh and .backup. Between the 2, we only have access to .backup, so we cd into it. Upon taking an ls in this new location, we see a zip file of what appears to be a backup of something. It’s a backup of the SSH key, which we can use to ssh into flag05! We can unzip the backup using the tar command, with the modifiers of e<strong>x</strong>tract, gun<strong>z</strong>ip, <strong>v</strong>erbose, and <strong>f</strong>ile. these will allow you to specify a file to be extracted with the gunzip protocol, and will tell you the files that get moved as they get moved. At the end of that put -C /home/level05 to specify that it should be extracted into /home/level05 rather than your current location. Keep in mind, you <strong>have</strong> to extract it to level05’s <strong>home directory</strong>. The ssh key belongs to flag05, and it being under your home directory is what allows you ssh into flag05. Once you’ve extracted the contents of the file into /home/level05, ssh into flag05@localhost. You’ll be given access, and now you can run getflag to claim your flag.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8457f96e1c1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nebula Level 04]]></title>
            <link>https://medium.com/@henlon30/nebula-level-04-736641385562?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/736641385562</guid>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Fri, 09 Feb 2018 23:03:02 GMT</pubDate>
            <atom:updated>2018-02-09T23:03:02.683Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description:</h4><p>This level requires you to read the <strong>token</strong> file, but the code restricts the files that can be read. Find a way to bypass it :)</p><p>To do this level, log in as the <strong>level04</strong> account with the password <strong>level04</strong>. Files for this level can be found in /home/flag04.</p><h4>Solution:</h4><p>The code for flag04 is as follows:</p><pre><em>#include &lt;stdlib.h&gt;</em> <br><em>#include &lt;unistd.h&gt;</em> <br><em>#include &lt;string.h&gt;</em> <br><em>#include &lt;sys/types.h&gt;</em> <br><em>#include &lt;stdio.h&gt;</em> <br><em>#include &lt;fcntl.h&gt;</em>  <br>int <strong>main</strong>(int argc, char <strong>**</strong>argv, char <strong>**</strong>envp) {<br>   char buf[1024];<br>   int fd, rc;</pre><pre>   if(argc <strong>==</strong> 1) {<br>       printf(&quot;%s [file to read]\n&quot;, argv[0]);<br>       exit(EXIT_FAILURE);<br>   }    </pre><pre>   if(strstr(argv[1], &quot;token&quot;) <strong>!=</strong> NULL) {<br>       printf(&quot;You may not access &#39;%s&#39;\n&quot;, argv[1]);<br>       exit(EXIT_FAILURE);<br>   }    </pre><pre>   fd <strong>=</strong> open(argv[1], O_RDONLY);</pre><pre>   if(fd <strong>==</strong> <strong>-</strong>1) {<br>       err(EXIT_FAILURE, &quot;Unable to open %s&quot;, argv[1]);<br>   }</pre><pre>   rc <strong>=</strong> read(fd, buf, sizeof(buf));</pre><pre>   if(rc <strong>==</strong> <strong>-</strong>1) {<br>       err(EXIT_FAILURE, &quot;Unable to read fd %d&quot;, fd);<br>   }</pre><pre>   write(1, buf, rc);<br>}</pre><p>This is a sizable chunk of code to read through to find one vulnerability, but in the end it just comes down to this process:</p><p>if the user doesn’t set a file to read, show them the proper syntax</p><p>if the file the user wants to read has “token” in its name, tell the user that they can’t access that file</p><p>if there is an error in reading the file, tell the user that you’re unable to read the file.</p><p>Otherwise, write out the contents of the file.</p><p>The vulnerability is that the only thing checking to make sure that you’re not reading into the token file is a check against the name of the file. You can create a symlink to the token file, and so long as the name of the file you’re symlinking from doesn’t have “token” in it, you’ll be able to read the contents of the token file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*XnDj-SnZGm1wAc_v3e8LsA.png" /></figure><p>use ln -s to make a symlink to a new file “taken”. then, use ./flag04 to read the new “taken” file. Following that, use su to switch into the flag04 account using the contents of “taken” as the password, and then run getflag.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=736641385562" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nebula Level 03]]></title>
            <link>https://medium.com/@henlon30/nebula-level-03-b793f01a8c16?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b793f01a8c16</guid>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Fri, 09 Feb 2018 21:42:17 GMT</pubDate>
            <atom:updated>2018-02-09T21:42:17.636Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description:</h4><p>Check the home directory of <strong>flag03</strong> and take note of the files there.</p><p>There is a crontab that is called every couple of minutes.</p><p>To do this level, log in as the <strong>level03</strong> account with the password <strong>level03</strong>. Files for this level can be found in /home/flag03.</p><h4>Solution:</h4><p>writable.sh gets ran every few minutes by the cronjob</p><p>contents of writable.sh:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*nnoLapjbEYgs-8gsIos_nQ.png" /></figure><p>writable.sh will run all executable files in the writable.d directory, however immediately after that it will delete them, along with any other files in the directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*ftQuoRDFjnS0BtRAzeHRmw.png" /></figure><p>in addition, ls -l shows us that writable.sh is both owned and executed by flag03, which means that the way to beat the level is probably to get writable.sh to run getflag somehow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*122lwTHhgv2YKDFyV-MB0w.png" /></figure><p>writable.sh runs as flag03, so just make a file that runs getflag and pipes the output to a separate file under /tmp. The cronjob will run it, and you’ll have the flag.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b793f01a8c16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nebula Level 02]]></title>
            <link>https://medium.com/@henlon30/nebula-level-02-9659571da74?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/9659571da74</guid>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Wed, 07 Feb 2018 23:29:31 GMT</pubDate>
            <atom:updated>2018-02-09T20:41:52.551Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description:</h4><p>There is a vulnerability in the below program that allows arbitrary programs to be executed, can you find it?</p><p>To do this level, log in as the level02 account with the password level02. Files for this level can be found in /home/flag02.</p><h4>Solution:</h4><p>Similar to previous level but a little different.</p><p>Draws from $USER rather than $PATH, and there’s an intermediary buffer, along with several other things</p><p>the flag02 file, located under /home/flag02 prints ‘about to call system(“/bin/echo level02 is cool”)’, followed by ‘level02 is cool’</p><p>the file is:</p><pre><em>#include &lt;stdlib.h&gt;</em> <br><em>#include &lt;unistd.h&gt;</em> <br><em>#include &lt;string.h&gt;</em> <br><em>#include &lt;sys/types.h&gt;</em> <br><em>#include &lt;stdio.h&gt;</em>  <br>int <strong>main</strong>(int argc, char <strong>**</strong>argv, char <strong>**</strong>envp) {<br>   char <strong>*</strong>buffer;</pre><pre>   gid_t gid;<br>   uid_t uid;</pre><pre>   gid <strong>=</strong> getegid();<br>   uid <strong>=</strong> geteuid();</pre><pre>   setresgid(gid, gid, gid);<br>   setresuid(uid, uid, uid);</pre><pre>   buffer <strong>=</strong> NULL;</pre><pre>   asprintf(<strong>&amp;</strong>buffer, &quot;/bin/echo %s is cool&quot;, getenv(&quot;USER&quot;));<br>   printf(&quot;about to call system(\&quot;%s\&quot;)\n&quot;, buffer);</pre><pre>   system(buffer); <br>}</pre><p>using ls -l, we see</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*OdeYBeRnU0DlI1kdUALjhg.png" /></figure><p>similar to last level, this file is owned by flag02 and ran as flag02. Therefore, if we can find a way for system(buffer) to run the getflag command, we’ll have made it through.</p><p>However, unlike last level, there’s a problem: there’s already a separate command in buffer that we can’t meddle with. buffer = “/bin/echo %s is cool”, and /bin/echo will make everything after it into a string, so we can’t just have it run a file we want because it will be turned into a string.</p><p>For now though, let’s create a similar file to the “echo” from level01:</p><pre>echo “getflag” &gt; /tmp/level02</pre><p>and make sure that it can be executed:</p><pre>chmod +x /tmp/level02</pre><p>now, let’s try to get ./flag02 to run it.</p><p>if you set USER=/tmp/level02, it won’t work as echo will override /tmp/level02 and turn it into a string. The output you get is “/tmp/level02 is cool”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*c_JbGT4b424qXl7SKMk9dw.png" /></figure><p>In order to run /tmp/level02 like we want to, we need some way to break it away from the /bin/echo that precedes it so that it will run… how about semicolons?</p><p>USER=;/tmp/level02; does not work, it tells you that “getflag is executing on a non-flag account, this doesn’t count” when you first set USER equal to it, and when you run ./flag02 the buffer is left blank.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*ohuihkkRBsfiFEgZkEaaWA.png" /></figure><p>It seems to break because it’s interpreting ;/tmp/level02; as an attempted command, so what if we put it in quotes, to make sure that it’s read as setting USER equal to a string?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*Xam3TuZjpdE68V0UHLrLng.png" /></figure><p>USer=”;/tmp/level02;” works, and earns you the flag. There’s an error message saying that “is” is not recognized as a command, but that’s due to breaking the command into 3 pieces, with the last piece not being a valid command.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9659571da74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nebula Level 01]]></title>
            <link>https://medium.com/@henlon30/nebula-level-01-a6cb4dc19245?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6cb4dc19245</guid>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Wed, 07 Feb 2018 23:29:15 GMT</pubDate>
            <atom:updated>2018-02-09T20:20:10.765Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description:</h4><p>There is a vulnerability in the below program that allows arbitrary programs to be executed, can you find it?</p><p>To do this level, log in as the level01 account with the password level01. Files for this level can be found in /home/flag01.</p><h4>Solution:</h4><p>there is a file, flag01, nestled inside the /home/flag01 directory, which is the key to this level.</p><p>using ls -l, we see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*bYKwUb7uv2QZsrTXp6o6Ow.png" /></figure><p>which shows that the file is owned by flag01, but can be executed by level01.</p><p>If we try running the file, all we get is an output saying “and now what?”</p><p>However, if we go to the nebula site, we can view the contents of the file, and see that there is more to it than that.</p><pre><em>#include &lt;stdlib.h&gt;</em> <br><em>#include &lt;unistd.h&gt;</em> <br><em>#include &lt;string.h&gt;</em> <br><em>#include &lt;sys/types.h&gt;</em> <br><em>#include &lt;stdio.h&gt;</em>  </pre><pre>int <strong>main</strong>(int argc, char <strong>**</strong>argv, char <strong>**</strong>envp) {<br>   gid_t gid;   uid_t uid;<br>   gid <strong>=</strong> getegid();<br>   uid <strong>=</strong> geteuid();</pre><pre>   setresgid(gid, gid, gid);<br>   setresuid(uid, uid, uid);</pre><pre>   system(&quot;/usr/bin/env echo and now what?&quot;); <br>}</pre><p>Inside the file, there’s an echo function that doesn’t seem to be doing anything for the current moment.</p><p>Because it echos under system(“”), if we can get “echo” to echo whatever we want, we can use it to pipe in the getflag command, which will be considered to have been run by flag01.</p><p>The echo function gets its path from PATH under /usr/bin/env, which can be abused:</p><p>currently,</p><pre>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</pre><p>however, you can run PATH=/tmp:$PATH to prepend /tmp: to the list of function locations, allowing us to create a function under tmp that ./flag01 will run as flag01.</p><p>now,</p><pre>PATH=/tmp:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</pre><p>the file runs an “echo” function, so we create a new echo function under tmp that will be ran:</p><pre>echo &quot;getflag&quot; &gt; /tmp/echo</pre><p>after doing so, we run</p><pre>chmod +x /tmp/echo</pre><p>in order to allow ./flag01 to execute the file.</p><p>upon running ./flag01, the new echo command pushes “getflag” into the file, resulting in ‘system(“getflag and now what?”)’ being ran, which will run getflag and earn us the flag.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6cb4dc19245" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nebula Level 00]]></title>
            <link>https://medium.com/@henlon30/nebula-level-00-aa6f1defafae?source=rss-2b20cc7dee------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa6f1defafae</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Henry Lonborg]]></dc:creator>
            <pubDate>Wed, 07 Feb 2018 23:29:01 GMT</pubDate>
            <atom:updated>2018-02-09T19:52:02.431Z</atom:updated>
            <content:encoded><![CDATA[<h4>Description:</h4><p>This level requires you to find a Set User ID program that will run as the “flag00” account. You could also find this by carefully looking in top level directories in / for suspicious looking directories.</p><p>Alternatively, look at the find man page.</p><h4>Solution:</h4><p>Use the find command to search the machine for an executable command with the Set User ID permission.</p><p>A SUID (<strong>S</strong>et <strong>U</strong>ser <strong>ID)</strong> bit runs a file as the owner of the file, rather than as the user who runs the file. Normally you see read, write, and execute permissions represented as 000–777, however a file with a SUID bit will be represented as 4000–4777. The 4 prepended to the 000–777 indicates that it has a SUID bit.</p><p>When finding a file with certain permissions, there are 3 filters you can use for permissions:</p><ol><li>-perm 777 finds all files with permissions <em>exactly </em>matching 777</li><li>-perm -777 finds all files with permissions of <em>at least </em>777</li><li>-perm /777 finds all files with permissions with a matching value in <em>at least</em> one of the 3 categories (r, w, x)</li></ol><p>more information on using permissions with find: <a href="http://www.tutonics.com/2012/12/find-files-based-on-their-permissions.html">http://www.tutonics.com/2012/12/find-files-based-on-their-permissions.html</a></p><p>We don’t know any of the permissions of the file we want to find aside from that it has an SUID bit, so we’ll search for files with an SUID bit and <em>at least</em> 000 for read, write, and execute. In addition, we’ll be sure to pipe standard error into /dev/null to clear up the garbage results.</p><p>find -executable -perm -4000 2&gt;/dev/null</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*WPwYpsnFA2C_gdb3xG_KjA.png" /><figcaption>Still many garbage results, even after filtering — the file you want is /rofs/bin/…/flag00</figcaption></figure><p>./rofs/bin/…/flag00</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*sZ0Hj-jC9TJXa3L6V4qTCA.png" /><figcaption>running flag00 changes you to user flag00, allowing you to run getflag</figcaption></figure><p>now run getflag to claim your flag.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa6f1defafae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>