コード例 #1
0
ファイル: views.py プロジェクト: scoradia/apate
def DownloadConfigurations(request):
    if "POST" not in str(request.method):
        return redirect("/")
    # Verify we got a 'key_id' parameter
    try:
        this_id = int(request.POST["key_id"])
    except:
        return redirect("/")

    # Get Honeypot Matching ID
    try:
        hpObj = HoneyPots.objects.get(id=this_id)
    except:
        return redirect("/")

    GetGlobalVars(globals())

    # Build Configuration file
    scripts = []
    temp = Services.objects.filter(relHoneypot=hpObj)
    if len(temp) is not 0:
        for script in temp:
            scripts.append(script.name)
    conf_string = _build_honeyd_configuration_file(
        machine_name=hpObj.name,
        personality=hpObj.personality,
        ip=hpObj.ip,
        ping_response=True,
        services=scripts)
    a = {}
    a['hp'] = hpObj
    a['conf_string'] = conf_string
    return render(request, "DownloadConfiguration.html", a)
コード例 #2
0
ファイル: views.py プロジェクト: scoradia/apate
def StartHoneypot(request):
    a = {}
    a['title'] = "Start the Honeypot"
    a['page'] = "StartHoneypot"
    a['info_message'] = ""
    a['honeypots'] = HoneyPots.objects.all()
    a['notifications'] = notifications

    if "POST" not in str(request.method):
        return redirect("/")

    # Verify we got a 'key_id' parameter
    try:
        this_id = int(request.POST["key_id"])
    except:
        a['info_message'] = "Could not get the 'key_id' parameter."
        return render(request, "ViewHoneypots.html", a)

    # Get Honeypot Matching ID
    try:
        hpObj = HoneyPots.objects.get(id=this_id)
    except:
        a['info_message'] = "Could not find that honeypot ID."
        return render(request, "ViewHoneypots.html", a)

    GetGlobalVars(globals())

    # Build Configuration file
    scripts = []
    temp = Services.objects.filter(relHoneypot=hpObj)
    if len(temp) is not 0:
        for script in temp:
            scripts.append(script.name)
    conf_string = _build_honeyd_configuration_file(
        machine_name=hpObj.name,
        personality=hpObj.personality,
        ip=hpObj.ip,
        ping_response=True,
        services=scripts)

    # Create the HoneyDWrapper
    try:
        newWrapper = HoneyDWrapper(
            host=hpObj.relHost.host,
            port=hpObj.relHost.ssh_port,
            network_interface=hpObj.relHost.interface,
            creds=[hpObj.relHost.username, hpObj.relHost.password],
            configurations=conf_string,
            machines_ip=hpObj.ip)
    except:
        hpObj.relHost.creds_valid = False
        notifications.append("Credentials for host %s are not valid." %
                             hpObj.relHost.host)
        a['notifications'] = notifications
        return render(request, "ViewHoneypots.html", a)

    newWrapper._WriteConfigurationFile()
    pid = newWrapper._StartHoneyd()

    # Starting a listener to accept output
    retrieverObj = GoldenRetriver(honey_id=newWrapper.conf_id,
                                  port=newWrapper.conf_id)
    thread = Thread(target=retrieverObj.StartListening, args=())
    thread.start()
    retriever_threads[newWrapper.conf_id] = thread
    puppies[newWrapper.conf_id] = retrieverObj

    # Starting Retriver in Client:
    newWrapper._CreateAndUploadRetriever()

    if pid is ERR:
        a['info_message'] = "Error starting the honeypot."
        return render(request, "ViewHoneypots.html", a)

    else:
        hpObj.state = True
        hpObj.honey_id = newWrapper.conf_id
        hpObj.save()
        active_honeypots.append([hpObj.honey_id, newWrapper])
        a['info_message'] = "Honeypot Started!."
        notifications.append("Honeypot %s was started." % hpObj.name)
        LogMe(caller=__name__,
              m_type=SUCCESS,
              message="Honeypot %s was started." % hpObj.name)
        a['notifications'] = notifications

        return render(request, "ViewHoneypots.html", a)
コード例 #3
0
ファイル: views.py プロジェクト: scoradia/apate
from django.core import serializers
from django.shortcuts import render, redirect

from threading import Thread

from apate.models import *
from apate.core.globals import *
from apate.core.retrival_agent import GoldenRetriver
from apate.core.honeyd_wrapper import HoneyDWrapper
from apate.core.dynamic_globals import GetGlobalVars
from apate.core.snitch import LogMe, INFORMATION, SUCCESS, WARNING, ERROR
from apate.core.aux import _get_os_list, _build_honeyd_configuration_file, _analyzeLogFile
# Create your views here.

GetGlobalVars(globals())


def Dashboard(request):
    a = {}
    a['page'] = "Dashboard"
    a['title'] = "%s | Dashboard" % APPNAME

    a['devices'] = AvailableHosts.objects.all()
    a['honeypots'] = HoneyPots.objects.all()
    a['events'] = Events.objects.all()

    a['tcp_count'] = len(Events.objects.filter(protocol_type=0))
    a['udp_count'] = len(Events.objects.filter(protocol_type=1))
    a['icmp_count'] = len(Events.objects.filter(protocol_type=2))

    total = a['tcp_count'] + a['udp_count'] + a['icmp_count']