From 2bfd19e016a47edb36ade499e6349a24b648cea6 Mon Sep 17 00:00:00 2001 From: mb Date: Sun, 6 Jan 2019 00:42:24 +0100 Subject: [PATCH] ysoserial-generator.py - fixed issue with shell() --- web/ysoserial-generator.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/ysoserial-generator.py b/web/ysoserial-generator.py index c616bd8..9fd285d 100755 --- a/web/ysoserial-generator.py +++ b/web/ysoserial-generator.py @@ -297,10 +297,14 @@ def processShellCmd(cmd): def shell(cmd, noOut = False): cmd = processShellCmd(cmd) - out, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() - - if not out and err: - out = err + out = "" + try: + out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + except subprocess.CalledProcessError as e: + if 'Available payload types' in e.output or 'mbechler' in e.output: + out = e.output + else: + Logger.dbg('Error ({}): shell(\'{}\') returned code {}: {}'.format(str(e), e.cmd, e.returncode, e.output)) if not noOut: Logger.dbg('shell(\'{}\') returned:\n"{}"\n'.format(cmd, out))