mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-09-28 20:54:52 +02:00
Async ip, tech, ports made
This commit is contained in:
@@ -54,6 +54,7 @@ class TechnologyCountSerializer(serializers.Serializer):
|
||||
count = serializers.CharField()
|
||||
name = serializers.CharField()
|
||||
|
||||
|
||||
class TechnologySerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Technology
|
||||
|
||||
@@ -26,7 +26,9 @@ router.register(r'listIps', IpAddressViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
url('^', include(router.urls)),
|
||||
path('listTechnologies', ListTechnologies.as_view(), name='listTechnologies'),
|
||||
path('listTechnologies/', ListTechnology.as_view(), name='listTechnologies'),
|
||||
path('listPorts/', ListPorts.as_view(), name='listPorts'),
|
||||
path('listIPs/', ListIPs.as_view(), name='listIPs'),
|
||||
]
|
||||
|
||||
urlpatterns += router.urls
|
||||
|
||||
+33
-4
@@ -17,20 +17,49 @@ from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
from rest_framework.decorators import api_view, action
|
||||
|
||||
class ListTechnologies(APIView):
|
||||
|
||||
class ListTechnology(APIView):
|
||||
def get(self, request, format=None):
|
||||
req = self.request
|
||||
scan_id = req.query_params.get('scan_id')
|
||||
if scan_id:
|
||||
tech = Technology.objects.filter(technologies__in=Subdomain.objects.filter(scan_history__id=scan_id)).annotate(count=Count('name'))
|
||||
tech = Technology.objects.filter(technologies__in=Subdomain.objects.filter(scan_history__id=scan_id)).annotate(count=Count('name')).order_by('-count')
|
||||
serializer = TechnologyCountSerializer(tech, many=True)
|
||||
return Response({"technologies": serializer.data})
|
||||
else:
|
||||
all_tech = Technology.objects.all()
|
||||
serializer = TechnologySerializer(all_tech, many=True)
|
||||
tech = Technology.objects.filter(technologies__in=Subdomain.objects.all()).annotate(count=Count('name')).order_by('-count')
|
||||
serializer = TechnologyCountSerializer(tech, many=True)
|
||||
return Response({"technologies": serializer.data})
|
||||
|
||||
|
||||
class ListPorts(APIView):
|
||||
def get(self, request, format=None):
|
||||
req = self.request
|
||||
scan_id = req.query_params.get('scan_id')
|
||||
if scan_id:
|
||||
port = Port.objects.filter(ports__in=IpAddress.objects.filter(ip_addresses__in=Subdomain.objects.filter(scan_history__id=scan_id))).distinct()
|
||||
serializer = PortSerializer(port, many=True)
|
||||
return Response({"ports": serializer.data})
|
||||
else:
|
||||
port = Port.objects.filter(ports__in=IpAddress.objects.filter(ip_addresses__in=Subdomain.objects.all())).distinct()
|
||||
serializer = PortSerializer(port, many=True)
|
||||
return Response({"ports": serializer.data})
|
||||
|
||||
|
||||
class ListIPs(APIView):
|
||||
def get(self, request, format=None):
|
||||
req = self.request
|
||||
scan_id = req.query_params.get('scan_id')
|
||||
if scan_id:
|
||||
ips = IpAddress.objects.filter(ip_addresses__in=Subdomain.objects.filter(scan_history__id=scan_id)).distinct()
|
||||
serializer = IpSerializer(ips, many=True)
|
||||
return Response({"ips": serializer.data})
|
||||
else:
|
||||
ips = IpAddress.objects.filter(ip_addresses__in=Subdomain.objects.all()).distinct()
|
||||
serializer = IpSerializer(ips, many=True)
|
||||
return Response({"ips": serializer.data})
|
||||
|
||||
|
||||
class IpAddressViewSet(viewsets.ModelViewSet):
|
||||
queryset = Subdomain.objects.none()
|
||||
serializer_class = IpSubdomainSerializer
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.6 on 2021-06-09 18:47
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('startScan', '0034_auto_20210609_0406'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='ipaddress',
|
||||
name='ports',
|
||||
field=models.ManyToManyField(related_name='ports', to='startScan.Port'),
|
||||
),
|
||||
]
|
||||
+1
-1
@@ -231,7 +231,7 @@ class Technology(models.Model):
|
||||
class IpAddress(models.Model):
|
||||
address = models.CharField(max_length=100, blank=True, null=True)
|
||||
is_cdn = models.BooleanField(default=False)
|
||||
ports = models.ManyToManyField('Port', related_name='port')
|
||||
ports = models.ManyToManyField('Port', related_name='ports')
|
||||
|
||||
def __str__(self):
|
||||
return str(self.address)
|
||||
|
||||
@@ -261,18 +261,13 @@ Detailed Scan Results for {{history.domain.name}}
|
||||
<div class="col-xl-4 col-lg-3 col-md-12 col-sm-12 col-12 layout-spacing">
|
||||
<div class="widget widget-ip">
|
||||
<div class="widget-heading">
|
||||
<h6 class=""><span class='badge outline-badge-dark'>{{ports.count}}</span> Unique Discovered Ports</small></h6>
|
||||
<h6 class=""><span id="ports-count"><span class="spinner-border text-dark align-self-center loader-sm"></span></span> Discovered Ports </h6>
|
||||
<small class="text-danger">*Ports highlighted with red are uncommon Ports.</small>
|
||||
</div>
|
||||
<div class="widget-content">
|
||||
<div class="mt-container mx-auto">
|
||||
{% if not history.port_scan %}
|
||||
<span class='text-muted'>Port Scan has not been initiated, please initiate port scan to discover unique and uncommon ports.</span>
|
||||
{% else %}
|
||||
{% for port in ports %}
|
||||
<span class='m-1 badge badge-pills outline-badge-{% if port.3 %}danger{%else%}info{% endif %} bs-tooltip' title='{% if port.3 %}Uncommon Port-{{port.2}}{%else%}{{port.2}}{% endif %}' data-toggle="modal" data-target="#detailScanModal" onclick="get_ips_from_port('{{port.0}}', {{history.id}})">{{port.0}}/{{port.1}}</span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div id="ports">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -280,11 +275,12 @@ Detailed Scan Results for {{history.domain.name}}
|
||||
<div class="col-xl-4 col-lg-3 col-md-12 col-sm-12 col-12 layout-spacing">
|
||||
<div class="widget widget-ip">
|
||||
<div class="widget-heading">
|
||||
<h6 class=""><span class='badge outline-badge-dark'>{{technology|length}}</span> Discovered Unique Technologies</h6>
|
||||
<h6 class=""><span id="technologies-count"><span class="spinner-border text-dark align-self-center loader-sm"></span></span> Discovered Technologies </h6>
|
||||
</div>
|
||||
<div class="widget-content">
|
||||
<div class="mt-container mx-auto">
|
||||
{{technologies}}
|
||||
<div id="technologies">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1290,7 +1286,11 @@ get_endpoint_changes_values({{scan_history_id}});
|
||||
|
||||
get_interesting_count({{scan_history_id}});
|
||||
|
||||
get_ip_and_port({{scan_history_id}});
|
||||
get_ips({{scan_history_id}});
|
||||
|
||||
get_technologies({{scan_history_id}});
|
||||
|
||||
get_ports({{scan_history_id}});
|
||||
|
||||
{% if history.fetch_url and history.used_gf_patterns %}
|
||||
// gf patterns
|
||||
|
||||
+32
-24
@@ -749,32 +749,40 @@ function get_endpoint_changes_values(scan_id){
|
||||
});
|
||||
}
|
||||
|
||||
function get_ip_and_port(scan_id){
|
||||
$.getJSON(`../api/listIps/?scan_id=${scan_id}&no_page`, function(data) {
|
||||
var ip_array = Array()
|
||||
var cdn_ip_array = Array()
|
||||
function get_ips(scan_id){
|
||||
$.getJSON(`../api/listIPs/?scan_id=${scan_id}&format=json`, function(data) {
|
||||
$('#ip-address-count').empty();
|
||||
for (var val in data){
|
||||
// gather ip
|
||||
for(var ip in data[val]['ip_addresses']){
|
||||
if ($.inArray(data[val]['ip_addresses'][ip]['address'], ip_array) == -1 && $.inArray(data[val]['ip_addresses'][ip]['address'], cdn_ip_array) == -1) {
|
||||
var ip_addr = data[val]['ip_addresses'][ip]['address'];
|
||||
if (data[val]['ip_addresses'][ip]['is_cdn']) {
|
||||
badge_color = 'warning'
|
||||
cdn_ip_array.push(ip_addr);
|
||||
}
|
||||
else{
|
||||
badge_color = 'info'
|
||||
ip_array.push(ip_addr);
|
||||
}
|
||||
$("#ip-address").append(`<span class='badge outline-badge-${badge_color} badge-pills m-1' data-toggle="modal" data-target="#detailScanModal" onclick="get_ports_for_ip('${ip_addr}, ${scan_id}')">${ip_addr}</span>`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (var val in data['ips']){
|
||||
ip = data['ips'][val]
|
||||
badge_color = ip['is_cdn'] ? 'warning' : 'info';
|
||||
$("#ip-address").append(`<span class='badge outline-badge-${badge_color} badge-pills m-1' data-toggle="tooltip" title="${ip['ports'].length} Ports Open.">${ip['address']}</span>`);
|
||||
}
|
||||
$('#ip-address-count').html(`<span class="badge outline-badge-dark">${ip_array.length+cdn_ip_array.length}</span>`);
|
||||
$('#ip-address-summary').html(`(${cdn_ip_array.length} CDN IPs)</span>`);
|
||||
$('#ip-address-count').html(`<span class="badge outline-badge-dark">${data['ips'].length}</span>`);
|
||||
$("body").tooltip({ selector: '[data-toggle=tooltip]' });
|
||||
});
|
||||
}
|
||||
|
||||
function get_technologies(scan_id){
|
||||
$.getJSON(`../api/listTechnologies/?scan_id=${scan_id}&format=json`, function(data) {
|
||||
$('#technologies-count').empty();
|
||||
for (var val in data['technologies']){
|
||||
tech = data['technologies'][val]
|
||||
$("#technologies").append(`<span class='badge outline-badge-info badge-pills m-1' data-toggle="tooltip" title="${tech['count']} Subdomains use this technology.">${tech['name']}</span>`);
|
||||
}
|
||||
$('#technologies-count').html(`<span class="badge outline-badge-dark">${data['technologies'].length}</span>`);
|
||||
$("body").tooltip({ selector: '[data-toggle=tooltip]' });
|
||||
});
|
||||
}
|
||||
|
||||
function get_ports(scan_id){
|
||||
$.getJSON(`../api/listPorts/?scan_id=${scan_id}&format=json`, function(data) {
|
||||
$('#ports-count').empty();
|
||||
for (var val in data['ports']){
|
||||
port = data['ports'][val]
|
||||
badge_color = port['is_uncommon'] ? 'danger' : 'info';
|
||||
$("#ports").append(`<span class='badge outline-badge-${badge_color} badge-pills m-1' data-toggle="tooltip" title="${port['description']}">${port['number']}/${port['service_name']}</span>`);
|
||||
}
|
||||
$('#ports-count').html(`<span class="badge outline-badge-dark">${data['ports'].length}</span>`);
|
||||
$("body").tooltip({ selector: '[data-toggle=tooltip]' });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user