コード例 #1
0
    def handle(self, *args, **options):
        """
        Script Execution.
        """

        stats.generate_yara_hits()
        stats.generate_sources()
        stats.generate_filetypes()
        stats.generate_campaign_stats()
        stats.generate_counts()
        stats.target_user_stats()
        stats.campaign_date_stats()
コード例 #2
0
ファイル: mapreduces.py プロジェクト: carriercomm/crits
    def handle(self, *args, **options):
        """
        Script Execution.
        """

        stats.generate_yara_hits()
        stats.generate_sources()
        stats.generate_filetypes()
        stats.generate_campaign_stats()
        stats.generate_counts()
        stats.target_user_stats()
        stats.campaign_date_stats()
コード例 #3
0
ファイル: handlers.py プロジェクト: davidhdz/crits
def generate_campaign_jtable(request, option):
    """
    Generate the jtable data for rendering in the list template.

    :param request: The request for this jtable.
    :type request: :class:`django.http.HttpRequest`
    :param option: Action to take.
    :type option: str of either 'jtlist', 'jtdelete', or 'inline'.
    :returns: :class:`django.http.HttpResponse`
    """

    refresh = request.GET.get("refresh", "no")
    if refresh == "yes":
        generate_campaign_stats()
    obj_type = Campaign
    type_ = "campaign"
    mapper = obj_type._meta['jtable_opts']
    if option == "jtlist":
        # Sets display url
        details_url = mapper['details_url']
        details_url_key = mapper['details_url_key']
        fields = mapper['fields']
        response = jtable_ajax_list(obj_type,
                                    details_url,
                                    details_url_key,
                                    request,
                                    includes=fields)
        # Ugly hack because we are the first tab in global search.
        # If there are no results for anything we will still try and
        # search campaigns since it will render that tab by default.
        # If the search parameters exclude Campaigns, we will get an
        # IGNORE. If we do, format a valid response of 0 results.
        if response['Result'] == "IGNORE":
            response = {
                'crits_type': 'Campaign',
                'term': 'No Results',
                'Records': [],
                'TotalRecordCount': 0,
                'Result': 'OK',
                'msg': ''
            }
        return HttpResponse(json.dumps(response, default=json_handler),
                            content_type="application/json")
    # Disable campaign removal
    if option == "jtdelete":
        response = {"Result": "ERROR"}
        #if jtable_ajax_delete(obj_type,request):
        #    response = {"Result": "OK"}
        return HttpResponse(json.dumps(response, default=json_handler),
                            content_type="application/json")
    jtopts = {
        'title':
        "Campaigns",
        'default_sort':
        mapper['default_sort'],
        'listurl':
        reverse('crits.%ss.views.%ss_listing' % (type_, type_),
                args=('jtlist', )),
        'searchurl':
        reverse(mapper['searchurl']),
        'fields':
        mapper['jtopts_fields'],
        'hidden_fields':
        mapper['hidden_fields'],
        'linked_fields':
        mapper['linked_fields']
    }
    jtable = build_jtable(jtopts, request)
    jtable['toolbar'] = [
        {
            'tooltip': "'All Campaigns'",
            'text': "'All'",
            'click':
            "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'New Campaigns'",
            'text': "'New'",
            'click':
            "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'New'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'In Progress Campaigns'",
            'text': "'In Progress'",
            'click':
            "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'In Progress'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'Analyzed Campaigns'",
            'text': "'Analyzed'",
            'click':
            "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'Analyzed'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'Deprecated Campaigns'",
            'text': "'Deprecated'",
            'click':
            "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'Deprecated'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip':
            "'Refresh campaign stats'",
            'text':
            "'Refresh Stats'",
            'click':
            "function () {$.get('" + reverse('crits.%ss.views.%ss_listing' %
                                             (type_, type_)) +
            "', {'refresh': 'yes'}, function () { $('#campaign_listing').jtable('reload');});}"
        },
        {
            'tooltip': "'Add Campaign'",
            'text': "'Add Campaign'",
            'click': "function () {$('#new-campaign').click()}",
        },
    ]
    # Make count fields clickable to search those listings
    for ctype in [
            "indicator", "email", "domain", "sample", "event", "ip", "pcap"
    ]:
        url = reverse('crits.%ss.views.%ss_listing' % (ctype, ctype))
        for field in jtable['fields']:
            if field['fieldname'].startswith("'" + ctype):
                field['display'] = """ function (data) {
                return '<a href="%s?campaign='+data.record.name+'">'+data.record.%s_count+'</a>';
            }
            """ % (url, ctype)
    if option == "inline":
        return render_to_response(
            "jtable.html", {
                'jtable': jtable,
                'jtid': '%s_listing' % type_,
                'button': '%ss_tab' % type_
            }, RequestContext(request))
    else:
        return render_to_response("%s_listing.html" % type_, {
            'jtable': jtable,
            'jtid': '%s_listing' % type_
        }, RequestContext(request))
コード例 #4
0
ファイル: handlers.py プロジェクト: gbartz/crits
def generate_campaign_jtable(request, option):
    """
    Generate the jtable data for rendering in the list template.

    :param request: The request for this jtable.
    :type request: :class:`django.http.HttpRequest`
    :param option: Action to take.
    :type option: str of either 'jtlist', 'jtdelete', or 'inline'.
    :returns: :class:`django.http.HttpResponse`
    """

    refresh = request.GET.get("refresh", "no")
    if refresh == "yes":
        generate_campaign_stats()
    obj_type = Campaign
    type_ = "campaign"
    mapper = obj_type._meta['jtable_opts']
    if option == "jtlist":
        # Sets display url
        details_url = mapper['details_url']
        details_url_key = mapper['details_url_key']
        fields = mapper['fields']
        response = jtable_ajax_list(obj_type,
                                    details_url,
                                    details_url_key,
                                    request,
                                    includes=fields)
        # Ugly hack because we are the first tab in global search.
        # If there are no results for anything we will still try and
        # search campaigns since it will render that tab by default.
        # If the search parameters exclude Campaigns, we will get an
        # IGNORE. If we do, format a valid response of 0 results.
        if response['Result'] == "IGNORE":
            response = {'crits_type': 'Campaign',
                        'term': 'No Results',
                        'Records': [],
                        'TotalRecordCount': 0,
                        'Result': 'OK',
                        'msg': ''}
        return HttpResponse(json.dumps(response,
                                       default=json_handler),
                            content_type="application/json")
    # Disable campaign removal
    if option == "jtdelete":
        response = {"Result": "ERROR"}
        #if jtable_ajax_delete(obj_type,request):
        #    response = {"Result": "OK"}
        return HttpResponse(json.dumps(response,
                                       default=json_handler),
                            content_type="application/json")
    jtopts = {
        'title': "Campaigns",
        'default_sort': mapper['default_sort'],
        'listurl': reverse('crits.%ss.views.%ss_listing' % (type_, type_),
                           args=('jtlist',)),
        'searchurl': reverse(mapper['searchurl']),
        'fields': mapper['jtopts_fields'],
        'hidden_fields': mapper['hidden_fields'],
        'linked_fields': mapper['linked_fields']
    }
    jtable = build_jtable(jtopts, request)
    jtable['toolbar'] = [
        {
            'tooltip': "'All Campaigns'",
            'text': "'All'",
            'click': "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'New Campaigns'",
            'text': "'New'",
            'click': "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'New'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'In Progress Campaigns'",
            'text': "'In Progress'",
            'click': "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'In Progress'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'Analyzed Campaigns'",
            'text': "'Analyzed'",
            'click': "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'Analyzed'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'Deprecated Campaigns'",
            'text': "'Deprecated'",
            'click': "function () {$('#campaign_listing').jtable('load', {'refresh': 'yes', 'status': 'Deprecated'});}",
            'cssClass': "'jtable-toolbar-center'",
        },
        {
            'tooltip': "'Refresh campaign stats'",
            'text': "'Refresh Stats'",
            'click': "function () {$.get('" + reverse('crits.%ss.views.%ss_listing' % (type_, type_)) + "', {'refresh': 'yes'}, function () { $('#campaign_listing').jtable('reload');});}"
        },
        {
            'tooltip': "'Add Campaign'",
            'text': "'Add Campaign'",
            'click': "function () {$('#new-campaign').click()}",
        },

    ]
    # Make count fields clickable to search those listings
    for ctype in ["indicator", "email", "domain", "sample", "event", "ip", "pcap"]:
        url = reverse('crits.%ss.views.%ss_listing' % (ctype, ctype))
        for field in jtable['fields']:
            if field['fieldname'].startswith("'" + ctype):
                field['display'] = """ function (data) {
                return '<a href="%s?campaign='+data.record.name+'">'+data.record.%s_count+'</a>';
            }
            """ % (url, ctype)
    if option == "inline":
        return render_to_response("jtable.html",
                                  {'jtable': jtable,
                                   'jtid': '%s_listing' % type_,
                                   'button': '%ss_tab' % type_},
                                  RequestContext(request))
    else:
        return render_to_response("%s_listing.html" % type_,
                                  {'jtable': jtable,
                                   'jtid': '%s_listing' % type_},
                                  RequestContext(request))