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 a "not" operator for hex bytes #1676

Merged
merged 5 commits into from
Apr 6, 2022

Conversation

shanehuntley
Copy link
Contributor

When specifying hex strings, we run across cases where we want to specify that a byte in not a specific value.

eg.

$want = " { 81 FE ?? ?? ?? ?? 7F } $dont_want = " { 81 FE ?? ?? ?? 00 7F }

This pull request adds a not operator (~) on bytes so you could specify:

$want_and_dont_want = " { 81 FE ?? ?? ?? ~00 7F }

This seems to be pretty straightforward and useful. At the moment only individual bytes can be negated, but it could be easily expanded to cover negated masked bytes such a ~7?

More complex would be expressing as a general construct so you can have things like ~(00 | 01) but I'm not sure how far we want to go in expanding hex strings to be a complete regex language in it's own right.

@@ -171,6 +171,21 @@ the length of the variable chunks, however, this is not always the case. In some
circumstances you may need to define strings with chunks of variable content and
length. In those situations you can use jumps instead of wild-cards:

.. code-block:: yara
Copy link
Member

Choose a reason for hiding this comment

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

The new example has been inserted at the wrong position in the text. It says:

In those situations you can use jumps instead of wild-cards:

And the sentence is followed by NotExample instead of JumpExample.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed now.

@plusvic plusvic merged commit 2f6dd01 into VirusTotal:master Apr 6, 2022
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.

None yet

2 participants