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

Adding Google Magika Tastes #436

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Adding Google Magika Tastes #436

wants to merge 2 commits into from

Conversation

phutelmyer
Copy link
Contributor

Describe the change
This change is still in draft, but the idea was to add another form of file tasting: Google Magika

Describe testing procedures
Built and tested against files - no known issues with file tasting outside perhaps misattribution (no errors)

The only error comes with import "magic" inside taste.yara and any yara that uses magic. A conflict?

Sample output

{
  "magika": [
    "iso"
  ],
  "mime": [
    "application/octet-stream"
  ],
  "yara": [
    "onenote_file"
  ]
}

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of and tested my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@ryanohoro ryanohoro self-requested a review February 19, 2024 16:25
Copy link
Collaborator

@ryanohoro ryanohoro left a comment

Choose a reason for hiding this comment

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

The following types output by Magika on the Strelka test fixtures but are missing from backend.yml include the following. We should look at each and consider including them by default in their scanners (even disabled ones like ScanElf)

  • application/javascript
  • application/octet-stream
  • application/vnd.debian.binary-package
  • application/vnd.tcpdump.pcap
  • application/x-apple-diskimage
  • application/x-executable-elf
  • application/x-mach-o
  • application/x-ms-shortcut
  • application/x-pem-file
  • application/x-plist
  • application/x-powershell (likely a false-positive type)
  • application/x-yaml
  • image/bmp
  • text/csv
  • text/vbscript
  • video/mp4 (likely a false-positive type)

@@ -206,6 +211,10 @@ def __init__(
if not self.coordinator:
logging.info("backend started without coordinator")

def taste_magika(self, data: bytes) -> list:
"""Tastes file data with magika."""
return [self.magika.identify_bytes(data).output.ct_label]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of using new types introduced by Magika, I'd suggest using MIME type output so that existing definitions can be used, but (hopefully) better covered by Magika analysis.


mimes.extend(self.taste_mime(data))
yaras.extend(self.taste_yara(data))
magika.extend(self.taste_magika(data))
Copy link
Collaborator

Choose a reason for hiding this comment

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

At this point, I'd make typing with libmime, yara, and Magika clearly and independently configurable so that users have more control over how files get typed.

@@ -206,6 +211,10 @@ def __init__(
if not self.coordinator:
logging.info("backend started without coordinator")

def taste_magika(self, data: bytes) -> list:
"""Tastes file data with magika."""
return [self.magika.identify_bytes(data).output.ct_label]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Magika offers extra features that we should probably expose. For example, the PredictionMode should be user configurable (defaults to High). We could output the confidence score as well so analysts can get context for odd files.

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