예제 #1
0
 def __init__(self, configuration):
     """Initialize class
     Args:
         host (str): The MySQL server host
         port (str): The MySQL server port
         user (str): The required username
         passwd (str): The required password
         database (str): The MySQL database to be used
         initquery (str): The query that will be concatenated in all requests
     Returns:
         None
     """
     self.setup(configuration)
     self.echo = None
     if "ECHO" in configuration:
         self.echo = configuration['ECHO']
     self.port = int(self.port)
     self.sqlparse = accept_bool(self.sqlparse)
     db_config = {}
     db_config['host'] = self.host
     db_config['port'] = self.port
     db_config['user'] = self.username
     db_config['passwd'] = self.password
     db_config['db'] = self.database
     self.connect(db_config)
     self.initialize()
     self.testquery()
     self.testfailquery()
예제 #2
0
 def setup(self, configuration):
     self.message = base64.b64decode(configuration['MESSAGE']).decode(
         "utf-8", "ignore")
     self.host = configuration['HOST']
     self.port = int(configuration['PORT'])
     self.https = accept_bool(configuration['HTTPS'])
     self.fail_regex = configuration['BLOCK']
     self.success_regex = configuration['BYPASS']
예제 #3
0
    def __init__(self, configuration, shared_memory, cross):
        self.setup(configuration)
        if not self.alphabet or isinstance(self.alphabet, str):
            self.alphabet = createalphabet(self.alphabet)
        super(SFADiff, self).__init__(self.alphabet)
        self.membership_queries = 0
        self.cache_membership_queries = 0
        self.equivalence_queries = 0
        self.cache_equivalence_queries = 0
        self.cache_equivalence = []
        self.cache_membership = {}
        self.ids_membership_queries = 0
        self.ids_cache_membership_queries = 0
        self.ids_equivalence_queries = 0
        self.ids_cache_equivalence_queries = 0
        self.ids_states = 0
        self.browserstates = 0
        self.cross_check_times = 0
        self.equivalence_queries_cached_membership = 0
        self.ids_equivalence_queries_cached_membership = 0
        self.num_diff = 2
        self.shared_memory = shared_memory
        self.cross = cross
        self.dfa1_minus_dfa2 = accept_bool(self.dfa1_minus_dfa2)
        self.mma = None
        self.mmac = None
        self.pda = None
        self.bypass = None

        if self.seed_file is not None and self.seed_file_type is not None:
            if self.seed_file_type == "FLEX":
                flex_object_m = _Flexparser(self.alphabet)
                self.mma = flex_object_m.yyparse(findlibrary(self.seed_file))
                self.mma.minimize()
            elif self.seed_file_type == "GRAMMAR":
                cfgtopda = _CfgPDA(self.alphabet)
                self.mma = cfgtopda.yyparse(findlibrary(self.seed_file), 1)
            elif self.seed_file_type == "FST":
                self.mma = _DFA(self.alphabet)
                self.mma.load(findlibrary(self.seed_file))
                self.mma.minimize()

        if self.tests_file is not None and self.tests_file_type is not None:
            if self.tests_file_type == "FLEX":
                flex_object_m = _Flexparser(self.alphabet)
                self.mmac = flex_object_m.yyparse(findlibrary(self.tests_file))
                self.mmac.minimize()
            elif self.tests_file_type == "GRAMMAR":
                cfgtopda = _CfgPDA(self.alphabet)
                self.mmac = cfgtopda.yyparse(findlibrary(self.tests_file), 1)
            elif self.tests_file_type == "FST":
                self.mmac = _DFA(self.alphabet)
                self.mmac.load(findlibrary(self.tests_file))
                self.mmac.minimize()
예제 #4
0
    def __init__(self, configuration):
        """
        Initialization function
        Args:
            wsport (int):     The web server port
            wbport (int):     The web socket server port
            browserparses (bool):   If set to true, then query is true
                                    if browser parses JavaScript.
                                    If set to false, then query is true
                                    if browser does not parse JavaScript.
        """

        self.setup(configuration)
        self.echo = None
        if "ECHO" in configuration:
            self.echo = configuration['ECHO']
        self.wsport = int(self.wsport)
        self.wbport = int(self.wbport)
        self.browserparse = accept_bool(self.browserparse)
        self.websocket = None
        self.webbrowser = None
        self.websocketserver = None
        self.webbrowserserver = None

        if self.browserparse:
            # Learn what the browser parses as valid javascript
            self.return_code_1 = '0'
            self.return_code_2 = '1'
        else:
            # Learn what the browser does not parse as valid javascript
            self.return_code_1 = '1'
            self.return_code_2 = '0'

        parent_conn_a, child_conn_a = Pipe()
        websocketserver = SimpleWebSocketServer(
            self.host, self.wsport, SocketHandler, parent_conn_a, child_conn_a, self.wsport)
        print 'Starting WebSocket Server at port ' + repr(self.wsport) + ': ',
        websocket = Thread(
            target=serve,
            args=(
                websocketserver,
            ))
        websocket.setDaemon(True)
        websocket.start()
        print 'OK'
        print 'Starting HTTP Server at port ' + repr(self.wbport) + ': ',
        webbrowserserver = SimpleWebServer(self.host, self.wbport, WebServerHandler, self.delay, self.wsport)
        webbrowser = Thread(
            target=serve_html,
            args=(
                webbrowserserver,
            ))
        webbrowser.setDaemon(True)
        webbrowser.start()
        print 'OK'
        print 'Please connect your Browser at http://' + self.host + ':' + repr(self.wbport)
        print 'Verifying Web Socket connection:',
        updates = parent_conn_a.recv()
        if updates[0] == "browserstatus" and updates[1] == 1:
            print 'OK'
        else:
            print 'FAIL'
        print 'Awaiting initialization command:',
        updates = parent_conn_a.recv()
        if updates[0] == "browserresponse" and updates[1] == "INIT":
            print 'OK'
        else:
            print 'FAIL'
        self.server = (parent_conn_a, child_conn_a)

        self.websocket = websocket
        self.webbrowser = webbrowser
        self.websocketserver = websocketserver
        self.webbrowserserver = webbrowserserver