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

Add PCAP recognition #25

Merged
merged 3 commits into from
Aug 13, 2021
Merged

Conversation

rakovskij-stanislav
Copy link
Contributor

Match first four bytes to detect pcap files

@rakovskij-stanislav
Copy link
Contributor Author

Also probably you should allow karton-yaramatcher to proceed unrecognized files with further changing status as "recognized" if there is any rule that has meta field "extension" and match this file. It will help to recognize some filetypes without changing code of karton-classifier. Or just add yara to karton-classifier and allow user to write rules that will be used as last resolve to detect file type :)

@nazywam
Copy link
Member

nazywam commented Aug 12, 2021

Hey, thanks for the PR!
What do you think about recognizing the PCAP files by looking at the output produced by file? We primarily use this method for all other file formats so it should fit in nicely.
Something like

if magic.startswith("pcap capture file"):
    sample_class.update(
        {
            "kind": "pcap",
        }
    )
    return sample_class

should work just fine

@chivay
Copy link
Contributor

chivay commented Aug 12, 2021

Maybe we should also add support for handling pcapng files?

@rakovskij-stanislav
Copy link
Contributor Author

Hi!
@nazywam, it looks fine

@chivay,
file command on pcapng prints: pcap-ng capture file - version 1.0

So yes, I'll renew this merge request right now, stay tuned)

Use `file` to determine extension. Add pcapng support.
@chivay
Copy link
Contributor

chivay commented Aug 12, 2021

It seems that you're using an old version of libmagic. In my case the output for pcapng has the following output: pcapng capture file - is seems that the change was made around 2019.
Please us this value in your patch. After this change LGTM.

We know that it's suboptimal to rely on values that aren't stable between environments. To alleviate this problem we'd like to stop depending on system-installed version of libmagic database and ship another one with the classifier. You can track this issue here: #26.

@rakovskij-stanislav
Copy link
Contributor Author

We know that it's suboptimal to rely on values that aren't stable between environments. To alleviate this problem we'd like to stop depending on system-installed version of libmagic database and ship another one with the classifier. You can track this issue here: #26.

Fmm, for current case with pcapng there is a solution, i'll make a new commit...

@rakovskij-stanislav
Copy link
Contributor Author

Also probably you should allow karton-yaramatcher to proceed unrecognized files with further changing status as "recognized" if there is any rule that has meta field "extension" and match this file. It will help to recognize some filetypes without changing code of karton-classifier. Or just add yara to karton-classifier and allow user to write rules that will be used as last resolve to detect file type :)

I would like to see this change, it's very useful thing BUT it changes the file processing pipeline, this way it need to be discussed with karton developers.

@rakovskij-stanislav
Copy link
Contributor Author

Thank you. Please look at other issues in karton-core.

@rakovskij-stanislav
Copy link
Contributor Author

Unmerged commits...

@rakovskij-stanislav
Copy link
Contributor Author

Only those with write access to this repository can merge pull requests.

Understood :)

@chivay chivay merged commit 501801f into CERT-Polska:master Aug 13, 2021
@chivay
Copy link
Contributor

chivay commented Aug 13, 2021

Thanks!

@nazywam nazywam mentioned this pull request Aug 13, 2021
@rakovskij-stanislav rakovskij-stanislav deleted the patch-1 branch August 13, 2021 12:07
@psrok1 psrok1 mentioned this pull request Sep 27, 2021
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.

3 participants