Bibliotheque
DiscordHackTheBoxTryHackMeGitHub
  • Welcome wanderer
    • Bibliotheque
    • Hacking Philosophy
    • Useful Links
  • PENTESTING
    • Methodology
    • Protocols
      • FTP
      • SMB
      • NFS
      • SSH
      • RDP
      • SMTP
      • IMAP / POP3
      • RSYNC
      • SNMP
      • IPMI
      • R-Services
      • WinRM
      • WMI
      • LDAP
    • Databases
      • MySQL
      • MSSQL
      • Oracle TNS
      • PostgreSQL
    • File Transfers
      • Windows
      • Linux
      • Code
      • Misc
    • Password Attacks
      • John The Ripper
      • Hashcat
    • Docker
  • TOOLS
    • Nmap
    • Metasploit
    • BloodHound
    • Other
  • Linux
    • Theory
    • Commands and Utilities
      • Useful Commands
    • Bash Scripting
    • Post-Exploitation
      • Cred Hunting
      • Pivoting
  • WINDOWS
    • Theory
      • Security
    • Commands and Utilities
    • PowerShell
    • Post-Exploitation
      • Tools
      • Enumeration
        • System
        • Network
        • Users
        • Groups
        • Processes / Services
        • Permissions
        • Defence
        • Programs
        • Files
      • Access
      • Pivoting
      • Cred Hunting
    • Privilege Escalation
      • Privileges
      • Built-In Groups
        • Backup Operators
        • Server Operators
        • Print Operators
        • DnsAdmins
        • Event Log Readers
      • Privilege Abuse
        • Potatoes
        • SeDebugPrivilege
        • SeTakeOwnershipPrivilege
      • MISC
        • UAC Bypass
        • User-Interaction Attacks
        • Weak Permissions
  • ACTIVE DIRECTORY
    • Theory
      • Terminology
    • Reconnaissance
      • Responder
      • Password Policies
      • DNS
      • Enumeration
        • Users
        • Groups
          • GPO's
        • Shares
        • Domain
        • Trusts
        • ACL
    • Movement
      • Credentials
        • Dumping
          • DCSync
          • DPAPI Secrets
        • Making a Target List
        • Spraying
        • Powershell Remoting
      • Kerberos
        • Kerbrute
        • Kerberoasting
          • Semi-Manual Way
          • Targeted Kerberoasting
        • ASREProasting
        • Forging
          • Golden Ticket
        • Overpass The Hash
        • Pass The Ticket
        • RBCD
        • noPAC
      • MITM / Coerced Auths
        • LLMNR, NBT-NS Poisoning
        • PetitPotam
      • DACL Abuse
        • AddMember
        • ForceChangePassword
      • Trust Abuse
        • ExtraSIDs
      • ADCS
        • ESC1
      • Printers
        • PrintNightmare
    • Tools
  • Networking
    • Theory
      • Types / Topologies
      • OSI & TCP/IP Models
      • TCP / UDP
      • MAC Addresses
      • IP / Subnetting
      • Proxies
      • ARP
    • Pivoting
      • Port-Forwarding
    • Commands and Utilities
    • Techniques
  • WEB
    • Web Recon
      • Fuzzing
    • DNS
  • CLOUD
    • Google GKE/GCP
      • Theory
Powered by GitBook
On this page
  • Basic Commands:
  • User Related:
  1. PENTESTING
  2. Databases

PostgreSQL

Connect to database

psql -U postgres

Basic Commands:

  • \?: Show help

  • \q: Quit

  • \c __database__: Connect to a database

  • \d __table__: Show table definition (columns, etc.) including triggers

  • \d+ __table__: More detailed table definition including description and physical disk size

  • \l: List databases

  • \dy: List events

  • \df: List functions

  • \di: List indexes

  • \dn: List schemas

  • \dt *.*: List tables from all schemas (if *.* is omitted will only show SEARCH_PATH ones)

  • \dT+: List all data types

  • \dv: List views

  • \dx: List all extensions installed

  • \df+ __function__ : Show function SQL code.

  • \x: Pretty-format query results instead of the not-so-useful ASCII tables

  • \copy (SELECT * FROM __table_name__) TO 'file_path_and_name.csv' WITH CSV: Export a table as CSV

  • \des+: List all foreign servers

  • \dE[S+]: List all foreign tables

  • \! __bash_command__: execute __bash_command__ (e.g. \! ls)

User Related:

  • \du: List users

  • \du __username__: List a username if present.

  • create role __test1__: Create a role with an existing username.

  • create role __test2__ noinherit login password __passsword__;: Create a role with username and password.

  • set role __test__;: Change role for current session to __test__.

  • grant __test2__ to __test1__;: Allow __test1__ to set its role as __test2__.

  • \deu+: List all user mapping on server


PreviousOracle TNSNextFile Transfers

Last updated 1 year ago