Exemplo n.º 1
0
def test_ssl_4550_error():
    result_string = '{"dnserr":"non-recoverable failure in name resolution","dst_name":"pretical.ee","dst_port":"443","from":"77.95.64.18","fw":4550,"msm_id":1006864,"msm_name":"SSLCert","prb_id":517,"timestamp":1380791230,"type":"sslcert"}'
    result = Result.get(result_string)
    assert(isinstance(result, SslResult))
    assert(result.af is None)
    assert(result.firmware == 4550)
    assert(result.destination_address is None)
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address is None)
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method is None)
    assert(result.version is None)
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-10-03T09:07:10+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 0)
    assert(result.is_error is True)
    try:
        result = Result.get(result_string, on_error=Result.ACTION_FAIL)
        assert False
    except ResultError:
        pass
Exemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     self.basic = Result.get(
         '{"af":4,"prb_id":1,"result":[{"rtt":10.001},{"rtt":10.002},{"rtt":10.003}],"ttl":20,"avg":10.002,"size":20,"from":"1.2.3.4","proto":"ICMP","timestamp":1440000000,"dup":0,"type":"ping","sent":3,"msm_id":1000001,"fw":4700,"max":10.003,"step":360,"src_addr":"2.3.4.5","rcvd":3,"msm_name":"Ping","lts":40,"dst_name":"my.name.ca","min":10.001,"dst_addr":"3.4.5.6"}'
     )
     self.no_packets = Result.get(
         '{"af":4,"prb_id":2,"result":[],"ttl":20,"avg":10.002,"size":20,"from":"1.2.3.4","proto":"ICMP","timestamp":1440000000,"dup":0,"type":"ping","sent":3,"msm_id":1000001,"fw":4700,"max":null,"step":360,"src_addr":"2.3.4.5","rcvd":0,"msm_name":"Ping","lts":40,"dst_name":"my.name.ca","min":null,"dst_addr":"3.4.5.6"}'
     )
Exemplo n.º 3
0
def test_error_timeout():
    broken_result = {u'from': u'84.132.219.105', u'msm_id': 1666006, u'timestamp':1400570732, u'fw': 4610, u'proto': u'UDP', u'af': 4, u'msm_name':u'Tdig', u'prb_id': 2960, u'error': {u'timeout': 5000}, u'src_addr':u'192.168.179.20', u'group_id': 1666005, u'type': u'dns', u'dst_addr':u'194.0.25.16'}
    result = Result.get(broken_result)
    assert(result.is_error is True)
    try:
        result = Result.get(broken_result, on_error=Result.ACTION_FAIL)
        assert(False)
    except ResultError as e:
        assert(str(e) == "Timeout: 5000")
Exemplo n.º 4
0
def test_http_0():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"GET4 193.0.6.139 0.042268 200 263 1406","timestamp":1319704299,"type":"http"}'
    result = Result.get(data)
    assert(result.is_error is True)
    try:
        Result.get(data, on_error=Result.ERROR_FAIL)
        assert False
    except ResultParseError:
        pass
Exemplo n.º 5
0
def test_http_0_error():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"connect error 4","timestamp":1323118908,"type":"http"}'
    result = Result.get(data)
    assert(result.is_error is True)
    try:
        Result.get(data, on_error=Result.ERROR_FAIL)
        assert False
    except ResultParseError:
        pass
Exemplo n.º 6
0
def test_http_0():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"GET4 193.0.6.139 0.042268 200 263 1406","timestamp":1319704299,"type":"http"}'
    result = Result.get(data)
    assert result.is_malformed is True
    try:
        Result.get(data, on_malformation=Result.ACTION_FAIL)
        assert False
    except ResultParseError:
        pass
Exemplo n.º 7
0
def test_http_1_error():
    data = '{"fw":1,"msm_id":12023,"prb_id":1,"src_addr":"connect error 4","timestamp":1323118908,"type":"http"}'
    result = Result.get(data)
    assert result.is_malformed is True
    try:
        Result.get(data, on_malformation=Result.ACTION_FAIL)
        assert False
    except ResultParseError:
        pass
Exemplo n.º 8
0
def test_ping_4480():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":95.756666666666661,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4480,"max":96.147999999999996,"min":95.388999999999996,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":95.733000000000004},{"rtt":96.147999999999996},{"rtt":95.388999999999996}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1349776268,"ttl":46,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 95.757)
    assert(result.rtt_median == 95.733)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "194.85.27.7")
    assert(result.firmware == 4480)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 96.148)
    assert(result.rtt_min == 95.389)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 165)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-10-09T09:51:08+00:00")
    assert(result.packets[0].rtt == 95.733)
    assert(result.packets[1].rtt == 96.148)
    assert(result.packets[2].rtt == 95.389)
    assert(result.packets[0].ttl == 46)
    assert(result.packets[1].ttl == 46)
    assert(result.packets[2].ttl == 46)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.3.8")
    assert(result.packets[1].source_address == "192.168.3.8")
    assert(result.packets[2].source_address == "192.168.3.8")
Exemplo n.º 9
0
def test_ping_4470():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":195.649,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4470,"max":197.79300000000001,"min":193.059,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":196.095},{"rtt":197.79300000000001},{"rtt":193.059}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1344514151,"ttl":46,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 195.649)
    assert(result.rtt_median == 196.095)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "194.85.27.7")
    assert(result.firmware == 4470)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 197.793)
    assert(result.rtt_min == 193.059)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 165)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-08-09T12:09:11+00:00")
    assert(result.packets[0].rtt == 196.095)
    assert(result.packets[1].rtt == 197.793)
    assert(result.packets[2].rtt == 193.059)
    assert(result.packets[0].ttl == 46)
    assert(result.packets[1].ttl == 46)
    assert(result.packets[2].ttl == 46)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.3.8")
    assert(result.packets[1].source_address == "192.168.3.8")
    assert(result.packets[2].source_address == "192.168.3.8")
Exemplo n.º 10
0
def test_qbuf():
    result = Result.get('{"from":"208.118.139.24","fw":4610,"group_id":1666151,"msm_id":1666151,"msm_name":"Tdig","prb_id":15112,"resultset":[{"af":4,"dst_addr":"8.8.8.8","proto":"TCP","qbuf":"dakBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjMDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=","result":{"ANCOUNT":0,"ARCOUNT":1,"ID":30121,"NSCOUNT":1,"QDCOUNT":1,"rt":57.764,"size":133},"src_addr":"10.0.5.101","subid":1,"submax":2,"time":1400665523},{"af":4,"dst_addr":"8.8.4.4","proto":"TCP","qbuf":"JTEBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjQDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=","result":{"ANCOUNT":0,"ARCOUNT":1,"ID":9521,"NSCOUNT":1,"QDCOUNT":1,"rt":57.263,"size":133},"src_addr":"10.0.5.101","subid":2,"submax":2,"time":1400665524}],"timestamp":1400665523,"type":"dns"}')
    assert(result.responses[0].abuf is None)
    assert(str(result.responses[0].qbuf) == "dakBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjMDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=")
    assert(result.responses[0].qbuf.header.aa is False)
    assert(result.responses[0].qbuf.header.qr is False)
    assert(result.responses[0].qbuf.header.nscount == 0)
    assert(result.responses[0].qbuf.header.qdcount == 1)
    assert(result.responses[0].qbuf.header.ancount == 0)
    assert(result.responses[0].qbuf.header.tc is False)
    assert(result.responses[0].qbuf.header.rd is True)
    assert(result.responses[0].qbuf.header.arcount == 1)
    assert(result.responses[0].qbuf.header.return_code == "NOERROR")
    assert(result.responses[0].qbuf.header.opcode == "QUERY")
    assert(result.responses[0].qbuf.header.ra is True)
    assert(result.responses[0].qbuf.header.z == 0)
    assert(result.responses[0].qbuf.header.id == 30121)
    assert(len(result.responses[0].qbuf.questions) == 1)
    assert(result.responses[0].qbuf.questions[0].klass == "IN")
    assert(result.responses[0].qbuf.questions[0].type == "A")
    assert(result.responses[0].qbuf.questions[0].name == "15112.1400665523.www.twitter.com.")
    assert(result.responses[0].qbuf.edns0.extended_return_code == 0)
    assert(result.responses[0].qbuf.edns0.udp_size == 512)
    assert(result.responses[0].qbuf.edns0.version == 0)
    assert(result.responses[0].qbuf.edns0.z == 255)
    assert(result.responses[0].qbuf.edns0.type == "OPT")
    assert(result.responses[0].qbuf.edns0.name == ".")
    assert(len(result.responses[0].qbuf.edns0.options) == 1)
    assert(result.responses[0].qbuf.edns0.options[0].code == 3)
    assert(result.responses[0].qbuf.edns0.options[0].name == "NSID")
    assert(result.responses[0].qbuf.edns0.options[0].nsid == "")
    assert(result.responses[0].qbuf.edns0.options[0].length == 0)
Exemplo n.º 11
0
def test_ntp_timeout():
    result = (
        '{ "msm_id":"1020235", "fw":4661, "lts":76, "timestamp":1418196642, "dst_name":"atlas", '
        '"prb_id":71, "dst_addr":"193.0.6.139", "src_addr":"193.0.10.127", "proto":"UDP", "af": 4,'
        '"from": "193.0.0.78", "type": "ntp", "result": '
        '[ { "x":"*" }, { "x":"*" }, { "x":"*" } ] '
        "}"
    )
    result = Result.get(result)
    assert isinstance(result, NtpResult)
    assert result.af == 4
    assert result.firmware == 4661
    assert result.destination_address == "193.0.6.139"
    assert result.destination_name == "atlas"
    assert result.source_address == "193.0.10.127"
    assert result.origin == "193.0.0.78"
    assert result.leap_second_indicator is None
    assert result.stratum is None
    assert result.rtt_median is None
    assert result.offset_median is None
    assert getattr(result.packets[0], "final_timestamp", None) is None
    assert getattr(result.packets[0], "final_times", None) is None
    assert getattr(result.packets[0], "origin_timestamp", None) is None
    assert getattr(result.packets[0], "origin_time", None) is None
    assert getattr(result.packets[0], "transmitted_timestamp", None) is None
    assert getattr(result.packets[0], "transmitted_time", None) is None
    assert getattr(result.packets[0], "received_timestamp", None) is None
    assert getattr(result.packets[0], "received_time", None) is None
    assert result.packets[0].offset is None
    assert result.packets[0].rtt is None
Exemplo n.º 12
0
    def aggregate(self, results, probes):

        # Build "sagans" as a list of Sagan result objects: http://goo.gl/HKFkHE
        sagans = []
        for result in results:
            try:
                result = Result.get(result)
                if not probes or result.probe_id in probes:
                    sagans.append(result)
            except ResultError:
                print("Bad result found: {}\n".format(json.dumps(result)))

        # Build a lookup dictionary of id:object for below
        probes = dict([
            (p.id, p) for p in Probe.get_from_api([r.probe_id for r in sagans])
        ])

        # Build the aggregate database
        db = {}
        for result in sagans:
            line = self.renderer.on_result(result, probes=probes)
            db.setdefault(probes[line.probe_id].country_code, []).append(
                line)

        # Print everything out
        r = ""
        for country, lines in db.items():
            r += "{}\n".format(country)
            for line in lines:
                r += "  {}".format(line)
            r += "\n"

        return r
Exemplo n.º 13
0
def test_ping_4500():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":30.114666666666665,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"80.56.151.3","fw":4500,"max":30.344999999999999,"min":29.960999999999999,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":30.038},{"rtt":29.960999999999999},{"rtt":30.344999999999999}],"sent":3,"size":20,"src_addr":"192.168.1.229","timestamp":1361244431,"ttl":55,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 30.115)
    assert(result.rtt_median == 30.038)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "80.56.151.3")
    assert(result.firmware == 4500)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 30.345)
    assert(result.rtt_min == 29.961)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2013-02-19T03:27:11+00:00")
    assert(result.packets[0].rtt == 30.038)
    assert(result.packets[1].rtt == 29.961)
    assert(result.packets[2].rtt == 30.345)
    assert(result.packets[0].ttl == 55)
    assert(result.packets[1].ttl == 55)
    assert(result.packets[2].ttl == 55)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
Exemplo n.º 14
0
def test_ssl_4610():
    result = Result.get('{"af":4,"cert":["-----BEGIN CERTIFICATE-----\nMIIEzjCCAragAwIBAgIDDky9MA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv\nb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ\nQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y\ndEBjYWNlcnQub3JnMB4XDTE0MDEwMzIxMjI1MVoXDTE0MDcwMjIxMjI1MVowGDEW\nMBQGA1UEAxQNKi5wcmV0aWNhbC5lZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\nAQoCggEBAMS+vX7gA8TvzFwxryFFRj1OyQjnW88GvfMuGhKJopalG1EB103oRsxi\nMcXqwFZUicpqLKHW4lCHcRuhpKoZp8EOILnRAJRKFOjgIrcHQ02Xn4Lf/ewl601h\n5qxqt1keU1P8j+u9m7zZN+vOoNlEKZ5SnZhysAAYqr/XIt1WY2cji/4GxjF+q1OH\nIl5zddkIfnE52UbREKKlIakfFdj/c6GXqqsP2QTmm4x2HitCD964tZ06fA9BitQj\nnnBXNhtm2MCuBIPBSq0/C7LREwmfnqxCFqE7iqEPNIQ2IT2D4Gh4c+nIZHqYKvCV\nP3zh3aUaBj1o5Lo83IDdXCKAIiQRFMkCAwEAAaOBvzCBvDAMBgNVHRMBAf8EAjAA\nMA4GA1UdDwEB/wQEAwIDqDA0BgNVHSUELTArBggrBgEFBQcDAgYIKwYBBQUHAwEG\nCWCGSAGG+EIEAQYKKwYBBAGCNwoDAzAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUH\nMAGGF2h0dHA6Ly9vY3NwLmNhY2VydC5vcmcvMDEGA1UdHwQqMCgwJqAkoCKGIGh0\ndHA6Ly9jcmwuY2FjZXJ0Lm9yZy9yZXZva2UuY3JsMA0GCSqGSIb3DQEBBQUAA4IC\nAQC0DDa/u4yY8e8Qaf+GVtB0mMd4EQlfbvlGAeW6+7JdEmqqZoNuzrPPYNV1RLCm\nct7GClgDhmIWu1UWP9uXmnNK7lwYqVSykGRkbJCG1Wnwku2CqIPvRwrazmd0IAOZ\nXO3kymgbo+pmARWIulpbxz5wzCG0K5OFSFO0Ow4p4MqdrGcid9tZ81Z+db7PbVkk\nGAwlJya0Y8kRZS/arG+UPCPl+O2OV6ICmZ3502+nJJhZ1Ahx7stjtv69HxWoX3zQ\n/xuBnKFIZK1EtlVKVvXcFth7akRqs0K9/h1kaxoKoPBfxpZqhjOiu6+OkdydP+CY\nkRZsj2WDYqZlbSnzYNsqy1Asp/cfsyWHp+scUBh+f4ENDg98M9sl4tpOATH+OFD7\nypdttWGjShYfOeQWWJF9J9Q/YFseYH1oAyQ4AV4ga4SM5BZksbsfXgEgXyxdo8DN\nZO4PfRAtaSH+ZKrmgmrcm/CcvNn+EaW6qw7dAhJE4JNkfUAm5qMTuA35ERMkgucD\nyu/PjjzBG2HeHrSqzb3ZoERlF8wfU0wIJeiDRtHYUfu/Hr+XA/80Uq66YrhRyqPS\nM1x0SqeaCYdgfsmK1fB0/brDbOhNXIYbvIShcimGyjfKyHK/FL18SF676/Mc9fbe\ngWyIey4h+S/dYCHJpVKj2HUq1Jni6n3CtxNyqF0EjR1FVA==\n-----END CERTIFICATE-----"],"dst_addr":"80.79.115.54","dst_name":"pretical.ee","dst_port":"443","from":"125.238.215.240","fw":4610,"method":"SSL","msm_id":1006864,"msm_name":"SSLCert","prb_id":74,"rt":696.07500000000005,"src_addr":"10.0.0.2","timestamp":1396269382,"ttc":345.97899999999998,"type":"sslcert","ver":"3.0"}')
    assert(isinstance(result, SslResult))
    assert(result.af == 4)
    assert(result.firmware == 4610)
    assert(result.destination_address == "80.79.115.54")
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address == "10.0.0.2")
    assert(result.port == 443)
    assert(result.origin == "125.238.215.240")
    assert(result.method == "SSL")
    assert(result.version == "3.0")
    assert(result.response_time == 696.075)
    assert(result.time_to_connect == 345.979)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 74)
    assert(result.created.isoformat() == "2014-03-31T12:36:22+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 1)
    assert(result.certificates[0])
    assert(result.certificates[0].subject_cn == "*.pretical.ee")
    assert(result.certificates[0].subject_o is None)
    assert(result.certificates[0].subject_c is None)
    assert(result.certificates[0].issuer_cn == "CA Cert Signing Authority")
    assert(result.certificates[0].issuer_o == "Root CA")
    assert(result.certificates[0].issuer_c is None)
    assert(result.certificates[0].valid_from.isoformat() == "2014-01-03T21:22:51+00:00")
    assert(result.certificates[0].valid_until.isoformat() == "2014-07-02T21:22:51+00:00")
    assert(result.certificates[0].checksum == "28:E6:A2:51:CE:D1:E9:34:2E:69:41:44:55:43:41:88:4D:93:4E:67:02:09:48:8C:86:68:25:8F:5E:DF:96:98")
    assert(result.certificates[0].checksum_md5 == "97:A2:0C:C7:93:E1:4B:24:6D:EA:55:09:6E:21:A8:96")
    assert(result.certificates[0].checksum_sha1 == "2B:FE:E8:F8:4B:25:19:D4:9B:3B:18:A3:29:E1:6C:79:72:FF:96:02")
    assert(result.certificates[0].checksum_sha256 == "28:E6:A2:51:CE:D1:E9:34:2E:69:41:44:55:43:41:88:4D:93:4E:67:02:09:48:8C:86:68:25:8F:5E:DF:96:98")
Exemplo n.º 15
0
def test_ping_4600():
    result = Result.get('{"af":4,"avg":47.951999999999998,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":0,"from":"188.195.183.141","fw":4600,"group_id":1000192,"lts":222,"max":48.990000000000002,"min":45.939,"msm_id":1000192,"msm_name":"Ping","prb_id":270,"proto":"ICMP","rcvd":3,"result":[{"rtt":45.939},{"rtt":48.927},{"rtt":48.990000000000002}],"sent":3,"size":12,"src_addr":"192.168.178.21","step":360,"timestamp":1392321470,"ttl":50,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 47.952)
    assert(result.rtt_median == 48.927)
    assert(result.destination_address == "62.2.16.24")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "188.195.183.141")
    assert(result.firmware == 4600)
    assert(result.seconds_since_sync == 222)
    assert(result.rtt_max == 48.99)
    assert(result.rtt_min == 45.939)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 270)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2014-02-13T19:57:50+00:00")
    assert(result.packets[0].rtt == 45.939)
    assert(result.packets[1].rtt == 48.927)
    assert(result.packets[2].rtt == 48.99)
    assert(result.packets[0].ttl == 50)
    assert(result.packets[1].ttl == 50)
    assert(result.packets[2].ttl == 50)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.178.21")
    assert(result.packets[1].source_address == "192.168.178.21")
    assert(result.packets[2].source_address == "192.168.178.21")
Exemplo n.º 16
0
def test_ssl_4520():
    result = Result.get('{"af":4,"cert":["-----BEGIN CERTIFICATE-----\nMIIEzjCCAragAwIBAgIDDXW/MA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv\nb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ\nQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y\ndEBjYWNlcnQub3JnMB4XDTEzMDcwNjA1NTQ1NFoXDTE0MDEwMjA1NTQ1NFowGDEW\nMBQGA1UEAxQNKi5wcmV0aWNhbC5lZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\nAQoCggEBAMS+vX7gA8TvzFwxryFFRj1OyQjnW88GvfMuGhKJopalG1EB103oRsxi\nMcXqwFZUicpqLKHW4lCHcRuhpKoZp8EOILnRAJRKFOjgIrcHQ02Xn4Lf/ewl601h\n5qxqt1keU1P8j+u9m7zZN+vOoNlEKZ5SnZhysAAYqr/XIt1WY2cji/4GxjF+q1OH\nIl5zddkIfnE52UbREKKlIakfFdj/c6GXqqsP2QTmm4x2HitCD964tZ06fA9BitQj\nnnBXNhtm2MCuBIPBSq0/C7LREwmfnqxCFqE7iqEPNIQ2IT2D4Gh4c+nIZHqYKvCV\nP3zh3aUaBj1o5Lo83IDdXCKAIiQRFMkCAwEAAaOBvzCBvDAMBgNVHRMBAf8EAjAA\nMA4GA1UdDwEB/wQEAwIDqDA0BgNVHSUELTArBggrBgEFBQcDAgYIKwYBBQUHAwEG\nCWCGSAGG+EIEAQYKKwYBBAGCNwoDAzAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUH\nMAGGF2h0dHA6Ly9vY3NwLmNhY2VydC5vcmcvMDEGA1UdHwQqMCgwJqAkoCKGIGh0\ndHA6Ly9jcmwuY2FjZXJ0Lm9yZy9yZXZva2UuY3JsMA0GCSqGSIb3DQEBBQUAA4IC\nAQA3/H0E30Ukgu+icBzxOIduVai4GMrNEved6P4toz7ZjzRXv4OczpIB8KSPS9S2\nv3EiL/YSymH9a+GrfuyZ83WqL8xNUEbCy8bkMimR0zL03dmQIM+9lCjofk80dl2l\nqhcvjk7H6nWyVJKxVN61+XiGCznhvqZJyAZLOFNaXqyryOLmnzPMM/a6kFOijU/m\nnhXrz56DVSYYbJVaTkJMFwNSQST+bJXz2OCWO3ovMd6iP13/w3/XL/L+p6p1wFOx\nYPa3j6pz0zeFYH4U4xlg95MtuMwMDxJtJBPavBotpKFHT89C2Da/mxgiJalmpcnh\nxFFRrbvkIc3oL2rW/+ZDhQpHbvMAXIhBnrBdTduSbargHaCm24Ga/R/JIxZJHP65\n2m17gtBbqijy+4fNxQE67+cWNS3k56LyXzW2Cm1Mvz9p8IjZFalO6zf45n55f5xE\nkK/kM2zZ5ZXJ28Y2wZ/nGABAqvQsbcd6/XtoTwcxt+GUQoCQ3AT2RR9Ar5p69yJG\n9aMR6bjnmtTnhCigtOj7L/IpKV1b1/+nK5+00wJEF6mIvtMCMr+7zf62LTLRgM8U\njzPNkFt0hzq3coOKOeho6pGvE9NyV+8Ed7K9H3DpYf4y5BDigOGfLVU9bnYaJdWn\ngRkq8Xmcm73lglN49oBXrxZrxQh0LAHWgbNxuQ3iMAvmuw==\n-----END CERTIFICATE-----"],"dst_addr":"80.79.115.54","dst_name":"pretical.ee","dst_port":"https","from":"77.95.64.18","fw":4520,"method":"SSL","msm_id":1006864,"msm_name":"SSLCert","prb_id":517,"src_addr":"77.95.64.18","timestamp":1378499876,"type":"sslcert","ver":"3.0"}')
    assert(isinstance(result, SslResult))
    assert(result.af == 4)
    assert(result.firmware == 4520)
    assert(result.destination_address == "80.79.115.54")
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address == "77.95.64.18")
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method == "SSL")
    assert(result.version == "3.0")
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-09-06T20:37:56+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 1)
    assert(result.certificates[0])
    assert(result.certificates[0].subject_cn == "*.pretical.ee")
    assert(result.certificates[0].subject_o is None)
    assert(result.certificates[0].subject_c is None)
    assert(result.certificates[0].issuer_cn == "CA Cert Signing Authority")
    assert(result.certificates[0].issuer_o == "Root CA")
    assert(result.certificates[0].issuer_c is None)
    assert(result.certificates[0].valid_from.isoformat() == "2013-07-06T05:54:54+00:00")
    assert(result.certificates[0].valid_until.isoformat() == "2014-01-02T05:54:54+00:00")
    assert(result.certificates[0].checksum == "F9:C1:DC:CE:CE:C2:E8:42:00:D1:A1:B5:0D:93:09:DE:73:DA:CE:56:0A:FD:A3:BB:B1:CC:1E:2E:47:15:C3:A6")
    assert(result.certificates[0].checksum_md5 == "38:07:D1:3C:0C:79:01:5E:F6:0E:6B:48:B4:3C:F4:59")
    assert(result.certificates[0].checksum_sha1 == "C5:31:2B:AC:B2:4F:D2:F8:47:57:2A:4F:04:D7:F9:18:91:20:C7:1F")
    assert(result.certificates[0].checksum_sha256 == "F9:C1:DC:CE:CE:C2:E8:42:00:D1:A1:B5:0D:93:09:DE:73:DA:CE:56:0A:FD:A3:BB:B1:CC:1E:2E:47:15:C3:A6")
Exemplo n.º 17
0
def test_ping_4570():
    result = Result.get('{"af":4,"avg":36.608333333333327,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"62.195.143.53","fw":4570,"lts":-1,"max":36.741,"min":36.423999999999999,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":36.741},{"rtt":36.659999999999997},{"rtt":36.423999999999999}],"sent":3,"size":12,"step":360,"timestamp":1384500425, "type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 36.608)
    assert(result.rtt_median == 36.66)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "62.195.143.53")
    assert(result.firmware == 4570)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 36.741)
    assert(result.rtt_min == 36.424)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2013-11-15T07:27:05+00:00")
    assert(result.packets[0].rtt == 36.741)
    assert(result.packets[1].rtt == 36.66)
    assert(result.packets[2].rtt == 36.424)
    assert(result.packets[0].ttl is None)
    assert(result.packets[1].ttl is None)
    assert(result.packets[2].ttl is None)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address is None)
    assert(result.packets[1].source_address is None)
    assert(result.packets[2].source_address is None)
Exemplo n.º 18
0
def test_ping_4560():
    result = Result.get('{"af":4,"avg":36.887,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"62.195.143.53","fw":4560,"lts":36,"max":40.234000000000002,"min":34.747999999999998,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":40.234000000000002},{"rtt":34.747999999999998,"srcaddr":"192.168.1.229"},{"rtt":35.679000000000002,"srcaddr":"192.168.1.229"}],"sent":3,"size":20,"src_addr":"192.168.1.229","step":360,"timestamp":1380586151,"ttl":54,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 36.887)
    assert(result.rtt_median == 35.679)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "62.195.143.53")
    assert(result.firmware == 4560)
    assert(result.seconds_since_sync is 36)
    assert(result.rtt_max == 40.234)
    assert(result.rtt_min == 34.748)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2013-10-01T00:09:11+00:00")
    assert(result.packets[0].rtt == 40.234)
    assert(result.packets[1].rtt == 34.748)
    assert(result.packets[2].rtt == 35.679)
    assert(result.packets[0].ttl == 54)
    assert(result.packets[1].ttl == 54)
    assert(result.packets[2].ttl == 54)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
Exemplo n.º 19
0
def test_ping_4550():
    result = Result.get('{"af":4,"avg":27.300999999999998,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"80.56.151.3","fw":4550,"lts":365,"max":27.300999999999998,"min":27.300999999999998,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":1,"result":[{"srcaddr":"192.168.1.229","x":"*"},{"x":"*"},{"rtt":27.300999999999998,"ttl":54}],"sent":3,"size":20,"src_addr":"192.168.1.229","step":360,"timestamp":1378271710,"ttl":54,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 27.301)
    assert(result.rtt_median == 27.301)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "80.56.151.3")
    assert(result.firmware == 4550)
    assert(result.seconds_since_sync == 365)
    assert(result.rtt_max == 27.301)
    assert(result.rtt_min == 27.301)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 1)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2013-09-04T05:15:10+00:00")
    assert(result.packets[0].rtt is None)
    assert(result.packets[1].rtt is None)
    assert(result.packets[2].rtt == 27.301)
    assert(result.packets[0].ttl is None)
    assert(result.packets[1].ttl is None)
    assert(result.packets[2].ttl == 54)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
Exemplo n.º 20
0
    def __iter__(self):

        sagans = []

        for line in self._iterable:

            # line may be a dictionary (parsed JSON)
            if hasattr(line, "strip"):
                line = line.strip()

            # Break out when there's nothing left
            if not line:
                break

            try:
                sagan = SaganResult.get(
                    line,
                    on_error=SaganResult.ACTION_IGNORE,
                    on_warning=SaganResult.ACTION_IGNORE
                )
                if not self._probes or sagan.probe_id in self._probes:
                    sagans.append(sagan)
                if len(sagans) > 100:
                    for sagan in self._attach_probes(sagans):
                        yield sagan
                    sagans = []
            except ResultParseError:
                pass  # Probably garbage in the file

        for sagan in self._attach_probes(sagans):
            yield sagan
Exemplo n.º 21
0
def test_ping_buggy():
    result = Result.get('{"af":4,"avg":-1,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":2,"from":"62.195.143.53","fw":4600,"lts":130,"max":-1,"min":-1,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":0,"result":[{"srcaddr":"192.168.1.229","x":"*"},{"dup":1,"rtt":1635.423,"ttl":55},{"dup":1,"rtt":1800.4939999999999}],"sent":1,"size":12,"src_addr":"192.168.1.229","step":360,"timestamp":1394745831,"ttl":55,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average is None)
    assert(result.rtt_median is None)
    assert(result.destination_address == "62.2.16.24")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 2)
    assert(result.origin == "62.195.143.53")
    assert(result.firmware == 4600)
    assert(result.seconds_since_sync == 130)
    assert(result.rtt_max is None)
    assert(result.rtt_min is None)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 0)
    assert(result.packets_sent == 1)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    print(result.created, type(result.created))
    print(result.created.isoformat())
    assert(result.created.isoformat() == "2014-03-13T21:23:51+00:00")
    assert(result.packets[0].rtt is None)
    assert(result.packets[1].rtt == 1635.423)
    assert(result.packets[2].rtt == 1800.494)
    assert(result.packets[0].ttl is None)
    assert(result.packets[1].ttl == 55)
    assert(result.packets[2].ttl == 55)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is True)
    assert(result.packets[2].dup is True)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
Exemplo n.º 22
0
 def add_probe_and_target_results(self, results_dict):
     with open(self.filename) as results:
         for result in results.readlines():
             parsed_result = Result.get(result)
             probe_id = self._get_attr("probe_id", parsed_result)
             target = self._get_attr("target", parsed_result)
             key = str(probe_id) + ' ; ' + target
             origin = parsed_result.origin
             try:
                 # see if this key exists yet
                 inner_dict = results_dict[str(key)]
             except KeyError:
                 # initialize all types to 0
                 results_dict[str(key)] = {"probe_id" : probe_id, "target" : target, "ping" : 0, "dns" : 0, "traceroute" : 0, "origins" : {}}
                 # increment the appropriate type (ping, dns, traceroute)
                 results_dict[str(key)][self.type] += 1
                 results_dict[str(key)]["origins"][origin] = 1
             else:
                 # already initialized, increment
                 results_dict[str(key)][self.type] += 1
                 # origins
                 try:
                     results_dict[str(key)]["origins"][origin] += 1
                 except KeyError:
                     results_dict[str(key)]["origins"][origin] = 1
Exemplo n.º 23
0
def test_wifi_error():
    raw_data = {
        "bundle": 1463493022,
        "error": "wpa timeout",
        "from": "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0",
        "fw": "4733",
        "group_id": 1021275,
        "msm_id": 1021275,
        "msm_name": "WiFi",
        "prb_id": 105,
        "timestamp": 1463493023,
        "type": "wifi",
        "wpa_supplicant": {"connect-time": "11"},
    }

    result = Result.get(raw_data)
    assert isinstance(result, WiFiResult)
    assert result.bundle == 1463493022
    assert result.origin == "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0"
    assert result.firmware == 4733
    assert result.group_id == 1021275
    assert result.created_timestamp == 1463493023
    assert result.wpa_supplicant.address is None
    assert result.wpa_supplicant.bssid is None
    assert result.wpa_supplicant.connect_time == "11"
    assert result.wpa_supplicant.group_cipher is None
    assert result.wpa_supplicant.wpa_supplicant_id is None
    assert result.wpa_supplicant.ip_address is None
    assert result.wpa_supplicant.key_management is None
    assert result.wpa_supplicant.mode is None
    assert result.wpa_supplicant.pairwise_cipher is None
    assert result.wpa_supplicant.ssid is None
    assert result.wpa_supplicant.wpa_state is None
Exemplo n.º 24
0
 def add_to_results_dict(self, key_name, results_dict):
     with open(self.filename) as results:
         for result in results.readlines():
             parsed_result = Result.get(result)
             key = self._get_attr(key_name, parsed_result)
             origin = parsed_result.origin
             target = self._get_attr("target", parsed_result)
             try:
                 # see if this key exists yet
                 inner_dict = results_dict[str(key)]
             except KeyError:
                 # initialize all types to 0
                 results_dict[str(key)] = {"ping" : 0, "dns" : 0, "traceroute" : 0, "origins" : {}, "targets" : {}}
                 # increment the appropriate type
                 results_dict[str(key)][self.type] += 1
                 results_dict[str(key)]["origins"][origin] = 1
                 results_dict[str(key)]["targets"][target] = 1
             else:
                 # already initialized, increment
                 results_dict[str(key)][self.type] += 1
                 # origins
                 try:
                     results_dict[str(key)]["origins"][origin] += 1
                 except KeyError:
                     results_dict[str(key)]["origins"][origin] = 1
                 # targets
                 try:
                     results_dict[str(key)]["targets"][target] += 1
                 except KeyError:
                     results_dict[str(key)]["targets"][target] = 1
Exemplo n.º 25
0
    def __call__(self, key, value):
        while type(value) == str or type(value) == unicode:
            value = json.load(value)

	parsed_result = Result.get(value)

        ipStr = parsed_result.origin

        gir = self.geo.record_by_addr(ipStr)
        if gir is None:
            value["geo"] = {}
            yield key, value
            return

        d = {}

        fields = ["country_code", "country_name", "region", "region_name",
                "city", "postal_code", "latitude", "longitude", "area_code",
                "time_zone", "metro_code"]

        saved_fields = ["cc", "country", "st", "state", "city", "postcode",
                "lat", "lng", "areacode", "tz", "metrocode"]

        for field, save_as in zip(fields, saved_fields):
            val = gir[field]
            if val is None: continue
            d[save_as] = val

        value["geo"] = d

        yield key, value
Exemplo n.º 26
0
    def process_results(self, results, probes_filter):
        logger.info("Processing results...")

        # Be sure to have info for every probe in the resultset
        self.update_probes(results)

        if len(results) == 0:
            logger.info("No results found.")
            return

        # Processing results...

        for json_result in results:
            result = Result.get(json_result, on_error=Result.ACTION_IGNORE,
                                on_malformation=Result.ACTION_IGNORE)

            probe = self.get_probe(result)
            if probe not in probes_filter:
                logger.debug(
                    "  skipping {} because of probes filter".format(probe)
                )
                continue

            self.process_result(result)
            self.update_latest_result_ts(result)
            self.internal_labels["results"] = {}

        self.ip_cache.save()
Exemplo n.º 27
0
    def setUp(self):
        result = {'af': 4, 'prb_id': 1216, 'result': [{'rtt': 27.429}, {'rtt': 25.672}, {'rtt': 25.681}], 'ttl': 54, 'avg': 26.2606666667, 'size': 20, 'from': '109.190.83.40', ' proto': 'ICMP', 'timestamp': 1445025400, 'dup': 0, 'type': 'ping', 'sent': 3, 'msm_id': 1000192, 'fw': 4700, 'max': 27.429, 'step': 360, 'src_addr': '192.168.103.132', 'rcvd': 3, 'msm_name': 'Ping', 'lts': 377, 'dst_name': 'hsi.cablecom.ch', 'min': 25.672, 'dst_addr': '62.2.16.24'}

        probes = [
            Probe(
                id=1216,
                meta_data={"country_code": "GR", "asn_v4": 3337, "asn_v6": "4445"}
            ),
            Probe(
                id=121,
                meta_data={"country_code": "GR", "asn_v4": 3338, "asn_v6": "4445"}
            ),
            Probe(
                id=12,
                meta_data={"country_code": "DE", "asn_v4": 3339, "asn_v6": 3337}
            ),
            Probe(
                id=1,
                meta_data={"country_code": "NL", "asn_v4": 3337, "asn_v6": "4446"}
            )
        ]
        self.sagan_results = []
        for probe in probes:
            sagan_result = Result.get(
                result, on_error=Result.ACTION_IGNORE, on_warning=Result.ACTION_IGNORE
            )
            sagan_result.probe = probe
            self.sagan_results.append(sagan_result)
Exemplo n.º 28
0
def test_ssl_4500():
    result = Result.get('{"af":4,"cert":["-----BEGIN CERTIFICATE-----\nMIIFBTCCAu2gAwIBAgIDDLHHMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv\nb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ\nQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y\ndEBjYWNlcnQub3JnMB4XDTEzMDEwNjE0MDA1NVoXDTEzMDcwNTE0MDA1NVowGDEW\nMBQGA1UEAxQNKi5wcmV0aWNhbC5lZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\nAQoCggEBAMS+vX7gA8TvzFwxryFFRj1OyQjnW88GvfMuGhKJopalG1EB103oRsxi\nMcXqwFZUicpqLKHW4lCHcRuhpKoZp8EOILnRAJRKFOjgIrcHQ02Xn4Lf/ewl601h\n5qxqt1keU1P8j+u9m7zZN+vOoNlEKZ5SnZhysAAYqr/XIt1WY2cji/4GxjF+q1OH\nIl5zddkIfnE52UbREKKlIakfFdj/c6GXqqsP2QTmm4x2HitCD964tZ06fA9BitQj\nnnBXNhtm2MCuBIPBSq0/C7LREwmfnqxCFqE7iqEPNIQ2IT2D4Gh4c+nIZHqYKvCV\nP3zh3aUaBj1o5Lo83IDdXCKAIiQRFMkCAwEAAaOB9jCB8zAMBgNVHRMBAf8EAjAA\nMA4GA1UdDwEB/wQEAwIDqDA0BgNVHSUELTArBggrBgEFBQcDAgYIKwYBBQUHAwEG\nCWCGSAGG+EIEAQYKKwYBBAGCNwoDAzAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUH\nMAGGF2h0dHA6Ly9vY3NwLmNhY2VydC5vcmcvMDEGA1UdHwQqMCgwJqAkoCKGIGh0\ndHA6Ly9jcmwuY2FjZXJ0Lm9yZy9yZXZva2UuY3JsMDUGA1UdEQQuMCyCDSoucHJl\ndGljYWwuZWWgGwYIKwYBBQUHCAWgDwwNKi5wcmV0aWNhbC5lZTANBgkqhkiG9w0B\nAQUFAAOCAgEAycddS/c47eo0WVrFxpvCIJdfvn7CYdTPpXNSg0kjapkSjYuAkcmq\nsrScUUGMBe6tfkmkdPTuNKwRVYNJ1Wi9EYaMvJ3CVw6x9O5mgktmu0ogbIXsivwI\nTSzGDMWcb9Of85e/ALWpK0cWIugtWO0d6v3qMWfxlYfAaYu49pttOJQOjbXAAhfR\njE5VOcDaIlWChG48jLAyCLsMwHlyLw8D5Myb9MfTs1XxgLESO9ZTSqGEqJw+BwTJ\nstHk/oCHo9FL/Xv5MmFcNaTpqbB60duYJ+DLLX1QiRRfLJ18G7wEiEAm6H9egupQ\nL9MhQQLJ4o60xTrCnpqGTXTSR16jiTm70bDB0+SU3xTpNwCzdigH6ceKbPIr0cO6\no0ump598e2JNCPsXIc+XcbLDDFgYrlnl3YnK3J+K3LC7SWPMsYdDfe+Im880tNuW\nOlnOCDpP8408KqCp4xm0DMznmThUM34/Ia+o8Q3NWNBfuaOsJ9aA+FmgobJhih9e\nUr9x3ByRQXcW5Cs/AMtCikKWVPsx+IA5eeyt+1i+dKBWksO40B3ADsq1O5DRYYRa\n+dwqdX/jduqZjbyHuFH04q28j4zVDviUBQEa9UQoDM3c82dILDjbYtZ+T28sPMTa\nbMZdcMur9E+ovrS58lIKGCvDEPSUDXHzr0tpb4A13TTnxW6pclqUyJk=\n-----END CERTIFICATE-----"],"dst_addr":"80.79.115.54","dst_name":"pretical.ee","dst_port":"https","from":"77.95.64.18","fw":4500,"method":"SSL","msm_id":1006864,"prb_id":517,"src_addr":"77.95.64.18","timestamp":1365577623,"type":"sslcert","ver":"3.0"}')
    assert(isinstance(result, SslResult))
    assert(result.af == 4)
    assert(result.firmware == 4500)
    assert(result.destination_address == "80.79.115.54")
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address == "77.95.64.18")
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method == "SSL")
    assert(result.version == "3.0")
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-04-10T07:07:03+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 1)
    assert(result.certificates[0])
    assert(result.certificates[0].subject_cn == "*.pretical.ee")
    assert(result.certificates[0].subject_o is None)
    assert(result.certificates[0].subject_c is None)
    assert(result.certificates[0].issuer_cn == "CA Cert Signing Authority")
    assert(result.certificates[0].issuer_o == "Root CA")
    assert(result.certificates[0].issuer_c is None)
    assert(result.certificates[0].valid_from.isoformat() == "2013-01-06T14:00:55+00:00")
    assert(result.certificates[0].valid_until.isoformat() == "2013-07-05T14:00:55+00:00")
    assert(result.certificates[0].checksum == "AC:D1:6F:FB:3A:F2:06:C9:92:A4:4D:2A:A2:0B:1C:37:35:25:75:A7:5D:4A:62:21:03:AD:E6:46:42:E5:65:4C")
    assert(result.certificates[0].checksum_md5 == "91:EA:DF:FF:57:6F:7C:91:F1:83:2A:9F:7F:A2:FE:E4")
    assert(result.certificates[0].checksum_sha1 == "11:00:27:07:F7:E8:0C:6B:5F:B6:A3:5A:20:19:BC:CA:22:85:E5:3C")
    assert(result.certificates[0].checksum_sha256 == "AC:D1:6F:FB:3A:F2:06:C9:92:A4:4D:2A:A2:0B:1C:37:35:25:75:A7:5D:4A:62:21:03:AD:E6:46:42:E5:65:4C")
Exemplo n.º 29
0
def test_ping_4460():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":48.388333333333328,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"188.194.234.136","fw":4460,"max":56.948999999999998,"min":43.869999999999997,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":270,"proto":"ICMP","rcvd":3,"result":[{"rtt":43.869999999999997},{"rtt":56.948999999999998},{"rtt":44.345999999999997}],"sent":3,"size":20,"src_addr":"192.168.178.21","timestamp":1340524626,"ttl":52,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 48.388)
    assert(result.rtt_median == 44.346)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "188.194.234.136")
    assert(result.firmware == 4460)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 56.949)
    assert(result.rtt_min == 43.87)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 270)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-06-24T07:57:06+00:00")
    assert(result.packets[0].rtt == 43.87)
    assert(result.packets[1].rtt == 56.949)
    assert(result.packets[2].rtt == 44.346)
    assert(result.packets[0].ttl == 52)
    assert(result.packets[1].ttl == 52)
    assert(result.packets[2].ttl == 52)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.178.21")
    assert(result.packets[1].source_address == "192.168.178.21")
    assert(result.packets[2].source_address == "192.168.178.21")
Exemplo n.º 30
0
def test_ping_4520():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":67.420999999999992,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4520,"max":70.230999999999995,"min":65.974999999999994,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":70.230999999999995},{"rtt":65.974999999999994},{"rtt":66.057000000000002}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1365379380,"ttl":47,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 67.421)
    assert(result.rtt_median == 66.057)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "194.85.27.7")
    assert(result.firmware == 4520)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 70.231)
    assert(result.rtt_min == 65.975)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 165)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2013-04-08T00:03:00+00:00")
    assert(result.packets[0].rtt == 70.231)
    assert(result.packets[1].rtt == 65.975)
    assert(result.packets[2].rtt == 66.057)
    assert(result.packets[0].ttl == 47)
    assert(result.packets[1].ttl == 47)
    assert(result.packets[2].ttl == 47)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.3.8")
    assert(result.packets[1].source_address == "192.168.3.8")
    assert(result.packets[2].source_address == "192.168.3.8")
Exemplo n.º 31
0
def test_ping_0(rr):
    result = Result.get(rr)
    print(result.af)
    print(result.rtt_average)
    print(result.rtt_median)
    print(result.destination_address)
    print(result.destination_name)
    print(result.duplicates)
    print(result.origin)
    print(result.firmware)
    print(result.seconds_since_sync)
    print(result.rtt_max)
    print(result.rtt_min)
    print(result.measurement_id)
    print(result.probe_id)
    print(result.protocol)
    print(result.packets_received)
    print(result.packets_sent)
    print(result.packet_size)
    print(result.step)
    print(result.created)
    print(result.packets)
Exemplo n.º 32
0
def test_ping_1():
    result = Result.get('{"addr":"62.2.16.12","avg":124.572,"dup":0,"from":"194.85.27.7","fw":1,"max":125.44499999999999,"min":123.89400000000001,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"rcvd":3,"sent":3,"size":56,"timestamp":1340523908,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 124.572)
    assert(result.rtt_median is None)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "194.85.27.7")
    assert(result.firmware == 1)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 125.445)
    assert(result.rtt_min == 123.894)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 165)
    assert(result.protocol is None)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size is None)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-06-24T07:45:08+00:00")
    assert(result.packets == [])
Exemplo n.º 33
0
def test_http_1():
    result = Result.get(
        '{"from":"62.194.83.50","fw":1,"msm_id":12023,"prb_id":1,"result":"GET4 193.0.6.139 0.030229 200 263 1406","timestamp":1333387900,"type":"http"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "62.194.83.50")
    assert (result.firmware == 1)
    assert (result.measurement_id == 12023)
    assert (result.probe_id == 1)
    assert (result.created.isoformat() == "2012-04-02T17:31:40+00:00")
    assert (result.uri is None)
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af is None)
    assert (result.responses[0].body_size == 1406)
    assert (result.responses[0].head_size == 263)
    assert (result.responses[0].destination_address == "193.0.6.139")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 30.229)
    assert (result.responses[0].source_address is None)
    assert (result.responses[0].version is None)
Exemplo n.º 34
0
def test_http_4430():
    result = Result.get(
        '{"from":"62.194.83.50","fw":4430,"msm_id":12023,"prb_id":1,"result":[{"addr":"193.0.6.139","bsize":1406,"hsize":263,"mode":"GET4","res":200,"rt":27.276,"srcaddr":"192.168.99.183","ver":"1.1"}],"timestamp":1336418202,"type":"http"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "62.194.83.50")
    assert (result.firmware == 4430)
    assert (result.measurement_id == 12023)
    assert (result.probe_id == 1)
    assert (result.created.isoformat() == "2012-05-07T19:16:42+00:00")
    assert (result.uri is None)
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af is None)
    assert (result.responses[0].body_size == 1406)
    assert (result.responses[0].head_size == 263)
    assert (result.responses[0].destination_address == "193.0.6.139")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 27.276)
    assert (result.responses[0].source_address == "192.168.99.183")
    assert (result.responses[0].version == "1.1")
Exemplo n.º 35
0
def test_http_4610_fail():
    result = Result.get('{"from":"2001:630:301:1080:220:4aff:fee0:20a0","fw":4610,"msm_id":1003932,"msm_name":"HTTPGet","prb_id":2493,"result":[{"af":6,"dst_addr":"2001:42d0:0:200::6","err":"timeout reading chunk","method":"GET","src_addr":"2001:630:301:1080:220:4aff:fee0:20a0"}],"timestamp":1398184661,"type":"http","uri":"http://www.afrinic.net/"}')
    assert(isinstance(result, HttpResult))
    assert(result.origin == "2001:630:301:1080:220:4aff:fee0:20a0")
    assert(result.firmware == 4610)
    assert(result.measurement_id == 1003932)
    assert(result.probe_id == 2493)
    assert(result.created.isoformat() == "2014-04-22T16:37:41+00:00")
    assert(result.uri == "http://www.afrinic.net/")
    assert(result.method == HttpResult.METHOD_GET)
    assert(isinstance(result.responses, list))
    assert(len(result.responses) == 1)
    assert(result.responses[0].af == 6)
    assert(result.responses[0].body_size is None)
    assert(result.responses[0].head_size is None)
    assert(result.responses[0].destination_address == "2001:42d0:0:200::6")
    assert(result.responses[0].code is None)
    assert(result.responses[0].response_time is None)
    assert(result.responses[0].source_address == "2001:630:301:1080:220:4aff:fee0:20a0")
    assert(result.responses[0].version is None)
    assert(result.responses[0].is_error is True)
    assert(result.responses[0].error_message == "timeout reading chunk")
Exemplo n.º 36
0
def test_ping_0():
    result = Result.get('{"avg":"58.042","dst_addr":"62.2.16.12","dup":"0","fw":0,"max":"58.272","min":"57.876","msm_id":1000192,"prb_id":677,"rcvd":"3","sent":"3","src_addr":"78.128.9.202","timestamp":1328019792,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 58.042)
    assert(result.rtt_median is None)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name is None)
    assert(result.duplicates == 0)
    assert(result.origin is None)
    assert(result.firmware == 0)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 58.272)
    assert(result.rtt_min == 57.876)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 677)
    assert(result.protocol is None)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size is None)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-01-31T14:23:12+00:00")
    assert(result.packets == [])
Exemplo n.º 37
0
def test_qbuf():
    result = Result.get(
        '{"from":"208.118.139.24","fw":4610,"group_id":1666151,"msm_id":1666151,"msm_name":"Tdig","prb_id":15112,"resultset":[{"af":4,"dst_addr":"8.8.8.8","proto":"TCP","qbuf":"dakBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjMDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=","result":{"ANCOUNT":0,"ARCOUNT":1,"ID":30121,"NSCOUNT":1,"QDCOUNT":1,"rt":57.764,"size":133},"src_addr":"10.0.5.101","subid":1,"submax":2,"time":1400665523},{"af":4,"dst_addr":"8.8.4.4","proto":"TCP","qbuf":"JTEBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjQDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=","result":{"ANCOUNT":0,"ARCOUNT":1,"ID":9521,"NSCOUNT":1,"QDCOUNT":1,"rt":57.263,"size":133},"src_addr":"10.0.5.101","subid":2,"submax":2,"time":1400665524}],"timestamp":1400665523,"type":"dns"}'
    )
    assert (result.responses[0].abuf is None)
    assert (
        str(result.responses[0].qbuf) ==
        "dakBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjMDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA="
    )
    assert (result.responses[0].qbuf.header.aa is False)
    assert (result.responses[0].qbuf.header.qr is False)
    assert (result.responses[0].qbuf.header.nscount == 0)
    assert (result.responses[0].qbuf.header.qdcount == 1)
    assert (result.responses[0].qbuf.header.ancount == 0)
    assert (result.responses[0].qbuf.header.tc is False)
    assert (result.responses[0].qbuf.header.rd is True)
    assert (result.responses[0].qbuf.header.arcount == 1)
    assert (result.responses[0].qbuf.header.return_code == "NOERROR")
    assert (result.responses[0].qbuf.header.opcode == "QUERY")
    assert (result.responses[0].qbuf.header.ra is True)
    assert (result.responses[0].qbuf.header.z == 0)
    assert (result.responses[0].qbuf.header.id == 30121)
    assert (len(result.responses[0].qbuf.questions) == 1)
    assert (result.responses[0].qbuf.questions[0].klass == "IN")
    assert (result.responses[0].qbuf.questions[0].type == "A")
    assert (result.responses[0].qbuf.questions[0].name ==
            "15112.1400665523.www.twitter.com.")
    assert (result.responses[0].qbuf.edns0.extended_return_code == 0)
    assert (result.responses[0].qbuf.edns0.udp_size == 512)
    assert (result.responses[0].qbuf.edns0.version == 0)
    assert (result.responses[0].qbuf.edns0.z == 255)
    assert (result.responses[0].qbuf.edns0.type == "OPT")
    assert (result.responses[0].qbuf.edns0.name == ".")
    assert (len(result.responses[0].qbuf.edns0.options) == 1)
    assert (result.responses[0].qbuf.edns0.options[0].code == 3)
    assert (result.responses[0].qbuf.edns0.options[0].name == "NSID")
    assert (result.responses[0].qbuf.edns0.options[0].nsid == "")
    assert (result.responses[0].qbuf.edns0.options[0].length == 0)
Exemplo n.º 38
0
def test_ping_4610():
    result = Result.get('{"af":4,"avg":57.140666666666668,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":0,"from":"188.195.181.120","fw":4610,"group_id":1000192,"lts":93,"max":63.213000000000001,"min":47.941000000000003,"msm_id":1000192,"msm_name":"Ping","prb_id":270,"proto":"ICMP","rcvd":3,"result":[{"rtt":63.213000000000001},{"rtt":47.941000000000003,"ttl":51},{"rtt":60.268000000000001,"ttl":50}],"sent":3,"size":12,"src_addr":"192.168.178.21","step":360,"timestamp":1395416383,"ttl":50,"type":"ping"}')
    assert(isinstance(result, Result))
    assert(isinstance(result, PingResult))
    assert(isinstance(result.packets[0], Packet))
    assert(isinstance(result.packets[1], Packet))
    assert(isinstance(result.packets[2], Packet))
    assert(result.af == 4)
    assert(result.rtt_average == 57.141)
    assert(result.rtt_median == 60.268)
    assert(result.destination_address == "62.2.16.24")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "188.195.181.120")
    assert(result.firmware == 4610)
    assert(result.seconds_since_sync == 93)
    assert(result.rtt_max == 63.213)
    assert(result.rtt_min == 47.941)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 270)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2014-03-21T15:39:43+00:00")
    assert(result.packets[0].rtt == 63.213)
    assert(result.packets[1].rtt == 47.941)
    assert(result.packets[2].rtt == 60.268)
    assert(result.packets[0].ttl == 50)
    assert(result.packets[1].ttl == 51)
    assert(result.packets[2].ttl == 50)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.178.21")
    assert(result.packets[1].source_address == "192.168.178.21")
    assert(result.packets[2].source_address == "192.168.178.21")
Exemplo n.º 39
0
def test_http_4470():
    result = Result.get(
        '{"from":"2001:4538:100:0:220:4aff:fec8:232b","fw":4470,"msm_id":1003930,"prb_id":303,"result":[{"af":6,"bsize":22243,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":765.25400000000002,"src_addr":"2001:4538:100:0:220:4aff:fec8:232b","ver":"1.1"}],"timestamp":1352869218,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2001:4538:100:0:220:4aff:fec8:232b")
    assert (result.firmware == 4470)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 303)
    assert (result.created.isoformat() == "2012-11-14T05:00:18+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 22243)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 765.254)
    assert (result.responses[0].source_address == result.origin)
    assert (result.responses[0].version == "1.1")
Exemplo n.º 40
0
def test_http_4460():
    result = Result.get(
        '{"from":"2001:780:100:6:220:4aff:fee0:2479","fw":4460,"msm_id":1003930,"prb_id":2707,"result":[{"af":6,"bsize":22383,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":71.146000000000001,"src_addr":"2001:780:100:6:220:4aff:fee0:2479","ver":"1.1"}],"timestamp":1350471605,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2001:780:100:6:220:4aff:fee0:2479")
    assert (result.firmware == 4460)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 2707)
    assert (result.created.isoformat() == "2012-10-17T11:00:05+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 22383)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 71.146)
    assert (result.responses[0].source_address == result.origin)
    assert (result.responses[0].version == "1.1")
Exemplo n.º 41
0
def test_http_4560():
    result = Result.get(
        '{"from":"2620:0:2ed0:aaaa::210","fw":4560,"msm_id":1003930,"msm_name":"HTTPGet","prb_id":1164,"result":[{"af":6,"bsize":39340,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":739.26999999999998,"src_addr":"2620:0:2ed0:aaaa::210","ver":"1.1"}],"timestamp":1385895661,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2620:0:2ed0:aaaa::210")
    assert (result.firmware == 4560)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 1164)
    assert (result.created.isoformat() == "2013-12-01T11:01:01+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 39340)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 739.27)
    assert (result.responses[0].source_address == "2620:0:2ed0:aaaa::210")
    assert (result.responses[0].version == "1.1")
def read_path(m):
    src_ip = m['from']
    r = Result.get(m)
    dst_ip = r.destination_address
    src_asn = get_asn(src_ip)
    dst_asn = get_asn(dst_ip)
    if src_asn is None or dst_asn is None:
        return None

    try:
        ippath = [x[0] for x in r.ip_path]
    except:
        ippath = []
    res = trim_path(src_asn, dst_asn, ippath)
    if res is None:
        return None
    return {
        'src_ip': src_ip,
        'dst_ip': dst_ip,
        'src_asn': src_asn,
        'dst_asn': dst_asn,
        'path': res,
    }
Exemplo n.º 43
0
def test_http_4500():
    result = Result.get(
        '{"from":"2a02:8304:1:4:220:4aff:fee0:228d","fw":4500,"msm_id":1003930,"prb_id":2954,"result":[{"af":6,"bsize":40103,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":234.048,"src_addr":"2a02:8304:1:4:220:4aff:fee0:228d","ver":"1.1"}],"timestamp":1367233244,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2a02:8304:1:4:220:4aff:fee0:228d")
    assert (result.firmware == 4500)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 2954)
    assert (result.created.isoformat() == "2013-04-29T11:00:44+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 40103)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 234.048)
    assert (result.responses[0].source_address == result.origin)
    assert (result.responses[0].version == "1.1")
Exemplo n.º 44
0
def test_http_4520():
    result = Result.get(
        '{"from":"2a02:27d0:100:115:6000::250","fw":4520,"msm_id":1003930,"msm_name":"HTTPGet","prb_id":2802,"result":[{"af":6,"bsize":40567,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":102.825,"src_addr":"2a02:27d0:100:115:6000::250","ver":"1.1"}],"timestamp":1379594363,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2a02:27d0:100:115:6000::250")
    assert (result.firmware == 4520)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 2802)
    assert (result.created.isoformat() == "2013-09-19T12:39:23+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 40567)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 102.825)
    assert (result.responses[0].source_address == result.origin)
    assert (result.responses[0].version == "1.1")
Exemplo n.º 45
0
    def add_compound_key_results(self, probe_id, results_dict, key_part1_str, key_part2_str):
        '''
        key_part1 - the first part of the key (e.g. "probe_id")
        key_part2 - the second part of the key (e.g. "target")
        So the key would be "probe_id ; target"
        '''
        with open(self.filename) as results:
            for result in results.readlines():

                # First determine whether to skip this result
                if probe_id != None:
                    this_probe_id = json.loads(result)["prb_id"]
                    if this_probe_id != probe_id:
                        continue    # skip to next result

                parsed_result = Result.get(result)
                val_part1 = self._get_attr(key_part1_str, parsed_result)
                val_part2 = self._get_attr(key_part2_str, parsed_result)
                key = str(val_part1) + ' ; ' + str(val_part2)
                origin = parsed_result.origin
                try:
                    # see if this key exists yet
                    inner_dict = results_dict[str(key)]
                except KeyError:
                    # initialize all types to 0
                    results_dict[str(key)] = {key_part1_str : val_part1, key_part2_str : val_part2, "ping" : 0, "dns" : 0, "traceroute" : 0, "origins" : {}}
                    # increment the appropriate type (ping, dns, traceroute)
                    results_dict[str(key)][self.type] += 1
                    results_dict[str(key)]["origins"][origin] = 1
                else:
                    # already initialized, increment
                    results_dict[str(key)][self.type] += 1
                    # origins
                    try:
                        results_dict[str(key)]["origins"][origin] += 1
                    except KeyError:
                        results_dict[str(key)]["origins"][origin] = 1
Exemplo n.º 46
0
def test_ping_duplicate():
    result = Result.get('{"af":4,"avg":27.768000000000001,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":2,"from":"109.190.83.40","fw":4610,"lts":38,"max":27.768000000000001,"min":27.768000000000001,"msm_id":1000192,"msm_name":"Ping","prb_id":1216,"proto":"ICMP","rcvd":1,"result":[{"srcaddr":"192.168.103.130","x":"*"},{"dup":1,"rtt":36.454000000000001,"ttl":54},{"dup":1,"rtt":37.756},{"rtt":27.768000000000001}],"sent":2,"size":12,"src_addr":"192.168.103.130","step":360,"timestamp":1395277728,"ttl":54,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 27.768)
    assert(result.rtt_median == 27.768)
    assert(result.destination_address == "62.2.16.24")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 2)
    assert(result.origin == "109.190.83.40")
    assert(result.firmware == 4610)
    assert(result.seconds_since_sync == 38)
    assert(result.rtt_max == 27.768)
    assert(result.rtt_min == 27.768)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 1216)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 1)
    assert(result.packets_sent == 2)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2014-03-20T01:08:48+00:00")
    assert(result.packets[0].rtt is None)
    assert(result.packets[1].rtt == 36.454)
    assert(result.packets[2].rtt == 37.756)
    assert(result.packets[3].rtt == 27.768)
    assert(result.packets[0].ttl is None)
    assert(result.packets[1].ttl == 54)
    assert(result.packets[2].ttl == 54)
    assert(result.packets[3].ttl == 54)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is True)
    assert(result.packets[2].dup is True)
    assert(result.packets[3].dup is False)
    assert(result.packets[0].source_address == "192.168.103.130")
    assert(result.packets[1].source_address == "192.168.103.130")
    assert(result.packets[2].source_address == "192.168.103.130")
    assert(result.packets[3].source_address == "192.168.103.130")
def get_results(mid):
    kwargs = {
        "msm_id": mid,
        }

    is_success, results = AtlasResultsRequest(**kwargs).create()

    if is_success:
#        print(results)
        pass
    else:
        raise Exception("Unsuccessful when getting results.")

    ret = {}
    for r in results:
        rp = Result.get(r)

        #print("probe_id=%d probe_ip=%s path=%s" % (rp.probe_id, rp.origin, str(normalize_ip_path(rp.ip_path))))
        if rp.probe_id in ret:
            raise Exception("Probe ID %d is already in result." % rp.probe_id)
        else:
            ret[rp.probe_id] = normalize_ip_path(rp.ip_path)

    return ret
Exemplo n.º 48
0
def test_http_4600():
    result = Result.get(
        '{"from":"2a01:6a8:0:f:220:4aff:fec5:5b5a","fw":4600,"msm_id":1003930,"msm_name":"HTTPGet","prb_id":720,"result":[{"af":6,"bsize":41020,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":195.84399999999999,"src_addr":"2a01:6a8:0:f:220:4aff:fec5:5b5a","ver":"1.1"}],"timestamp":1396163194,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2a01:6a8:0:f:220:4aff:fec5:5b5a")
    assert (result.firmware == 4600)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 720)
    assert (result.created.isoformat() == "2014-03-30T07:06:34+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 41020)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 195.844)
    assert (result.responses[0].source_address ==
            "2a01:6a8:0:f:220:4aff:fec5:5b5a")
    assert (result.responses[0].version == "1.1")
Exemplo n.º 49
0
def test_http_4480():
    result = Result.get(
        '{"fw":4480,"msm_id":1003930,"prb_id":2184,"result":[{"af":6,"bsize":39777,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":660.40999999999997,"src_addr":"2a02:6c80:5:0:220:4aff:fee0:2774","ver":"1.1"}],"src_addr":"2a02:6c80:5:0:220:4aff:fee0:2774","timestamp":1372582858,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin is None)
    assert (result.firmware == 4480)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 2184)
    assert (result.created.isoformat() == "2013-06-30T09:00:58+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 39777)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 660.41)
    assert (result.responses[0].source_address ==
            "2a02:6c80:5:0:220:4aff:fee0:2774")
    assert (result.responses[0].version == "1.1")
Exemplo n.º 50
0
def test_http_4610():
    result = Result.get(
        '{"from":"2a01:9e00:a217:d00:220:4aff:fec6:cb5b","fw":4610,"group_id":1003930,"msm_id":1003930,"msm_name":"HTTPGet","prb_id":780,"result":[{"af":6,"bsize":41020,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":154.755,"src_addr":"2a01:9e00:a217:d00:220:4aff:fec6:cb5b","ver":"1.1"}],"timestamp":1396359320,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2a01:9e00:a217:d00:220:4aff:fec6:cb5b")
    assert (result.firmware == 4610)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 780)
    assert (result.created.isoformat() == "2014-04-01T13:35:20+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 41020)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 154.755)
    assert (result.responses[0].source_address ==
            "2a01:9e00:a217:d00:220:4aff:fec6:cb5b")
    assert (result.responses[0].version == "1.1")
Exemplo n.º 51
0
def test_http_4570():
    result = Result.get(
        '{"from":"2001:8b0:34f:5b8:220:4aff:fee0:21fc","fw":4570,"msm_id":1003930,"msm_name":"HTTPGet","prb_id":2030,"result":[{"af":6,"bsize":41021,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":187.02199999999999,"src_addr":"2001:8b0:34f:5b8:220:4aff:fee0:21fc","ver":"1.1"}],"timestamp":1395324614,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2001:8b0:34f:5b8:220:4aff:fee0:21fc")
    assert (result.firmware == 4570)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 2030)
    assert (result.created.isoformat() == "2014-03-20T14:10:14+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 41021)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 187.022)
    assert (result.responses[0].source_address ==
            "2001:8b0:34f:5b8:220:4aff:fee0:21fc")
    assert (result.responses[0].version == "1.1")
Exemplo n.º 52
0
def test_http_4550():
    result = Result.get(
        '{"from":"2001:4538:100:0:220:4aff:fec8:232b","fw":4550,"msm_id":1003930,"msm_name":"HTTPGet","prb_id":303,"result":[{"af":6,"bsize":40118,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":2092.447,"src_addr":"2001:4538:100:0:220:4aff:fec8:232b","ver":"1.1"}],"timestamp":1380901810,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2001:4538:100:0:220:4aff:fec8:232b")
    assert (result.firmware == 4550)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 303)
    assert (result.created.isoformat() == "2013-10-04T15:50:10+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 40118)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 2092.447)
    assert (result.responses[0].source_address ==
            "2001:4538:100:0:220:4aff:fec8:232b")
    assert (result.responses[0].version == "1.1")
Exemplo n.º 53
0
def test_http_4540():
    result = Result.get(
        '{"from":"2001:980:36af:1:220:4aff:fec8:226d","fw":4540,"msm_id":1003930,"msm_name":"HTTPGet","prb_id":26,"result":[{"af":6,"bsize":40485,"dst_addr":"2001:67c:2e8:22::c100:68b","hsize":279,"method":"GET","res":200,"rt":158.994,"src_addr":"2001:980:36af:1:220:4aff:fec8:226d","ver":"1.1"}],"timestamp":1377695803,"type":"http","uri":"http://www.ripe.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2001:980:36af:1:220:4aff:fec8:226d")
    assert (result.firmware == 4540)
    assert (result.measurement_id == 1003930)
    assert (result.probe_id == 26)
    assert (result.created.isoformat() == "2013-08-28T13:16:43+00:00")
    assert (result.uri == "http://www.ripe.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size == 40485)
    assert (result.responses[0].head_size == 279)
    assert (
        result.responses[0].destination_address == "2001:67c:2e8:22::c100:68b")
    assert (result.responses[0].code == 200)
    assert (result.responses[0].response_time == 158.994)
    assert (result.responses[0].source_address ==
            "2001:980:36af:1:220:4aff:fec8:226d")
    assert (result.responses[0].version == "1.1")
Exemplo n.º 54
0
#!/usr/bin/env python3

import base64
import dns.message  # provided by dnspython
from ripe.atlas.sagan import Result  # provided by ripe.atlas.sagan
import sys

# testing
# abuf='mE6BgAABAAoAAAAACTEtY291cmllcgRwdXNoBWFwcGxlA2NvbQAAAQABwAwABQABAAA2pwAlATESY291cmllci1wdXNoLWFwcGxlA2NvbQZha2FkbnMDbmV0AMA2AAUAAQAAADsAJRdwb3AtZXVyLWJlbmVsdXgtY291cmllcgpwdXNoLWFwcGxlwEvAZwABAAEAAAA7AAQR/EwVwGcAAQABAAAAOwAEEfxMGcBnAAEAAQAAADsABBH8TBfAZwABAAEAAAA7AAQR/EwRwGcAAQABAAAAOwAEEfxMI8BnAAEAAQAAADsABBH8TB/AZwABAAEAAAA7AAQR/EwKwGcAAQABAAAAOwAEEfxMEw=='
# dnsmsg = dns.message.from_wire(base64.b64decode(abuf))
# print(dnsmsg)

file = sys.argv[1]
with open(file) as results:
    for result in results.readlines():
        parsed_result = Result.get(result)
        try:
            print(
                dns.message.from_wire(
                    base64.b64decode(str(parsed_result.responses[0].abuf))))
        except Exception as e:
            print("Parsing failed for probe ID: " +
                  str(parsed_result.probe_id))
            print(str(e))
Exemplo n.º 55
0
if is_success:
    print("Succes!")
else:
    exit

# Define the output filename
filename = "results_{}_{}_{}.dat".format(args.start.strftime("%Y%m%d%H%M"),
                                         args.end.strftime("%Y%m%d%H%M"),
                                         args.msmid)

# Loop through everything and write to outputfile
fail_count = 0
with open(filename, "w") as outputfile:
    for result in results:
        tr = Result.get(result)
        ip_list = []
        failed = False
        for hop in tr.hops:
            ips = list(
                set([
                    ip_address(x.origin) for x in hop.packets
                    if x is not None and x.origin is not None
                ]))
            if len(ips) == 0:
                ip_list.append("*")
            elif len(ips) > 1:
                failed = True
                fail_count += 1
                break
            else:
Exemplo n.º 56
0
def test_ping_lts():
    result = Result.get(
        '{"af":4,"prb_id":270,"result":[{"rtt":70.265},{"rtt":54.584,"ttl":51},{"rtt":52.875}],"ttl":51,"avg":59.2413333333,"size":12,"from":"188.193.157.75","proto":"ICMP","timestamp":1406561624,"dup":0,"type":"ping","sent":3,"msm_id":1000192,"fw":4650,"max":70.265,"step":360,"src_addr":"192.168.178.21","rcvd":3,"msm_name":"Ping","lts":76,"dst_name":"hsi.cablecom.ch","min":52.875,"group_id":1000192,"dst_addr":"62.2.16.24"}'
    )
    assert (result.seconds_since_sync == 76)
Exemplo n.º 57
0
    def setUp(self):
        result = {
            'af': 4,
            'prb_id': 1216,
            'result': [{
                'rtt': 27.429
            }, {
                'rtt': 25.672
            }, {
                'rtt': 25.681
            }],
            'ttl': 54,
            'avg': 26.2606666667,
            'size': 20,
            'from': '109.190.83.40',
            ' proto': 'ICMP',
            'timestamp': 1445025400,
            'dup': 0,
            'type': 'ping',
            'sent': 3,
            'msm_id': 1000192,
            'fw': 4700,
            'max': 27.429,
            'step': 360,
            'src_addr': '192.168.103.132',
            'rcvd': 3,
            'msm_name': 'Ping',
            'lts': 377,
            'dst_name': 'hsi.cablecom.ch',
            'min': 25.672,
            'dst_addr': '62.2.16.24'
        }

        probes = [
            Probe(id=1216,
                  meta_data={
                      "country_code": "GR",
                      "asn_v4": 3337,
                      "asn_v6": "4445"
                  }),
            Probe(id=121,
                  meta_data={
                      "country_code": "GR",
                      "asn_v4": 3338,
                      "asn_v6": "4445"
                  }),
            Probe(id=12,
                  meta_data={
                      "country_code": "DE",
                      "asn_v4": 3339,
                      "asn_v6": 3337
                  }),
            Probe(id=1,
                  meta_data={
                      "country_code": "NL",
                      "asn_v4": 3337,
                      "asn_v6": "4446"
                  })
        ]
        self.sagan_results = []
        for probe in probes:
            sagan_result = Result.get(result,
                                      on_error=Result.ACTION_IGNORE,
                                      on_warning=Result.ACTION_IGNORE)
            sagan_result.probe = probe
            self.sagan_results.append(sagan_result)
Exemplo n.º 58
0
#public api:
#https://api.iptoasn.com/v1/as/ip/<ip address>

#AS-path de la source LB2(IDM):
aspath = []
path = []
idv6 = [12459070, 12459079, 12459088, 12599687, 12599693, 12599699, 12599711]
idv4 = [12459144, 12459154, 12459163, 12599748, 12599755, 12599761, 12599793]
#AS-PATH de IR:
#idv6=[12459071,12459080,12459089,12599688,12599694,12599700,12599712]
#idv4=[12459145,12459155,12459164,12599749,12599756,12599762,12599794]
result = requests.get(
    'https://atlas.ripe.net/api/v2/measurements/{}/results/?&format=json'.
    format(idv6[1]))
response = json.loads(result.content.decode('utf-8'))
my_result = Result.get(response[0])
hop = my_result.hops
ip = []
for k in hop:
    packet = k.packets
    for j in packet:
        if (j.origin not in ip) and (j.origin != 'None'):
            ip.append(j.origin)
    #print(ip)

AS = []
country = []
for k in ip:
    j = requests.get("https://api.iptoasn.com/v1/as/ip/{}".format(k))
    if j.status_code == 200:
        r = json.loads(j.content.decode('utf-8'))
    if response.status_code == 200:
        result_v6.append(json.loads(response.content.decode('utf-8')))

for i in vector_ID_v4:

    result = 'https://atlas.ripe.net/api/v2/measurements/{}/results/?format=json'.format(
        i)
    response = requests.get(result)
    if response.status_code == 200:
        result_v4.append(json.loads(response.content.decode('utf-8')))

my_result_v6 = []
my_result_v4 = []
for i in result_v6:
    for j in range(len(i)):
        my_result_v6.append(Result.get(i[j]))
for i in result_v4:
    for j in range(len(i)):
        my_result_v4.append(Result.get(i[j]))
total_hop_v6 = []
total_hop_v4 = []

for i in range(len(my_result_v6)):
    if my_result_v6[i].is_success and my_result_v4[i].is_success:
        total_hop_v6.append(my_result_v6[i].total_hops)
        total_hop_v4.append(my_result_v4[i].total_hops)

rtt_v6 = []
rtt_v4 = []
for i in range(len(my_result_v6)):
    if my_result_v6[i].is_success and my_result_v4[i].is_success:
Exemplo n.º 60
0
import sys
import json
import urllib
from datetime import datetime
from ripe.atlas.sagan import Result, TracerouteResult

from ripe.atlas.cousteau import AtlasLatestRequest

kwargs = {"msm_id": 11304100}

is_succ, results = AtlasLatestRequest(**kwargs).create()

#if is_succ:
#	print(results)

for result in results:
    print(Result.get(result))
    tracert = TracerouteResult(result)
    print(tracert.total_hops)
    print(tracert.ip_path)