def test_sessionctx_sniffer_lo(self):
        raise NotImplementedError("NOT YET IMPLEMENTED")
        """
        USAGE: <host> <port> <inteface or pcap> <keyfile> <num pkts>
        
        """
        sniffer = PythonInterpreter("sessionctx_sniffer.py",
                                    args=list(self.bind) +
                                    ["lo", SERVER_PEM, 10],
                                    cwd=EXAMPLES_CWD)
        #wait_for_server(self.bind)
        # we cannot poll as this would mess up the server socket
        time.sleep(3)
        # connect with client (openssl)
        for _ in xrange(50):
            client = OpenSslClient(args=(self.bind))
            client.stdin.write("It works!\r\n\r\n")
            self.assertEqual(client.getReturnCode("Q\n"), 0)
            client.kill()
            if sniffer.pid.returncode:
                # sniffer exited (after processing 10 valid packets)
                break

        self.assertEqual(sniffer.getReturnCode(), 0)
        print("server exit")
        print("terminating client...")
        sniffer.kill()
 def server_testcase(self, target, args=[], cwd=None):
     # spawn server (example script)
     server = PythonInterpreter(target, args, cwd)
     # we cannot poll as this would mess up the server socket
     self.assertEqual(client.getReturnCode("Q\n"), 0)
     client.kill()
     server.kill()
 def server_testcase(self,
                     target,
                     args=[],
                     cwd=None,
                     expect_client=0,
                     expect_server=0,
                     stdin="It works!\r\n\r\n",
                     assert_client_stderr=None):
     # spawn server (example script)
     wait_for_bind_to_become_ready(tuple(args[:2]))
     server = PythonInterpreter(target, args, cwd)
     #wait_for_server(self.bind)
     # we cannot poll as this would mess up the server socket
     time.sleep(3)
     # connect with client (openssl)
     client = OpenSslClient(
         args=(self.bind),
         want_stderr=True if assert_client_stderr else False)
     # wait for server to exit until client quits (getReturnCode waits until proc exits)
     if stdin:
         client.stdin.write(stdin)
     self.assertEqual(server.getReturnCode(), expect_server)
     print("server exit")
     print("terminating client...")
     self.assertEqual(client.getReturnCode("Q\n"), expect_client)
     if assert_client_stderr:
         self.assertIn(assert_client_stderr, client.stderr)
     client.kill()
     server.kill()
Exemple #4
0
    def test_security_scanner_client_mode(self):
        """
        USAGE: <mode> <host> <port> [starttls] [num_worker] [interface]
           mode     ... client | sniff
           starttls ... starttls keyword e.g. 'starttls\n' or 'ssl\n'

        """
        pid = PythonInterpreter("security_scanner.py", 
                                args=["client",]+list(self.bind), 
                                cwd=EXAMPLES_CWD)
        self.assertEqual(pid.getReturnCode(), 0)
        pid.kill()
Exemple #5
0
    def test_sessionctx_sniffer_pcap_mode(self):
        """
        USAGE: <host> <port> <inteface or pcap> <keyfile> <num pkts>

        python ../examples/sessionctx_sniffer.py 192.168.220.131 443 ../tests/files/RSA_WITH_AES_128_CBC_SHA.pcap ../tests/files/openssl_1_0_1_f_server.pem
        
        """
        raise NotImplementedError("NOT YET IMPLEMENTED")
        pid = PythonInterpreter("sessionctx_sniffer.py", 
                                args=["192.168.220.131", 443, 
                                      os.path.join(basedir,"./tests/files/RSA_WITH_AES_128_CBC_SHA.pcap"),
                                      os.path.join(basedir,"./tests/files/openssl_1_0_1_f_server.pem")],
                                cwd=EXAMPLES_CWD)
        self.assertEqual(pid.getReturnCode(), 0)
        pid.kill()
    def test_sessionctx_sniffer_pcap_mode(self):
        """
        USAGE: <host> <port> <inteface or pcap> <keyfile> <num pkts>

        python ../examples/sessionctx_sniffer.py 192.168.220.131 443 ../tests/files/RSA_WITH_AES_128_CBC_SHA_w_key.pcap ../tests/files/openssl_1_0_1_f_server.pem
        
        """
        pid = PythonInterpreter(
            "sessionctx_sniffer.py",
            args=[
                "192.168.220.131", 443,
                os.path.join(
                    basedir,
                    "./tests/files/RSA_WITH_AES_128_CBC_SHA_w_key.pcap"),
                os.path.join(basedir,
                             "./tests/files/openssl_1_0_1_f_server.pem")
            ],
            cwd=EXAMPLES_CWD,
            want_stdout=True)
        self.assertEqual(pid.getReturnCode(), 0)
        self.assertIn(
            "no client certificate available\\n</BODY></HTML>\\r\\n\\r\\n",
            pid.stdout)
        pid.kill()
 def test(self):
     pid = PythonInterpreter(target, args, cwd)
     self.assertEqual(pid.getReturnCode(), 0)
     pid.kill()