<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>WriteUp on Kartone's Reversing Garage</title><link>https://blog.kartone.ninja/tags/writeup/</link><description>Recent content in WriteUp on Kartone's Reversing Garage</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 28 Jun 2018 10:27:23 +0000</lastBuildDate><atom:link href="https://blog.kartone.ninja/tags/writeup/index.xml" rel="self" type="application/rss+xml"/><item><title>Vulnhub Homeless - Writeup</title><link>https://blog.kartone.ninja/writeup/</link><pubDate>Thu, 28 Jun 2018 10:27:23 +0000</pubDate><guid>https://blog.kartone.ninja/writeup/</guid><description>&lt;p&gt;This writeup covers the Vulnhub CTF machine named &lt;a class="link" href="https://www.vulnhub.com/entry/homeless-1,215/" target="_blank" rel="noopener"
&gt;Homeless&lt;/a&gt; by &lt;a class="link" href="http://l33thacker.com/" target="_blank" rel="noopener"
&gt;Min Ko Ko&lt;/a&gt;. Honestly this was a hard box and I had a hard time with some really nasty tricks but finally, I learned a lot. Seriously, a lot.&lt;/p&gt;
&lt;p&gt;After booting up victim box and kali, initial phase, as always, is discovering the box:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*TOwUTPllTCg5Ht205mFr6A.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Discovering box&lt;/p&gt;
&lt;p&gt;Box had from my DHCP server address &lt;strong&gt;172.16.10.127&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Mapping some ports:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*JS-Qb8JkC8KaY-5c4fsqDQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Scanning for open ports&lt;/p&gt;
&lt;p&gt;Nothing too much interesting, standard HTTP port and SSH port. What seems interesting is the robots.txt that gives some clue about a special wordlist that eventually will be used in the next phases. But, trust me, we are very far from there right now. :-)&lt;/p&gt;
&lt;p&gt;So, time to open up our browser and give a look around. What caught my attention is that somewhere on the page is rendered our browser User-Agent header:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*VuCjmWFnKTsX14bfLojZqg.png"
loading="lazy"
&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*QzF423KoCBiSSZA9WrDY6g.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;So, instantly, what comes to mind is Shellshock! Sadly I spent two entire days poking around with every single point of injection trying to take advantage of this bug but nothing showed up. Literally nothing. :-\&lt;/p&gt;
&lt;p&gt;So I went brutal and I downloaded every single piece of this website and analyzed every single evidence. Very much time but, in the end, well spent:&lt;/p&gt;
&lt;p&gt;This small file, &lt;strong&gt;favicon.jpg&lt;/strong&gt;, it’s not the usual one.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*_2FxLbePvd5TRcG_xL-Dew.png"
loading="lazy"
&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*L1lNxLaM3vOvMcqXWNM3DQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Another big trick. What’s this image? What’s his purpose? Again I spent another day analyzing this image without any luck…after a while I tried to insert what is written in that caption “Cyberdog Sledding Portal” inside the User-Agent header and…&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*G9Jx9GXkTlIAjHrMRWoXiQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;So, this little bastard was expecting some password to open it up. Again, bastard!&lt;/p&gt;
&lt;p&gt;Back on track again, we need to go to another location: /myuploader_priv. Seems pretty easy uh? Upload a PHP reverse shell and we go in. Sadly, for the second time, no:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*zwxQlB7FJ-hUn709E-blEQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;I tried to upload every kind of files, of every size, tried changing every single header but nothing. Every file I tried to upload was always too large. I went manually and tried to upload files containing one, two, three characters and so I was able to get the max allowed file size that is 8 BYTES. Seriously? What the f**ck is supposed to mean? No way to upload PHP shells or reverse shells because, as far as I know, the smallest code execution snippet is this: &lt;?=`$_GET[1]`?&gt;. No way to fit in this ridiculously 8 bytes limit. So, how we can step forward? Simple, manually.&lt;/p&gt;
&lt;p&gt;So, I found that the only commands we can execute are limited to two characters long, so with &amp;lt;?=’ls’ inside a file named sploit.php we found:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*l29CgWr1UIbeXRmPGq9uVQ.png"
loading="lazy"
&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*mETweNedGYd0khHRmI_DrA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;That was hard.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*9WCU2xpce_57HFXipdyv7A.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;But nothing compared to this:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*SWNngAiPFAIa_0Ugk7FrPQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Ok, I really need a hint :-|&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*Ar-I86_xxW-nmnKcca3iEQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;After checking this login form and, in particular, that piece of code I really wanted to die.&lt;/p&gt;
&lt;p&gt;How can I suppose to break this one?&lt;/p&gt;
&lt;p&gt;Another three days passed and I was asking for some help on every single social media I had. Thanks to &lt;a class="link" href="https://twitter.com/devl00p" target="_blank" rel="noopener"
&gt;this guy&lt;/a&gt; that pointed me in this right direction, I found &lt;a class="link" href="https://github.com/thereal1024/python-md5-collision" target="_blank" rel="noopener"
&gt;this&lt;/a&gt; useful python script that can generate md5 collisions.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*gmpuG38oK9_dE0EVA1X3KA.png"
loading="lazy"
&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*1H3BgTb1nEt57MN6h7KvpA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;But, yeah, it’s not that easy, right?&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*-ufeGkYLaRnHxOqF8m7syg.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;They’re binary and we can’t send them directly to the HTTP form without encoding problems that, essentially, will break the md5 signature…&lt;/p&gt;
&lt;p&gt;Maybe we can try to encode them:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*UXGlMKFq69bne3VOp2eQgw.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;And send them to their good form:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*K1rny6MLK1pYOxBT9LqeXA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Please, kill me and give me flag…not now:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*9DWMcnn9NfUB0wvHIdrsFA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Basically we have a command execution form:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*t1SJNjRLN7KqnVoUpQLUyA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;So we can have a shell via netcat. Luckily we have a good version of it:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*-l_ES9ZomzyVPqf_wxNFjQ.png"
loading="lazy"
&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*d_JQNlqHH31xlz31XXONFA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;And from now on, it’s pretty easy. Standard usual enumerating stuff:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*ya3ITqshay-QBN2AzFL1SA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;We have a username and we have a good wordlist: Rockyou.txt so we can brute force it. Sadly this was long, very long. But finally we had a shot:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*7HzxQhCJlN1gXOtyhU8vQQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;We can now have a real shell with lowpriv access:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*a1owys1JQ3Lkf9yxpfr3QQ.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Found and fixed a cronjob and modified it to send back a python reverse shell with root privileges:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*Xp466GDjNKcLGOGdSpk7vQ.png"
loading="lazy"
&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*3rgdG6yqUnf1i4HJTypghA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;And finally:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://cdn-images-1.medium.com/max/1600/1*NASfTsLDgZGoR0a9vW1roA.png"
loading="lazy"
&gt;&lt;/p&gt;
&lt;p&gt;Finally a Victory&lt;/p&gt;
&lt;p&gt;Yeah. Try Harder.&lt;/p&gt;</description></item></channel></rss>