예제 #1
0
 def test_username_config_bypass(self):
     ssh_command_line.context.config["SSHOptions"]["require_explicit_username"] = False
     cmdline = "ssh host -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline + " -oPubkeyAuthentication=no -oUserKnownHostsFile=/dev/null -T")
예제 #2
0
 def test_username_l_option_2(self):
     cmdline = "echo ls |ssh host -p2222 -v -T -l user -oPubkeyAuthentication=no -oUserKnownHostsFile=/dev/null ; " \
               "echo 'Done!'&"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #3
0
 def test_complex_case(self):
     cmdline = "torify ssh root@host -p2222 &"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], "torify ssh root@host -p2222 -oPubkeyAuthentication=no "
                                 "-oUserKnownHostsFile=/dev/null -T &")
예제 #4
0
 def test_option_config_bypass(self):
     ssh_command_line.context.config["SSHOptions"]["force_disable_pty_allocation"] = False
     ssh_command_line.context.config["SSHOptions"]["prevent_ssh_key_leaks"] = False
     ssh_command_line.context.config["SSHOptions"]["disable_known_hosts"] = False
     cmdline = "ssh root@host -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #5
0
 def test_username_config_bypass(self):
     old = ssh_command_line.context.config["SSHOptions"]["require_explicit_username"]
     ssh_command_line.context.config["SSHOptions"]["require_explicit_username"] = False
     cmdline = "ssh host -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline + " -T")
     ssh_command_line.context.config["SSHOptions"]["require_explicit_username"] = old
예제 #6
0
 def test_T_option_config_bypass(self):
     old = ssh_command_line.context.config["SSHOptions"]["force_disable_pty_allocation"]
     ssh_command_line.context.config["SSHOptions"]["force_disable_pty_allocation"] = False
     cmdline = "ssh root@host -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
     ssh_command_line.context.config["SSHOptions"]["force_disable_pty_allocation"] = old
예제 #7
0
 def test_standard_case(self):
     cmdline = "ssh root@host -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline + " -oPubkeyAuthentication=no -oUserKnownHostsFile=/dev/null -T")
예제 #8
0
 def test_username_complex(self):
     cmdline = "echo ls |ssh host -p2222 -v ; echo 'Done!'&"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.CANCEL)
     self.assertEqual(result[1], None)
예제 #9
0
 def test_username_standard(self):
     cmdline = "ssh host -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.CANCEL)
     self.assertEqual(result[1], None)
예제 #10
0
 def test_not_really_ssh(self):
     cmdline = "mv ~/.ssh/id_rsa ssh"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #11
0
 def test_no_ssh(self):
     cmdline = "ls -l |grep passwords > /tmp/pass"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #12
0
 def test_option_already_present(self):
     cmdline = "ssh root@host -oPubkeyAuthentication=no -oUserKnownHostsFile=/dev/null -T -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #13
0
 def test_standard_case(self):
     cmdline = "ssh root@host -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline + " -T")
예제 #14
0
 def test_username_not_applicable(self):
     cmdline = "find . -name ls |base64"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #15
0
 def test_pubkey_explicit(self):
     cmdline = "ssh root@host -p2222 -vT  -oUserKnownHostsFile=yolo -i ~/.ssh/id_rsa"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #16
0
 def test_option_already_present(self):
     cmdline = "ssh root@host -T -p2222 -v"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #17
0
 def test_complex_case(self):
     cmdline = "torify ssh root@host -p2222 &"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], "torify ssh root@host -p2222 -T &")
예제 #18
0
 def test_pubkey_authentication_present(self):
     cmdline = "ssh root@host -p2222 -vT -oPubkeyAuthentication=yolo -oUserKnownHostsFile=yolo"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)
예제 #19
0
 def test_username_l_option(self):
     cmdline = "echo ls |ssh host -p2222 -v -T -oPubkeyAuthentication=no -lroot ; echo 'Done!'&"
     p = SSHOptions()
     result = p.apply(cmdline)
     self.assertEqual(result[0], ProcessorAction.FORWARD)
     self.assertEqual(result[1], cmdline)