Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request : be able to select specific file extensions in yara #1312

Open
emmanubo opened this issue Jun 30, 2020 · 7 comments
Open

feature request : be able to select specific file extensions in yara #1312

emmanubo opened this issue Jun 30, 2020 · 7 comments

Comments

@emmanubo
Copy link

emmanubo commented Jun 30, 2020

there are scenarios where only specific file extensions needs to be scanned.
So, I've added an option (--exts) in order to specify which file extensions should be scanned in my custom yara build :

yara64.exe -C webshells.bin . --exts=.asp/.aspx/.dll/.jsp/.php

I would like to know if this is something that is planned in the feature list. If needed, I can share the code I'm currently using (I'm new to github).

Thanks!

Emmanuel

@tlansec
Copy link
Contributor

tlansec commented Jul 1, 2020

Hello,

I would suggest that this is done outside of YARA. To do this you could:

  1. precompile rules
  2. find files of correct extension using external method such as "dir /S /B *.asp"
  3. run yara against each file in file list using precompiled ruleset (to avoid recompiling each time) using " --scan-list"

Cheers,
Tom

@emmanubo
Copy link
Author

emmanubo commented Jul 1, 2020

Hello Tom,

my team is performing incident response. We need to limit process creation (which would occur if we run yara after performing some file filtering). In adition, we are commonly scanning directories with millions of files. I've already implemened the needed feature. I think it may be usefull for other people too.
I've created the following pull request related to this : #1314

Thanks,

Emmanuel

@tlansec
Copy link
Contributor

tlansec commented Jul 1, 2020

Hi,

OK, but if you use "--scan-list" as I suggest, it does not create millions of processes, it creates one process.

Cheers,
Tom

@emmanubo
Copy link
Author

emmanubo commented Jul 1, 2020

Hello Tom,

this only address part of the issue : filelist must be created first (we want to avoid writing any file to disk) and we ended up to scan directories twice.

Cheers,

Emmanuel

@DanielRuf
Copy link

DanielRuf commented Jun 28, 2022

I face the same problem. Currently I have to create, filter and prove a filelist to skip only a few but rather small or irrelevant files (like txt, zip and so on).

How can we bring this feature request forward?
Or do we users have to manually patch our own yara binaries?

@Jwalker107
Copy link

Perhaps a solution to allow --scan-list to read from stdin rather than a file?

I'm concerned that building a scan-list file could require generating a sizeable file when listing directories or files from large disks, but allowing --scan-list to read from stdin rather than a file opens many scenarios to read piped input from 'find' or 'dir' or higher-level scripts.

@Jwalker107
Copy link

Jwalker107 commented Nov 2, 2022

For what it's worth, I have a local workaround using 'mkfifo' to create a circular buffer file that is then the input for --scan-list.
Here I create the /tmp/listing_file.txt, which will be populated by the output of multiple 'find' commands, and read as an input by yara. This allows using 'find' to perform all the filtering, stick within a device, etc.

LISTING_FILE=/tmp/listing_file.txt
rm -f $LISTING_FILE
mkfifo $LISTING_FILE

(
for j in `df -l --output=target -x tmpfs -x devtmpfs | sed 1d`
 do  find $j -xdev -not \( -path "/proc" -prune \) -not \( -path "/dev" -prune \)
done
)   > $LISTING_FILE &


/bin/yara -C /var/opt/yara-signatures/OpenSSL_3_lower_307.yarc --scan-list $LISTING_FILE --print-strings --no-follow-symlinks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants