Skip to content

Commit

Permalink
Remove length limit on oplog fields
Browse files Browse the repository at this point in the history
In particular, Mythic agents can generate very long IP address entries
on agents that have multiple IPv6 NICs that would overflow the 255
character limit.
  • Loading branch information
ColonelThirtyTwo committed Dec 8, 2023
1 parent 6bd74d2 commit 4b58a94
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 11 deletions.
44 changes: 44 additions & 0 deletions ghostwriter/oplog/migrations/0012_auto_20231208_2134.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 3.2.19 on 2023-12-08 21:34

from django.db import migrations
import ghostwriter.oplog.models


class Migration(migrations.Migration):

dependencies = [
('oplog', '0011_auto_20230323_2248'),
]

operations = [
migrations.AlterField(
model_name='oplog',
name='name',
field=ghostwriter.oplog.models.NoLengthLimitCharField(),
),
migrations.AlterField(
model_name='oplogentry',
name='dest_ip',
field=ghostwriter.oplog.models.NoLengthLimitCharField(blank=True, help_text='Provide the destination hostname / ip on which the command was ran.', null=True, verbose_name='Destination IP / Hostname'),
),
migrations.AlterField(
model_name='oplogentry',
name='operator_name',
field=ghostwriter.oplog.models.NoLengthLimitCharField(blank=True, help_text='The operator that performed the action.', null=True, verbose_name='Operator'),
),
migrations.AlterField(
model_name='oplogentry',
name='source_ip',
field=ghostwriter.oplog.models.NoLengthLimitCharField(blank=True, help_text='Provide the source hostname / IP from which the command originated.', null=True, verbose_name='Source IP / Hostname'),
),
migrations.AlterField(
model_name='oplogentry',
name='tool',
field=ghostwriter.oplog.models.NoLengthLimitCharField(blank=True, help_text='Name the tool you used to execute the action.', null=True, verbose_name='Tool Name'),
),
migrations.AlterField(
model_name='oplogentry',
name='user_context',
field=ghostwriter.oplog.models.NoLengthLimitCharField(blank=True, help_text='The user context under which the command executed.', null=True, verbose_name='User Context'),
),
]
24 changes: 13 additions & 11 deletions ghostwriter/oplog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Django Imports
from django.core.exceptions import ValidationError
from django.db import models
from django import forms

# 3rd Party Libraries
from taggit.managers import TaggableManager
Expand All @@ -15,10 +16,16 @@
logger = logging.getLogger(__name__)


class NoLengthLimitCharField(models.TextField):
def formfield(self, **kwargs):
kwargs["widget"] = forms.TextInput
return super().formfield(**kwargs)


class Oplog(models.Model):
"""Stores an individual operation log."""

name = models.CharField(max_length=255)
name = NoLengthLimitCharField()
project = models.ForeignKey(
"rolodex.Project",
on_delete=models.CASCADE,
Expand Down Expand Up @@ -56,33 +63,29 @@ class OplogEntry(models.Model):
blank=True,
help_text="Provide the date and time the action concluded.",
)
source_ip = models.CharField(
source_ip = NoLengthLimitCharField(
"Source IP / Hostname",
null=True,
blank=True,
help_text="Provide the source hostname / IP from which the command originated.",
max_length=255,
)
dest_ip = models.CharField(
dest_ip = NoLengthLimitCharField(
"Destination IP / Hostname",
null=True,
blank=True,
help_text="Provide the destination hostname / ip on which the command was ran.",
max_length=255,
)
tool = models.CharField(
tool = NoLengthLimitCharField(
"Tool Name",
null=True,
blank=True,
help_text="Name the tool you used to execute the action.",
max_length=255,
)
user_context = models.CharField(
user_context = NoLengthLimitCharField(
"User Context",
null=True,
blank=True,
help_text="The user context under which the command executed.",
max_length=255,
)
command = models.TextField(
"Command",
Expand All @@ -108,12 +111,11 @@ class OplogEntry(models.Model):
blank=True,
help_text="Any additional comments or useful information.",
)
operator_name = models.CharField(
operator_name = NoLengthLimitCharField(
"Operator",
null=True,
blank=True,
help_text="The operator that performed the action.",
max_length=255,
)
tags = TaggableManager(blank=True)
# Foreign Keys
Expand Down

0 comments on commit 4b58a94

Please sign in to comment.