diff --git a/reNgine/common_func.py b/reNgine/common_func.py index 1e2cc39c..604f656a 100644 --- a/reNgine/common_func.py +++ b/reNgine/common_func.py @@ -1,3 +1,5 @@ +import whois +import json from django.db.models import Q from functools import reduce @@ -107,3 +109,17 @@ def get_interesting_endpoint(scan_history=None, target=None): url_of__id=scan_history).filter(page_title_lookup_query) return url_lookup | title_lookup + +def check_keyword_exists(keyword_list, subdomain): + return any(sub in subdomain for sub in keyword_list) + +def get_whois(domain_name): + whois_data = whois.whois(domain_name) + whois_json = {} + for data in whois_data: + if data == 'expiration_date' or data == 'updated_date' or data == 'created_date': + if type + whois_json[data] = whois_data + whois_json[data] = whois_data[data] + print(json.dumps(whois_json)) + return json.loads(whois_json) diff --git a/reNgine/tasks.py b/reNgine/tasks.py index 232f859d..a2b43e56 100644 --- a/reNgine/tasks.py +++ b/reNgine/tasks.py @@ -7,7 +7,6 @@ import requests import logging import tldextract - from celery import shared_task from discord_webhook import DiscordWebhook from reNgine.celery import app @@ -35,7 +34,7 @@ from targetApp.models import Domain from notification.models import NotificationHooks from scanEngine.models import EngineType, Configuration, Wordlist -from .utils import * +from .common_func import * ''' task for background scan @@ -71,6 +70,7 @@ def doScan(domain_id, scan_history_id, scan_type, engine_type): # once the celery task starts, change the task status to Started task.scan_status = 1 task.last_scan_date = current_scan_time + task.whois = get_whois(domain.domain_name) task.save() activity_id = create_scan_activity(task, "Scanning Started", 2) diff --git a/reNgine/utils.py b/reNgine/utils.py deleted file mode 100644 index 1cd975ca..00000000 --- a/reNgine/utils.py +++ /dev/null @@ -1,2 +0,0 @@ -def check_keyword_exists(keyword_list, subdomain): - return any(sub in subdomain for sub in keyword_list) diff --git a/requirements.txt b/requirements.txt index 0ebbc557..ca1dce2a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -51,3 +51,4 @@ validators==0.18.1 vine==5.0.0 wcwidth==0.2.5 discord-webhook==0.11.0 +python-whois diff --git a/startScan/migrations/0002_scanhistory_whois_json.py b/startScan/migrations/0002_scanhistory_whois_json.py new file mode 100644 index 00000000..73111fe7 --- /dev/null +++ b/startScan/migrations/0002_scanhistory_whois_json.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.6 on 2021-04-17 16:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('startScan', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='scanhistory', + name='whois_json', + field=models.JSONField(null=True), + ), + ] diff --git a/startScan/models.py b/startScan/models.py index bd21872c..bf4dc561 100644 --- a/startScan/models.py +++ b/startScan/models.py @@ -10,6 +10,7 @@ class ScanHistory(models.Model): domain_name = models.ForeignKey(Domain, on_delete=models.CASCADE) scan_type = models.ForeignKey(EngineType, on_delete=models.CASCADE) celery_id = models.CharField(max_length=100, blank=True) + whois_json = JSONField(null=True) def __str__(self): # debug purpose remove scan type and id in prod diff --git a/startScan/templates/startScan/detail_scan.html b/startScan/templates/startScan/detail_scan.html index 2d4feef7..1952f8b5 100644 --- a/startScan/templates/startScan/detail_scan.html +++ b/startScan/templates/startScan/detail_scan.html @@ -49,11 +49,7 @@ All Subdomains