How to use the webtech.encoder.Encoder function in webtech

To help you get started, we’ve selected a few webtech examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kaiiyer / webtech / webtech / target.py View on Github external
Generate a report
        """
        if output_format == Format['grep']:
            techs = ""
            for tech in self.report['tech']:
                if len(techs): techs += "//"
                techs += "{}/{}".format(tech.name, 'unknown' if tech.version is None else tech.version)

            headers = ""
            for header in self.report['headers']:
                if len(headers): headers += "//"
                headers += "{}:{}".format(header["name"], header["value"])

            return "Url>{}\tTechs>{}\tHeaders>{}".format(self.data['url'], techs, headers)
        elif output_format == Format['json']:
            return json.loads(json.dumps(self.report, cls=encoder.Encoder))
        else:
            retval = ""
            retval += "Target URL: {}\n".format(self.data['url'])
            if self.report['tech']:
                retval += "Detected technologies:\n"
                for tech in self.report['tech']:
                    retval += "\t- {} {}\n".format(tech.name, '' if tech.version is None else tech.version)
            if self.report['headers']:
                retval += "Detected the following interesting custom headers:\n"
                for header in self.report['headers']:
                    retval += "\t- {}: {}\n".format(header["name"], header["value"])
            return retval
github ShielderSec / webtech / webtech / target.py View on Github external
Generate a report
        """
        if output_format == Format['grep']:
            techs = ""
            for tech in self.report['tech']:
                if len(techs): techs += "//"
                techs += "{}/{}".format(tech.name, 'unknown' if tech.version is None else tech.version)

            headers = ""
            for header in self.report['headers']:
                if len(headers): headers += "//"
                headers += "{}:{}".format(header["name"], header["value"])

            return "Url>{}\tTechs>{}\tHeaders>{}".format(self.data['url'], techs, headers)
        elif output_format == Format['json']:
            return json.loads(json.dumps(self.report, cls=encoder.Encoder))
        else:
            retval = ""
            retval += "Target URL: {}\n".format(self.data['url'])
            if self.report['tech']:
                retval += "Detected technologies:\n"
                for tech in self.report['tech']:
                    retval += "\t- {} {}\n".format(tech.name, '' if tech.version is None else tech.version)
            if self.report['headers']:
                retval += "Detected the following interesting custom headers:\n"
                for header in self.report['headers']:
                    retval += "\t- {}: {}\n".format(header["name"], header["value"])
            return retval