@@ -44,7 +44,10 @@ def __init__(self):
4444 XP_cmdshell .__init__ (self )
4545
4646 def execCmd (self , cmd , silent = False ):
47- if self .webBackdoorUrl and not isStackingAvailable ():
47+ if Backend .isDbms (DBMS .PGSQL ) and self .checkCopyExec ():
48+ self .copyExecCmd (cmd )
49+
50+ elif self .webBackdoorUrl and not isStackingAvailable ():
4851 self .webBackdoorRunCmd (cmd )
4952
5053 elif Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
@@ -60,7 +63,10 @@ def execCmd(self, cmd, silent=False):
6063 def evalCmd (self , cmd , first = None , last = None ):
6164 retVal = None
6265
63- if self .webBackdoorUrl and not isStackingAvailable ():
66+ if Backend .isDbms (DBMS .PGSQL ) and self .checkCopyExec ():
67+ retVal = self .copyExecCmd (cmd )
68+
69+ elif self .webBackdoorUrl and not isStackingAvailable ():
6470 retVal = self .webBackdoorRunCmd (cmd )
6571
6672 elif Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
@@ -103,14 +109,19 @@ def shell(self):
103109 logger .info (infoMsg )
104110
105111 else :
106- if Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
107- infoMsg = "going to use injected sys_eval and sys_exec "
108- infoMsg += "user-defined functions for operating system "
112+ if Backend .isDbms (DBMS .PGSQL ) and self .checkCopyExec ():
113+ infoMsg = "going to use 'COPY ... FROM PROGRAM ...' "
114+ infoMsg += "command execution"
115+ logger .info (infoMsg )
116+
117+ elif Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
118+ infoMsg = "going to use injected user-defined functions "
119+ infoMsg += "'sys_eval' and 'sys_exec' for operating system "
109120 infoMsg += "command execution"
110121 logger .info (infoMsg )
111122
112123 elif Backend .isDbms (DBMS .MSSQL ):
113- infoMsg = "going to use xp_cmdshell extended procedure for "
124+ infoMsg = "going to use extended procedure 'xp_cmdshell' for "
114125 infoMsg += "operating system command execution"
115126 logger .info (infoMsg )
116127
@@ -200,7 +211,9 @@ def initEnv(self, mandatory=True, detailed=False, web=False, forceInit=False):
200211
201212 logger .warn (warnMsg )
202213
203- if Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
214+ if any ((conf .osCmd , conf .osShell )) and Backend .isDbms (DBMS .PGSQL ) and self .checkCopyExec ():
215+ success = True
216+ elif Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
204217 success = self .udfInjectSys ()
205218
206219 if success is not True :
0 commit comments