yaralyzer 1.0.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.1
2
+ Name: yaralyzer
3
+ Version: 1.0.11
4
+ Summary: Visualize and force decode YARA and regex matches found in a file or byte stream with colors. Lots of colors.
5
+ Home-page: https://github.com/michelcrypt4d4mus/yaralyzer
6
+ License: GPL-3.0-or-later
7
+ Keywords: ascii art,binary,character encoding,color,cybersecurity,data visualization,decode,DFIR,encoding,infosec,maldoc,malicious,malware,malware analysis,regex,regular expressions,reverse engineering,reversing,security,threat assessment,threat hunting,threat intelligence,threat research,threatintel,visualization,yara
8
+ Author: Michel de Cryptadamus
9
+ Author-email: michel@cryptadamus.com
10
+ Requires-Python: >=3.10,<4.0
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Information Technology
14
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Artistic Software
22
+ Classifier: Topic :: Scientific/Engineering :: Visualization
23
+ Classifier: Topic :: Security
24
+ Requires-Dist: chardet (>=5.0.0,<6.0.0)
25
+ Requires-Dist: python-dotenv (>=1.1.1,<2.0.0)
26
+ Requires-Dist: rich (>=14.1.0,<15.0.0)
27
+ Requires-Dist: rich-argparse-plus (>=0.3.1,<0.4.0)
28
+ Requires-Dist: yara-python (>=4.5.4,<5.0.0)
29
+ Project-URL: Changelog, https://github.com/michelcrypt4d4mus/yaralyzer/blob/master/CHANGELOG.md
30
+ Project-URL: Documentation, https://michelcrypt4d4mus.github.io/yaralyzer/
31
+ Project-URL: Repository, https://github.com/michelcrypt4d4mus/yaralyzer
32
+ Description-Content-Type: text/markdown
33
+
34
+ [![GithubRelease](https://img.shields.io/github/v/release/michelcrypt4d4mus/yaralyzer?sort=semver)](https://pypi.org/project/yaralyzer/)
35
+ ![Release](https://img.shields.io/pypi/v/yaralyzer)
36
+ ![Downloads](https://img.shields.io/pypi/dm/yaralyzer)
37
+ [![Tests](https://github.com/michelcrypt4d4mus/yaralyzer/actions/workflows/python-package.yml/badge.svg)](https://github.com/michelcrypt4d4mus/yaralyzer/actions/workflows/python-package.yml)
38
+ ![Python Version](https://img.shields.io/pypi/pyversions/yaralyzer)
39
+
40
+ # THE YARALYZER
41
+
42
+ ![YARA match](https://github.com/michelcrypt4d4mus/yaralyzer/raw/master/doc/rendered_images/top_of_readme.png)
43
+
44
+ Visually inspect all of the regex matches (and their sexier, more cloak and dagger cousins, the [YARA](https://github.com/VirusTotal/yara-python) matches) found in binary data and/or text. See what happens when you force various character encodings upon those matched bytes. [With colors](https://github.com/michelcrypt4d4mus/yaralyzer#example-output).
45
+
46
+ #### Quick Start
47
+ ```sh
48
+ pipx install yaralyzer
49
+
50
+ # Scan against YARA definitions in a file:
51
+ yaralyze --yara-rules /secret/vault/sigmunds_malware_rules.yara lacan_buys_the_dip.pdf
52
+
53
+ # Scan against an arbitrary regular expression:
54
+ yaralyze --regex-pattern 'good and evil.*of\s+\w+byte' the_crypto_archipelago.exe
55
+
56
+ # Scan against an arbitrary YARA hex pattern
57
+ yaralyze --hex-pattern 'd0 93 d0 a3 d0 [-] 9b d0 90 d0 93' one_day_in_the_life_of_ivan_cryptosovich.bin
58
+ ```
59
+
60
+ #### What It Do
61
+ 1. **See the actual bytes your YARA rules are matching.** No more digging around copy/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.
62
+ 1. **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 live between front slashes. Same story for quotes, BOMs, etc. Any regex YARA can handle is supported so the sky is the limit.
63
+ 1. **Detect the possible encodings of each set of matched bytes.** [`chardet`](https://github.com/chardet/chardet) is a sophisticated library for guessing character encodings and it is leveraged here.
64
+ 1. **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`](https://github.com/chardet/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.
65
+ 1. **Export the matched regions/decodings to SVG, HTML, and colored text files.** Show off your ASCII art.
66
+
67
+ #### Why It Do
68
+ The Yaralyzer's functionality was extracted from [The Pdfalyzer](https://github.com/michelcrypt4d4mus/pdfalyzer) when it became apparent that visualizing and decoding pattern matches in binaries had more utility than just in a PDF analysis tool.
69
+
70
+ [YARA](https://github.com/VirusTotal/yara-python), for those who are unaware[^1], 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
71
+ 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.
72
+
73
+ 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:
74
+
75
+ 1. Bytes between escaped quotes (`\".+\"` and `\'.+\'`)
76
+ 1. 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.
77
+
78
+ 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.
79
+
80
+ 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.
81
+
82
+ **The Yaralyzer** isn't a malware reversing tool. It can't do all the things a tool like [CyberChef](https://gchq.github.io/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](https://gchq.github.io/CyberChef/).
83
+
84
+ # Installation
85
+ Install it with [`pipx`](https://pypa.github.io/pipx/) or `pip3`. `pipx` is a marginally better solution as it guarantees any packages installed with it will be isolated from the rest of your local python environment. Of course if you don't really have a local python environment this is a moot point and you can feel free to install with `pip`/`pip3`.
86
+ ```
87
+ pipx install yaralyzer
88
+ ```
89
+
90
+
91
+ # Usage
92
+ Run `yaralyze -h` to see the command line options (screenshot below).
93
+
94
+ ![](https://github.com/michelcrypt4d4mus/yaralyzer/raw/master/doc/rendered_images/yaralyze_help.png)
95
+
96
+ For info on exporting SVG images, HTML, etc., see [Example Output](#example-output).
97
+
98
+ ### Configuration
99
+ If you place a file called `.yaralyzer` in your home directory or the current working directory then environment variables specified in that `.yaralyzer` file will be added to the environment each time yaralyzer is invoked. This provides a mechanism for permanently configuring various command line options so you can avoid typing them over and over. See the example file [`.yaralyzer.example`](.yaralyzer.example) to see which options can be configured this way.
100
+
101
+ Only one `.yaralyzer` file will be loaded and the working directory's `.yaralyzer` takes precedence over the home directory's `.yaralyzer`.
102
+
103
+ ### As A Library
104
+ [`Yaralyzer`](yaralyzer/yaralyzer.py) is the main class. Auto generated documentation for `Yaralyzer`'s various classes and methods can be found [here](https://michelcrypt4d4mus.github.io/yaralyzer/). It has a variety of [alternate constructors](https://michelcrypt4d4mus.github.io/yaralyzer/api/yaralyzer/) supporting:
105
+
106
+ 1. Precompiled YARA rules
107
+ 1. Creating a YARA rule from a string
108
+ 1. Loading YARA rules from files
109
+ 1. Loading YARA rules from all `.yara` file in a directory
110
+ 1. Scanning `bytes`
111
+ 1. Scanning a file
112
+
113
+ Should you want to iterate over the [`BytesMatch`](https://michelcrypt4d4mus.github.io/yaralyzer/api/bytes_match/) (like a `re.Match` object for a YARA match) and [`BytesDecoder`](https://michelcrypt4d4mus.github.io/yaralyzer/api/bytes_decoder/) (tracks decoding attempt stats) objects used by The Yaralyzer, you can do so like this:
114
+
115
+ ```python
116
+ from yaralyzer.yaralyzer import Yaralyzer
117
+
118
+ yaralyzer = Yaralyzer.for_rules_files(['/secret/rule.yara'], 'lacan_buys_the_dip.pdf')
119
+
120
+ for bytes_match, bytes_decoder in yaralyzer.match_iterator():
121
+ do_stuff()
122
+ ```
123
+
124
+ ### Troubleshooting
125
+ If you get a `yara.Error` with a numerical error code you can check what that code might mean [here](https://github.com/VirusTotal/yara/blob/master/libyara/include/yara/error.h).
126
+
127
+
128
+ # Example Output
129
+ The Yaralyzer can export visualizations to HTML, ANSI colored text, and SVG vector images using the file export functionality that comes with [Rich](https://github.com/Textualize/rich) as well as a (somewhat limited) plain text JSON format. SVGs can be turned into `png` format images with a tool like [Inkscape](https://inkscape.org/) or `cairosvg`. In our experience they both work though we've seen some glitchiness with `cairosvg`.
130
+
131
+ **PyPi Users:** If you are reading this document [on PyPi](https://pypi.org/project/yaralyzer/) be aware that it renders a lot better [over on GitHub](https://github.com/michelcrypt4d4mus/yaralyzer). Pretty pictures, footnotes that work, etc.
132
+
133
+ #### Raw YARA match result:
134
+
135
+ ![](https://github.com/michelcrypt4d4mus/yaralyzer/raw/master/doc/rendered_images/yara_match_result.jpg)
136
+
137
+ #### Display hex, raw python string, and various attempted decodings of both the match and the bytes before and after the match (configurable):
138
+
139
+ ![](https://github.com/michelcrypt4d4mus/yaralyzer/raw/master/doc/rendered_images/font_34_frontslash_scan.png)
140
+
141
+ #### Bonus: see what `chardet.detect()` thinks about the likelihood your bytes are in a given encoding/language:
142
+
143
+ ![](https://github.com/michelcrypt4d4mus/yaralyzer/raw/master/doc/rendered_images/decoding_and_chardet_table_2.png)
144
+
145
+
146
+ # Contributing
147
+ Contributions are more than welcome; see [CONTRIBUTING.md](CONTRIBUTING.md) for details on environment setup, running the test suite, etc. There's also a TODO list over there of work that needs to be done.
148
+
149
+
150
+ [^1]: As I was until recently.
151
+
@@ -0,0 +1,34 @@
1
+ .yaralyzer.example,sha256=z3_mk41xxm0Pr_8MGM7AKQG0xEFRtGcyJLboMuelRp4,3504
2
+ CHANGELOG.md,sha256=Tpj8nD-T6hjoJExxBrE0daWWidl4ovBvfFCsc_jv654,3709
3
+ LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
4
+ yaralyzer/__init__.py,sha256=8whEyq7VRhxLlDizYhNEccA_5vXRSVA3xwchb_59ew0,3044
5
+ yaralyzer/bytes_match.py,sha256=-XvBDRLaCPhQDQIhFdX5VmjmP61CjRddgK_4S6Pf4dg,10488
6
+ yaralyzer/config.py,sha256=uVT8Jjw6kViH_PvBQ0etaH3JXPWOIXgiaoAv3ompnJA,4558
7
+ yaralyzer/decoding/bytes_decoder.py,sha256=OAE8dvrdxSaFjPN9IhyDmfw09VODhrDHkwK8nEj4pKQ,10354
8
+ yaralyzer/decoding/decoding_attempt.py,sha256=gUroTUSgWrgD-EZH8t5vsdDk0DSPqHMt0ow947sSFok,10290
9
+ yaralyzer/encoding_detection/character_encodings.py,sha256=_b3Vk5abAcKVDZ7QQyrAMQODAgMjG54AjqxdSGSdaj0,5637
10
+ yaralyzer/encoding_detection/encoding_assessment.py,sha256=q7wa2rls5nXEioX9UqzaNk4TxdW5WKzXjQik9e9AHs4,3262
11
+ yaralyzer/encoding_detection/encoding_detector.py,sha256=9zV1ZA6D3z9t6-Bz2IhcmqufJ_7zGJ0Rzh2gn0fmaO8,6487
12
+ yaralyzer/helpers/bytes_helper.py,sha256=BrSuBDAGLZaSirEt80lR6dMFzHbaz7l7jbEzYCpLRBg,10340
13
+ yaralyzer/helpers/dict_helper.py,sha256=rhyu-xlpl4yevXdLZUIgVwap0b57O9I3DNAEv8MfTlI,186
14
+ yaralyzer/helpers/file_helper.py,sha256=tjiwCr8EMFHHmX4R13J4Sba5xv0IWXhEGyWUvGvCSa8,1588
15
+ yaralyzer/helpers/list_helper.py,sha256=zX6VzJDbnyxuwQpth5Mc7k7yeJytqWPzpo1v5nXCMtE,394
16
+ yaralyzer/helpers/rich_text_helper.py,sha256=J6Ped5POlxrojRWUnmmt4C7rRcDEo9EErBIrhnpfs1E,5450
17
+ yaralyzer/helpers/string_helper.py,sha256=8XsvYlKn-fGhKihfJBOG6mqi5nV_8LM-IWgHzvkRgCc,933
18
+ yaralyzer/output/decoding_attempts_table.py,sha256=cSD6me2TEecSkFMuzG8o4XMLDIocU7snBoMl9yB4cr0,2784
19
+ yaralyzer/output/decoding_table_row.py,sha256=MPpv9lLhCgw7bDo_kSMF-NM2luKC99lSiVdslmJ-s5k,2408
20
+ yaralyzer/output/file_export.py,sha256=iTlCYErquuy6tqBZ1_BQHxBk-6jZ2ihTnGe83HEI_5o,3300
21
+ yaralyzer/output/file_hashes_table.py,sha256=pKbIc1bHJIIorqk9R2gz3IhTxKJpYU1TioGgceyoxiI,2615
22
+ yaralyzer/output/regex_match_metrics.py,sha256=ZQjzePPXpq_g99KNQjHrRQ1N6u_OUxD32uf9xnqcOw8,4341
23
+ yaralyzer/output/rich_console.py,sha256=XwncUKnsmn8JsO4cWBP8kRdkaavf4wrae_yWFFJ1YlE,4053
24
+ yaralyzer/util/argument_parser.py,sha256=ZOsBf5xkAWHFSWPbZt7_OdkYHIY3RIjtK1QIXOj2g6U,13281
25
+ yaralyzer/util/logging.py,sha256=aBvpNukwZTGOgzm_zpwWzTWFrptThk-g2cqi8D4Fkmo,4616
26
+ yaralyzer/yara/error.py,sha256=tgqLNl6v9EPjhBR1sCTs9AicNCxKxe4PvVYHOLgmtuE,2864
27
+ yaralyzer/yara/yara_match.py,sha256=BwWbVgYYCybT9TMhWgkT5vA54C9XJ7fAmGf6JKncjhA,5845
28
+ yaralyzer/yara/yara_rule_builder.py,sha256=PeuhPtO4FvXJoTegQr0NXwGpX7wxPfGzAO1tMozaZd8,4535
29
+ yaralyzer/yaralyzer.py,sha256=OGdQNpr0o70n8CzwIDGcokXFoA0z-6-o5UMyxk7_3Gc,13813
30
+ yaralyzer-1.0.11.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
31
+ yaralyzer-1.0.11.dist-info/METADATA,sha256=Tu6OJdjRHefMcHn8RCGZo89Wfj36EwyLtQwpU471nrk,11673
32
+ yaralyzer-1.0.11.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
33
+ yaralyzer-1.0.11.dist-info/entry_points.txt,sha256=7LnLJrNTfql0vuctjRWwp_ZD-BYvtv9ENVipdjuT7XI,136
34
+ yaralyzer-1.0.11.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.7.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ yaralyze=yaralyzer:yaralyze
3
+ yaralyzer_show_color_theme=yaralyzer.helpers.rich_text_helper:yaralyzer_show_color_theme
4
+