THE YARALYZER v0.9.3 releases: Visually inspect YARA and regex matches found in both binary and text data
THE YARALYZER
Visually inspect all of the regex matches (and their sexier, more cloak-and-dagger cousins, the YARA matches) found in binary data and/or text. See what happens when you force various character encodings upon those matched bytes.
What It Do
- See the actual bytes your YARA rules are matching. No more digging around copying/pasting the start positions reported by YARA into your favorite hex editor. Displays both the bytes matched by YARA as well as a configurable number of bytes before and after each match in hexadecimal and “raw” python string representation.
- Do the same for byte patterns and regular expressions without writing a YARA file. If you’re too lazy to write a YARA file but are trying to determine, say, whether there’s a regular expression hidden somewhere in the file you could scan for the pattern
'/.+/'
and immediately get a window into all the bytes in the file that lives between front slashes. Same story for quotes, BOMs, etc. Any regex YARA can handle is supported so the sky is the limit. - Detect the possible encodings of each set of matched bytes. The
chardet
library is a sophisticated library for guessing character encodings and it is leveraged here. - Display the result of forcing various character encodings upon the matched areas. Several default character encodings will be forcibly attempted in the region around the match.
chardet
will also be leveraged to see if the bytes fit the pattern of any known encoding. If chardet is confident enough (configurable), an attempt at decoding the bytes using that encoding will be displayed. - Export the matched regions/decodings to SVG, HTML, and colored text files. Show off your ASCII art.
Why It Do
The Yaralyzer’s functionality was extracted from The Pdfalyzer when it became apparent that visualizing and decoding pattern matches in binaries had more utility than just in a PDF analysis tool.
YARA, for those who are unaware, is branded as a malware analysis/alerting tool but it’s actually both a lot more and a lot less than that. One way to think about it is that YARA is a regular expression matching engine on steroids. It can locate regex matches in binaries like any regex engine but it can also do far wilder things like combine regexes in logical groups, compare regexes against all 256 XORed versions of a binary, check for base64 and other encodings of the pattern, and more. Maybe most importantly of all YARA provides a standard text-based format for people to share their ‘roided regexes with the world. All these features are particularly useful when analyzing or reverse engineering malware, whose authors tend to invest a great deal of time into making stuff hard to find.
But… that’s also all YARA does. Everything else is up to the user. YARA’s just a match engine and if you don’t know what to match (or even what character encoding you might be able to match in) it only gets you so far. I found myself a bit frustrated trying to use YARA to look at all the matches of a few critical patterns:
- Bytes between escaped quotes (\”.+\” and \’.+\’)
- Bytes between front slashes (/.+/). Front slashes demarcate a regular expression in many implementations and I was trying to see if any of the bytes matching this pattern were actually regexes.
YARA just tells you the byte position and the matched string but it can’t tell you whether those bytes are UTF-8, UTF-16, Latin-1, etc., etc. (or none of the above). I also found myself wanting to understand what was going in the region of the matched bytes and not just in the matched bytes. In other words, I wanted to scope the bytes immediately before and after whatever got matched.
Enter The Yaralyzer, which lets you quickly scan the regions around matches while also showing you what those regions would look like if they were forced into various character encodings.
It’s important to note that The Yaralyzer isn’t a full-on malware-reversing tool. It can’t do all the things a tool like CyberChef does and it doesn’t try to. It’s more intended to give you a quick visual overview of suspect regions in the binary so you can hone in on the areas you might want to inspect with a more serious tool like CyberChef.
Changelog v0.9.3
- Lock
yara-python
at 4.2.3 bc 4.3.x causes problems
Install & Use
Copyright (C) 2022 michelcrypt4d4mus