mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-09-18 07:47:42 +02:00
Send Slack notif working
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import NotificationHooks
|
||||
# Register your models here.
|
||||
admin.site.register(NotificationHooks)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.0.6 on 2020-05-22 03:59
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='NotificationHooks',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('hook_name', models.CharField(max_length=200)),
|
||||
('hook_url', models.CharField(max_length=500)),
|
||||
('send_notif', models.BooleanField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -1,3 +1,9 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class NotificationHooks(models.Model):
|
||||
hook_name = models.CharField(max_length=200)
|
||||
hook_url = models.CharField(max_length=500)
|
||||
send_notif = models.BooleanField()
|
||||
|
||||
def __str__(self):
|
||||
return self.hook_name
|
||||
|
||||
@@ -43,15 +43,13 @@ Push Notifications
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for domain in domains.all %}
|
||||
{% for hook in all_hooks.all %}
|
||||
<tr>
|
||||
<td class="checkbox-column"> {{ domain.id }} </td>
|
||||
<td>{{ domain.domain_name }}</td>
|
||||
<td>{{ domain.domain_description }}</td>
|
||||
<td>{{ domain.insert_date }}</td>
|
||||
<td class="text-center"><span class="shadow-none badge badge-warning">Never Scanned Before</span></td>
|
||||
<td class="checkbox-column"> {{ hook.id }} </td>
|
||||
<td>{{ hook.hook_name }}</td>
|
||||
<td>{{ hook.hook_url }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'start_scan' domain.id %}" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Scan">
|
||||
<a href="" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Scan">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather table-scan feather-zap" id="myInput" value="helloworld">
|
||||
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
|
||||
</svg>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
from .models import NotificationHooks
|
||||
|
||||
def index(request):
|
||||
context = {'notification_nav_active': 'true'}
|
||||
notification_hooks = NotificationHooks.objects
|
||||
context = {'notification_nav_active': 'true', 'all_hooks': notification_hooks}
|
||||
return render(request, 'notification/index.html', context)
|
||||
|
||||
+8
-1
@@ -3,12 +3,14 @@ from django.contrib import messages
|
||||
from django.http import JsonResponse, HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from .models import ScanHistory, ScannedSubdomains
|
||||
from notification.models import NotificationHooks
|
||||
from targetApp.models import Domain
|
||||
from scanEngine.models import EngineType
|
||||
import threading
|
||||
from . import sublist3r
|
||||
from django.utils import timezone
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
def index(request):
|
||||
return render(request, 'startScan/index.html')
|
||||
@@ -46,6 +48,7 @@ def start_scan_ui(request, id):
|
||||
|
||||
def doScan(id, domain):
|
||||
task = ScanHistory.objects.get(pk=id)
|
||||
notif_hook = NotificationHooks.objects.filter(send_notif=True)
|
||||
subdomains = sublist3r.main(domain.domain_name, 40, False, ports= None, silent=False, verbose= False, enable_bruteforce= False, engines=None)
|
||||
for subdomain in subdomains:
|
||||
scanned = ScannedSubdomains()
|
||||
@@ -59,6 +62,10 @@ def doScan(id, domain):
|
||||
scanned.save()
|
||||
task.scan_status = 2
|
||||
task.save()
|
||||
scan_status_msg = {'text': "reEngine finished scanning " + domain.domain_name}
|
||||
headers = {'content-type': 'application/json'}
|
||||
for notif in notif_hook:
|
||||
requests.post(notif.hook_url, data=json.dumps(scan_status_msg), headers=headers)
|
||||
|
||||
def checkScanStatus(request, id):
|
||||
task = Crawl.objects.get(pk=id)
|
||||
|
||||
Reference in New Issue
Block a user