Commit Graph

262 Commits

Author SHA1 Message Date
Stefan Schantl
97870bf29c ids.cgi: Stop suricata when the rulest source has been changed
If the ruleset source has been changed, it has to be configured again.
This happens because of different rule categories, filenames rule ID's etc.

In case suricata currently is running it has to be stopped and after the configuration
has been done by the user, it can be launched again.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-05 12:43:49 +01:00
Stefan Schantl
5709768b0b ids.cgi: Fix downloading rules if source changed
Fix the if statement to detect wheater the ruleset has been
changed and automatically download the new one.

Fixes #11984.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-05 12:36:30 +01:00
Stefan Schantl
b7a9b4edc2 ids.cgi: Update automatic download texts
Update the showed texts in the dropdown box as mentioned in the
bug report.

Fixes #11985

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-05 12:13:28 +01:00
Stefan Schantl
912d7472a8 ids.cgi: Automatically download ruleset if the ruleset source has been changed.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-31 08:55:05 +01:00
Stefan Schantl
e0cec9fe99 ids.cgi: Dynamically generate SHOW/HIDE for expanding or collapsing a ruleset category
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 10:53:17 +01:00
Stefan Schantl
cf02bf2f7d ids.cgi: Show IDS setting area only if a ruleset is present.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 10:12:11 +01:00
Stefan Schantl
013274d7d8 ids.cgi: Diplay reason, why a ruleset could not be downloaded, if the system is offline.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 10:05:14 +01:00
Stefan Schantl
5fd2e9d64a ids.cgi: Also download the ruleset when saving the ruleset settings
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 09:57:49 +01:00
Stefan Schantl
34a3843865 ids.cgi: Add dropdown option for Emergingthreats.net Pro rules.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 09:42:28 +01:00
Stefan Schantl
d618d67e01 ids.cgi: Only show "update ruleset" button if a ruleset is present
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 09:39:17 +01:00
Stefan Schantl
674912fc3a ids.cgi: Draw daemon status and setting in the same box.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 09:33:47 +01:00
Stefan Schantl
029b8ed2b1 ids.cgi: Show/Hide subscription code area dynamically.
Dynamically (Java Script) show/hide the area for entering the
subscription code / oinkcode based on the choosen ruleset.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 09:27:37 +01:00
Stefan Schantl
bc4a2223cc ids.cgi: Remove help text for obtaining an oinkcode
This information is only valid for sourcefire (snort) rulesets, may
confuse users and therefore should be handled in the wiki.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 09:25:34 +01:00
Stefan Schantl
9283e9b9cf ids.cgi: Move and rename GenerateIgnoreList() function to ids-functions.pl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-22 13:25:13 +01:00
Stefan Schantl
c1a3401235 Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next-suricata 2019-01-21 13:04:13 +01:00
Matthias Fischer
d01b31914a snort: Update to 2.9.12
For details see:

Release notes:
https://snort.org/downloads/snort/release_notes_2.9.12.txt

Changelog:
https://snort.org/downloads/snort/changelog_2.9.12.txt

Signed-off-by: Matthias Fischer <matthias.fischer@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-05 15:42:34 +00:00
Stefan Schantl
74cc8f5a3d ids-functions.pl: Introduce function write_modify_sids_file()
This function is used to write the corresponding file which
tells oinkmaster to alter the whole ruleset and finally
switches suricata into an IPS or IDS.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-25 18:49:57 +01:00
Stefan Schantl
b02e30fd81 ids.cgi: Move variable declaration to ids-functions.pl
Also move some functions from the cgi file to the library file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-25 18:26:21 +01:00
Stefan Schantl
53817b89c0 ids.cgi: Hack to use the correct language string for red network zone.
This hack is needed because "red" is used as "internet" in the language files
and "red1" contains the correct "red" translations.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-24 13:19:06 +01:00
Stefan Schantl
99b372b51d ids.cgi: Colourize network zones
Colourize the network with the proper colour.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-24 13:18:14 +01:00
Stefan Schantl
01d02eb63b ids.cgi: Change RUN_MODE to MONITOR_TRAFFIC_ONLY
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-24 10:04:55 +01:00
Stefan Schantl
ea5c8eeb83 ids.cgi: Seperate IPS and ruleset settings
Now each of both have their own corresponding configuration areas.
The taken settings will be saved in "/var/ipfire/suricata/settings" for
all IDS/IPS related settings and in "/var/ipfire/suricata/rules-settings" for
ruleset related settings.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-24 08:26:39 +01:00
Stefan Schantl
ebdd0f9a90 ids.cgi: Prevent from starting suricata without ruleset or selected network zone
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-20 13:18:48 +01:00
Stefan Schantl
0a1bba1a1d ids.cgi: Access ruleset by its own name
This improves accessing the single rules of a rule category.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-20 11:55:13 +01:00
Stefan Schantl
8353c3fd36 ids.cgi: Allways use the whitelist
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-18 15:19:30 +01:00
Peter Müller
0c451a4a32 fix downloading Snort rules if behind upstream proxy
Currently, the wget call only uses proxy information for HTTP.
Since rulesets are downloaded via HTTPS now, the same information
also needs to be applied for HTTPS.

Signed-off-by: Peter Müller <peter.mueller@link38.eu>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-11-01 10:30:08 +00:00
Stefan Schantl
eadad5fda6 ids.cgi: Add support for autoupdate of the IDS ruleset
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-09-26 14:43:09 +02:00
Stefan Schantl
dae534f2ca ids.cgi: Only write oinkmaster-modify-sids.conf if neccessary.
Only write to the file if the runmode of the IDS has been changed.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-09-26 13:02:28 +02:00
Stefan Schantl
43ab7d9c30 ids.cgi: Set state of used rulefile to on if it contains rules
Only set the state of a used rulefile to "on" if it is present in
the %idsrules hash. This happens if it contains at least one rule.

This prevents from showing a rulefile in the ruleset section if, it
does not exist anymore or does not contains any rules at all.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-09-11 12:00:31 +02:00
Stefan Schantl
b7e2974394 ids.cgi: Introduce whitelisting of IP-addresses
If an IP-address has been added to the whitelist, any traffic from
this host will not longer inspected by suricata.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-09-11 11:58:11 +02:00
Stefan Schantl
80bcd4dd1a ids.cgi: Hide rules config section if no rules a present
Do not show the rules config section anymore if there is not
ruleset available.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-30 18:18:26 +02:00
Stefan Schantl
00512a5ac8 ids.cgi: Create file for used rulefiles on first execution if not present
Create this file on first execution of the script if it does not exist yet.
This will allow suricata to imediately be started. Otherwise the ruleset has
to be downloaded and configured before this file has been created and suricata
could be launched.

Fixes #11833.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-29 11:50:59 +02:00
Stefan Schantl
004b13b7e8 ids.cgi: Fix get_memory_usage()
Change the get_memory_usage() function to grab and return the
memory usage of the entire process, containing all sub-processes and
threads.

Fixes #11821

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-29 10:55:32 +02:00
Stefan Schantl
01ba4be48d ids.cgi: Create oinkmaster related files at first call
With this commit, the CGI file will create the oinkmaster related
files during first run if they does not exist.

Fixes #11822.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-24 07:39:04 +02:00
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
Peter Müller
5ed6cdd920 download ET IDS rules via HTTPS
The Emerging Threats ruleset server supports HTTPS. It should
be used for downloading the ruleset in IPFire, too.

This also needs to be applied on the upcoming ids.cgi file for Suricata
which I will do in a second patch.

The third version of this patch superseds the first and
second one which were broken due to bugs in the MUAs GPG
implementation.

Signed-off-by: Peter Müller <peter.mueller@link38.eu>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-08-16 18:54:06 +01: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
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
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
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
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
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