(self)
| 105 | self.execCmd(cmd) |
| 106 | |
| 107 | def shell(self): |
| 108 | if self.webBackdoorUrl and (not isStackingAvailable() or kb.udfFail): |
| 109 | infoMsg = "calling OS shell. To quit type " |
| 110 | infoMsg += "'x' or 'q' and press ENTER" |
| 111 | logger.info(infoMsg) |
| 112 | |
| 113 | else: |
| 114 | if Backend.isDbms(DBMS.PGSQL) and self.checkCopyExec(): |
| 115 | infoMsg = "going to use 'COPY ... FROM PROGRAM ...' " |
| 116 | infoMsg += "command execution" |
| 117 | logger.info(infoMsg) |
| 118 | |
| 119 | elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL): |
| 120 | infoMsg = "going to use injected user-defined functions " |
| 121 | infoMsg += "'sys_eval' and 'sys_exec' for operating system " |
| 122 | infoMsg += "command execution" |
| 123 | logger.info(infoMsg) |
| 124 | |
| 125 | elif Backend.isDbms(DBMS.MSSQL): |
| 126 | infoMsg = "going to use extended procedure 'xp_cmdshell' for " |
| 127 | infoMsg += "operating system command execution" |
| 128 | logger.info(infoMsg) |
| 129 | |
| 130 | else: |
| 131 | errMsg = "feature not yet implemented for the back-end DBMS" |
| 132 | raise SqlmapUnsupportedFeatureException(errMsg) |
| 133 | |
| 134 | infoMsg = "calling %s OS shell. To quit type " % (Backend.getOs() or "Windows") |
| 135 | infoMsg += "'x' or 'q' and press ENTER" |
| 136 | logger.info(infoMsg) |
| 137 | |
| 138 | autoCompletion(AUTOCOMPLETE_TYPE.OS, OS.WINDOWS if Backend.isOs(OS.WINDOWS) else OS.LINUX) |
| 139 | |
| 140 | while True: |
| 141 | command = None |
| 142 | |
| 143 | try: |
| 144 | command = _input("os-shell> ") |
| 145 | command = getUnicode(command, encoding=sys.stdin.encoding) |
| 146 | except UnicodeDecodeError: |
| 147 | pass |
| 148 | except KeyboardInterrupt: |
| 149 | print() |
| 150 | errMsg = "user aborted" |
| 151 | logger.error(errMsg) |
| 152 | except EOFError: |
| 153 | print() |
| 154 | errMsg = "exit" |
| 155 | logger.error(errMsg) |
| 156 | break |
| 157 | |
| 158 | if not command: |
| 159 | continue |
| 160 | |
| 161 | if command.lower() in ("x", "q", "exit", "quit"): |
| 162 | break |
| 163 | |
| 164 | self.runCmd(command) |
no test coverage detected