コード例 #1
0
def test_end_to_end_success_test():
    """ test the full function end to end """

    ocsp_result = get_ocsp_status("github.com", 443)

    assert ocsp_result == ['Host: github.com:443',\
                           'OCSP URL: http://ocsp.digicert.com', 'OCSP Status: GOOD']
コード例 #2
0
def test_strip_https_from_host():
    """ Validate stripping https from host """

    host = "https://github.com"
    ocsp_request = get_ocsp_status(host, 443)

    assert ocsp_request == ['Host: https://github.com:443',\
                            'OCSP URL: http://ocsp.digicert.com', 'OCSP Status: GOOD']
コード例 #3
0
ファイル: urlclass.py プロジェクト: jokersunited/UrlAnalyze
    def print_cmdreport(self):
        print("\n===== Page Info =====")
        print("Destination URL: " + str(self.final_url))
        print("Destination Title: " + str(self.driver.title))

        print("\n===== Domain Info =====")
        print("Registrar: " + str(self.whois.registrar))
        if type(self.whois.creation_date) is list:
            print("Creation Date: " + str(self.whois.creation_date[0]))
        else:
            print("Creation Date: " + str(self.whois.creation_date))
        if type(self.whois.expiration_date) is list:
            print("Expiry Date: " + str(self.whois.expiration_date[0]))
        else:
            print("Expiry Date: " + str(self.whois.expiration_date))
        print("Abuse Emails: ")
        if type(self.whois.emails) is list:
            for x in self.whois.emails: print("- " + str(x))
        else:
            print("- " + str(self.whois.emails))

        print("\n===== Cert Info =====")
        if self.cert is not None:
            print("Cert Issuer: " + str(self.cert.get_issuer().CN) + " " + str(self.cert.get_issuer().O))
            print("Cert Expired?: " + str(self.cert.has_expired()))
            ocsp_request = ocspchecker.get_ocsp_status(self.final_url)
            ocsp_status = [i for i in ocsp_request if "OCSP Status:" in i][0]
            print("Cert Validity: " + str(ocsp_status.split(":")[1][1:]))
        else:
            print("No SSL Cert Found!")

        print("\n===== Initiated Requests =====")
        for index, item in enumerate(get_status(self.driver.get_log('performance'))):
            print("Request " + str(index + 1) + ": " + str(item[0]) + ', ' + item[2] + ', ' + item[1])
        if self.link_count != 0:
            print("\n===== Hyperlink Info =====")
            print("Total links: " + str(self.link_count))
            print("\nloc %:" + str(len(self.link_dict['loc']) / self.link_count * 100))
            print("ext %:" + str(len(self.link_dict['ext']) / self.link_count * 100))
            print("static %:" + str(len(self.link_dict['static']) / self.link_count * 100))

            if len(self.uniq_dom.keys()) > 0:
                print("\nUnique external domains: ")
                for key in self.uniq_dom.keys():
                    print("- " + key)
            if len(self.link_dict['loc']) > 0:
                print("\nUnique local links %: " + str(self.get_uniqlocal() * 100))
            else:
                print("\nNo Local Links!")

            print("\n===== Potential Spoof Domain Scores =====")
            for key, value in self.spoof.items():
                if value > 0.4: print(key + ": " + str(value))

        else:
            print("\nNo hyperlinks on page!")
コード例 #4
0
def test_bad_port_typeerror():
    """Validate passing a bad port results in failure"""

    host = "espn.com"
    ocsp_request = get_ocsp_status(host, "a")  # type: ignore

    assert ocsp_request == [
        "Host: espn.com:a",
        "Error: Invalid port: 'a'. Port must be between 0-65535.",
    ]
コード例 #5
0
def test_bad_port_overflow():
    """Validate passing a bad port results in failure"""

    host = "espn.com"
    ocsp_request = get_ocsp_status(host, 80000)

    assert ocsp_request == [
        "Host: espn.com:80000",
        "Error: Invalid port: '80000'. Port must be between 0-65535.",
    ]
コード例 #6
0
def test_a_cert_from_each_root_ca(root_ca):
    """Test a cert from each root CA to ensure test coverage"""

    try:
        ocsp_request = get_ocsp_status(root_ca, 443)

    except Exception as err:
        raise err

    assert ocsp_request[2] == "OCSP Status: GOOD"
コード例 #7
0
def test_end_to_end_test_bad_fqdn():
    """test the full function end to end"""

    host = "nonexistentdomain"
    ocsp_request = get_ocsp_status(host, 443)

    assert ocsp_request == [
        "Host: nonexistentdomain:443",
        f"Error: {host} is not a valid FQDN.",
    ]
コード例 #8
0
def test_strip_http_from_host():
    """Validate stripping http from host"""

    host = "http://github.com"
    ocsp_request = get_ocsp_status(host, 443)

    assert ocsp_request == [
        "Host: http://github.com:443",
        "OCSP URL: http://ocsp.digicert.com",
        "OCSP Status: GOOD",
    ]
コード例 #9
0
def test_no_port_supplied():
    """Validate that when no port is supplied, the default of 443 is used"""

    host = "github.com"
    ocsp_request = get_ocsp_status(host)

    assert ocsp_request == [
        "Host: github.com:443",
        "OCSP URL: http://ocsp.digicert.com",
        "OCSP Status: GOOD",
    ]
コード例 #10
0
def test_end_to_end_test_host_timeout():
    """test the full function end to end"""

    func_name: str = "get_certificate_chain"

    host = "espn.com"
    ocsp_request = get_ocsp_status(host, 65534)

    assert ocsp_request == [
        "Host: espn.com:65534",
        f"Error: {func_name}: Connection to espn.com:65534 timed out.",
    ]
コード例 #11
0
def test_end_to_end_test_bad_host():
    """test the full function end to end"""

    func_name: str = "get_certificate_chain"

    host = "nonexistenthost.com"
    ocsp_request = get_ocsp_status(host, 443)

    assert ocsp_request == [
        "Host: nonexistenthost.com:443",
        f"Error: {func_name}: nonexistenthost.com:443 is invalid or not known.",
    ]
コード例 #12
0
ファイル: urlclass.py プロジェクト: jokersunited/UrlAnalyze
    def get_certocsp(self):
        ocsp_request = ocspchecker.get_ocsp_status(self.final_url)

        ocsp_status = [i for i in ocsp_request if "OCSP Status:" in i]
        ocsp_error = [i for i in ocsp_request if "OCSP Request Error:" in i]

        if len(ocsp_status) != 0:
            return str(ocsp_status[0].split(":")[1][1:])
        elif len(ocsp_error) != 0:
            return str(ocsp_error[0].split(":")[2][1:])
        else:
            return "ERROR"
コード例 #13
0
def ocsp_stat(uri):
    start_time = time.time()
    ocsp_request = ocspchecker.get_ocsp_status(uri)
    end_time = time.time()

    responsetime = float(end_time - start_time)

    if len(ocsp_request) == 3:
        if ocsp_request[2].split()[2] == "GOOD":
            data = f'OCSP_Check,URI="{uri}" resolution=1,response_time={responsetime},raw="{ocsp_request}"'
    else:
        data = f'OCSP_Check,URI="{uri}" resolution=2,response_time={responsetime},raw="{ocsp_request}"'
    return data