xorsearch.py: Searching With Regexes – SANS Internet Storm Center

Date:

Share post:

As promised in diary entry “XORsearch: Searching With Regexes”, I will outline another method to search with xorsearch and regexes.

In stead of XORsearch.exe, the original tool that is written in C and compiled, we will use xorsearch.py, a new tool written in Python.

Unlike XORsearch.exe, xorsearch.py supports YARA rules, and thus regex searches.

Let’s say we want to use this trivial regular expression to match IPv4 addresses (it’s matching 4 numbers separated by dots): \d+\.\d+\.\d+\.\d+

We can create a YARA rule for this regex:

And then we can use this rule on a test file (test-xor-1.bin):

This tells us that YARA rule ipv4 (namespace ipv4.yara) triggered on file test-xor-1.bin when it is XOR encoded with key 0x19.

To see the YARA rule strings that were matched, use option –yarastrings:

To see the encoded file, use one of the many dump options, like -a for a HEX/ASCII dump:

Or a binary dump with option -d:

If you find it cumbersome to create a YARA rule just for a simple regex (I find it cumbersome 🙂 ), you can pass the regex via the command line prefixed with #r#, and xorsearch.py will generate the YARA rule for you:

I will give more examples of this in an upcoming diary entry.

 

Didier Stevens

Senior handler

blog.DidierStevens.com

 

Source link

spot_img

Related articles

‘EA Sports Madden NFL 26’ Switch 2 File Size Seemingly Revealed

Although Nintendo's first-party titles for the Switch 2 won't take up much space, it seems the early batch...

ToyMaker Uses LAGTOY to Sell Access to CACTUS Ransomware Gangs for Double Extortion

î ‚Apr 26, 2025î „Ravie LakshmananMalware / Vulnerability Cybersecurity researchers have detailed the activities of an initial access broker (IAB) dubbed...

Redragon M612 Predator RGB Gaming Mouse Review

Key Features8000 DPI11 Programmable Buttons5 Backlit ModesPros & ConsPros:Responsive ControlsCustomizable LightingSolid BuildGood SoftwareAffordable PriceCons:Cable StiffnessSize PreferenceDouble Click PositionOur...

The Impact Of VR On Virtual Events & Digital Experiences

Sometimes, one has to look on the bright side of things. From the ashes of the destruction caused...