Commit Graph

2798 Commits

Author SHA1 Message Date
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
f2f0d61fc1 logs.cgi/ids.dat: Rework linking to external rule documentation.
Check if the sid of a rule belongs to sourcefire and link to the
changed URL for gathering more details. If the sid of the rule belongs
to emergingthreads now link to the emergingthreads documentation.

Fixes #11806.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-08-14 11:48:03 +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
Michael Tremer
1fb7f56e11 make.sh: Add command to update list of contributors
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-08-05 11:10:28 +01: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
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
3983aebdec ids.cgi: Rework CGI logic to download a new ruleset
* Drop function to show a notice about snort is working.
* Introduce the log_error function which is responsible for log any
  error messages. Currently it writes it to a tempory file, which will
  be read by the WUI, the message will be displayed and the temporary file
  will be released again.
* Introduce a tiny function to easily perform a reload of the generated
  webpage.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:58:01 +02:00
Stefan Schantl
a69b96d200 ids.cgi: Use tarball information from ids-functions.pl
Directly use the value from the ids-functions.pl for the
location and filename of the tarball which includes the snort ruleset.

This will save to declare this information twice and prevents from any
failures if the location of filname every changes.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:57:23 +02:00
Stefan Schantl
ad1d8a8acc ids.cgi: Drop dirty hook for updating the ruleset
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:57:00 +02:00
Stefan Schantl
25f5cb0d4b ids.cgi: Move function to call oinkmaster to ids-functions.pl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:56:45 +02:00
Stefan Schantl
eea2670b39 ids.cgi: Move downloader code to ids-functions.pl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:56:28 +02:00
Stefan Schantl
59052432f4 ids.cgi: Use ids-functions.pl for checking available discspace
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:56:03 +02:00
Stefan Schantl
8dcebe5342 IDS: Introduce ids-functions.pl.
This library will contain a set of functions used by the IDS CGI script
and the planned update script for auto-updating the snort ruleset.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:54:25 +02:00
Stefan Schantl
c724524e2e ids.cgi: Drop loading of File::Copy module.
This is not required, at any time by the script.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:53:24 +02:00
Stefan Schantl
c77bd49235 logs.cgi/log.dat: Add support for oinkmaster
This will allow to display the logged output of oinkmaster
via the webinterface.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:53:07 +02:00
Stefan Schantl
1504a37517 ids.cgi: Rework snort configuration area
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:52:55 +02:00
Stefan Schantl
a6edfcbd9b ids.cgi: Pipe the oinkmaster output to the logger binary
This will allow anybody, to access the log of oinkmaster and
get detailed information about any changes which have been done
on the ruleset.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:52:35 +02:00
Stefan Schantl
43263ea68e ids.cgi: Rework downloader for rulesets
Doing the rules download in pure perl instead of using
the external wget.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:51:41 +02:00
Stefan Schantl
e524290c9c ids.cgi: Drop old control code
The control file are not longer required, because the
initscript uses the settings file to determine if snort
should be started and binded to which interfaches.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:50:27 +02:00
Stefan Schantl
ef5171ab71 ids.cgi: Call oinkmaster without a log target
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:49:40 +02:00
Stefan Schantl
afe26a0586 ids.cgi: Introduce ruleset-source.list
This new file will contain the vendor information and url
for downloading their ruleset. In future if the download location
or filename changes, we only need to adjust this one file and ship
it via a core update.

Also extend the downloadrulesfile to be able to directly call the
subfunction.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:49:19 +02:00
Stefan Schantl
a232b58ca7 ids.cgi: Adjust code for saving snort settings
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:48:42 +02:00
Stefan Schantl
8f22237beb ids.cgi: Remove logfile after wget has successfully downloaded the ruleset
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:47:00 +02:00
Stefan Schantl
500c5c55d0 ids.cgi: Rework code which shows if oinkmaster is working
Move the code for displaying a notice that snort currently is working
into an own subfunction which will be called if oinkmaster currently
is started.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:46:42 +02:00
Stefan Schantl
aa12410222 ids.cgi: Drop old code for debuging purposes
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:46:17 +02:00
Stefan Schantl
c51a044a2a ids.cgi: Add check when altering the ruleset
Add a check if the currently processing sid is nummeric, otherwise skip it.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:46:00 +02:00
Stefan Schantl
525998650a ids.cgi: Rework code for downloading/updating the ruleset
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:45:37 +02:00
Stefan Schantl
56dacb580e ids.cgi: Move call of oinkmaster to an own subfunction
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:45:17 +02:00
Stefan Schantl
376595057b ids.cgi: Always write config files for enabled/disabled rule files
If a single sid has been activated and then disabled without doing
any other ruleset modifications only one of the oinkmaster files
for enabled / disabled rules has been modified.

In this case it was possible, that the same sid, was part of the
file for enabled rules and part of the file for disabled rules at the
same time.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:45:02 +02:00
Stefan Schantl
466c67794b ids.cgi: Process enabled rulefiles in an own loop
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:44:48 +02:00
Stefan Schantl
603334734a ids.cgi: Drop enabled/disabled rules from cgiparams hash
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:44:32 +02:00
Stefan Schantl
b65b5ef377 ids.cgi: Drop enabled rulefile from cgiparams hash after processing
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:44:12 +02:00
Stefan Schantl
e573807983 ids.cgi: Re-add code for enable/disable rulefiles
The enabled rulefiles (rule categories) now will be added
to an own file, which will be included by the snort main config
file.

This will allow us to update snort and push the new main config file
without loosing the activated rulesets anymore.

* Introducing snort-used-rulefiles.conf

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:43:36 +02:00
Stefan Schantl
0b89daee93 ids.cgi: Code cleanup
* Drop a lot of unused variables and code.
* Re-ordering some code parts.
* Add a lot of comments.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:43:22 +02:00
Stefan Schantl
298723b9db ids.cgi: Re-add code to save the ruleset.
The manually enabled or disabled rules by the user now will be written
to own config files, which will be used by oinkmaster to keep these rules
in the same state after a rules update has been performed.

In short words, if you adjust your ruleset, the changes will not be lost
again if you perform an update of your ruleset.

* Grabbing and storing the cgi values now in an own hash (%cgiparams)
* Introducing oinkmaster config files for enabled and disabled rules.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:43:05 +02:00
Stefan Schantl
0b568bb965 ids.cgi: Drop unused css code
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:42:09 +02:00
Stefan Schantl
177266446a ids.cgi: Rework code for displaying the single rules
The complete ruleset will be grouped as categories by it's
corresponding rulefile and printed in hidden tables.

They easiely can be displayed by klicking on the show link and
vice-versa.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:41:55 +02:00
Stefan Schantl
f7fcd1c020 ids.cgi: Always display ruleset
Display the rule categories any time and do not hide them
if no instance of snort is runing.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-07-26 11:41:31 +02:00