Skip to content

Instantly share code, notes, and snippets.

@usualsuspect
Last active December 24, 2022 04:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save usualsuspect/ce70e5db438178611a75b4f051f8d570 to your computer and use it in GitHub Desktop.
Save usualsuspect/ce70e5db438178611a75b4f051f8d570 to your computer and use it in GitHub Desktop.
YARA rule to match zips containing specific file extensions
rule zip_with_ext
{
meta:
author = "@jaydinbas"
description = "Only match zip files containing desired file extensions"
strings:
$file_sig = "PK\x03\x04" //zip header sig
$entry_sig = "PK\x01\x02" //ZIPDIRENTRY sig
//add in any file extensions/file name suffices you want
$ext1 = ".exe" nocase
$ext2 = ".dll" nocase
$ext3 = ".scr" nocase
condition:
$file_sig at 0
and for any i in (1..#entry_sig) :
(
for any of ($ext*) :
(
$ at (@entry_sig[i] + 46 + uint16(@entry_sig[i]+28) - !)
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment