From db2ce0ef83d882ceb943a5c3fd86dd30df610eaa Mon Sep 17 00:00:00 2001 From: Matt Lorentzen Date: Tue, 18 Sep 2018 10:48:20 +0100 Subject: [PATCH] PowerShell class now fully supports the pipeline --- .gitignore | 9 +++++++++ actions/shell/powershell.py | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 749ccda..f9428b3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,12 @@ __pycache__/ *.py[cod] *$py.class + + +# au3 files +*.au3 + +# any content +*.txt +*.doc +*.docx diff --git a/actions/shell/powershell.py b/actions/shell/powershell.py index 21a23ab..0d37b76 100644 --- a/actions/shell/powershell.py +++ b/actions/shell/powershell.py @@ -51,7 +51,13 @@ def typing_block(self, commands): for command in commands: # these are individual send commands so don't need to be # wrapped in a block - typing_text += (space + 'Send("' + command + '{ENTER}")\n') + # check to see if the command is an object pipeline command + if ("{" in command or "?" in command or "$_" in command or "|" in command): + # send in the raw keystroke option + typing_text += (space + 'Send("' + command + '", 1)\n') + typing_text += (space + 'Send("{ENTER}")\n') + else: + typing_text += (space + 'Send("' + command + '{ENTER}")\n') # add in random delay between 2 seconds and 2 minutes command_delay = str(random.randint(2000, 12000)) typing_text += (space + "sleep(" + command_delay + ")\n")