Ejemplo n.º 1
0
    def data_only_answers(self):
        na = 2
        nq = 0
        data = PacketsExample({'na': na, 'nq': nq})

        for i in range(na):
            data.add_packet({'flags': '8000'})

        return data
Ejemplo n.º 2
0
    def data_only_queries(self):
        na = 0
        nq = 2
        data = PacketsExample({'na': na, 'nq': nq})

        data = PacketsExample()
        for i in range(nq):
            data.add_packet({'flags': '0'})

        return data
Ejemplo n.º 3
0
    def data_example(self):
        na = 2
        nq = 2
        data = PacketsExample({'na': na, 'nq': nq})

        for i in range(na):
            data.add_packet({'flags': '8000'})
        for i in range(nq):
            data.add_packet({'flags': '0'})

        return data
    def data_example(self):
        data = PacketsExample()
        for i in range(30):
            data.add_packet({"flags": "8000", "source": "12345678", "queries": [{"qname": "www.nic.cl."}]})

        for i in range(25):
            data.add_packet({"flags": "8000", "source": "1234567890", "queries": [{"qname": "www.uchile.cl."}]})

        data.set_expected("udp", {"IPv4": 30, "IPv6": 25})

        data.put_information("TrafficVolumeResponses", ["udp"])

        return data
Ejemplo n.º 5
0
    def data_only_answers(self):

        data = PacketsExample()
        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.nic.cl'}]})
        data.set_expected('www.nic.cl', 5)

        for i in range(3):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.jerry.cl'}]})
        data.set_expected('www.jerry.cl', 3)

        return data
Ejemplo n.º 6
0
    def dataExample(self):
        data = PacketsExample()
        data.add_packet({'flags': '0', 'queries': []})

        data.set_expected('', 1)

        data.put_information('QNames', {''})
        return data
    def data_example(self):
        data = PacketsExample()
        for i in range(30):
            data.add_packet({'flags': '0', 'source': '12345678',
                             'queries': [{'qname': 'www.nic.cl.'}]})

        for i in range(25):
            data.add_packet({'flags': '0',
                             'source': '1234567890',
                             'queries': [{'qname': 'www.uchile.cl.'}]})

        data.set_expected('udp', {'IPv4': 30, 'IPv6': 25})

        data.put_information('TrafficVolumeQueries', ['udp'])

        return data
Ejemplo n.º 8
0
    def data_only_queries(self):
        data = PacketsExample()
        data.do_not_change_order()

        for i in range(5):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.nic.cl'}]})

        for i in range(3):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.jerry.cl'}]})

        for i in range(2):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.pinky.cl'}]})

        return data
Ejemplo n.º 9
0
    def data_just_answers(self):

        data = PacketsExample()
        data.add_packet({'flags': '8000', 'queries': [
            {'qname': 'www.nic.cl'}]})  # Answers
        data.add_packet({'flags': '8000', 'queries': [
            {'qname': 'www.brain.cl'}]})
        data.add_packet({'flags': '8000', 'queries': [
            {'qname': 'www.pinky.cl'}]})

        return data
Ejemplo n.º 10
0
    def data_example(self):
        data = PacketsExample()

        for i in range(5):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.nic.cl'}]})

        data.set_expected('512-1023', 5)

        data.put_information("EdnsBufsiz", ['512-1023'])

        return data
Ejemplo n.º 11
0
    def data_without_queries(self):
        answers = [{'flags': '8000', 'id': 'a6c7'}, {
            'flags': '8000', 'id': '5433'}, {'flags': '8000', 'id': 'a276'}]
        data = PacketsExample({'queries': 0, 'answers': len(answers)})

        for answer in answers:
            data.add_packet(answer)

        data.set_expected('AloneAnswers', answers)
        data.set_expected('AloneQueries', [])

        return data
Ejemplo n.º 12
0
    def data_without_answers(self):
        queries = [{'flags': '0', 'id': 'a6c7'}, {'flags': '0', 'id': '5433'},
                   {'flags': '0', 'id': 'a276'}, {'flags': '0', 'id': '4321'}]
        data = PacketsExample({'queries': len(queries), 'answers': 0})

        for query in queries:
            data.add_packet(query)

        data.set_expected('AloneAnswers', [])
        data.set_expected('AloneQueries', queries)

        return data
Ejemplo n.º 13
0
    def data_example(self):
        data = PacketsExample()

        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.nic.cl'}]})

        data.set_expected(0, 5)

        data.put_information("Rcode", [0])

        return data
Ejemplo n.º 14
0
    def data_example(self):
        data = PacketsExample()

        for i in range(5):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.nic.cl'}]})

        data.set_expected("set", 5)

        data.put_information('rdBit', ["set"])

        return data
Ejemplo n.º 15
0
    def data_example(self):
        data = PacketsExample()

        for i in range(5):
            data.add_packet({'dest': 'encrypted(dnsip1)',
                             'source': 'encrypted(ip1)',
                             'flags': '0',
                             'queries': [
                                 {'qname': 'www.ni_c.cl', 'qtype': '1'}]})

        data.set_expected("encrypted(ip1)", 5)

        data.put_information("src", ["encrypted(ip1)"])

        return data
Ejemplo n.º 16
0
    def data_repeat_error(self):
        data = PacketsExample()

        data.put_information('problematicSources', {
            'encrypted(ip1)': [{'qname': 'www.ni_c.cl', 'qtype': '1'}],
            'encrypted(ip2)': [{'qname': 'www.nic_labs.cl', 'qtype': '2'}]})

        count_of_errors = {}

        for i in range(3):
            data.add_packet({'source': 'encrypted(ip1)', 'flags': '0',
                             'queries': [{'qname': 'www.ni_c.cl',
                                          'qtype': '1'}]})
        count_of_errors['encrypted(ip1)'] = 3

        for i in range(2):
            data.add_packet({'source': 'encrypted(ip2)', 'flags': '0',
                             'queries': [{'qname': 'www.nic_labs.cl',
                                          'qtype': '2'}]})
        count_of_errors['encrypted(ip2)'] = 2

        data.put_information('countOfErrors', count_of_errors)
        return data
Ejemplo n.º 17
0
    def data_example(self):
        data = PacketsExample()

        for i in range(5):
            data.add_packet(
                {
                    "dest": "encrypted(dnsip1)",
                    "source": "encrypted(ip1)",
                    "flags": "0",
                    "queries": [{"qname": "www.ni_c.cl", "qtype": "1"}],
                }
            )

        data.set_expected("1", 5)

        data.put_information("Qtype", ["1"])

        return data
Ejemplo n.º 18
0
    def data_example(self):

        data = PacketsExample()
        data.put_information('problematicSources', {
            'encrypted(ip1)':
                [{'qname': 'www.ni_c.cl', 'qtype': '1'}],
            'encrypted(ip2)':
                [{'qname': 'www.nic_labs.cl', 'qtype': '2'}],
            'encrypted(ip3)':
                [{'qname': 'www._jerry_.cl', 'qtype': '6'}],
            'encrypted(ip4)':
                [{'qname': 'www._pinky.cl', 'qtype': 'f'}]})

        # Problems with qnames
        data.add_packet({'source': 'encrypted(ip1)', 'flags': '0', 'queries': [
            {'qname': 'www.ni_c.cl', 'qtype': '1'}]})
        data.set_expected('encrypted(ip1)',  {"cnt": 1, 'queries': [
            {'qname': 'www.ni_c.cl', 'qtype': '1'}]})

        data.add_packet({'source': 'encrypted(ip2)', 'flags': '0', 'queries': [
            {'qname': 'www.nic_labs.cl', 'qtype': '2'}]})
        data.set_expected('encrypted(ip2)',  {"cnt": 1, 'queries': [
            {'qname': 'www.nic_labs.cl', 'qtype': '1'}]})

        data.add_packet({'source': 'encrypted(ip3)', 'flags': '0', 'queries': [
            {'qname': 'www._jerry_.cl', 'qtype': '6'}]})
        data.set_expected('encrypted(ip3)',  {"cnt": 1, 'queries': [
            {'qname': 'www._jerry_.cl', 'qtype': '1'}]})

        data.add_packet({'source': 'encrypted(ip4)', 'flags': '0', 'queries': [
            {'qname': 'www._pinky.cl', 'qtype': 'f'}]})
        data.set_expected('encrypted(ip4)',  {"cnt": 1, 'queries': [
            {'qname': 'www._pinky.cl', 'qtype': '1'}]})

        # Normal data, critical qtypes
        data.add_packet({'source': 'encrypted(ip1)', 'flags': '0', 'queries': [
            {'qname': 'www.nic.cl', 'qtype': '1'}]})
        data.add_packet({'source': 'encrypted(ip2)', 'flags': '0', 'queries': [
            {'qname': 'www.niclabs.cl', 'qtype': '2'}]})
        data.add_packet({'source': 'encrypted(ip3)', 'flags': '0', 'queries': [
            {'qname': 'www.jerry.cl', 'qtype': '6'}]})
        data.add_packet({'source': 'encrypted(ip4)', 'flags': '0', 'queries': [
            {'qname': 'www.pinky.cl', 'qtype': 'f'}]})

        # Normal data
        data.add_packet({'source': 'encrypted(ip1)', 'flags': '0',
                         'queries': [{'qname': 'www.nic.cl', 'qtype': '3'}]})
        data.add_packet({'source': 'encrypted(ip2)', 'flags': '8000',
                         'queries': [{'qname': 'www.niclabs.cl',
                                      'qtype': '4'}]})
        data.add_packet({'source': 'encrypted(ip3)', 'flags': '0',
                         'queries': [{'qname': 'www.jerry.cl', 'qtype': '5'}]})
        data.add_packet({'source': 'encrypted(ip4)', 'flags': '8000',
                         'queries': [{'qname': 'www.pinky.cl',
                                      'qtype': '7'}]})

        # Underscore data, noncritical qtypes
        data.add_packet({'source': 'encrypted(ip1)', 'flags': '0',
                         'queries': [{'qname': 'www.ni_c.cl', 'qtype': '3'}]})
        data.add_packet({'source': 'encrypted(ip2)', 'flags': '0',
                         'queries': [{'qname': 'www.nic_labs.cl',
                                      'qtype': '4'}]})
        data.add_packet({'source': 'encrypted(ip3)', 'flags': '0',
                         'queries': [{'qname': 'www._jerry_.cl',
                                      'qtype': '5'}]})
        data.add_packet({'source': 'encrypted(ip4)', 'flags': '0',
                         'queries': [{'qname': 'www._pinky.cl',
                                      'qtype': '7'}]})

        # Answers
        data.add_packet({'source': 'encrypted(dnsip1)', 'flags': '8000',
                         'queries': [{'qname': 'www.ni_c.cl',
                                      'qtype': '1'}]})
        data.add_packet({'source': 'encrypted(dnsip2)', 'flags': '8000',
                         'queries': [{'qname': 'www.niclabs.cl',
                                      'qtype': '2'}]})
        data.add_packet({'source': 'encrypted(dnsip3)', 'flags': '8000',
                         'queries': [{'qname': 'www.jerry.cl',
                                      'qtype': '5'}]})
        data.add_packet({'source': 'encrypted(dnsip4)', 'flags': '8000',
                         'queries': [{'qname': 'www._pinky.cl',
                                      'qtype': '7'}]})

        return data
Ejemplo n.º 19
0
    def data_example(self):
        data = PacketsExample()
        for i in range(3):
            data.add_packet({"flags": "0", "queries": [{"qname": u"www.nic.xn--cm-5ja."}]})
            data.add_packet({"flags": "0", "queries": [{"qname": u"www.uchile.cl."}]})
            data.add_packet(
                {
                    "flags": "0",
                    "queries": [{"qname": u"data-agkn-com-1198526359." + u"us-east-1.elb.amazonaws.com.imunimacu.cl."}],
                }
            )
            data.add_packet(
                {
                    "flags": "0",
                    "queries": [
                        {"qname": u"data-agkn-com-1198526359.us-east-1" + u".elb.amazonaws.com.xn--imunimacu-t6a.cl."}
                    ],
                }
            )

        data.set_expected(unicode("xn--cm-5ja", "utf8").encode("idna"), 3)
        data.set_expected(unicode("cl", "utf8").encode("idna"), 3)

        data.put_information("IdnVSTld", [unicode("cóm", "utf8").encode("idna"), unicode("cl", "utf8").encode("idna")])

        return data
    def data_example(self):
        data = PacketsExample()
        for i in range(30):
            data.add_packet({"flags": "0", "queries": [{"qname": "www.nic.cl.", "qtype": 1}]})
            data.add_packet({"flags": "0", "queries": [{"qname": "www.nic.cl.", "qtype": 2}]})

        for i in range(25):
            data.add_packet({"flags": "0", "queries": [{"qname": "www.uchile.cl.", "qtype": 3}]})

        data.set_expected(1, {"www.nic.cl.": 30})
        data.set_expected(2, {"www.nic.cl.": 30})
        data.set_expected(3, {"www.uchile.cl.": 25})

        data.put_information("ChaosTypesAndNames", [1, 2, 3])

        return data
Ejemplo n.º 21
0
    def data_different_case(self):
        data = PacketsExample()
        data.put_information('problematicQName', 'www.ni_c.cl')

        expected_list = []

        data.add_packet({'dest': 'encrypted(dnsip1)',
                         'source': 'encrypted(ip1)',
                         'flags': '0',
                         'queries': [
                             {'qname': 'www.ni_c.cl', 'qtype': '1'}]})
        expected_list.append({'server': 'encrypted(dnsip1)',
                              'sender': 'encrypted(ip1)',
                              'query': {
                                  'qname': 'www.ni_c.cl', 'qtype': '1'}})

        data.add_packet({'dest': 'encrypted(dnsip1)',
                         'source': 'encrypted(ip1)',
                         'flags': '0',
                         'queries': [
                             {'qname': 'WWW.NI_C.CL', 'qtype': '1'}]})
        expected_list.append({'server': 'encrypted(dnsip1)',
                              'sender': 'encrypted(ip1)',
                              'query': {
                                  'qname': 'WWW.NI_C.CL', 'qtype': '1'}})

        data.set_expected('www.ni_c.cl', expected_list)

        data.add_packet({'dest': 'encrypted(dnsip1)',
                         'source': 'encrypted(ip1)',
                         'flags': '0',
                         'queries': [
                             {'qname': 'wwww.ni_c.cl', 'qtype': '1'}]})
        data.add_packet({'dest': 'encrypted(dnsip1)',
                         'source': 'encrypted(ip1)',
                         'flags': '0',
                         'queries': [
                             {'qname': 'WWW:NI_C.CL', 'qtype': '1'}]})

        return data
Ejemplo n.º 22
0
    def data_only_queries(self):

        data = PacketsExample()
        for i in range(4):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.niclabs.cl'}]})
        data.set_expected('www.niclabs.cl', 4)

        for i in range(3):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.uchile.cl'}]})
        data.set_expected('www.uchile.cl', 3)

        for i in range(2):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.pinky.cl'}]})
        data.set_expected('www.pinky.cl', 2)

        return data
Ejemplo n.º 23
0
    def data_different_case(self):
        data = PacketsExample()

        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.nic.cl'}]})
        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'WWW.NIC.CL'}]})
        data.set_expected('www.nic.cl', 10)

        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'WWW:NIC.CL'}]})
        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'wwww.nic.cl'}]})
        data.put_information('criticalQName', 'www.nic.cl')
        return data
Ejemplo n.º 24
0
    def data_example(self):
        data = PacketsExample()

        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.nic.cl'}]})
        data.set_expected('www.nic.cl', 5)

        for i in range(3):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.jerry.cl'}]})
        data.set_expected('www.jerry.cl', 3)

        data.put_information('QNames', {'www.nic.cl', 'www.jerry.cl'})
        return data
Ejemplo n.º 25
0
    def data_equal_rating(self):
        n = 10
        queries = {'www.nic.cl': n, 'www.niclabs.cl': n,
                   'www.uchile.cl': n, 'www.jerry.cl': n, 'www.pinky.cl': n}
        data = PacketsExample(queries)
        data.put_information('equalQnames', 5)
        for i in range(n):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.nic.cl'}]})

        for i in range(n):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.niclabs.cl'}]})

        for i in range(n):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.uchile.cl'}]})

        for i in range(n):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.jerry.cl'}]})

        for i in range(n):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.pinky.cl'}]})

        return data
Ejemplo n.º 26
0
    def data_repeat_error(self):
        data = PacketsExample()
        data.put_information('problematicQNames', {
            'www.ni_c.cl', 'www.nic_labs.cl'})

        expected_list = []
        for i in range(3):
            data.add_packet({'dest': 'encrypted(dnsip1)',
                             'source': 'encrypted(ip1)',
                             'flags': '0',
                             'queries': [
                                 {'qname': 'www.ni_c.cl', 'qtype': '1'}]})
            expected_list.append({'server': 'encrypted(dnsip1)',
                                  'sender': 'encrypted(ip1)',
                                  'query': {
                                      'qname': 'www.ni_c.cl', 'qtype': '1'}})
        data.set_expected('www.ni_c.cl', expected_list)

        expected_list = []
        for i in range(2):
            data.add_packet({'dest': 'encrypted(dnsip2)',
                             'source': 'encrypted(ip2)',
                             'flags': '0',
                             'queries': [
                                 {'qname': 'www.nic_labs.cl', 'qtype': '2'}]})
            expected_list.append({'server': 'encrypted(dnsip2)',
                                  'sender': 'encrypted(ip2)',
                                  'query': {
                                      'qname': 'www.nic_labs.cl',
                                      'qtype': '2'}})
        data.set_expected('www.nic_labs.cl', expected_list)

        return data
    def data_example(self):
        data = PacketsExample()
        for i in range(30):
            data.add_packet({'flags': '8000',
                             'queries': [{'qname': 'www.nic.cl.'}]})
            data.add_packet({'flags': '0', 'queries': [
                            {'qname': 'www.niclabs.cl.'}]})

        for i in range(25):
            data.add_packet({'flags': '8000', 'queries': [
                            {'qname': 'www.uchile.cl.'}]})

        data.set_expected(0, {15: 55})

        data.put_information('RcodeVSReplylen', [0])

        return data
Ejemplo n.º 28
0
    def data_example(self):

        queries = {'www.nic.cl': 5, 'www.niclabs.cl': 4,
                   'www.uchile.cl': 3, 'www.jerry.cl': 3, 'www.pinky.cl': 2}
        data = PacketsExample(queries)

        # Returns a list with the elements of
        # the dict in descending order of its keys
        data.put_information('sortedQnames',
                             map(list, sorted(queries.items(),
                                              key=operator.itemgetter(
                                 1), reverse=True)))

        for i in range(5):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.nic.cl'}]})

        for i in range(4):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.niclabs.cl'}]})

        for i in range(3):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.uchile.cl'}]})

        for i in range(3):
            data.add_packet({'flags': '8000', 'queries': [
                {'qname': 'www.jerry.cl'}]})

        for i in range(2):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.pinky.cl'}]})

        return data
    def data_example(self):
        data = PacketsExample()
        for i in range(50):
            data.add_packet({'flags': '0', 'queries': [
                            {'qname': 'www.nic.cl.', 'qtype': 1}]})
            data.add_packet({'flags': '0', 'queries': [
                            {'qname': 'www.uchile.cl.', 'qtype': 2}]})

        for i in range(50):
            data.add_packet({'flags': '0', 'queries': [
                            {'qname': 'www.google.com.', 'qtype': 1}]})
            data.add_packet({'flags': '0', 'queries': [
                            {'qname': 'www.facebook.com.', 'qtype': 2}]})

        data.add_packet({'flags': '0', 'queries': [
                        {'qname': 'www.asdf.net.', 'qtype': 3}]})
        data.add_packet({'flags': '0', 'queries': [
                        {'qname': 'www.qwerty.net.', 'qtype': 3}]})

        data.set_expected('udp', {15: 202})

        data.put_information('TrafficSizesQueries', ['udp'])

        return data
Ejemplo n.º 30
0
    def data_different_case(self):
        queries = {'www.nic.cl': 10, 'www.niclabs.cl': 5, 'wwww.niclabs.cl': 6}
        data = PacketsExample(queries)

        # Returns a list with the elements of
        # the dict in descending order of its keys
        data.put_information('sortedQnames',
                             map(list, sorted(queries.items(),
                                              key=operator.itemgetter(
                                 1), reverse=True)))

        for i in range(5):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.nic.cl'}]})
        for i in range(5):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'WWW.NIC.CL'}]})

        for i in range(5):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'www.niclabs.cl'}]})
        for i in range(6):
            data.add_packet({'flags': '0', 'queries': [
                {'qname': 'WwWW.NicLaBs.cl'}]})

        return data