Commit Graph

12193 Commits

Author SHA1 Message Date
Stefan Schantl
d221283622 ids.cgi: Rework handling of enabled/disabled sids
Now the enabled or disabled sids are stored in a single
hash instead of two arrays, which easily can be modified.

When saving the ruleset, the new read_enabled_disabled_sids() function
will be used to read-in the current (old) saved enabled or disabled sids
and add them to the new hash structure.

After adding or modifiying sids to the hash, the entries will be written
to the corresponding files.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-22 08:39:57 +02:00
Stefan Schantl
a5d617520b ids.cgi: Add function to read the enabled/disabled sid files
This function is used to read-in the files for enabled or disabled sid
files and stores the sid and their state into a temporary hash which will
be returned by the function.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-22 08:38:16 +02:00
Stefan Schantl
5a28e721e0 ids.cgi: Fix check if the IDS is running
The correct function name is ids_is_running()!

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-21 19:18:01 +02:00
Stefan Schantl
bbb6efae56 ids.cgi: Add backend code to handle switch between IDS and IPS mode
This commit adds the required backend code to allow switching
between IDS and IPS mode of suricata.

Technically the behaviour of suricata is specified by the rules -
each of them can contain the action "alert" or "drop" (There are
more actions supported but these two are currently the important one)

When running in IDS mode, the ruleset does not need to be touched,
because the default action is "alert". When switching to IPS mode,
the CGI writes a single line to "oinkmaster-modify-sids.conf" which
is included by oinkmaster and modify the action for each single rule
from alert to drop.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-18 15:10:44 +02:00
Stefan Schantl
a4ccfcbbc6 ids.cgi: Allow to switch between IDS/IPS mode
Add the option to select the runmode for suricata, wheater it
should run in intrusion detection mode or intrusion prevention mode.

If the option has not configured yet, it defaults to IPS mode.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-18 10:16:12 +02:00
Stefan Schantl
d9711d91ef ids-functions.pl: Display error if oinkmaster cannot be executed
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-18 10:01:14 +02:00
Stefan Schantl
88daf7eb3a ids-functions.pl: Log correct error message if download fails
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-17 08:49:06 +02:00
Stefan Schantl
55658ee381 suricata: Fix detection of enabled IDS on zone in initscript
I accidently commited the wrong file in the previous commit.
This is the fixed and working version.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-17 08:45:47 +02:00
Stefan Schantl
00a031145e suricata: Give 644 permissions to the suricata pidfile
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-17 08:24:19 +02:00
Stefan Schantl
04b5c77a45 ruleset-sources: Move to suricata optimized ruleset when using emerginthreads.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-17 07:36:54 +02:00
Stefan Schantl
3c2c54831f suricata: Add code to create iptables rules to the initscript
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-16 18:51:13 +02:00
Stefan Schantl
7c82ee6165 firewall: Add chains for IPS (suricata)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-16 18:50:39 +02:00
Stefan Schantl
cc60d3dfd3 suricata: Fix include of used rulefiles yaml
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-12 18:40:31 +02:00
Stefan Schantl
4230305558 suricata: Use HOME_NET declaration from external file
Use the gernerated HOME_NET details from
/var/ipfire/suricata/suricata-homenet.yaml which will be
generated by the WUI.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-12 07:05:24 +02:00
Stefan Schantl
6187da5055 IDS: Add reload option to initscript
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-11 22:28:07 +02:00
Stefan Schantl
e2e7880dc7 ids.cgi: Add code to start/stop/reload the IDS when neccessary
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-11 22:11:18 +02:00
Stefan Schantl
5240a80987 ids-functions.pl: Add function to call suricatactrl binary
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-11 22:10:29 +02:00
Stefan Schantl
8d2f6b0b59 ids.cgi: Dynamically generate the HOME_NET details for suricata.
Introduce generate_home_net_file() which uses the current network
config to obtain the network address and subnetmask for each
available network zone, generate and write these HOME_NET information
into a yaml compatible file which can be included into the suricata
configuration file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-09 15:33:25 +02:00
Stefan Schantl
e0bfd338ee ids.cgi: Rename form name from SNORT to IDS
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-05 19:42:33 +02:00
Stefan Schantl
8766096429 ids.cgi: Display if the IDS is running
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-05 14:24:20 +02:00
Stefan Schantl
796eea2154 ids-functions.pl: Add function to check if the IDS is running
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-05 14:23:45 +02:00
Stefan Schantl
1286e0d41e ids.cgi: Rework section to configure the IDS
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-05 12:57:44 +02:00
Stefan Schantl
1cae702c22 ids-functions.pl: Add function to get the available network zones
The get_available_network_zones() function uses the /var/ipfire/ethernet/settings
file and translates the configured mode into an array, which contains the names
of the configured network zones.

The array will be returned and easily can be used to loop over this list of
available network zones and perform any kind of actions in other scripts.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-05 10:33:46 +02:00
Stefan Schantl
ab114c276b ids.cgi: Call suricatactrl for restarting the IDS
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-03 13:51:59 +02:00
Stefan Schantl
06b569a442 oinkmaster: Install config file to /var/ipfire/suricata
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-03 13:48:46 +02:00
Stefan Schantl
d33874f496 daq: Drop package
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-03 10:20:18 +02:00
Stefan Schantl
843a8c570c snort: Drop package
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-03 10:19:35 +02:00
Stefan Schantl
914cca3d8e initscripts: Link against suricata initscript in runlevels and red.up hook
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-03 10:02:34 +02:00
Stefan Schantl
74b7d695c6 misc-progs: Rename snortctrl to suricatactrl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-03 09:50:31 +02:00
Stefan Schantl
ef640882ab make.sh: Add ids-ruleset-source
I accidently forgot to commit this file in 1d9b879140

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 19:58:41 +02:00
Stefan Schantl
d72b3e64c2 suricata: Introduce basic initscript
Add a very basic initscript, which currently allows to start/stop/restart suricata and
check if the daemon is running.

The script will detect when starting suricata how many CPU cores are present on the system and
will launch suricata in inline mode (NFQUEUE) and listen to as much queues as CPU cores are
detected.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 19:54:22 +02:00
Stefan Schantl
101d3ece24 ids-ruleset-sources: Update download URL for snort rules
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 19:33:37 +02:00
Stefan Schantl
bce84f3975 ids-functions.pl: Rename ruleset-sources.list to ruleset-sources
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 19:31:52 +02:00
Stefan Schantl
1d9b879140 ids-ruleset-sources: New package
Move the file which contains the download URL's for the IDS rulesets
into an own common package. This will allow us in future to easily ship
a changed file with a core update.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 19:29:36 +02:00
Stefan Schantl
72b2109c72 configroot: Move from snort to suricata
Create /var/ipfire/suricata and /var/ipfire/suricata/settings instead of
/var/ipfire/snort and /var/ipfire/snort/settings.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 15:47:31 +02:00
Stefan Schantl
4c6d6c1ee3 suricata: Install very basic config file
This config file is mostly based on the example configuration shipped
by the suricata project and needs to be enhanched.

See #11808.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 09:10:25 +02:00
Stefan Schantl
101c888174 ids.cgi: Generate suricata compatiple used-rulefiles file
* Rename filename to suricata-used-rulefiles.yaml
 * Adjust file generation as a yaml file to be compatible with suricata
 * Adjust code to correctly read-in and parse the changed file

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-02 09:07:12 +02:00
Stefan Schantl
164eab6627 ids-functions.pl: Move path details from snort to suricata
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-30 21:36:07 +02:00
Stefan Schantl
a8b8c9e5b2 Merge branch 'next-new-ids.cgi' into next-suricata-and-cgi 2018-07-30 21:33:25 +02:00
Stefan Schantl
67752a9510 suricata: New package
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-30 21:31:15 +02:00
Stefan Schantl
3498300d87 libhtp: New package
This is build and runtime dependency for suricata.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-29 09:45:05 +02:00
Stefan Schantl
91cc908f84 yaml: New package
This is a build and runtime dependency for suricata.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-29 09:44:52 +02:00
Stefan Schantl
434001d0a0 IDS: Rework error and log handling in ids-functions.pl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-28 16:34:50 +02:00
Stefan Schantl
02844177af IDS: Introduce settingsdir variable
The $settingsdir variable is declared in the ids-functions.pl and used to to
store the path where the various files which contains the settings for the IDS and
oinkmaster is located.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-27 07:58:23 +02:00
Stefan Schantl
298ef5bafa IDS: Move rulepath declaration to ids-functions.pl
This will help if the path ever changed. Also remove hard coded rulepath
from oinkmaster call.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 15:56:47 +02:00
Stefan Schantl
9d18656ba7 ids.cgi: Rename snortrules hash to idsrules.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 15:51:15 +02:00
Stefan Schantl
fdfd8913ab ids.cgi: Drop code which is detecting if oinkmaster is running
This code is not longer required and therefore can be dropped.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:59:44 +02:00
Stefan Schantl
27760092c0 ids.cgi: Reimplement function to lock page and show working notice
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:59:31 +02:00
Stefan Schantl
eb5592c1ce ids-functions.pl: Also log errors to syslog
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:59:15 +02:00
Stefan Schantl
0e40e1e772 ids-functions.pl: Use pure perl to log oinkmaster result to syslog
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:58:54 +02:00