def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.ssl_supported = RandomHelper.flip_coin() to_populate.ssl_version = WsFaker.get_ssl_version_name() to_populate.fingerprint_result = RandomHelper.flip_coin() to_populate.fingerprint_name = WsFaker.get_fingerprint_service_name() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker to_populate.port_results = WsFaker.get_port_statuses() to_populate.port_scan_method = WsFaker.get_port_scan_method() to_populate.scan_start_time = WsFaker.get_time_in_past() to_populate.scan_end_time = WsFaker.get_time_in_past() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker to_populate.network_service_port = WsFaker.get_port() to_populate.network_service_protocol = WsFaker.get_network_protocol() to_populate.network_service_uuid = WsFaker.create_uuid() to_populate.network_service_discovered_by = WsFaker.get_network_service_discovery_method() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker to_populate.domain_names = WsFaker.get_domain_names() to_populate.history_collection_method = WsFaker.get_domain_history_collection_method( ) to_populate.history_distance = WsFaker.get_random_int() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker to_populate.total_header_count = WsFaker.get_random_int(minimum=1, maximum=500) to_populate.unique_header_count = WsFaker.get_random_int(minimum=1, maximum=500) to_populate.server_headers = WsFaker.get_server_header_values() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.domain_name = WsFaker.get_domain_name() to_populate.resolutions = WsFaker.get_domain_resolutions() to_populate.has_resolutions = RandomHelper.flip_coin() to_populate.subdomains = WsFaker.get_subdomains() to_populate.related_ips = WsFaker.get_domain_related_ips() return to_populate
def create_dummy(cls): from lib import WsFaker start_time = WsFaker.get_past_time(minutes=20) return LoginAttemptModel( ip_address=WsFaker.get_ipv4_address(), user_agent=WsFaker.get_user_agent(), attempt_date=start_time, )
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper contains_ip = RandomHelper.flip_coin() to_populate.record_type = WsFaker.get_dns_record_type() to_populate.record_content = WsFaker.get_dns_record_content() to_populate.contains_ip_address = contains_ip to_populate.ip_address_uuid = WsFaker.create_uuid( ) if contains_ip else None return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker to_populate.network_uuid = WsFaker.create_uuid() to_populate.network_address = WsFaker.get_ipv4_address() to_populate.network_name = WsFaker.get_network_name() to_populate.network_mask_length = WsFaker.get_random_int(minimum=1, maximum=32) to_populate.network_cidr_range = "%s/%s" % (to_populate.network_address, to_populate.network_mask_length) to_populate.network_added_by = WsFaker.get_word() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.uses_wordpress = RandomHelper.flip_coin() to_populate.wordpress_version = WsFaker.get_version_string() to_populate.uses_iss = RandomHelper.flip_coin() to_populate.iis_version = WsFaker.get_version_string() to_populate.uses_apache = RandomHelper.flip_coin() to_populate.apache_version = WsFaker.get_version_string() to_populate.uses_nginx = RandomHelper.flip_coin() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.response_code = WsFaker.get_http_response_status() to_populate.response_has_content = RandomHelper.flip_coin() to_populate.response_mime_type = WsFaker.get_mime_string() to_populate.response_primary_hash = WsFaker.get_sha256_string() to_populate.response_secondary_hash = WsFaker.get_sha256_string() to_populate.over_ssl = RandomHelper.flip_coin() to_populate.hostname = WsFaker.get_domain_name() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker cert_model = SslCertificateModel.from_x509_certificate( certificate=WsFaker.get_ssl_certificate(as_string=False)) for mapped_attribute in cert_model.all_mapping_fields: cert_model_value = getattr(cert_model, mapped_attribute) if cert_model_value is not None: setattr(to_populate, mapped_attribute, cert_model_value) to_populate.ssl_version = WsFaker.get_ssl_version_name() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.ssl_version = WsFaker.get_ssl_version_name() to_populate.pyopenssl_protocol = ConversionHelper.pyopenssl_protocol_name_from_ssl_version( to_populate.ssl_version) to_populate.supported = RandomHelper.flip_coin() to_populate.accepted_ciphers = WsFaker.get_words() to_populate.rejected_ciphers = WsFaker.get_words() to_populate.errored_ciphers = WsFaker.get_words() to_populate.preferred_cipher = WsFaker.get_words(1)[0] return to_populate
def create_dummy(cls): from lib import DatetimeHelper, WsFaker return ZmapResultModel( start_time=DatetimeHelper.minutes_ago(5), end_time=DatetimeHelper.now(), port=WsFaker.get_port(), discovered_endpoints=WsFaker.create_ip_addresses(), cmd_line= "zmap -B 10M -f \"saddr,daddr\" -w /tmp/white -o /tmp/zmap_output -p 80 -i en0", scanned_networks=WsFaker.create_class_c_networks(), org_uuid=WsFaker.create_uuid(), )
def create_dummy(cls): from lib import RandomHelper, WsFaker start_time = WsFaker.get_past_time(minutes=20) end_time = datetime.now() is_successful = RandomHelper.flip_coin() traceback = WsFaker.get_traceback( base64_encoded=True) if not is_successful else None return TaskResultModel( name=WsFaker.get_task_function_name(), start_time=start_time, end_time=end_time, uuid=WsFaker.create_uuid(), successful=is_successful, traceback=traceback, )
def __populate_networks_for_organization(self, organization=None, user_string=None, count=2): """ Populate the given organization with networks. :param organization: The organization to add networks to. :param user_string: A string representing the user that is being populated. :param count: The number of networks to add to the organization. :return: The newly-created networks. """ network_ips = set() while True: network_ips.add(WsFaker.get_ipv4_address()) if len(network_ips) == count: break new_networks = [] for index, network_ip in enumerate(network_ips): new_network = organization.networks.create( address=network_ip, mask_length=24, name="Test Network %s" % (index, ), scanning_enabled=True, ) self.__populate_ip_addresses_for_network(network=new_network, user_string=user_string) new_networks.append(new_network) return new_networks
def __populate_web_services_for_network_service(self, network_service=None, user_string=None, count=1): """ Populate web services for the given network service. :param network_service: The network service to populate web services for. :param count: The number of web services to add to the network service. :param user_string: A string depicting the user that is being populated. :return: The list of newly-created web services. """ hostnames = set() while True: hostnames.add(WsFaker.get_domain_name()) if len(hostnames) == count: break new_services = [] for hostname in hostnames: new_web_service = network_service.web_services.create( ip_address=network_service.ip_address.address, port=network_service.port, host_name=hostname, ssl_enabled=RandomHelper.flip_coin(), ) self.__populate_web_service_scans_for_web_service( web_service=new_web_service, user_string=user_string) new_services.append(new_web_service) return new_services
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.title = WsFaker.get_word() to_populate.tag_decomposition = WsFaker.get_word() to_populate.total_tag_count = WsFaker.get_random_int() to_populate.html_tags = WsFaker.get_html_tag_counts() to_populate.internal_url_reference_count = WsFaker.get_random_int() to_populate.external_url_reference_count = WsFaker.get_random_int() to_populate.forms = WsFaker.get_html_forms() to_populate.meta_refresh_location = WsFaker.get_url() to_populate.has_login_form = RandomHelper.flip_coin() to_populate.has_local_login_form = RandomHelper.flip_coin() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker to_populate.geolocation = WsFaker.get_geohash() to_populate.country_code = WsFaker.get_country_code() to_populate.region = WsFaker.get_region() to_populate.geo_source = WsFaker.get_geo_source() to_populate.postal_code = WsFaker.get_zip_code() to_populate.latitude = WsFaker.get_latitude() to_populate.longitude = WsFaker.get_longitude() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.user_agent_type = WsFaker.get_word() to_populate.user_agent_name = WsFaker.get_word() to_populate.user_agent_string = WsFaker.get_user_agent() to_populate.response_has_content = RandomHelper.flip_coin() to_populate.response_mime_type = WsFaker.get_mime_string() to_populate.response_primary_hash = WsFaker.get_sha256_string() to_populate.response_secondary_hash = WsFaker.get_sha256_string() to_populate.response_status_code = WsFaker.get_http_response_status() return to_populate
def __populate_network_services_for_ip_address(self, ip_address=None, user_string=None, count=1): """ Populate the given IP address with network services. :param ip_address: The IP address to add network services to. :param count: The number of network services to add to the IP address for each of the supported network service protocols (TCP, UDP). :param user_string: A string representing the user that is being populated. :return: The newly-created network services. """ service_ports = set() while True: service_ports.add(WsFaker.get_random_int(minimum=1, maximum=65535)) if len(service_ports) == count: break new_services = [] for service_port in service_ports: new_tcp_service = ip_address.network_services.create( port=service_port, is_monitored=False, protocol="tcp", scanning_status=False, discovered_by=WsFaker.get_network_service_discovery_method(), ) self.__populate_network_service_scans_for_network_service( network_service=new_tcp_service, user_string=user_string, ) self.__populate_web_services_for_network_service( network_service=new_tcp_service, user_string=user_string, ) new_services.append(new_tcp_service) return new_services
def _populate_dummy(cls, to_populate): from lib import WsFaker, DatetimeHelper to_populate.start_time = WsFaker.get_time_in_past() to_populate.end_time = DatetimeHelper.now() to_populate.cmd_line = WsFaker.get_command_line() discovered_endpoints = WsFaker.create_ip_addresses() to_populate.discovered_endpoints = discovered_endpoints to_populate.live_service_count = len(discovered_endpoints) to_populate.port = WsFaker.get_port() to_populate.protocol = WsFaker.get_network_protocol() scanned_networks = WsFaker.get_networks() to_populate.scanned_networks = scanned_networks to_populate.scanned_networks_count = len(scanned_networks) return to_populate
def __populate_network_service_scans_for_network_service( self, network_service=None, user_string=None, count=2): """ Populate network service scans for the given network service. :param network_service: The network service to add network service scans to. :param user_string: A string depicting the user that is being populated. :param count: The number of network service scans to add to the network service. :return: The newly-populated network service scans. """ new_scans = [] for i in range(count): start_time = timezone.now() - WsFaker.get_timedelta() new_scan = network_service.network_service_scans.create( started_at=start_time, ) self.__populate_elasticsearch_for_network_service_scan( network_service_scan=new_scan, is_latest_scan=i == count - 1, user_string=user_string, ) new_scans.append(new_scan) return new_scans
def __populate_web_service_scans_for_web_service(self, web_service=None, user_string=None, count=2): """ Populate web service scans for the given web service. :param web_service: The web service to populate web service scans for. :param user_string: A string depicting the user that is being populated. :param count: The number of web service scans to add to the given web service. :return: The newly-created web service scans. """ to_return = [] for i in range(count): start_time = timezone.now() - WsFaker.get_timedelta() new_scan = web_service.web_service_scans.create( started_at=start_time, ) self.__populate_elasticsearch_for_web_service_scan( web_service_scan=new_scan, is_latest_scan=i == count - 1, user_string=user_string, ) to_return.append(new_scan) return to_return
def __populate_ip_address_scans_for_ip_address(self, ip_address=None, user_string=None, count=2): """ Populate the IP address scans for the given IP address. :param ip_address: The IP address to populate scans for. :param user_string: A string depicting the user to add the scans for. :param count: The number of IP address scans to add. :return: The newly-populated IP address scans. """ new_scans = [] for i in range(count): start_time = timezone.now() - WsFaker.get_timedelta() new_scan = ip_address.ip_address_scans.create( started_at=start_time, ) self.__add_ip_address_report_to_ip_address_scan( ip_address_scan=new_scan, is_latest_scan=i == count - 1, user_string=user_string, ) new_scans.append(new_scan) return new_scans
def __populate_domain_names_for_organization(self, organization=None, user_string=None, count=3): """ Populate domain names for the given organization. :param organization: The organization to add domain names to. :param user_string: A string depicting the user to add domain names for. :param count: The number of domain names to add. :return: The newly-created domain names. """ domains = set() while True: domains.add(WsFaker.get_domain_name()) if len(domains) == count: break new_domains = [] for domain in domains: new_domain = organization.domain_names.create(name=domain, ) self.__populate_domain_name_scans_for_domain_name( domain_name=new_domain, user_string=user_string) new_domains.append(new_domain) return new_domains
def __populate_domain_name_scans_for_domain_name(self, domain_name=None, user_string=None, count=2): """ Populate domain name scan objects for the given domain name. :param domain_name: The domain name to populate domain name scans for. :param user_string: A string depicting the user to add domain name scans for. :param count: The number of domain name scans to add to the domain name. :return: A list containing the domain name scans that were created by this method. """ to_return = [] for i in range(count): start_time = timezone.now() - WsFaker.get_timedelta() new_scan = domain_name.domain_name_scans.create( started_at=start_time, ) self.__populate_elasticsearch_for_domain_name_scan( domain_name_scan=new_scan, is_latest_scan=i == count - 1, user_string=user_string, ) to_return.append(new_scan) return to_return
def create_delete_object_for_user(self, user="******"): user = self.get_user(user=user) org = rest.models.Organization.objects.create( **WsFaker.get_organization_kwargs()) org.add_admin_user(user) return org
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.cert_serial_number = ":".join(WsFaker.get_words()) to_populate.cert_version = WsFaker.get_random_int() to_populate.cert_has_start_time = RandomHelper.flip_coin() to_populate.cert_start_time = WsFaker.get_time_in_past() to_populate.cert_has_invalid_time = RandomHelper.flip_coin() to_populate.cert_invalid_time = WsFaker.get_time_in_future() to_populate.cert_expired = RandomHelper.flip_coin() to_populate.cert_md5_digest = WsFaker.get_sha256_string() to_populate.cert_sha1_digest = WsFaker.get_sha256_string() to_populate.cert_sha256_digest = WsFaker.get_sha256_string() to_populate.cert_sha512_digest = WsFaker.get_sha256_string() to_populate.cert_key_bits = WsFaker.get_random_int() to_populate.cert_key_type = "RSA" to_populate.cert_public_key = ".".join(WsFaker.get_words(200)) to_populate.cert_content = ".".join(WsFaker.get_words(200)) to_populate.cert_issuer_common_name = WsFaker.get_words(1)[0] to_populate.cert_issuer_country = WsFaker.get_words(1)[0] to_populate.cert_issuer_email = WsFaker.get_words(1)[0] to_populate.cert_issuer_hash = WsFaker.get_words(1)[0] to_populate.cert_issuer_locality = WsFaker.get_words(1)[0] to_populate.cert_issuer_organization = WsFaker.get_words(1)[0] to_populate.cert_issuer_organizational_unit = WsFaker.get_words(1)[0] to_populate.cert_issuer_state = WsFaker.get_words(1)[0] to_populate.cert_subject_common_name = WsFaker.get_domain_name() to_populate.cert_subject_country = WsFaker.get_words(1)[0] to_populate.cert_subject_email = WsFaker.get_words(1)[0] to_populate.cert_subject_hash = WsFaker.get_words(1)[0] to_populate.cert_subject_locality = WsFaker.get_words(1)[0] to_populate.cert_subject_organization = WsFaker.get_words(1)[0] to_populate.cert_subject_organizational_unit = WsFaker.get_words(1)[0] to_populate.cert_subject_state = WsFaker.get_words(1)[0] to_populate.cert_extension_names = WsFaker.get_words(5) to_populate.cert_has_authority_key_id = RandomHelper.flip_coin() to_populate.cert_authority_key_id = WsFaker.get_words(1)[0] to_populate.cert_has_subject_key_id = RandomHelper.flip_coin() to_populate.cert_subject_key_id = WsFaker.get_words(1)[0] to_populate.cert_has_extended_key_usage = RandomHelper.flip_coin() to_populate.cert_extended_key_usage = WsFaker.get_words(1)[0] to_populate.cert_has_certificate_policies = RandomHelper.flip_coin() to_populate.cert_certificate_policies = WsFaker.get_words(1)[0] to_populate.cert_has_crl_distribution_points = RandomHelper.flip_coin() to_populate.cert_crl_distribution_points = WsFaker.get_words(1)[0] to_populate.cert_has_subject_alt_name = RandomHelper.flip_coin() to_populate.cert_subject_alt_name = WsFaker.get_words(1)[0] to_populate.cert_has_authority_info_access = RandomHelper.flip_coin() to_populate.cert_authority_info_access = WsFaker.get_words(1)[0] to_populate.cert_is_valid = RandomHelper.flip_coin() to_populate.supports_fallback_scsv = RandomHelper.flip_coin() to_populate.is_vulnerable_to_heartbleed = RandomHelper.flip_coin() to_populate.is_vulnerable_to_ccs_injection = RandomHelper.flip_coin() to_populate.accepts_client_renegotiation = RandomHelper.flip_coin() to_populate.supports_secure_renegotiation = RandomHelper.flip_coin() to_populate.is_ticket_resumption_supported = RandomHelper.flip_coin() to_populate.supports_sslv3 = RandomHelper.flip_coin() to_populate.supports_tlsv1 = RandomHelper.flip_coin() to_populate.supports_tlsv1_1 = RandomHelper.flip_coin() to_populate.supports_tlsv1_2 = RandomHelper.flip_coin() to_populate.sslv3_preferred_cipher = WsFaker.get_words() to_populate.tlsv1_preferred_cipher = WsFaker.get_words() to_populate.tlsv1_1_preferred_cipher = WsFaker.get_words() to_populate.tlsv1_2_preferred_cipher = WsFaker.get_words() to_populate.sslv3_supported_ciphers = WsFaker.get_words() to_populate.tlsv1_supported_ciphers = WsFaker.get_words() to_populate.tlsv1_1_supported_ciphers = WsFaker.get_words() to_populate.tlsv1_2_supported_ciphers = WsFaker.get_words() to_populate.is_vulnerable = RandomHelper.flip_coin() to_populate.cert_is_trusted = RandomHelper.flip_coin() to_populate.scan_completed_at = WsFaker.get_time_in_past() to_populate.cert_extensions = WsFaker.get_certificate_extensions() to_populate.supports_sslv2 = RandomHelper.flip_coin() to_populate.sslv2_preferred_cipher = WsFaker.get_words() to_populate.sslv2_supported_ciphers = WsFaker.get_words() to_populate.heartbleed_test_errored = RandomHelper.flip_coin() to_populate.fallback_scsv_test_errored = RandomHelper.flip_coin() to_populate.ccs_injection_test_errored = RandomHelper.flip_coin() to_populate.session_renegotiation_test_errored = RandomHelper.flip_coin( ) to_populate.session_resumption_test_errored = RandomHelper.flip_coin() to_populate.cert_certificate_policy_oids = WsFaker.get_words() to_populate.cert_is_extended_validation = RandomHelper.flip_coin() return to_populate
def _populate_dummy(cls, to_populate): from lib import WsFaker, RandomHelper to_populate.vuln_test_name = WsFaker.get_word() to_populate.test_errored = RandomHelper.flip_coin() to_populate.test_results = WsFaker.get_ssl_vuln_test_results() return to_populate