Skip to content

Commit

Permalink
Merge branch 'dev' into 'master'
Browse files Browse the repository at this point in the history
Final Merge for v2.2.2

See merge request ghostmanager/Ghostwriter!126
  • Loading branch information
chrismaddalena committed Oct 22, 2021
2 parents 25a92c8 + 6aa1d72 commit 5a93835
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 29 deletions.
57 changes: 32 additions & 25 deletions ghostwriter/modules/linting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,41 @@

# Example JSON reporting data for loading into templates for rendering tests
LINTER_CONTEXT = {
"report_date": "March 25, 2021",
"report_date": "Mar. 25, 2021",
"project": {
"id": 1,
"name": "2021-03-01 Kabletown, Inc. Red Team (KABLE-01)",
"type": "Red Team",
"start_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"start_month": "March",
"start_day": 1,
"start_year": 2021,
"end_date": "June 25, 2021",
"end_date": "Jun. 25, 2021",
"end_month": "June",
"end_day": 25,
"end_year": 2021,
"codename": "KABLE-01",
"timezone": "America/Los_Angeles",
"note": "<p>This is an assessment for Kabletown but targets NBC assets. The goal is to answer specific questions prior to Kabletown absorbing NBC.</p>",
"slack_channel": "#ghostwriter",
"complete": False,
"start_time": "09:00:00",
"end_time": "17:00:00",
},
"client": {
"id": 1,
"contacts": [
{
"name": "Hank Hooper",
"timezone": "America/Los_Angeles",
"job_title": "CEO",
"email": "[email protected]",
"phone": "(212) 664-4444",
"note": '<p>A self-described "family man," Vietnam veteran, and head of Kabletown. He always seems happy on the surface (laughing incessantly), while directing thinly-veiled insults and threats to subordinates. Handle with care.</p>',
},
{
"name": "John Francis Donaghy",
"timezone": "America/Los_Angeles",
"job_title": "Vice President of East Coast Television",
"email": "[email protected]",
"phone": "(212) 664-4444",
Expand All @@ -48,35 +53,37 @@
"role": "Assessment Lead",
"name": "Benny the Ghost",
"email": "[email protected]",
"start_date": "March 1, 2021",
"end_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"end_date": "Jun. 25, 2021",
"timezone": "America/Los_Angeles",
"note": "<p>Benny will lead the assessment for the full duration.</p>",
},
{
"role": "Assessment Oversight",
"name": "Christopher Maddalena",
"email": "[email protected]",
"start_date": "March 1, 2021",
"end_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"end_date": "Jun. 25, 2021",
"timezone": "America/Los_Angeles",
"note": "<p>Christopher will provide oversight and assistance (as needed).</p>",
},
],
"objectives": [
{
"priority": "Primary",
"status": "Active",
"deadline": "June 25, 2021",
"deadline": "Jun. 25, 2021",
"percent_complete": 50.0,
"tasks": [
{
"deadline": "June 25, 2021",
"deadline": "Jun. 25, 2021",
"marked_complete": "",
"task": "Extract information about Kenneth Parcell",
"complete": False,
},
{
"deadline": "June 4, 2021",
"marked_complete": "March 22, 2021",
"deadline": "Jun. 4, 2021",
"marked_complete": "Mar. 22, 2021",
"task": "Locate information about Kenneth Parcell to begin the search (Page Program subnet)",
"complete": True,
},
Expand All @@ -91,11 +98,11 @@
{
"priority": "Secondary",
"status": "Active",
"deadline": "June 25, 2021",
"deadline": "Jun. 25, 2021",
"percent_complete": 0.0,
"tasks": [
{
"deadline": "March 16, 2021",
"deadline": "Mar. 16, 2021",
"marked_complete": "",
"task": "Locate systems and data repositories used by HR and contract teams",
"complete": False,
Expand All @@ -111,11 +118,11 @@
{
"priority": "Primary",
"status": "Active",
"deadline": "April 23, 2021",
"deadline": "Apr. 23, 2021",
"percent_complete": 0.0,
"tasks": [
{
"deadline": "March 24, 2021",
"deadline": "Mar. 24, 2021",
"marked_complete": "",
"task": "Run BloodHound!",
"complete": False,
Expand Down Expand Up @@ -172,8 +179,8 @@
{
"activity": "Phishing",
"domain": "getghostwriter.io",
"start_date": "March 1, 2021",
"end_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"end_date": "Jun. 25, 2021",
"dns": [
{
"static_server": "172.67.132.12",
Expand All @@ -187,8 +194,8 @@
{
"activity": "Command and Control",
"domain": "ghostwriter.wiki",
"start_date": "March 1, 2021",
"end_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"end_date": "Jun. 25, 2021",
"dns": [
{
"static_server": "104.236.176.100",
Expand All @@ -202,8 +209,8 @@
{
"activity": "Command and Control",
"domain": "specterops.io",
"start_date": "March 1, 2021",
"end_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"end_date": "Jun. 25, 2021",
"dns": [
{
"static_server": "",
Expand All @@ -222,8 +229,8 @@
"provider": "Digital Ocean",
"activity": "Command and Control",
"role": "Team Server / C2 Server",
"start_date": "March 1, 2021",
"end_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"end_date": "Jun. 25, 2021",
"dns": [
{"domain": "ghostwriter.wiki", "endpoint": "", "subdomain": "www"}
],
Expand All @@ -235,8 +242,8 @@
"provider": "Microsoft Azure",
"activity": "Command and Control",
"role": "Team Server / C2 Server",
"start_date": "March 1, 2021",
"end_date": "June 25, 2021",
"start_date": "Mar. 1, 2021",
"end_date": "Jun. 25, 2021",
"dns": [
{
"domain": "getghostwriter.io",
Expand Down
55 changes: 55 additions & 0 deletions ghostwriter/modules/reportwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os
import random
import re
from datetime import datetime, timedelta

# Django Imports
from django.conf import settings
Expand Down Expand Up @@ -121,6 +122,58 @@ def compromised(targets):
return filtered_targets


def add_days(date, format_str, days):
"""
Add a number of business days to a date.
**Parameters**
``date``
Date string to add business days to
``format_str``
The format of the provided date
``days``
Number of business days to add to the date
"""
# Loop until all days added
date = datetime.strptime(date, format_str)
if days > 0:
while days > 0:
# Add one day to the date
date += timedelta(days=1)
# Check if the day is a business day
weekday = date.weekday()
if weekday >= 5:
# Return to the top (Sunday is 6)
continue
# Decrement the number of days to add
days -= 1
else:
# Same as above but in reverse for negative days
while days < 0:
date -= timedelta(days=1)
weekday = date.weekday()
if weekday >= 5:
continue
days += 1
return date.strftime(format_str)


def format_datetime(date, current_format, new_format):
"""
Change the format of a given date string.
**Parameters**
``date``
Date string to modify
``format_str``
The format of the provided date
"""
current = datetime.strptime(date, current_format)
return current.strftime(new_format)


def prepare_jinja2_env(debug=False):
"""Prepare a Jinja2 environment with all custom filters."""
if debug:
Expand All @@ -133,6 +186,8 @@ def prepare_jinja2_env(debug=False):
env.filters["filter_type"] = filter_type
env.filters["strip_html"] = strip_html
env.filters["compromised"] = compromised
env.filters["add_days"] = add_days
env.filters["format_datetime"] = format_datetime

return env

Expand Down
2 changes: 1 addition & 1 deletion ghostwriter/oplog/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, project=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.project_instance = project
# Limit the list to just projects not marked as complete
active_projects = Project.objects.filter(complete=False)
active_projects = Project.objects.filter(complete=False).order_by("-start_date")
if active_projects:
self.fields["project"].empty_label = "-- Select an Active Project --"
else:
Expand Down
2 changes: 1 addition & 1 deletion ghostwriter/reporting/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(self, project=None, *args, **kwargs):
self.project_instance = project
# Limit the list to just projects not marked as complete
active_projects = Project.objects.filter(complete=False).order_by(
"start_date", "client", "project_type"
"-start_date", "client", "project_type"
)
if active_projects:
self.fields["project"].empty_label = "-- Select an Active Project --"
Expand Down
3 changes: 1 addition & 2 deletions ghostwriter/shepherd/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

from .models import (
Domain,
DomainHistory,
DomainNote,
DomainStatus,
HealthStatus,
Expand Down Expand Up @@ -678,7 +677,7 @@ def check_domains(domain=None):
)

# Check if the domain is checked-out and send a message to that project channel
latest_checkout = DomainHistory.objects.filter(domain=domain).latest(
latest_checkout = History.objects.filter(domain=domain).latest(
"end_date"
)
if (
Expand Down
3 changes: 3 additions & 0 deletions ghostwriter/shepherd/templates/shepherd/domain_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
cssAsc: 'down',
cssDesc: 'up',
cssNone: 'none',
headers: {
5: {sorter: 'digit'}
}
}
);
$('.tablesorter').trigger('update');
Expand Down

0 comments on commit 5a93835

Please sign in to comment.