From 78bd74eaec79fc3c5454888cd501ee2258245dfe Mon Sep 17 00:00:00 2001 From: Tim W Date: Mon, 18 May 2020 19:20:34 +0800 Subject: [PATCH] add a test for stderr output to the cmd_exec tests --- test/modules/post/test/cmd_exec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/modules/post/test/cmd_exec.rb b/test/modules/post/test/cmd_exec.rb index b8f8a8c216..f8d80e511b 100644 --- a/test/modules/post/test/cmd_exec.rb +++ b/test/modules/post/test/cmd_exec.rb @@ -93,4 +93,20 @@ class MetasploitModule < Msf::Post end end end + + def test_cmd_exec_stderr + vprint_status("Starting cmd_exec stderr tests") + + it "should return the stderr output" do + test_string = Rex::Text.rand_text_alpha(4) + if session.platform.eql? 'windows' + output = cmd_exec("cmd.exe", "/c echo #{test_string} 1>&2") + output.rstrip == test_string + else + output = cmd_exec("echo #{test_string} 1>&2") + output == test_string + end + end + + end end