22 Commits
Author SHA1 Message Date
Jurriaan Bremer df0c6da1ca allow submission of files pointed to by symbolic links
In the future this will be improved by copying over the file upon
submission, however, for now this will do just fine.
2018-02-07 16:51:42 +01:00
Jurriaan Bremer f56688f06f further streamline extractor support for handling office files
This commit introduces and improves a number of things related to static
analysis of malicious Microsoft Office files. In particular:
* Extend Extractor logic to allow for static-only analysis.
* Enhance Yara integration allowing it to take external variables,
  perform on in-memory buffers, and work correctly with Office archives.
* Improve parsing logic of cmd.exe in our Scripting engine.
* More Extracted Artefacts logic and handling as well as versioning.
* Various tweaks and improvements.

This commit is mostly complete, however, it could certainly use more
error/exception handling. We should also more generically catch
exceptions thrown in Extractor plugins.
2017-11-08 14:38:39 +01:00
Jurriaan Bremer cb41a60643 also implement strings method next to string 2017-09-06 11:30:16 +02:00
Jurriaan Bremer f7277068fb ensure yara matches have a meta.description #1687 (thanks stmerry)
From now on we'll force our reports to contain a meta.description for
each Yara match, regardless of whether said Yara rule has a description
or not. This simplifies the patches that would be required for #1687.
Any and all failing reports should 'simply' be reprocessed now.
2017-07-14 15:25:44 +02:00
Jurriaan Bremer 7662e0c360 recursively walk and load yara rules on startup
Rather than creating the index_*.yar files during "cuckoo -d" and then
loading those when running "cuckoo process", we'll from now on always
enumerate the available Yara rules recursively and load 'em on-the-go.

This simplifies life when updating Yara rules and re-running "cuckoo
process -r". Furthermore this commit adds recursive walking support as
well as following symbolic links.

Currently there's a limitation in the usage of Yara rules, though, as at
the moment it isn't possible to use "include" statements in the rules
(with relative paths, anyway). We may be able to fix that by temporarily
os.chdir()'ing into the yara/category/ directory.

This commit resolves #773 and provides a stepping stone for #776 & #512.
2017-06-24 04:40:25 +02:00
Jurriaan Bremer 5f42c09434 include yara-python 3.6.1 by default now it is available
Note that the os.path.realpath() is required since Mac OS X symlinks
/var to /private/var and the "sample" filepath points to /private/var
whereas the CWD points to /var, causing unit testing issues.

Thanks to Victor Manuel Alvarez for working on properly releasing the
yara-python package (and Yara in general, of course).
2017-06-06 09:51:04 +02:00
Jurriaan Bremer 22aea3236e include payload type or package name, default to zero index 2017-05-27 23:07:45 +02:00
Jurriaan Bremer 695d628ba3 recursive extraction with 3rd party plugin support
Implements the ability to recursively extract core elements from other
extracted elements (and in the future perhaps other items as well?)
For now solely depends on Yara rules to start the recursive extraction
process. Introduces a new Extractor class for which rules may be placed
in $CWD/signatures/extractor/.
2017-05-27 23:06:31 +02:00
Jurriaan Bremer 46b032694a provide static analysis of archived samples
* Make Static handle archives transparently.
* Take the "exe" package for granted just as the others.
* Move get_keys() to File where it's more appropriate.
2017-03-22 14:59:16 +01:00
Jurriaan Bremer a2e2cf8fa7 analysis summary and targetinfo archive support
In order to show proper information about the file that has been
analyzed, these two need each other. From now on the reports will be
able to share information (size, hashes, etc) about the actual file
being analyzed rather than the archive around it.
Introduces the concept of temporary files that are removed after the
object expires / is no longer used.
2017-03-22 10:55:05 +01:00
Jurriaan Bremer 12bede8d91 was apparently missing windows support for get-urls 2017-03-21 15:29:49 +01:00
Jurriaan Bremer e146c439c6 move yara compilation to startup and crash hard on errors
By compiling all of the Yara rules at Cuckoo's startup we avoid the
issue that we've been having up until now: finding out about Yara
problems at runtime. Naturally this simplifies some Yara-related code,
resolves an issue where, in case one of the referenced Yara rules has a
syntax error, no Yara rule matches are performed & get_yara() returns
None (i.e., silently not doing any Yara magic & later on crashing hard
due to the silent thing), and some accompanying unit tests.
2017-03-20 03:48:28 +01:00
Jurriaan Bremer 842a4c4c81 base64 encode yara string matches
Naturally MongoDB doesn't really like "bytes".
2017-03-18 20:09:34 +01:00
Jurriaan Bremer c8abfdac6b mongodb does not accept leading dollar signs so strip those
To be properly unittested with real-life MongoDB sessions soon!
2017-03-18 14:03:50 +01:00
Jurriaan Bremer 8a09e7a550 include yara offsets and prepare for 3.5.0+ inclusion
In a couple of weeks there will be a new Yara release which we can
properly include as a dependency. With that release we'll be able to
bind Cuckoo to our version of choice, i.e., the latest version.
The new offset field will allow us to quickly locate where the strings
were found in the binary / memory / etc.
This probably breaks backwards compatibility with older versions of
Yara, but if no Yara release is around in time, we can just do a soft
error on versions that are not 3.5.0.
Also disables some kernel driver stuff that's not yet ready for
deployment.
2017-03-17 18:48:59 +01:00
Jurriaan Bremer 328e9b694e verify, unit test, and document m2crypto setup 2016-11-07 15:43:19 +01:00
Jurriaan Bremer 5ceda18633 tweak some unit tests for windows compatibility 2016-10-30 16:35:24 +01:00
Jurriaan Bremer 496b5e7f82 first progress on improving windows unit testing 2016-10-29 19:21:17 +02:00
Jurriaan Bremer 8907ebe6f7 upgrade python-magic library to latest version with unittests
Also gets rid of older behavior and backwards compatibility with another
version of the libmagic library. Note that removing such older code from
now on requires proper unittests to ensure that code remains working.
2016-09-11 17:05:10 +02:00
Jurriaan Bremer 71bf965d72 mismatching filetype depending on the installed library version 2016-08-23 03:21:10 +02:00
Jurriaan Bremer 6505d3263f some basic unittests 2016-08-23 02:51:08 +02:00
Jurriaan Bremer afe8077162 rewrite the tests so they use pytest
Also reintroduce the capability to provide a custom connection string to
the Database (which is possible now that making the connection is no
longer part of __init__).
2016-08-23 02:10:14 +02:00