Exemplo n.º 1
0
Arquivo: asn.py Projeto: eacha/Web-OSR
def signature_asn(request, port, number=None, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=port)
    if scan_date is None:
        scan_date = scan_date_list.last().date

    trusted = AsnHTTPSSignature.objects.filter(asn=number, port=port, date=scan_date, valid=True).values('signature').order_by('signature') \
        .annotate(total=Sum('total')).order_by('signature')[:10]
    untrusted = AsnHTTPSSignature.objects.filter(asn=number, port=port, date=scan_date, valid=False).values('signature').order_by('signature') \
        .annotate(total=Sum('total')).order_by('signature')[:10]

    signature_values = sorted(set([i['signature'] for i in trusted]) | set([i['signature'] for i in untrusted]))

    return render(request, 'graphs/cert_signature_asn.html',
                  {'port': port,
                   'number': number,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {
                       'title': 'Signature on Autonomous System %s' % number,
                       'xaxis': 'Signature Algorithm',
                       'yaxis': 'Number of Handshake',
                       'label_rotation': -45,
                       'categories': [i for i in signature_values],
                       'values': [
                           {'name': 'https trusted', 'data': [i['total'] for i in filter_by_name(trusted, signature_values, 'signature', 'total')]},
                           {'name': 'https untrusted', 'data': [i['total'] for i in filter_by_name(untrusted, signature_values, 'signature', 'total')]}
                       ]
                   }})
Exemplo n.º 2
0
def cipher_suite(request, port, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=port)
    if scan_date is None:
        scan_date = scan_date_list.last().date

    trusted = HTTPSCipherSuite.objects.filter(port=port, date=scan_date, valid=True).values('cipher_suite').order_by('cipher_suite') \
        .annotate(total=Sum('total')).order_by('cipher_suite')
    untrusted = HTTPSCipherSuite.objects.filter(port=port, date=scan_date, valid=False).values('cipher_suite').order_by('cipher_suite') \
        .annotate(total=Sum('total')).order_by('cipher_suite')

    cipher_suite_values = sorted(set([i['cipher_suite'] for i in trusted]) | set([i['cipher_suite'] for i in untrusted]))

    return render(request, 'graphs/cert_cipher_suite.html',
                  {'port': port,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {
                       'title': 'Cipher Suites',
                       'xaxis': 'Cipher Suite',
                       'yaxis': 'Number of Handshake',
                       'label_rotation': -90,
                       'categories': [i for i in cipher_suite_values],
                       'values': [
                           {'name': 'https trusted', 'data': [i['total'] for i in filter_by_name(trusted, cipher_suite_values, 'cipher_suite', 'total')]},
                           {'name': 'https untrusted', 'data': [i['total'] for i in filter_by_name(untrusted, cipher_suite_values, 'cipher_suite', 'total')]}
                       ]
                   }})
Exemplo n.º 3
0
Arquivo: asn.py Projeto: eacha/Web-OSR
def tls_version_asn(request, port, number=None, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=port)
    if scan_date is None:
        scan_date = scan_date_list.last().date

    trusted = AsnHTTPSTlsProtocol.objects.filter(asn=number, port=port, date=scan_date, valid=True).values('protocol').order_by('protocol') \
        .annotate(total=Sum('total')).order_by('protocol')
    untrusted = AsnHTTPSTlsProtocol.objects.filter(asn=number, port=port, date=scan_date, valid=False).values('protocol').order_by('protocol') \
        .annotate(total=Sum('total')).order_by('protocol')

    tls_values = sorted(set([i['protocol'] for i in trusted]) | set([i['protocol'] for i in untrusted]))

    return render(request, 'graphs/cert_tls_version_asn.html',
                  {'port': port,
                   'number': number,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {
                       'title': 'Cipher Suites on Autonomous System %s' % number,
                       'xaxis': 'TLS Version',
                       'yaxis': 'Number of Handshake',
                       'categories': [i for i in tls_values],
                       'values': [
                           {'name': 'https trusted', 'data': [i['total'] for i in filter_by_name(trusted, tls_values, 'protocol', 'total')]},
                           {'name': 'https untrusted', 'data': [i['total'] for i in filter_by_name(untrusted, tls_values, 'protocol', 'total')]}
                       ]
                   }})
Exemplo n.º 4
0
def key_bits(request, port, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=port)
    if scan_date is None:
            scan_date = scan_date_list.last().date

    trusted = HTTPSKeyBits.objects.filter(port=port, date=scan_date, valid=True).values('bits').order_by('bits') \
        .annotate(total=Sum('total')).order_by('bits')[:10]
    untrusted = HTTPSKeyBits.objects.filter(port=port, date=scan_date, valid=False).values('bits').order_by('bits') \
        .annotate(total=Sum('total')).order_by('bits')[:10]

    key_bits_values = sorted(set([i['bits'] for i in trusted]) | set([i['bits'] for i in untrusted]))

    return render(request, 'graphs/cert_key_bits.html',
                  {'port': port,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {
                       'title': 'Key Bits (HTTPS)',
                       'xaxis': 'Bits',
                       'yaxis': 'Number of Certificates',
                       'categories': [i for i in key_bits_values],
                       'values': [
                           {'name': 'https trusted', 'data': [i['total'] for i in filter_by_name(trusted, key_bits_values, 'bits', 'total')]},
                           {'name': 'https untrusted', 'data': [i['total'] for i in filter_by_name(untrusted, key_bits_values, 'bits', 'total')]}
                       ]
                   }})
Exemplo n.º 5
0
Arquivo: asn.py Projeto: eacha/Web-OSR
def key_bits_asn(request, port, number=None, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=port)
    if scan_date is None:
            scan_date = scan_date_list.last().date

    trusted = AsnHTTPSKeyBits.objects.filter(asn=number, port=port, date=scan_date, valid=True).values('bits').order_by('bits') \
        .annotate(total=Sum('total')).order_by('bits')[:10]
    untrusted = AsnHTTPSKeyBits.objects.filter(asn=number, port=port, date=scan_date, valid=False).values('bits').order_by('bits') \
        .annotate(total=Sum('total')).order_by('bits')[:10]

    key_bits_values = sorted(set([i['bits'] for i in trusted]) | set([i['bits'] for i in untrusted]))

    return render(request, 'graphs/cert_key_bits_asn.html',
                  {'port': port,
                   'number': number,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {
                       'title': 'Key Bits (HTTPS) on Autonomous System %s' % number,
                       'xaxis': 'Bits',
                       'yaxis': 'Number of Certificates',
                       'categories': [i for i in key_bits_values],
                       'values': [
                           {'name': 'https trusted', 'data': [i['total'] for i in filter_by_name(trusted, key_bits_values, 'bits', 'total')]},
                           {'name': 'https untrusted', 'data': [i['total'] for i in filter_by_name(untrusted, key_bits_values, 'bits', 'total')]}
                       ]
                   }})
Exemplo n.º 6
0
def http_server_all(request, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    http80 = (
        HTTPServer.objects.filter(port=80, date=scan_date)
        .values("product")
        .order_by("product")
        .annotate(total=Sum("total"))
        .order_by("-total")[:10]
    )
    http443 = filter_by_name(
        HTTPServer.objects.filter(port=443, date=scan_date)
        .values("product")
        .order_by("product")
        .annotate(total=Sum("total")),
        [i["product"] for i in http80],
        "product",
        "total",
    )
    http8000 = filter_by_name(
        HTTPServer.objects.filter(port=8000, date=scan_date)
        .values("product")
        .order_by("product")
        .annotate(total=Sum("total")),
        [i["product"] for i in http80],
        "product",
        "total",
    )
    http8080 = filter_by_name(
        HTTPServer.objects.filter(port=8080, date=scan_date)
        .values("product")
        .order_by("product")
        .annotate(total=Sum("total")),
        [i["product"] for i in http80],
        "product",
        "total",
    )

    return render(
        request,
        "graphs/http_server.html",
        {
            "port": "all",
            "scan_date": scan_date,
            "scan_list": [i.date for i in scan_date_list],
            "bars": {
                "title": "Web Server Running (HTTP)",
                "xaxis": "Web Server",
                "yaxis": "Number of Servers",
                "categories": [i["product"] for i in http80],
                "values": [
                    {"name": "port 80", "data": [i["total"] for i in http80]},
                    {"name": "port 443", "data": [i["total"] for i in http443]},
                    {"name": "port 8000", "data": [i["total"] for i in http8000]},
                    {"name": "port 8080", "data": [i["total"] for i in http8080]},
                ],
            },
        },
    )
Exemplo n.º 7
0
def signature_asn(request, port, number=None, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=port)
    if scan_date is None:
        scan_date = scan_date_list.last().date

    trusted = AsnHTTPSSignature.objects.filter(asn=number, port=port, date=scan_date, valid=True).values('signature').order_by('signature') \
        .annotate(total=Sum('total')).order_by('signature')[:10]
    untrusted = AsnHTTPSSignature.objects.filter(asn=number, port=port, date=scan_date, valid=False).values('signature').order_by('signature') \
        .annotate(total=Sum('total')).order_by('signature')[:10]

    signature_values = sorted(
        set([i['signature']
             for i in trusted]) | set([i['signature'] for i in untrusted]))

    return render(
        request, 'graphs/cert_signature_asn.html', {
            'port': port,
            'number': number,
            'scan_date': scan_date,
            'scan_list': [i.date for i in scan_date_list],
            'bars': {
                'title':
                'Signature on Autonomous System %s' % number,
                'xaxis':
                'Signature Algorithm',
                'yaxis':
                'Number of Handshake',
                'label_rotation':
                -45,
                'categories': [i for i in signature_values],
                'values': [{
                    'name':
                    'https trusted',
                    'data': [
                        i['total'] for i in filter_by_name(
                            trusted, signature_values, 'signature', 'total')
                    ]
                }, {
                    'name':
                    'https untrusted',
                    'data': [
                        i['total'] for i in filter_by_name(
                            untrusted, signature_values, 'signature', 'total')
                    ]
                }]
            }
        })
Exemplo n.º 8
0
def tls_version_asn(request, port, number=None, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=port)
    if scan_date is None:
        scan_date = scan_date_list.last().date

    trusted = AsnHTTPSTlsProtocol.objects.filter(asn=number, port=port, date=scan_date, valid=True).values('protocol').order_by('protocol') \
        .annotate(total=Sum('total')).order_by('protocol')
    untrusted = AsnHTTPSTlsProtocol.objects.filter(asn=number, port=port, date=scan_date, valid=False).values('protocol').order_by('protocol') \
        .annotate(total=Sum('total')).order_by('protocol')

    tls_values = sorted(
        set([i['protocol']
             for i in trusted]) | set([i['protocol'] for i in untrusted]))

    return render(
        request, 'graphs/cert_tls_version_asn.html', {
            'port': port,
            'number': number,
            'scan_date': scan_date,
            'scan_list': [i.date for i in scan_date_list],
            'bars': {
                'title':
                'Cipher Suites on Autonomous System %s' % number,
                'xaxis':
                'TLS Version',
                'yaxis':
                'Number of Handshake',
                'categories': [i for i in tls_values],
                'values': [{
                    'name':
                    'https trusted',
                    'data': [
                        i['total'] for i in filter_by_name(
                            trusted, tls_values, 'protocol', 'total')
                    ]
                }, {
                    'name':
                    'https untrusted',
                    'data': [
                        i['total'] for i in filter_by_name(
                            untrusted, tls_values, 'protocol', 'total')
                    ]
                }]
            }
        })
Exemplo n.º 9
0
def device_type_asn_all(request, number, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    device80 = AsnHTTPType.objects.filter(asn=number, port=80, date=scan_date).values('type').order_by('type') \
                            .annotate(total=Sum('total')).order_by('-total')[:10]
    device443 = filter_by_name(AsnHTTPType.objects.filter(asn=number, port=443, date=scan_date).values('type').order_by('type') \
                           .annotate(total=Sum('total')).order_by('-total'), [i['type'] for i in device80], 'type', 'total')
    device8000 = filter_by_name(AsnHTTPType.objects.filter(asn=number, port=8000, date=scan_date).values('type').order_by('type') \
                            .annotate(total=Sum('total')).order_by('-total'), [i['type'] for i in device80], 'type', 'total')
    device8080 = filter_by_name(AsnHTTPType.objects.filter(asn=number, port=8080, date=scan_date).values('type').order_by('type') \
                            .annotate(total=Sum('total')).order_by('-total'), [i['type'] for i in device80], 'type', 'total')

    return render(
        request, 'graphs/http_device_type_asn.html', {
            'port': 'all',
            'number': number,
            'scan_date': scan_date,
            'scan_list': [i.date for i in scan_date_list],
            'bars': {
                'title':
                'Device Type of Server (HTTP) on Autonomous System %s' %
                number,
                'xaxis':
                'Type of Device',
                'yaxis':
                'Number of Servers',
                'categories': [i['type'] for i in device80],
                'values': [{
                    'name': 'port 80',
                    'data': [i['total'] for i in device80]
                }, {
                    'name': 'port 443',
                    'data': [i['total'] for i in device443]
                }, {
                    'name': 'port 8000',
                    'data': [i['total'] for i in device8000]
                }, {
                    'name': 'port 8080',
                    'data': [i['total'] for i in device8080]
                }]
            }
        })
Exemplo n.º 10
0
def operating_system_server_asn_all(request, number, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    os80 = AsnHTTPOS.objects.filter(asn=number, port=80, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total')[:10]
    os443 = filter_by_name(AsnHTTPOS.objects.filter(asn=number, port=443, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total'), [i['os'] for i in os80], 'os', 'total')
    os8000 = filter_by_name(AsnHTTPOS.objects.filter(asn=number, port=8000, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total'), [i['os'] for i in os80], 'os', 'total')
    os8080 = filter_by_name(AsnHTTPOS.objects.filter(asn=number, port=8080, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total'), [i['os'] for i in os80], 'os', 'total')

    return render(
        request, 'graphs/http_operative_systems_asn.html', {
            'port': 'all',
            'number': number,
            'scan_date': scan_date,
            'scan_list': [i.date for i in scan_date_list],
            'bars': {
                'title':
                'Operative System of Server (HTTP) on Autonomous System %s' %
                number,
                'xaxis':
                'Operative Systems',
                'yaxis':
                'Number of Servers',
                'categories': [i['os'] for i in os80],
                'values': [{
                    'name': 'port 80',
                    'data': [i['total'] for i in os80]
                }, {
                    'name': 'port 443',
                    'data': [i['total'] for i in os443]
                }, {
                    'name': 'port 8000',
                    'data': [i['total'] for i in os8000]
                }, {
                    'name': 'port 8080',
                    'data': [i['total'] for i in os8080]
                }]
            }
        })
Exemplo n.º 11
0
def http_server_all(request, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    http80 = HTTPServer.objects.filter(port=80, date=scan_date).values('product').order_by('product') \
        .annotate(total=Sum('total')).order_by('-total')[:10]
    http443 = filter_by_name(HTTPServer.objects.filter(port=443, date=scan_date).values('product').order_by('product') \
        .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')
    http8000 = filter_by_name(HTTPServer.objects.filter(port=8000, date=scan_date).values('product').order_by('product') \
        .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')
    http8080 = filter_by_name(HTTPServer.objects.filter(port=8080, date=scan_date).values('product').order_by('product') \
        .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')

    return render(
        request, 'graphs/http_server.html', {
            'port': 'all',
            'scan_date': scan_date,
            'scan_list': [i.date for i in scan_date_list],
            'bars': {
                'title':
                'Web Server Running (HTTP)',
                'xaxis':
                'Web Server',
                'yaxis':
                'Number of Servers',
                'categories': [i['product'] for i in http80],
                'values': [{
                    'name': 'port 80',
                    'data': [i['total'] for i in http80]
                }, {
                    'name': 'port 443',
                    'data': [i['total'] for i in http443]
                }, {
                    'name': 'port 8000',
                    'data': [i['total'] for i in http8000]
                }, {
                    'name': 'port 8080',
                    'data': [i['total'] for i in http8080]
                }]
            }
        })
Exemplo n.º 12
0
Arquivo: asn.py Projeto: eacha/Web-OSR
def device_type_asn_all(request, number, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    device80 = AsnHTTPType.objects.filter(asn=number, port=80, date=scan_date).values('type').order_by('type') \
                            .annotate(total=Sum('total')).order_by('-total')[:10]
    device443 = filter_by_name(AsnHTTPType.objects.filter(asn=number, port=443, date=scan_date).values('type').order_by('type') \
                           .annotate(total=Sum('total')).order_by('-total'), [i['type'] for i in device80], 'type', 'total')
    device8000 = filter_by_name(AsnHTTPType.objects.filter(asn=number, port=8000, date=scan_date).values('type').order_by('type') \
                            .annotate(total=Sum('total')).order_by('-total'), [i['type'] for i in device80], 'type', 'total')
    device8080 = filter_by_name(AsnHTTPType.objects.filter(asn=number, port=8080, date=scan_date).values('type').order_by('type') \
                            .annotate(total=Sum('total')).order_by('-total'), [i['type'] for i in device80], 'type', 'total')

    return render(request, 'graphs/http_device_type_asn.html',
                  {'port': 'all',
                   'number': number,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {'title': 'Device Type of Server (HTTP) on Autonomous System %s' % number, 'xaxis': 'Type of Device',
                            'yaxis': 'Number of Servers',
                            'categories': [i['type'] for i in device80],
                            'values': [{'name': 'port 80', 'data': [i['total'] for i in device80]},
                                       {'name': 'port 443', 'data': [i['total'] for i in device443]},
                                       {'name': 'port 8000', 'data': [i['total'] for i in device8000]},
                                       {'name': 'port 8080', 'data': [i['total'] for i in device8080]}]}})
Exemplo n.º 13
0
Arquivo: asn.py Projeto: eacha/Web-OSR
def operating_system_server_asn_all(request, number, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    os80 = AsnHTTPOS.objects.filter(asn=number, port=80, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total')[:10]
    os443 = filter_by_name(AsnHTTPOS.objects.filter(asn=number, port=443, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total'), [i['os'] for i in os80], 'os', 'total')
    os8000 = filter_by_name(AsnHTTPOS.objects.filter(asn=number, port=8000, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total'), [i['os'] for i in os80], 'os', 'total')
    os8080 = filter_by_name(AsnHTTPOS.objects.filter(asn=number, port=8080, date=scan_date).values('os').order_by('os') \
        .annotate(total=Sum('total')).order_by('-total'), [i['os'] for i in os80], 'os', 'total')

    return render(request, 'graphs/http_operative_systems_asn.html',
                  {'port': 'all',
                   'number': number,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {'title': 'Operative System of Server (HTTP) on Autonomous System %s' % number, 'xaxis': 'Operative Systems',
                            'yaxis': 'Number of Servers',
                            'categories': [i['os'] for i in os80],
                            'values': [{'name': 'port 80', 'data': [i['total'] for i in os80]},
                                       {'name': 'port 443', 'data': [i['total'] for i in os443]},
                                       {'name': 'port 8000', 'data': [i['total'] for i in os8000]},
                                       {'name': 'port 8080', 'data': [i['total'] for i in os8080]}]}})
Exemplo n.º 14
0
Arquivo: asn.py Projeto: eacha/Web-OSR
def http_server_all_asn(request, number=None, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=80)
    if scan_date is None:
        # NO FUNCIONARA HASTA QUE TENGAMOS TODOS LOS DATOS TRANSFORMEITED!
        # Para ver como queda usar first() en vez de last()
        scan_date = scan_date_list.last().date
    if not number:
        try:
            number = int(request.POST['number'])
            print reverse('graphs/asn/server/all', kwargs={'number': number, 'scan_date': scan_date})
            return HttpResponseRedirect(reverse('graphs/asn/server/all', kwargs={'number': number, 'scan_date': scan_date}))
        except ValueError:
            return HttpResponseRedirect(reverse('graphs/asn/server/all'))

    http80 = AsnHTTPServer.objects.filter(asn=number, port=80, date=scan_date).values('product').order_by('product') \
                 .annotate(total=Sum('total')).order_by('-total')[:10]
    http443 = filter_by_name(AsnHTTPServer.objects.filter(asn=number, port=443, date=scan_date).values('product').order_by('product') \
                             .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')
    http8000 = filter_by_name(AsnHTTPServer.objects.filter(asn=number, port=8000, date=scan_date).values('product').order_by('product') \
                              .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')
    http8080 = filter_by_name(AsnHTTPServer.objects.filter(asn=number, port=8080, date=scan_date).values('product').order_by('product') \
                              .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')

    return render(request, 'graphs/http_server_asn.html',
                  {'port': 'all',
                   'number': number,
                   'scan_date': scan_date,
                   'scan_list': [i.date for i in scan_date_list],
                   'bars': {'title': 'Web Server Running (HTTP) on Autonomous System %s' % number, 'xaxis': 'Web Server', 'yaxis': 'Number of Servers',
                            'categories': [i['product'] for i in http80],
                            'values': [
                                {'name': 'port 80', 'data': [i['total'] for i in http80]},
                                {'name': 'port 443', 'data': [i['total'] for i in http443]},
                                {'name': 'port 8000', 'data': [i['total'] for i in http8000]},
                                {'name': 'port 8080', 'data': [i['total'] for i in http8080]}
                            ]}
                   })
Exemplo n.º 15
0
def device_type_all(request, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    device80 = (
        HTTPType.objects.filter(port=80, date=scan_date)
        .values("type")
        .order_by("type")
        .annotate(total=Sum("total"))
        .order_by("-total")[:10]
    )
    device443 = filter_by_name(
        HTTPType.objects.filter(port=443, date=scan_date)
        .values("type")
        .order_by("type")
        .annotate(total=Sum("total"))
        .order_by("-total"),
        [i["type"] for i in device80],
        "type",
        "total",
    )
    device8000 = filter_by_name(
        HTTPType.objects.filter(port=8000, date=scan_date)
        .values("type")
        .order_by("type")
        .annotate(total=Sum("total"))
        .order_by("-total"),
        [i["type"] for i in device80],
        "type",
        "total",
    )
    device8080 = filter_by_name(
        HTTPType.objects.filter(port=8080, date=scan_date)
        .values("type")
        .order_by("type")
        .annotate(total=Sum("total"))
        .order_by("-total"),
        [i["type"] for i in device80],
        "type",
        "total",
    )

    return render(
        request,
        "graphs/http_device_type.html",
        {
            "port": "all",
            "scan_date": scan_date,
            "scan_list": [i.date for i in scan_date_list],
            "bars": {
                "title": "Device Type of Server (HTTP)",
                "xaxis": "Type of Device",
                "yaxis": "Number of Servers",
                "categories": [i["type"] for i in device80],
                "values": [
                    {"name": "port 80", "data": [i["total"] for i in device80]},
                    {"name": "port 443", "data": [i["total"] for i in device443]},
                    {"name": "port 8000", "data": [i["total"] for i in device8000]},
                    {"name": "port 8080", "data": [i["total"] for i in device8080]},
                ],
            },
        },
    )
Exemplo n.º 16
0
def operating_system_server_all(request, scan_date):
    scan_date_list = ZmapLog.objects.filter(port=80)
    os80 = (
        HTTPOS.objects.filter(port=80, date=scan_date)
        .values("os")
        .order_by("os")
        .annotate(total=Sum("total"))
        .order_by("-total")[:10]
    )
    os443 = filter_by_name(
        HTTPOS.objects.filter(port=443, date=scan_date)
        .values("os")
        .order_by("os")
        .annotate(total=Sum("total"))
        .order_by("-total"),
        [i["os"] for i in os80],
        "os",
        "total",
    )
    os8000 = filter_by_name(
        HTTPOS.objects.filter(port=8000, date=scan_date)
        .values("os")
        .order_by("os")
        .annotate(total=Sum("total"))
        .order_by("-total"),
        [i["os"] for i in os80],
        "os",
        "total",
    )
    os8080 = filter_by_name(
        HTTPOS.objects.filter(port=8080, date=scan_date)
        .values("os")
        .order_by("os")
        .annotate(total=Sum("total"))
        .order_by("-total"),
        [i["os"] for i in os80],
        "os",
        "total",
    )

    return render(
        request,
        "graphs/http_operative_systems.html",
        {
            "port": "all",
            "scan_date": scan_date,
            "scan_list": [i.date for i in scan_date_list],
            "bars": {
                "title": "Operative System of Server (HTTP)",
                "xaxis": "Operative Systems",
                "yaxis": "Number of Servers",
                "categories": [i["os"] for i in os80],
                "values": [
                    {"name": "port 80", "data": [i["total"] for i in os80]},
                    {"name": "port 443", "data": [i["total"] for i in os443]},
                    {"name": "port 8000", "data": [i["total"] for i in os8000]},
                    {"name": "port 8080", "data": [i["total"] for i in os8080]},
                ],
            },
        },
    )
Exemplo n.º 17
0
def http_server_all_asn(request, number=None, scan_date=None):
    scan_date_list = ZmapLog.objects.filter(port=80)
    if scan_date is None:
        # NO FUNCIONARA HASTA QUE TENGAMOS TODOS LOS DATOS TRANSFORMEITED!
        # Para ver como queda usar first() en vez de last()
        scan_date = scan_date_list.last().date
    if not number:
        try:
            number = int(request.POST['number'])
            print reverse('graphs/asn/server/all',
                          kwargs={
                              'number': number,
                              'scan_date': scan_date
                          })
            return HttpResponseRedirect(
                reverse('graphs/asn/server/all',
                        kwargs={
                            'number': number,
                            'scan_date': scan_date
                        }))
        except ValueError:
            return HttpResponseRedirect(reverse('graphs/asn/server/all'))

    http80 = AsnHTTPServer.objects.filter(asn=number, port=80, date=scan_date).values('product').order_by('product') \
                 .annotate(total=Sum('total')).order_by('-total')[:10]
    http443 = filter_by_name(AsnHTTPServer.objects.filter(asn=number, port=443, date=scan_date).values('product').order_by('product') \
                             .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')
    http8000 = filter_by_name(AsnHTTPServer.objects.filter(asn=number, port=8000, date=scan_date).values('product').order_by('product') \
                              .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')
    http8080 = filter_by_name(AsnHTTPServer.objects.filter(asn=number, port=8080, date=scan_date).values('product').order_by('product') \
                              .annotate(total=Sum('total')), [i['product'] for i in http80], 'product', 'total')

    return render(
        request, 'graphs/http_server_asn.html', {
            'port': 'all',
            'number': number,
            'scan_date': scan_date,
            'scan_list': [i.date for i in scan_date_list],
            'bars': {
                'title':
                'Web Server Running (HTTP) on Autonomous System %s' % number,
                'xaxis':
                'Web Server',
                'yaxis':
                'Number of Servers',
                'categories': [i['product'] for i in http80],
                'values': [{
                    'name': 'port 80',
                    'data': [i['total'] for i in http80]
                }, {
                    'name': 'port 443',
                    'data': [i['total'] for i in http443]
                }, {
                    'name': 'port 8000',
                    'data': [i['total'] for i in http8000]
                }, {
                    'name': 'port 8080',
                    'data': [i['total'] for i in http8080]
                }]
            }
        })