예제 #1
0
    def test_browser_error(self, config):
        """ Browser.scan() exception test """

        br = browser.__new__(browser)
        with self.assertRaises(BrowserError) as context:
            reader = Reader(
                browser_config={
                    'list': config.scan,
                    'torlist': config.torlist,
                    'use_random': config.is_random_list,
                    'is_external_wordlist': config.is_external_wordlist,
                    'is_standalone_proxy': config.is_standalone_proxy,
                    'is_external_torlist': config.is_external_torlist,
                    'prefix': config.prefix
                })
            result = {}
            result['total'] = helper.counter()
            result['items'] = helper.list()

            setattr(reader, '_Reader__config', self.__configuration)
            setattr(br, '_Browser__debug', Debug(config))
            setattr(br, '_Browser__pool', self.__pool)
            setattr(br, '_Browser__config', config)
            setattr(br, '_Browser__reader', reader)
            setattr(br, '_Browser__response',
                    Response(config=config, debug=Debug(config), tpl=Tpl))
            setattr(br, '_Browser__result', result)
            br.scan()
        self.assertTrue(BrowserError == context.expected)
예제 #2
0
    def test_browser_error(self, config):
        """ Browser.scan() exception test """

        br = browser.__new__(browser)
        with self.assertRaises(BrowserError) as context:
            reader = Reader(browser_config={
                'list': config.scan,
                'torlist': config.torlist,
                'use_random': config.is_random_list,
                'is_external_wordlist': config.is_external_wordlist,
                'is_standalone_proxy': config.is_standalone_proxy,
                'is_external_torlist': config.is_external_torlist,
                'prefix': config.prefix
            })
            result = {}
            result['total'] = helper.counter()
            result['items'] = helper.list()

            setattr(reader, '_Reader__config', self.__configuration)
            setattr(br, '_Browser__debug', Debug(config))
            setattr(br, '_Browser__pool', self.__pool)
            setattr(br, '_Browser__config', config)
            setattr(br, '_Browser__reader', reader)
            setattr(br, '_Browser__response', Response(config=config, debug=Debug(config), tpl=Tpl))
            setattr(br, '_Browser__result', result)
            br.scan()
        self.assertTrue(BrowserError == context.expected)
예제 #3
0
    def test_http_scan(self, config):
        """ Browser.scan() http test """

        br = browser.__new__(browser)
        reader = Reader(
            browser_config={
                'list': config.scan,
                'torlist': config.torlist,
                'use_random': config.is_random_list,
                'is_external_wordlist': config.is_external_wordlist,
                'is_standalone_proxy': config.is_standalone_proxy,
                'is_external_torlist': config.is_external_torlist,
                'prefix': config.prefix
            })
        result = {}
        result['total'] = helper.counter()
        result['items'] = helper.list()

        setattr(reader, '_Reader__config', self.__configuration)
        setattr(br, '_Browser__debug', Debug(config))
        setattr(br, '_Browser__pool', self.__pool)
        setattr(br, '_Browser__config', config)
        setattr(br, '_Browser__reader', reader)
        setattr(br, '_Browser__response',
                Response(config=config, debug=Debug(config), tpl=Tpl))
        setattr(br, '_Browser__result', result)
        self.assertIs(br.scan(), None)
예제 #4
0
    def __init__(self, params):
        """
        Browser constructor
        :param dict params: filtered input params
        :raise BrowserError
        """

        try:
            self.__client = None
            self.__config = Config(params)
            self.__debug = Debug(self.__config)
            self.__result = {'total': {}, 'items': {}}
            self.__reader = Reader(
                browser_config={
                    'list': self.__config.scan,
                    'torlist': self.__config.torlist,
                    'use_random': self.__config.is_random_list,
                    'use_extensions': self.__config.is_extension_filter,
                    'use_ignore_extensions':
                    self.__config.is_ignore_extension_filter,
                    'is_external_wordlist': self.__config.is_external_wordlist,
                    'wordlist': self.__config.wordlist,
                    'is_standalone_proxy': self.__config.is_standalone_proxy,
                    'is_external_torlist': self.__config.is_external_torlist,
                    'prefix': self.__config.prefix
                })

            if True is self.__config.is_external_reports_dir:
                Reporter.external_directory = self.__config.reports_dir

            if self.__config.scan == self.__config.DEFAULT_SCAN:
                if True is self.__config.is_extension_filter:
                    self.__reader.filter_by_extension(
                        target=self.__config.scan,
                        output='extensionlist',
                        extensions=self.__config.extensions)
                elif True is self.__config.is_ignore_extension_filter:
                    self.__reader.filter_by_ignore_extension(
                        target=self.__config.scan,
                        output='ignore_extensionlist',
                        extensions=self.__config.ignore_extensions)
            self.__reader.count_total_lines()

            Filter.__init__(self, self.__config, self.__reader.total_lines)

            self.__pool = ThreadPool(num_threads=self.__config.threads,
                                     total_items=self.__reader.total_lines,
                                     timeout=self.__config.delay)

            self.__result = {'total': helper.counter(), 'items': helper.list()}

            self.__response = response(config=self.__config,
                                       debug=self.__debug,
                                       tpl=tpl)

        except (ResponseError, ReaderError) as error:
            raise BrowserError(error)
예제 #5
0
    def __init__(self, params):
        """
        Browser constructor
        :param dict params: filtered input params
        :raise BrowserError
        """

        try:
            self.__client = None
            self.__config = Config(params)
            self.__debug = Debug(self.__config)
            self.__result = {'total': {}, 'items': {}}
            self.__reader = Reader(browser_config={
                'list': self.__config.scan,
                'torlist': self.__config.torlist,
                'use_random': self.__config.is_random_list,
                'use_extensions': self.__config.is_extension_filter,
                'use_ignore_extensions': self.__config.is_ignore_extension_filter,
                'is_external_wordlist': self.__config.is_external_wordlist,
                'wordlist': self.__config.wordlist,
                'is_standalone_proxy': self.__config.is_standalone_proxy,
                'is_external_torlist': self.__config.is_external_torlist,
                'prefix': self.__config.prefix
            })

            if True is self.__config.is_external_reports_dir:
                Reporter.external_directory = self.__config.reports_dir

            if self.__config.scan == self.__config.DEFAULT_SCAN:
                if True is self.__config.is_extension_filter:
                    self.__reader.filter_by_extension(target=self.__config.scan,
                                                      output='extensionlist',
                                                      extensions=self.__config.extensions
                                                      )
                elif True is self.__config.is_ignore_extension_filter:
                    self.__reader.filter_by_ignore_extension(target=self.__config.scan,
                                                             output='ignore_extensionlist',
                                                             extensions=self.__config.ignore_extensions
                                                             )
            self.__reader.count_total_lines()

            Filter.__init__(self, self.__config, self.__reader.total_lines)

            self.__pool = ThreadPool(num_threads=self.__config.threads, total_items=self.__reader.total_lines,
                                     timeout=self.__config.delay)

            self.__result = {'total': helper.counter(), 'items': helper.list()}

            self.__response = response(config=self.__config, debug=self.__debug, tpl=tpl)

        except (ResponseError, ReaderError) as error:
            raise BrowserError(error)
예제 #6
0
    def test_done(self, params):
        """ Browser.done() test """

        br = browser.__new__(browser)
        result = {}

        result['total'] = helper.counter()
        result['items'] = helper.list()
        setattr(br, '_Browser__result', result)
        setattr(br, '_Browser__pool', self.__pool)
        setattr(br, '_Browser__pool.size', 0)
        setattr(br, '_Browser__config', self.__browser_configuration(params))
        self.assertIs(br.done(), None)
예제 #7
0
    def test_done(self, params):
        """ Browser.done() test """

        br = browser.__new__(browser)
        result = {}

        result['total'] = helper.counter()
        result['items'] = helper.list()
        setattr(br, '_Browser__result', result)
        setattr(br, '_Browser__pool', self.__pool)
        setattr(br, '_Browser__pool.size', 0)
        setattr(br, '_Browser__config', self.__browser_configuration(params))
        self.assertIs(br.done(), None)
예제 #8
0
    def test_done_exception(self, params):
        """ Browser.done() exception test """

        br = browser.__new__(browser)
        result = {}

        result['total'] = helper.counter()
        result['items'] = helper.list()
        setattr(br, '_Browser__result', result)
        setattr(br, '_Browser__pool', self.__pool)
        setattr(br, '_Browser__pool.size', 0)
        setattr(br, '_Browser__config', self.__browser_configuration(params))

        with self.assertRaises(BrowserError) as context:
            br.done()
        self.assertTrue('raisesexc' in str(context.exception))
        self.assertTrue(BrowserError == context.expected)
예제 #9
0
    def test_done_exception(self, params):
        """ Browser.done() exception test """

        br = browser.__new__(browser)
        result = {}

        result['total'] = helper.counter()
        result['items'] = helper.list()
        setattr(br, '_Browser__result', result)
        setattr(br, '_Browser__pool', self.__pool)
        setattr(br, '_Browser__pool.size', 0)
        setattr(br, '_Browser__config', self.__browser_configuration(params))

        with self.assertRaises(BrowserError) as context:
            br.done()
        self.assertTrue('raisesexc' in str(context.exception))
        self.assertTrue(BrowserError == context.expected)
예제 #10
0
파일: browser.py 프로젝트: ll2b/OpenDoor
    def __init__(self, params):
        """
        Browser constructor
        :param dict params: filtered input params
        :raise BrowserError
        """

        try:
            self.__client = None
            self.__config = Config(params)
            self.__debug = Debug(self.__config)
            self.__result = {}
            self.__result['total'] = {}
            self.__result['items'] = {}

            self.__reader = Reader(
                browser_config={
                    'list': self.__config.scan,
                    'torlist': self.__config.torlist,
                    'use_random': self.__config.is_random_list,
                    'is_external_wordlist': self.__config.is_external_wordlist,
                    'is_standalone_proxy': self.__config.is_standalone_proxy,
                    'is_external_torlist': self.__config.is_external_torlist,
                    'prefix': self.__config.prefix
                })

            self.__reader.count_total_lines()

            Filter.__init__(self, self.__config, self.__reader.total_lines)

            self.__pool = ThreadPool(num_threads=self.__config.threads,
                                     total_items=self.__reader.total_lines,
                                     timeout=self.__config.delay)

            self.__result = {}
            self.__result['total'] = helper.counter()
            self.__result['items'] = helper.list()

            self.__response = response(config=self.__config,
                                       debug=self.__debug,
                                       tpl=tpl)

        except ReaderError as e:
            raise BrowserError(e)