Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
    def create(self, validated_data):

        is_valid_password = UserModel.validate_password_complexity(
            validated_data['password'])

        if not is_valid_password:
            raise WsRestNonFieldException(
                UserModel.INVALID_PASSWORD_COMPLEXITY_ERROR_MESSAGE)

        try:
            user = UserModel.objects.create(
                username=validated_data['username'],
                #Right now your username is your email, if this changes we need to change this
                email=validated_data['username'],
                first_name=validated_data['first_name'],
                last_name=validated_data['last_name'])
            user.set_password(validated_data['password'])
            user.email_registration_code = RandomHelper.get_cryptographic_uuid(
            )
            user.save()

            #Send verification email
            send_emails_for_user_signup.delay(unicode(user.uuid))

            return user
        except IntegrityError as ie:
            raise WsRestNonFieldException(
                'A user with this username already exists!')
        except Exception as e:
            raise WsRestNonFieldException(e.message)
        return None
Пример #6
0
def create_network_for_organization(name=None,
                                    address=None,
                                    mask_length=None,
                                    org_uuid=None):
    """
    Create and return a new Network object that's been associated with the given organization.
    :param name: The name to associate with the network.
    :param address: The address to associate with the network.
    :param mask_length: The mask length to associate with the network.
    :param org_uuid: The UUID of the organization to add the network to.
    :return: The newly-created Network.
    """
    if name is None:
        name = "Auto-gen Network %s" % (
            RandomHelper.get_random_token_of_length(10))
    cidr_wrapper = CidrRangeWrapper.from_cidr_range(address=address,
                                                    mask_length=mask_length)
    address = ConversionHelper.ipv4_to_class_c_prefix(address)
    return Network.new(
        name=name,
        address=address,
        mask_length=mask_length,
        organization_id=org_uuid,
        scanning_enabled=True,
        added_by="ws",
        endpoint_count=pow(2, 32 - mask_length),
        cidr_range=cidr_wrapper.parsed_cidr_range,
        times_scanned=0,
    )
Пример #7
0
 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
Пример #8
0
 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
Пример #9
0
 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
Пример #10
0
 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
Пример #11
0
 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
Пример #12
0
 def setUp(self):
     """
     Set up this test case so that user_1 has a forgot password token associated with their
     user.
     :return: None
     """
     super(TestVerifyForgotPasswordView, self).setUp()
     user = self.get_user(user="******")
     user.forgot_password_code = RandomHelper.get_cryptographic_uuid()
     user.forgot_password_date = timezone.now()
     self._email_token = user.forgot_password_code
     user.save()
Пример #13
0
    def validate(self, attrs):
        email_address = attrs.get('email_address')
        user = get_object_or_404(UserModel, email=email_address)
        # Start the forgot password reset process
        user.forgot_password_code = RandomHelper.get_cryptographic_uuid()
        user.forgot_password_date = timezone.now()
        user.save()

        # Send the forgot password email
        smtp_helper = SmtpEmailHelper.instance()
        smtp_helper.send_forgot_password_email(user.email,
                                               str(user.forgot_password_code),
                                               user.first_name, str(user.uuid))
        return attrs
Пример #14
0
 def _populate_dummy(cls, to_populate):
     from lib import WsFaker, RandomHelper
     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()
     return to_populate
Пример #15
0
    def validate(self, attrs):
        user_uuid = attrs['user_uuid']
        user = UserModel.objects.filter(uuid=user_uuid).first()

        if user:
            #Reset the verification code
            user.email_registration_code = RandomHelper.get_cryptographic_uuid(
            )
            user.save()

            # Send verification email
            send_emails_for_user_signup.delay(user_uuid=user_uuid)
        else:
            raise WsRestNonFieldException('No user with that uuid found.')
        return attrs
Пример #16
0
 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,
     )
Пример #17
0
 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
Пример #18
0
 def _populate_dummy(cls, to_populate):
     from lib import RandomHelper, DatetimeHelper
     to_populate.is_alive = RandomHelper.flip_coin()
     to_populate.checked_at = DatetimeHelper.now()
     return to_populate
Пример #19
0
 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
Пример #20
0
 def _populate_dummy(cls, to_populate):
     from lib import RandomHelper, DatetimeHelper, WsFaker
     to_populate.is_alive = RandomHelper.flip_coin()
     to_populate.checked_at = DatetimeHelper.now()
     to_populate.liveness_cause = WsFaker.get_word()
     return to_populate
Пример #21
0
 def _populate_dummy(cls, to_populate):
     from lib import WsFaker, RandomHelper
     to_populate.web_service_uuid = WsFaker.create_uuid()
     to_populate.web_service_host_name = WsFaker.get_domain_name()
     to_populate.web_service_uses_ssl = RandomHelper.flip_coin()
     return to_populate
Пример #22
0
 def _populate_dummy(cls, to_populate):
     from lib import WsFaker, RandomHelper
     to_populate.uses_wordpress = RandomHelper.flip_coin()
     to_populate.uses_iss = RandomHelper.flip_coin()
     to_populate.uses_apache = RandomHelper.flip_coin()
     to_populate.uses_nginx = RandomHelper.flip_coin()
     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()
     to_populate.transactions_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=500)
     to_populate.ok_count = WsFaker.get_random_int(minimum=1, maximum=500)
     to_populate.has_ok = to_populate.ok_count > 0
     to_populate.redirect_count = WsFaker.get_random_int(minimum=1,
                                                         maximum=500)
     to_populate.has_redirect = to_populate.redirect_count > 0
     to_populate.client_error_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=500)
     to_populate.has_client_error = to_populate.client_error_count > 0
     to_populate.server_error_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=500)
     to_populate.has_server_error = to_populate.server_error_count > 0
     to_populate.total_resource_size = WsFaker.get_random_int(
         minimum=100000, maximum=500000)
     to_populate.uses_tomcat_management_portal = RandomHelper.flip_coin()
     to_populate.has_screenshots = RandomHelper.flip_coin()
     to_populate.screenshots_count = WsFaker.get_random_int(minimum=1,
                                                            maximum=10)
     to_populate.main_screenshot_s3_bucket = WsFaker.get_s3_bucket()
     to_populate.main_screenshot_s3_key = WsFaker.get_s3_key()
     to_populate.response_count = WsFaker.get_random_int(minimum=1,
                                                         maximum=10)
     to_populate.redirect_301_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=10)
     to_populate.redirect_302_count = WsFaker.get_random_int(minimum=1,
                                                             maximum=10)
     to_populate.all_responses_redirects = RandomHelper.flip_coin()
     to_populate.all_responses_server_errors = RandomHelper.flip_coin()
     to_populate.all_responses_client_errors = RandomHelper.flip_coin()
     to_populate.response_statuses = WsFaker.get_http_response_statuses()
     to_populate.hostname_resolves = RandomHelper.flip_coin()
     to_populate.resolved_ip_matches_hostname = RandomHelper.flip_coin()
     to_populate.response_content_types = WsFaker.get_response_content_types(
     )
     to_populate.www_authenticate_headers = WsFaker.get_words()
     to_populate.has_www_authenticate_headers = RandomHelper.flip_coin()
     to_populate.has_basic_auth = RandomHelper.flip_coin()
     to_populate.has_digest_auth = RandomHelper.flip_coin()
     to_populate.has_ntlm_auth = RandomHelper.flip_coin()
     to_populate.basic_auth_realms = WsFaker.get_words()
     to_populate.has_server_headers = RandomHelper.flip_coin()
     to_populate.has_multiple_server_headers = RandomHelper.flip_coin()
     to_populate.all_responses_not_found = RandomHelper.flip_coin()
     to_populate.resolved_ip_address = WsFaker.get_ipv4_address()
     to_populate.ssl_certificate_cname = WsFaker.get_domain_name()
     to_populate.ssl_certificate_expired = RandomHelper.flip_coin()
     to_populate.ssl_certificate_is_valid = RandomHelper.flip_coin()
     to_populate.ssl_certificate_start_time = WsFaker.get_time_in_past()
     to_populate.ssl_certificate_invalid_time = WsFaker.get_time_in_future()
     to_populate.scan_completed_at = DatetimeHelper.now()
     to_populate.hostname_is_ip_address = RandomHelper.flip_coin()
     to_populate.has_ssl_certificate_data = RandomHelper.flip_coin()
     to_populate.ssl_certificate_md5_digest = WsFaker.get_md5_string()
     to_populate.open_ports = WsFaker.get_web_app_open_ports()
     to_populate.landing_header_redirect_location = WsFaker.get_url()
     to_populate.landing_meta_refresh_location = WsFaker.get_url()
     to_populate.landing_response_status = WsFaker.get_http_response_status(
     )
     to_populate.landing_title = " ".join(WsFaker.get_words())
     to_populate.local_login_form_count = WsFaker.get_random_int()
     to_populate.local_login_form_https_count = WsFaker.get_random_int()
     to_populate.remote_login_form_count = WsFaker.get_random_int()
     to_populate.remote_login_form_https_count = WsFaker.get_random_int()
     to_populate.user_agent_fingerprints = WsFaker.get_user_agent_fingerprints(
     )
     return to_populate
Пример #23
0
 def _populate_dummy(cls, to_populate):
     from lib import WsFaker, RandomHelper
     to_populate.domain_scan_uuid = WsFaker.create_uuid()
     to_populate.is_latest_scan = RandomHelper.flip_coin()
     return to_populate