Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 006d9d1

Browse files
committed
Bug fix for a problem reported by a user via ML (--os-shell)
1 parent fb65caa commit 006d9d1

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

lib/takeover/xp_cmdshell.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from lib.core.agent import agent
99
from lib.core.common import Backend
10+
from lib.core.common import flattenValue
1011
from lib.core.common import getLimitRange
1112
from lib.core.common import getSQLSnippet
1213
from lib.core.common import hashDBWrite
@@ -226,12 +227,16 @@ def xpCmdshellEvalCmd(self, cmd, first=None, last=None):
226227
inject.goStacked("DELETE FROM %s" % self.cmdTblName)
227228

228229
if output and isListLike(output) and len(output) > 1:
229-
if not (output[0] or "").strip():
230-
output = output[1:]
231-
elif not (output[-1] or "").strip():
232-
output = output[:-1]
230+
_ = ""
231+
lines = [_ for _ in flattenValue(output) if _ is not None]
233232

234-
output = "\n".join(line for line in filter(None, output))
233+
for i in xrange(len(lines)):
234+
line = lines[i] or ""
235+
if line is None or i in (0, len(lines) - 1) and not line.strip():
236+
continue
237+
_ += "%s\n" % line
238+
239+
output = _.rstrip('\n')
235240

236241
return output
237242

0 commit comments

Comments
 (0)