Commit Graph

7958 Commits (38b698c50f44c07e59dd37728155700b9eaccf96)

Author SHA1 Message Date
Victor Julien 33614fcae0 stream-events: fix mapping 7 years ago
Victor Julien 83e7ddf41f http: fix setting event on the last tx 7 years ago
Victor Julien 62e6e0eb3c pcap-file: fix segv on bad pcap format 7 years ago
Victor Julien d0cded2523 http: set events for too many layers of compression
libhtp would already issue warnings, but these were not mapped
to events yet.
7 years ago
Danny Browning 2dc6b6ee14 source-pcap-file: delete when done (2417)
https://redmine.openinfosecfoundation.org/issues/2417

Add option to have pcap files deleted after they have been processed.
This option combines well with pcap file continuous and streaming
files to a directory being processed.
7 years ago
Victor Julien 84fc43842f detect: fix memory leak in app-layer-event keyword
Bug #2515.
7 years ago
Victor Julien 5c584c2b74 app-layer/tcp: set STREAM_MIDSTREAM flag 7 years ago
Victor Julien 2e6014b15c rust/smb: search for record on midstream start
Calls with both START and MIDSTREAM mean the record might be cut and the
start of it could be missing. For this case, enable the same logic as is
used when catching up after a GAP. Search for the start of the record
instead of assuming it sits exactly at the start of the input data.
7 years ago
Victor Julien 7bc3c3ac6e app-layer: pass STREAM_* flags to parser
Pass the STREAM_* flags to the app-layer parser functions so that
the parser can know more about how it is called.
7 years ago
Victor Julien df88c048ba detect: fix delayed detect
Last multi-detect changes broken delayed-detect by refusing to reload
a 'stub' detect engine. This patch distinguishes between a stub for
multi-tenancy and for delayed detect.
7 years ago
Victor Julien 5bcae21653 detect: reload-rules shouldn't reload a stub 7 years ago
Victor Julien 4eaec2dff0 detect/debug: suppress noisy info messages 7 years ago
Victor Julien 8c918a4bea detect/multi-tenant: fix mix of default detect engine and tenants 7 years ago
Victor Julien 6e9d81289d detect: make detect engine types explicit
There are 3 types of detect engine objects:
    1. normal
       The normal detection engine if no multi-tenancy is in use

    2. tenant
       A per tenant detection engine

    3. stub
       A stub (or minimal as it was called before) detect engine
       that is needed to have something in place when there are
       only tenants.

       A stub is also used in case of 'delayed detect', where we
       need a minimal detect engine to start up which is replaced
       by a full (normal type) detect engine after startup.

This patch adds a new field 'type' to the DetectEngineCtx object
to distinguish between the types. This replaces the boolean 'minimal'.
7 years ago
Jason Ish 7d5f8295bc yaml-loader: fix memory leak on fail include
Redmine issue:
https://redmine.openinfosecfoundation.org/issues/1929

If an include failed to load, either by the file not existing or
a parse error, the file pointer and yaml parser instance were
leaked.
7 years ago
Eric Leblond ec0a7b22a5 output-json-alert: log correct dns and dnp3 tx
Using transaction log entry is not correct to log the transaction
that did cause the alert. The tx_id in the PacketAlert is correct
so let's use that.
7 years ago
Victor Julien d377eba254 detect/multi-tenant: fix removing of tenant id 0 7 years ago
Victor Julien f8ebcac736 unix/multi-tenant: improve (log) messages 7 years ago
Victor Julien 4866295bfb detect/tenants: fix crash when adding mapping
When no tenants and mappings are defined in 'live' mode, adding a
mapping resulted in a crash.
7 years ago
Victor Julien 663549d02c detect: remove lock from global keyword logic
The global keyword registration and per thread init handling used
the lock from the DetectEngineMasterCtx. This lead to a dead lock
situation at multi-tenancy tenant reloads.

The lock was unnecessary however, as the only time the registration
list is updated is at engine initialization. At that time Suricata
is still running in a single thread. After this, the data structure
doesn't change anymore.

Bug #2516.
7 years ago
Jacob Masen-Smith ec77632e84 Adds WinDivert support to Windows builds
Enables IPS functionality on Windows using the open-source
(LGPLv3/GPLv2) WinDivert driver and API.

From https://www.reqrypt.org/windivert-doc.html : "WinDivert is a
user-mode capture/sniffing/modification/blocking/re-injection package
for Windows Vista, Windows Server 2008, Windows 7, and Windows 8.
WinDivert can be used to implement user-mode packet filters, packet
sniffers, firewalls, NAT, VPNs, tunneling applications, etc., without
the need to write kernel-mode code."

- adds `--windivert [filter string]` and `--windivert-forward [filter
    string]` command-line options to enable WinDivert IPS mode.
    `--windivert[-forward] true` will open a filter for all traffic. See
    https://www.reqrypt.org/windivert-doc.html#filter_language for more
    information.

Limitation: currently limited to `autofp` runmode.

Additionally:
- `tmm_modules` now zeroed during `RegisterAllModules`
- fixed Windows Vista+ `inet_ntop` call in `PrintInet`
- fixed `GetRandom` bug (nonexistent keys) on fresh Windows installs
- fixed `RandomGetClock` building on Windows builds
- Added WMI queries for MTU
7 years ago
Jason Ish cf33c9975a filestore: fix truncation warnings 7 years ago
fooinha f67aa5deaa packet: gre over ip link type 7 years ago
Victor Julien 2d50fe499a tls: new config for dealing with encrypted traffic
Much of encrypted traffic is uninteresting to Suricata. Once encrypted
communication starts, inspecting the packet payloads is generally
not interesting anymore. The default behavior is to disable the parts
of the detection engine and stream reassembly that relate to raw content
inspection.

The tls app-layer parser also had a crude option to affect this behavior:
set 'no-reassemble' to true went much further than the default behavior.
It disabled the TCP reassembly on the flow completely, disabled all
inspection on the flow and enabled bypass if available.

This patch adds a new option: full inspection. This continues to treat
a TLS session as any other, so without any limits to inspection.

The new option is implemented in a new config option 'encrypt-handling',
that replaces 'no-reassemble'. The new option has 3 values:
'default', 'full' and 'bypass'. Default is the current default behavior,
'bypass' is the current 'no-reassemble = true' behavior and 'full'
is the new full inspection mode.
7 years ago
Victor Julien e6a009ae7f detect/stream_size: code cleanups 7 years ago
Victor Julien f30f038179 detect/stream_size: apply rule to packets & stream
The use of stream_size in combination with raw content matches is an
indication that the rule needs to be evaluated per packet, not just
per reassembled stream chunk.
7 years ago
Victor Julien c677e07d3e kerberos: minor doc updates, add author 7 years ago
Victor Julien b61e9c2173 dhcp: add author 7 years ago
Jason Ish 9210d8743b rust/dhcp: Rust based DHCP decoder and logger.
This is a DHCP decoder and logger written in Rust. Unlike most
parsers, this one is stateless so responses are not matched
up to requests by Suricata. However, the output does contain
enough fields to match them up in post-processing.

Rules are included to alert of malformed or truncated options.
7 years ago
Jason Ish 05e20c5c57 eve: check if enabled before attempting to setup
Before setting up a sub eve-logger, check that it is enabled. This
allows us to set "enabled: no" for loggers that are not registered
with the system without generating an error. An example of this
is loggers that are only available with Rust.
7 years ago
Jason Ish 14843a7b43 app-layer-register: add GetTxIterator
Add a field to set the GetTxIterator function to the AppLayerParser
registration struct.
7 years ago
Jason Ish 9fc1250ca8 app-layer-detect-proto: remove unnecessary gotos 7 years ago
Pierre Chifflier 1076c7cd47 Add krb5_err_code detection keyword 7 years ago
Pierre Chifflier d6b9c0294a Add krb5_cname and krb5_sname detection keywords 7 years ago
Pierre Chifflier 0bd81ff838 Add krb5_msg_type detection keyword 7 years ago
Pierre Chifflier 1e5f5d405f Kerberos 5: add support for TCP as well 7 years ago
Pierre Chifflier fd175f2bfb Add logger for Kerberos 5 metadata 7 years ago
Pierre Chifflier 77f0c11c9e Add Kerberos 5 application layer 7 years ago
Eric Leblond 325f336f63 util-random: fix detection of getrandom failure 8 years ago
Eric Leblond 851efd9c60 util-random: workaround getrandom unavailability
getrandom syscall availability is detected at runtime. So it is
possible that the build is done on a box that supports it but
the run is done on a system with no availability. So a workaround
solution is needed to fix this case.

Also we have seen some issue in docker environment where the build
is detecting getrandom but where it does not work at runtime.

For both reasons, the code is updated to have a call to a fallback
function if ever the getrandom call returns that the syscall is
not available.
8 years ago
Jason Ish 95481a9176 eve/json/xff - remove check for flow being NULL.
Fix Coverity issue:
** CID 1435535:  Null pointer dereferences  (REVERSE_INULL)
/src/output-json-file.c: 212 in JsonBuildFileInfoRecord()

Where we check a variable for being NULL, when all paths to the
code show that it can't be NULL.
8 years ago
Victor Julien 26b61bad90 htp: cleanup and fix test 8 years ago
Victor Julien 08af5ddd88 http: add tests for header folding
To test for https://github.com/OISF/libhtp/issues/159
8 years ago
Victor Julien 953dceece2 http: clean up unittest 8 years ago
Victor Julien d0a8310fcf pcap-log: don't divide by 0 on no traffic 8 years ago
Jason Ish 0d51ebc71a eve/alert: use eve-level xff config by default
The alert section can still have an xff configuration which
will take priority over the eve level xff config.
8 years ago
Jason Ish e3645bd9ae eve/alert: separate xff and metadata configuration
Put xff setup and metadata setup into their own
functions.
8 years ago
Jason Ish 36ec1281b2 eve/files: use eve-level xff config by default
The files section can still have an xff configuration which
will take priority over the eve level xff config.
8 years ago
Jason Ish 6607ee8489 eve/http: use eve-level xff config by default
The http section can still have an xff configuration which
will take priority over the eve level xff config.
8 years ago
Jason Ish 576584152c eve: use eve-level xff configuration
If an "xff" configuration section exists on the eve object,
parse and save it for child loggers to use.
8 years ago
Jason Ish 781a7e1089 xff: HttpXFFGetCfg - allow conf to be NULL
The code fully handles conf being NULL, and we have other functions
where conf can be NULL.
8 years ago
Maurizio Abba 2543930d74 xff: Use XFF configuration in eve and filestore
XFF configuration is already set in app-layer-htp-xff, and in
output-json-alert. Extending XFF configuration to files and HTTP allow
to get the same behavior as for alerts.

Extend the configuration of filestore json to let filestore metafile
dump be aware of xff. This is available only if write-fileinfo is set
to yes and file-store version is 2.
8 years ago
Elazar Broad 6ba02cac50 Fix segfault when the protocol is anything other than HTTP
When a file is transferred over anything other than HTTP, the previously hard-coded HTTP protocol would trigger a non-existent index into htp_list_array_get(), causing a segfault. This patch mimics the logic in detect-lua-extensions.c.
8 years ago
Mats Klepsland 2d2c01e772 detect-tls-cert-fingerprint: fix typo in unittest 8 years ago
Mats Klepsland 4671d57d7a detect-tls-cert-fingerprint: fix failing unittest
Fix unittest that failed with the content validation callback.
8 years ago
Mats Klepsland f36d578ee0 detect-tls-ja3-hash: add setup callback to lowercase content
Add setup callback that lowercase the content that follows 'ja3_hash'.
8 years ago
Mats Klepsland 5b954212f7 detect-tls-ja3-hash: add warning if nocase is used 8 years ago
Mats Klepsland 2501d48ac8 detect-tls-cert-serial: add warning if nocase is used 8 years ago
Mats Klepsland 2c5d5bbdaa detect-tls-cert-fingerprint: add warning if nocase is used 8 years ago
Mats Klepsland 4c9d448fa1 detect-tls-ja3-hash: add content validation callback
Validate that the content that follows the 'ja3_hash' keyword has
the correct length.
8 years ago
Mats Klepsland 52d9d45747 detect-tls-cert-fingerprint: add setup callback to lowercase content
Add setup callback that lowercase the content that follows
'tls_cert_fingerprint'.
8 years ago
Mats Klepsland f788719348 detect-tls-cert-fingerprint: add content validation callback
Validate that the content that follows the 'tls_cert_fingerprint'
keyword is on the correct form and has the correct length.
8 years ago
Mats Klepsland 6cf4c3c26e detect-tls-cert-serial: add setup callback to uppercase content
Add setup callback that uppercase the content that follows
'tls_cert_serial'.
8 years ago
Mats Klepsland 321603de37 detect-engine: add DetectEngineCtx to setup callback function
Add detect engine context as variable to setup callback function
in 'DetectBufferTypeRegisterSetupCallback'.
8 years ago
Mats Klepsland 48a5ea9df0 detect-tls-cert-serial: add content validation callback
Validate that the content that follows the 'tls_cert_serial' keyword
is on the correct form. If it's longer than two bytes it should be
separated by colons.
8 years ago
Max Fillinger b85a0b188b Add an option for compressing pcap-log files
Introduces the option 'outputs.pcap-log.compression' which can be set
to 'none' or 'lz4', plus options to set the compression level and to
enable checksums. SCFmemopen is used to make pcap_dump() write to a
buffer which is then compressed using liblz4.
8 years ago
Eric Leblond 6062c27eb7 af-packet: kill some white spaces 8 years ago
Eric Leblond 75b6972cfd util-ioctl: fix a typo in setter message 8 years ago
Eric Leblond f53e687bb8 af-packet: dump counters when timeout occurs
When traffic is becoming null (mainly seen in tests) we reach the
situation where there is timeouts in the poll on the socket and
only that. Existing code is then just looping on the poll and
the result is that the packet iface counters are not updated.

This patch calls the dump counter function to be sure to get
the counter right faster (and not only right at exit).
8 years ago
Victor Julien 8a5710307d hyperscan: don't abort on payloads > 64k
SPM API was recently updated to accept 32 bit length fields instead of
16 bits. This could trigger a BUG_ON in the hyperscan implementation.
8 years ago
Victor Julien a5de9968dd gcc8: fix format truncation warnings 8 years ago
Victor Julien 5faaa5dceb file_data/http: inspect cleanup 8 years ago
Eric Leblond 1d0727d85f stream-tcp: fix stream depth computation
The stream depth computation was partly done with the stream_config
depth instead of using the value in the TCP session. As a result,
some configuration were resulting in abnormal behavior.

In particular, when stream depth was 0 and the file store depth was
not 0, Suricata was stopping the streaming on the flow as soon as
the filestore was started.

Reported-by: Pascal Delalande <pdl35@free.fr>
8 years ago
Eric Leblond 1012fc4466 file: update logger API to log direction
By adding the flow direction to the logger we can have an accurate
logging of fileinfo events that has source and destination IP
correctly set.
8 years ago
Eric Leblond 2515c8927b app-layer-ftp: fill direction of transfer
This is required to return the file when asked with one direction.
8 years ago
Maurizio Abba d2bf7a3ba9 detect: fix buffer length to uint32
There is a difference in the size of the buffer length as passed from
the content buffers (cfr HttpReassembledBody.buffer_len) and the buflen
variable passed to mpm primitives. This can cause a misdetection
whenever the bufferlen is multiple of 65536 (as uint16(X*65536) == 0).
Increasing the buflen variable type to uint32 solves the issue (this
does not cause any issue with primitives, they all accept uint32).
8 years ago
Victor Julien 2e8fd612a6 files: properly close files on flow timeout
If a file transfer stops on flow timeout, it won't be closed or
truncated. This patch makes sure that in such cases the files
are indeed truncated. This fixes the filestore-v2 output module,
as that requires a sha256 for storing the partial file correctly.
8 years ago
Victor Julien 81c0b53d3f flow: track flow for ip proto 41 8 years ago
Victor Julien 8c75a022ea eve/netflow: only log response record if we've seen response pkts 8 years ago
Victor Julien c662383b53 flow: track flow for ICMP
Change packet layout to allow for expected counterpart type.
8 years ago
Victor Julien 708aad3f4a unified2: address strict aliasing issue 8 years ago
Victor Julien 7ce77f9351 decode/ipv6: expose addr as 'struct in6_addr' as well 8 years ago
Victor Julien 49b02f8f1b mingw: minor compile warning fixes 8 years ago
Giuseppe Longo 28849509b2 tests/detect-engine-hsbd: deinit det_ctx threads 8 years ago
Giuseppe Longo c620fc3dc4 detect-engine: free events
Events are stored in a detection engine but actually
they are not freed.
8 years ago
Victor Julien f461be75c5 smb: use inspect API v2 for smb keywords
Simplies code and supports transforms.
8 years ago
Victor Julien 3854c304d8 mpm/hs: fix minor coverity warning
CID 1428797 (#1 of 1): Unchecked return value (CHECKED_RETURN)
    check_return: Calling HashTableAdd without checking return value
    (as is done elsewhere 5 out of 6 times).
8 years ago
Victor Julien e834d94fd2 detect/pktvar: clean up keyword parsing 8 years ago
Alexander Gozman 10a360280f Print syslog format with SCLogDebug() instead of printf() 8 years ago
Mats Klepsland 21078521f8 app-layer-ssl: remove possibility to overflow HAS_SPACE macro 8 years ago
Mats Klepsland 598ef96b7b app-layer-ssl: really fix CID 1433623 8 years ago
Mats Klepsland 900c27e235 app-layer-ssl: fix use-after-free (CID 1433623)
Ja3BufferAddValue frees the buffer on error, so there is no point
in doing it twice (use-after-free).
8 years ago
Mats Klepsland fc0e339467 app-layer-ssl: fix use-after-free (CID 14336229)
Nullify JA3 buffer on free to avoid use-after-free vulnerability.
8 years ago
Victor Julien 3b474ac599 tls: work around coverity warnings 8 years ago
Alexander Gozman 5c1a2b53f9 Bug #2466: map SC_LOG_CONFIG level to syslogs LOG_DEBUG 8 years ago
Mats Klepsland 7f0cfc0717 app-layer-ssl: use BIT_U32 for flags 8 years ago
Mats Klepsland 3e597512ea app-layer-tls-handshake: remove since it is no longer needed
Remove this file and all its content, since the functionality
was reimplemented in app-layer-ssl.
8 years ago
Mats Klepsland e93fef5c44 app-layer-ssl: reimplement function for decoding certificates
Do a complete rewrite of the function for decoding the SSL/TLS
certificate from the handshake.
8 years ago
Mats Klepsland d9ddae4592 tls: replace variable in header file with TAILQ_EMPTY()
Use TAILQ_EMPTY to check if a certificate exists instead of
setting two variables in the app-layer-ssl header file for
that purpose only.
8 years ago
Victor Julien f201a3761f rust: remove multi level 'experimental'
Don't treat 'external' parsers as more experimental. All parsers
depend on crates to some extend, and all have C glue code. So the
distinction doesn't really make sense.
8 years ago