Rapid7 Vulnerability & Exploit Database

PostgreSQL for Microsoft Windows Payload Execution

Back to Search

PostgreSQL for Microsoft Windows Payload Execution



On default Microsoft Windows installations of PostgreSQL the postgres service account may write to the current directory (which is usually "C:\Program Files\PostgreSQL\\data" where is the major.minor version of PostgreSQL). UDF DLL's may be sourced from there as well. This module uploads a Windows DLL file via the pg_largeobject method of binary injection and creates a UDF (user defined function) from that DLL. Because the payload is run from DllMain, it does not need to conform to specific Postgres API versions.


  • Bernardo Damele A. G. <bernardo.damele@gmail.com>
  • todb <todb@metasploit.com>




Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/windows/postgres/postgres_payload
msf exploit(postgres_payload) > show targets
msf exploit(postgres_payload) > set TARGET < target-id >
msf exploit(postgres_payload) > show options
    ...show and set options...
msf exploit(postgres_payload) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security