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

Wide character strings comparisons in conditions #1863

Open
BitsOfBinary opened this issue Jan 17, 2023 · 1 comment
Open

Wide character strings comparisons in conditions #1863

BitsOfBinary opened this issue Jan 17, 2023 · 1 comment

Comments

@BitsOfBinary
Copy link
Contributor

It is possible in YARA to do various string comparisons in a rule's condition, e.g. your_variable == "foo". However, some variables you want to compare (such as ones parsed out in modules) may be unicode/wide character strings, meaning you'd have to add null characters in the comparison, e.g. your_variable == "f\x00o\x00o\x00". This can be make rules more obscure/prone to errors when writing.

A possible solution to this could be to add a modifier to strings, similar to that of in C/C++, to indicate that a string is a wide character strings. I.e. L"foo" is equivalent to "f\x00o\x00o\x00". Therefore, the same condition as before would become your_variable == L"foo". This would make rules more concise, and prevent those writing rules having to worry about including null characters.

This would likely require some grammar updates in YARA, as well as tests to make sure operators like contains and matches still work as expected.

An alternative solution could be to have a function in, for example, the string module that will attempt to convert a wide character string to an ASCII string; but having a built in operator L"" feels easier to use.

@wxsBSD
Copy link
Collaborator

wxsBSD commented Jan 17, 2023

This has been brought up in the past, but never settled on a solution: #522.

I, for one, like the idea. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants