Skip to content

Instantly share code, notes, and snippets.

@morimolymoly
Forked from usualsuspect/zip_ext.yara
Created December 24, 2022 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morimolymoly/d33e1c24aba2c33f98c159269328ed45 to your computer and use it in GitHub Desktop.
Save morimolymoly/d33e1c24aba2c33f98c159269328ed45 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
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