def __generate_results_page(self, service): """ Generate HTML code that contains command outputs of all the checks that have been run for the specified service. :param Service service: Service Model """ tpl = FileUtils.read(REPORT_TPL_DIR + '/results.tpl.html') # service_string = 'host <span class="font-weight-bold">{ip}</span> | ' \ # 'port <span class="font-weight-bold">{port}/{proto}</span> | ' \ # 'service <span class="font-weight-bold">{service}</span>'.format( # ip=str(service.host.ip), # port=service.port, # proto={Protocol.TCP: 'tcp', Protocol.UDP: 'udp'}.get( # service.protocol), # service=service.name) tpl = tpl.replace('{{MISSION_NAME}}', self.mission) tpl = tpl.replace('{{SERVICE_ICON}}', IconsMapping.get_icon_html('service', service.name)) tpl = tpl.replace('{{SERVICE_IP}}', str(service.host.ip)) tpl = tpl.replace('{{SERVICE_PORT}}', str(service.port)) tpl = tpl.replace('{{SERVICE_PROTO}}', { Protocol.TCP: 'tcp', Protocol.UDP: 'udp' }.get(service.protocol)) tpl = tpl.replace('{{SERVICE_NAME}}', service.name) tpl = tpl.replace('{{SIDEBAR_CHECKS}}', self.__generate_sidebar_checks(service)) tpl = tpl.replace('{{RESULTS}}', self.__generate_command_outputs(service)) return tpl
def __generate_index(self): """ Generate HTML index code from template "index.tpl.html" """ tpl = FileUtils.read(REPORT_TPL_DIR + '/index.tpl.html') tpl = tpl.replace('{{MISSION_NAME}}', self.mission) tpl = tpl.replace('{{TABLE_SERVICES_CONTENT}}', self.__generate_table_services()) tpl = tpl.replace('{{TABLE_HOSTS_CONTENT}}', self.__generate_table_hosts()) tpl = tpl.replace('{{TABLE_WEB_CONTENT}}', self.__generate_table_web()) tpl = tpl.replace('{{TABLE_OPTIONS_CONTENT}}', self.__generate_table_options()) tpl = tpl.replace('{{TABLE_PRODUCTS_CONTENT}}', self.__generate_table_products()) tpl = tpl.replace('{{TABLE_CREDS_CONTENT}}', self.__generate_table_credentials()) tpl = tpl.replace('{{TABLE_VULNS_CONTENT}}', self.__generate_table_vulns()) return tpl
def read(self): return FileUtils.read(self.path)