Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model extensions. Closes #405 . #407

Merged
merged 23 commits into from
Dec 17, 2024

Conversation

regulartim
Copy link
Collaborator

@regulartim regulartim commented Dec 13, 2024

Description

Several changes to the IOC model are introduced:

  • days_seen now has the list function as a default value (for convenience)
  • rename times_seen and add interaction count
  • add IP reputation, the attacker's ASN, a list of ports the IP has requested and a counter of attempted logins (currently only based on data from Heralding)

To populate these new fields, the attack data extraction process had to be rewritten. I did not touch the extraction process of log4pot yet, as I don't have one running. However, this should definitely be done at some point. I'll open an issue after this is merged.

I also added a model for CowrieSessions to eventually create a specialised feed for Cowrie.

Related issues

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).

Checklist

  • I have read and understood the rules about how to Contribute to this project.
  • The pull request is for the branch develop.
  • I have added documentation of the new features.
  • Linters (Black, Flake, Isort) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved. All the tests (new and old ones) gave 0 errors.
  • If changes were made to an existing model/serializer/view, the docs were updated and regenerated (check CONTRIBUTE.md).
  • If the GUI has been modified:
    • I have a provided a screenshot of the result in the PR.
    • I have created new frontend tests for the new component or updated existing ones.

Important Rules

  • If you miss to compile the Checklist properly, your PR won't be reviewed by the maintainers.
  • If your changes decrease the overall tests coverage (you will know after the Codecov CI job is done), you should add the required tests to fix the problem
  • Everytime you make changes to the PR and you think the work is done, you should explicitly ask for a review. After being reviewed and received a "change request", you should explicitly ask for a review again once you have made the requested changes.

@regulartim
Copy link
Collaborator Author

GUI change: "Times Seen" renamed
image

@regulartim regulartim marked this pull request as ready for review December 16, 2024 13:33
@regulartim regulartim requested a review from mlodic December 16, 2024 13:33
Copy link
Member

@mlodic mlodic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work!

Comment on lines +57 to +67
class CowrieSession(models.Model):
session_id = models.BigIntegerField(primary_key=True)
start_time = models.DateTimeField(blank=True, null=True)
duration = models.FloatField(blank=True, null=True)
login_attempt = models.BooleanField(blank=False, null=False, default=False)
credentials = pg_fields.ArrayField(models.CharField(max_length=256, blank=True), blank=False, null=False, default=list)
command_execution = models.BooleanField(blank=False, null=False, default=False)
interaction_count = models.IntegerField(blank=False, null=False, default=0)
source = models.ForeignKey(IOC, on_delete=models.CASCADE, blank=False, null=False)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be useful to create a visualization with search options in the Django Admin interface. It should be pretty straightforward and would allow to analyze data without having to create a complex interface in the frontend

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case also some indexes for the search fields could be useful addition

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll have to read into that and would like to implement it in a different branch, if that's fine for you?
You mean DB indexes, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep to both

ip_reputation = models.CharField(max_length=32, blank=True)
asn = models.IntegerField(blank=True, null=True)
destination_ports = pg_fields.ArrayField(models.IntegerField(), blank=False, null=False, default=list)
login_attempts = models.IntegerField(blank=False, null=False, default=0)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also just noticed that there is not index here too. This could be helpful for the Django visualization too.

Plus, the already existing Enrichment API would be affected incredibily positively :) If you don't have time, I'll try to add this later myself

@regulartim regulartim merged commit 08e251a into intelowlproject:develop Dec 17, 2024
6 checks passed
@regulartim regulartim deleted the advanced_feeds branch December 17, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants