Граф коммитов

78 Коммитов

Автор SHA1 Сообщение Дата
Aaron Meihm d0e77beaf8 file: honor matchlimit, uses channels for result processing
The matchlimit option to the file module was not working correctly due
to a couple reasons.

First, it relied on the Totalhits value in the module statistics to
compare the number of hits to the match limit. This value was compiled
in buildResults, so was 0 throughout module execution. Because of this
matchlimit would never be exceeded.

Also, the comparison to Totalhits was only occuring on directory entry.
This means if the match limit was hit while scanning a single directory,
it would continue to scan files exceeding the match limit.

This modifies the way results are processed by Search types, so
individual checks submit matched files via a channel to the parent
Search entry. The Search entry can then maintain a list of matches, and
increment Totalhits as required while the processing is occuring instead
of in buildResults.

Closes #382
2017-08-21 16:58:33 -05:00
Aaron Meihm 543fe004fb file: add test for MatchAll 2017-08-21 13:14:19 -05:00
Aaron Meihm 800a3508a2 file: adds tests which perform search using file as a path component 2017-08-21 13:05:53 -05:00
Aaron Meihm 349d26a0d2 file: some cleanup of tests, unify various test tables
Reworks test tables so all tests execute from a single table, and test
file system creation is separated from the individual tests themselves.
This should permit more complicated test cases. This also removes
various Linux specific path elements so the tests should work on all
platforms.
2017-08-21 12:51:49 -05:00
Aaron Meihm 700832b3d4 file: remove files created while executing tests 2017-08-21 12:51:49 -05:00
Aaron Meihm 254b2fa489 file: export member types of SearchResults
Since we need to export SearchResults, also export it's member types so
they are directly usable outside the package and visible in godoc.
2017-08-21 12:51:49 -05:00
Aaron Meihm f3a8b5f9e5 file: add comment to exported SearchResults type
SearchResults needs to be exported as it is used in modules which
reference the file module as a dependency (e.g., scribe, others).
2017-08-21 12:51:49 -05:00
Aaron Meihm 75de19cd75 file: JsonResults -> JSONResults 2017-08-21 12:51:49 -05:00
Aaron Meihm d366003445 file: remove else blocks that end in a return 2017-08-21 12:51:49 -05:00
Aaron Meihm 6ca741f255 file: remove explicit assignment of the zero value to var definitions 2017-08-21 12:51:49 -05:00
Aaron Meihm 77dccc6de5 file: don't export Parameters, which is only used locally 2017-08-21 12:51:49 -05:00
Aaron Meihm 7c12770f41 file: omit bool type declaration which is inferred 2017-08-21 12:51:49 -05:00
Aaron Meihm 40e84c67ea file: standardize package godoc comment 2017-08-21 12:51:49 -05:00
Aaron Meihm 4d60a0b6be file: don't skip adding path separator if directory entry is a symlink
If a file symlink existed in the root of a search path (e.g., /tmp was
being searched and /tmp/file was a symlink) path separators were not
being added correctly, resulting in no separator between the directory
path and the file name.

This caused subsequent checks (e.g., trying to follow and open the
symlink for content inspection) to fail, resulting in errors being
included in the module error log.
2017-08-18 15:22:44 -05:00
Aaron Meihm de41ae30a0 Merge pull request #335 from ameihm0912/yara
Yara module
2017-04-12 09:58:25 -05:00
Aaron Meihm bff54881db [minor] remove direct doc link from ping module code 2017-04-11 16:00:34 -05:00
Aaron Meihm 378dd9d8ce [doc] documentation for yara module 2017-04-03 15:35:55 -05:00
Aaron Meihm 5fd4941043 [medium] yara module, base implementation
Adds a yara module that supports scanning of files on agent systems
using yara rules. Based on go-yara.
2017-04-03 15:35:55 -05:00
Aaron Meihm dba7d958de [minor] add default fswatch profiles for darwin/windows, currently empty 2017-02-27 17:00:58 -06:00
Aaron Meihm dddd044688 [doc] fix typo in fswatch documentation 2017-02-27 16:59:24 -06:00
Aaron Meihm 0072184fd7 [doc] add documentation for fswatch module 2017-02-27 16:54:44 -06:00
Aaron Meihm b9bf973b19 [minor] ignore paths in walk we encounter an error entering 2017-02-27 15:48:45 -06:00
Aaron Meihm 95ca0f14a0 [minor] fswatch support for module config file for monitoring paths 2017-02-27 15:28:00 -06:00
Aaron Meihm a2d8334a90 [medium] update fswatch to use platform specific notification mechanisms
makes use of fsnotify to utilize os file system notification mechanisms
(e.g., inotify) rather than periodic polling for changes.
2017-02-27 14:58:37 -06:00
Aaron Meihm 6fc175c94c [medium] addition of fswatch module
fswatch is a simple file system monitoring module that takes advantage
of the persistent module framework in MIG to do continuous file
integrity scans of specific paths on the file system. When changes are
detected, alerts are generated and appear in the agent's log file.
2017-02-27 14:57:36 -06:00
Aaron Meihm 84169977b8 Merge branch 'master' into issue-291-win-netstat 2016-12-22 15:06:53 -06:00
Rob Murtha 77dae55003 [medium] netstat windows support
closes #291
2016-12-22 11:31:47 -05:00
Aaron Meihm bbd4b8d2e4 [minor] remove upgrade module and additional references to module 2016-12-21 15:08:49 -06:00
Aaron Meihm bfec483d5c [medium] persistent module config file support
Adds the ability for persistent modules to read a configuration file
that can be used to control their behavior.

In some cases, we may want a persistent module to be configurable. A new
configuration variable PERSISTCONFIGDIR has been added which indicates a
directory the agent will look in for persistent module configs. When the
agent starts a persistent module, it will determine if modulename.cfg
exists in the config directory; if so the agent will load the config and
send it to the newly executed module, which it will read on stdin. The
module can then read this configuration, and configure itself as needed
before it begins it's primary execution functions.

Modules specify the configuration format within the module code itself,
so each module that makes use of this can have it's own configuration
parameters.
2016-12-16 15:42:16 -06:00
Aaron Meihm 7ca2887a98 [medium/bug] resolve bufio issues under high agent/module comms
When a message between a module and the agent is read by either,
ReadInput is used which uses buffered IO to read a single line. A bug
existed here where a new bufio Reader was being allocated each time.

Under normal circumstances there would be no issue, since a single line
is generally sent to the module from the agent and read. However, in a
case where a large number of messages were being exchanged between the
agent and the module (e.g., persistent modules) it was possible the
bufio reader could have buffered more than one line. Since a new buffer
was being allocated each time, this resulted in loss of partial message
data, and usually ended up generating JSON unmarshaling errors since
part of the JSON structure was missing.

This was resolved by introducing a new ModuleReader and ModuleWriter
type that is used to read/write between the agent and modules.
ModuleReader allocates the buffered reader on creation once, so we only
ever have the single buffered reader for the lifetime of the module
execution.
2016-12-16 09:55:21 -06:00
Aaron Meihm 73acf16f96 [minor] document examplepersist and other persistent mod code added 2016-10-18 11:48:39 -05:00
Aaron Meihm 192860ae0e [minor] dynamic socket registration for persistent modules
We will want to use different socket types for persistent module
communication depending on the platform, e.g., unix sockets are not
available on Windows. This adds support for more dynamic registration of
the socket for a given running module. When the persistent module is
initialized, we allocate the listener and then notify the agent where we
area listening, so queries can dial the address as needed.
2016-10-17 15:47:30 -05:00
Aaron Meihm f6117e782e [minor] improve error handling in module stream io 2016-10-14 13:15:00 -05:00
Aaron Meihm f758ee2594 [minor] remove extra sleep 2016-10-09 00:01:11 -05:00
Aaron Meihm 2c10c2928f [minor] add an example persistent module 2016-10-08 23:38:20 -05:00
Aaron Meihm 33ac7d9ff6 [major] add support for persistent modules
Persistent modules are modules that are executed continuously by the
agent. They can perform background tasks, and can be queried using
mig-cmd or mig-console in the same way as regular modules.

The modules are executed by the agent on startup, and a management
channel is used to validate the module is running and collect logs from
the module.

Queries into the persistent module are handled initially through the
same code path as a normal module query; but in the case of a persistent
module an adapter is used to simulate the module IO and collect results
using a domain socket.
2016-10-08 23:29:48 -05:00
Aaron Meihm 853112bafc [minor] epm implementation for scribe module 2016-08-29 14:06:51 -05:00
Aaron Meihm e27686218e [minor] epm implementation for netstat module 2016-08-29 14:06:51 -05:00
Aaron Meihm e93187cfd6 [minor] epm implementation for file module 2016-08-29 14:06:51 -05:00
Aaron Meihm b1f1543e67 [minor] agent epm implementation
EPM (extra privacy mode) is an agent option that if enabled, will
inform modules they should apply additional masking on returned results.

For example, by default if the file module matches a search, the name of
the matching file will be returned. With this enabled, it may inform the
investigator that something on the system matched, but will not provide
meta-data.
2016-08-29 14:06:45 -05:00
Aaron Meihm 070fba3b4a [minor] handle pkg version invert using !, remove additional flag
Handles inverting version filter logic in similar manner to file module
content flag.
2016-05-24 14:03:55 -05:00
Aaron Meihm 38e0202cc6 [minor] optionally invert version filtering logic in pkg module 2016-05-22 14:19:05 -05:00
Aaron Meihm 360f1cbc64 [minor] support filtering by version in pkg module
Closes #182
2016-05-22 14:07:00 -05:00
Julien Vehent 54cc5c2fde [minor] type in file's buildResults 2016-05-09 12:56:43 -04:00
Julien Vehent 293a63e2d8 [minor] various nits on file module 2016-05-08 09:07:19 -04:00
Julien Vehent 2d54479a6a [minor] make 0 mean 'unlimited' in file module's maxdepth and matchlimit options 2016-05-08 09:06:16 -04:00
Julien Vehent 106090bb2c [minor] limit walking errors returned by file module, fixes #227 2016-05-08 09:04:40 -04:00
Yves AGOSTINI 9c55e4bdbe [medium/bug] windows bug in pathwalk, fixes #213 2016-05-02 09:12:29 +02:00
Aaron Meihm 212e131291 [minor/bug] correctly set ipmask in darwin netstat module HasIPConnected
net.ParseIP will return IPv4 addresses as a 16 byte value (result comes
from net.IPv4()). Rather than use the length of the return value, try to
convert it to an IPv4 address to test the address family and set the
mask accordingly.

Closes #187
2016-04-27 21:42:52 -05:00
Aaron Meihm ad8eccecb0 [minor] netstat module on linux, look for ipv4 mapped ipv6 addresses
Connections to for example tcp6 sockets are stored in IPv6 related /proc
net files (e.g., /proc/net/tcp6). Also scan these files when searching
for an IPv4 address.
2016-04-27 21:42:45 -05:00