json parsed and saved to dn

This commit is contained in:
Yogesh Ojha
2020-05-24 22:29:33 +05:30
parent 638bb8012e
commit 01ea33c319
+19 -2
View File
@@ -13,7 +13,6 @@ import requests
import json
import os
def index(request):
return render(request, 'startScan/index.html')
@@ -69,7 +68,7 @@ def doScan(id, domain):
with open(scan_results_file) as subdomain_list:
for subdomain in subdomain_list:
scanned = ScannedHost()
scanned.subdomain = subdomain
scanned.subdomain = subdomain.rstrip('\n')
scanned.scan_history = task
scanned.takeover_possible = False
scanned.save()
@@ -79,6 +78,24 @@ def doScan(id, domain):
aquatone_command = 'cat {} | /app/tools/aquatone -ports xlarge -out {}'.format(with_protocol_path, output_aquatone_path)
os.system(aquatone_command)
aqua_json_path = output_aquatone_path + '/aquatone_session.json'
with open(aqua_json_path, 'r') as json_file:
data = json.load(json_file)
subdomain_details = ScannedHost.objects.filter(scan_history__id=id)
# should be a better way for this
for sub in subdomain_details:
for host in data['pages']:
if sub.subdomain == data['pages'][host]['hostname']:
subdomain_proto = ScannedSubdomainWithProtocols()
subdomain_proto.host = sub
subdomain_proto.url = data['pages'][host]['url']
subdomain_proto.ip_address = data['pages'][host]['addrs']
subdomain_proto.page_title = data['pages'][host]['pageTitle']
subdomain_proto.http_status = data['pages'][host]['status'][0:3]
subdomain_proto.technology_stack = 'fake'
subdomain_proto.save()
task.scan_status = 2
task.save()
# notify on slack