Commit Graph

320 Commits

Author SHA1 Message Date
Stefan Schantl
c8dcd46537 general-functions.pl: Add get_nameservers().
This function simply return an array of all used nameservers.

It also takes care if the usage of ISP assigned nameservers
is enabled or not and if user-added nameservers are enabled or not.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2020-01-09 16:08:13 +01:00
Stefan Schantl
9702252470 dns.cgi: Move grab_address_from_file function to general-functions.pl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2020-01-08 18:44:41 +01:00
Peter Müller
fd2dccaabb Core Update 139: fix syntax of generated Suricata DNS server file
The YAML syntax of /var/ipfire/suricata/suricata-dns-servers.yaml was
invalid and caused Suricata to crash after upgrading to Core Update 139.

Due to strange NFQUEUE behaviour, this caused IPsec traffic to be
emitted to the internet directly. While this patch represents a quick
solution for Core Update 139, another one is needed for changing the
IPtables chain order to avoid similar information leaks in future.

Thanks to Michael for his debugging effort.

Fixes #12260
Partially fixes #12257

Cc: Michael Tremer <michael.tremer@ipfire.org>
Cc: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Reviewed-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2019-12-14 07:26:05 +00:00
Stefan Schantl
30ee98e949 ids-functions.pl: Introduce generate_dns_servers_file()
This function is used to generate a yaml file which take care of the
current used DNS configuration and should be included in the main
suricata config file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2019-11-13 19:13:09 +00:00
Alexander Marx
cc724c142a BUG12070: Its not possible to use the underscore in email addresses
Using IPFire's Mailservice does not allow to enter a senders mail address with the underscore.
The function used to verify that is used from general-functions.pl.
Now the function 'validemail' allows the underscore in the address.

Fixes: #12070

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-06-18 09:12:49 +01:00
Stefan Schantl
81bae51f61 ids-functions.pl: Rework function write_modify_sids_file().
Directly implement the logic to determine the used ruleset and if
IDS or IPS mode should be used into the function instead of pass those
details as arguments.

This helps to prevent from doing this stuff at several places again and again.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-06-05 12:41:49 +01:00
Tim FitzGeorge
a5ba473c15 suricata: correct rule actions in IPS mode
In IPS mode rule actions need to be have the action 'drop' for the
protection to work, however this is not appropriate for all rules.
Modify the generator for oinkmaster-modify-sids.conf to leave
rules with the action 'alert' here this is appropriate.  Also add
a script to be run on update to correct existing downloaded rules.

Fixes #12086

Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
Tested-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-06-05 12:39:57 +01:00
Stefan Schantl
fefb5173cf ids-functions.pl: Do not delete the whitelist file on rulesdir cleanup.
Fixes #12087.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2019-05-26 16:09:21 +02:00
Peter Müller
40407aee99 ids.cgi: Fix upstream proxy validation
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Acked-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-05-20 18:50:06 +01:00
Florian Bührle
1dcf513a41 webif: Add a GUI for configuring VLAN interfaces
This patch adds a new CGI file which allows users to edit the
VLAN configuration as well as configuring zones as bridges.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-05-08 12:15:27 +01:00
Michael Tremer
2dd5e64592 suricata: Do not always convert rules to be bi-directional
This creates some overhead that we do not need and rules need to
be adjusted to match any direction they are supposed to match.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-04-23 20:18:07 +01:00
Michael Tremer
26dc79a6fe suricata: Do not let oinkmaster be too verbose
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-04-17 21:24:25 +01:00
Michael Tremer
e96adc7797 suricata: Redirect oinkmaster output to perl function
The output was written to stderr before and landed in apache's
error log where we do not want it.

Fixes: #12004
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-04-17 20:59:55 +01:00
Michael Tremer
abe2149852 GeoIP: Do not crash when locations database does not exist
Fixes: #12021
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-03-22 02:58:57 +00:00
Michael Tremer
06f57f7230 general-functions.pl: Only skip lines with a # at the beginning
This accidientially dropped all lines that include #. That resulted
in colour codes not being loaded from file any more.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-18 11:36:37 +01:00
Stefan Schantl
7c3b7cdcca ids-functions.pl: Tune rules to always monitor in both directions.
This will allow to scan the traffic from an EXTERNAL_NET to the HOME_NET and from
the HOME_NET to the EXTERNAL_NET.

Reference: 10273

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-18 10:55:27 +01:00
Stefan Schantl
8076deba79 ids-functions.pl: Add code to lock/unlock ids page while autoupdating the ruleset
Reference #11991

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-07 07:59:20 +01:00
Stefan Schantl
155b3b56a8 ids-functions.pl: Do not send HEAD requests to sourcefire (snort.org) servers
Using this feature to fetch the size of the requested tarball is not allowed by these
servers, so skip this feature for their rulesets.

Fixes #11987

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-06 10:58:59 +01:00
Stefan Schantl
c17a9778d6 Revert "ids-functions.pl: Use GET method to fetch Header data of a file"
Using the GET method will download the file twice and does not provide the
desired mechanism here.

This reverts commit 81592314eb.
2019-02-06 10:00:17 +01:00
Stefan Schantl
81592314eb ids-functions.pl: Use GET method to fetch Header data of a file
The sourcfire web servers does not support the HEAD request so we have to do
this with a GET here.

Fixes #11987

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-05 12:01:43 +01:00
Stefan Schantl
4924cfdc73 ids-functions.pl: Fix show HTTP error code and message
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-02-05 11:55:37 +01:00
Stefan Schantl
bcbc9897e3 ids-functions.pl: Grab address for RED by using get_red_address() function.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-31 09:50:47 +01:00
Stefan Schantl
de8e1e5b6c ids-functions.pl: Add function to the the current assigned IP-address of RED.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-31 09:41:35 +01:00
Stefan Schantl
23c0347ac5 ids-functions.pl: Add RED address and aliases to the HOME_NET
Reference: #11981

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 12:51:51 +01:00
Stefan Schantl
77c3130174 ids-functions.pl: Add get_aliases()
This subfunction is used to get all configured and enabled aliases
for the RED network zone. They will be returned as an array.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-30 11:57:49 +01:00
Stefan Schantl
3c59b1fab8 ids-functions.pl: Set correct ownership for the stored error file.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-29 08:58:08 +01:00
Stefan Schantl
1fedede6a0 ids-functions.pl: Add set_ownership() function.
This function is used to change the ownership of a given file
or directory to the user "nobody" and the group "nobody", which is
used by the WUI.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-29 08:50:16 +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
Michael Tremer
d499e86b16 GeoIP: Add accidentially removed paths to database
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-13 12:28:10 +01:00
Stefan Schantl
0ca3baedfc Revert "geoip-functions.pl: Re-write code to lookup the iso country code of a given IP-address."
Enhanching the code to fix the lookup will rapidely slow down the lookup speed. Because using
the GeoIP2 module is no option ( the reasons have been described in the commit message which will
now reverted), we have decided to temporary switch back to the old module until a nice solution has
been found.

This reverts commit ff21ff90d2.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-11 00:09:04 +00:00
Stefan Schantl
30c59cbb0b geoip-locations.pl: Add get_geoip_locations().
This function is used to get all available GeoIP locations.

The functions returns them as array, sorted in alphabetical order.

Reference #11959

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-10 22:42:52 +00:00
Stefan Schantl
ff21ff90d2 geoip-functions.pl: Re-write code to lookup the iso country code of a given IP-address.
Drop the usage of the old legacy GeoIP perl module which was not able to handle the
new GeoLite2 databases.

Write some code to directly access the databases and extract the required data.

Usage of the GeoIP2 perl module would provide a lot of more functionality which is not
used/needed. Unfortunately ir requires at lot of additional perl modules which are
not available on IPFire and would only be build and shipped for this module. Buildig all
of them will slow down the entire build process, mess up the system and requires a lot
more space on disk.

Fixes #11962.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-07 01:21:48 +00:00
Stefan Schantl
b749416ad7 ids-functions.pl: Downloader should reads settings from correct file
In commit ea5c8eeb83 the taken settings
for the ruleset have been stored into an own file.

The Downloader now uses this file to read-in which ruleset should be used
and downloaded.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2019-01-06 14:11:30 +01:00
Michael Tremer
d68e150e86 proxy: Drop web browser check
This is neither reliable nor up to date and is therefore removed

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-08 15:54:56 +01:00
Daniel Weismüller
1a3323f2e6 BUG 11786 - squid: Remove setting for filter processes the number of Squid processes
I added a function to determine the number of cores.
Now the number of squid processes will be equal to the number of logical cores.
Further I removed the possibility of changing the number
of squid processes in the proxy.cgi

Signed-off-by: Daniel Weismüller <daniel.weismueller@ipfire.org>
Signed-off-by: root <root@ipfire.test>
2019-01-08 02:02:05 +01:00
Stefan Schantl
6994f00174 ids-functions.pl: Downloader now also uses upstream proxy for HTTPS
Fixes #11953

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-26 16:33:54 +01:00
Stefan Schantl
04a0d07c97 ids-functions.pl: Add function to get the version of suricata
The get_suricata_version() function is used to get the version
of the on the system installed version of suricata. You can
specify the how detailed the returned result should be "major" will
return only the major version, were "minor" will provide the major
and minor version (1.2 for example). All other calls will be answered
with the full version string (1.2.3).

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-26 16:05:46 +01:00
Stefan Schantl
2ee510888c ids-functions.pl: Fix typo
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-25 20:19:12 +01: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
25b6545a6e ids-functions.pl: Use temporary file in downloader.
Download the requested rules tarball into a temporay file
and if every thing is fine, replace the old by the
downloaded one.

In addition with the previously implemented file size check,
we are saved now from a corrupt rules tarball on disk.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-18 15:14:08 +01:00
Stefan Schantl
96da5803a7 ids-functions.pl: Introduce filesize check for downloader
The downloader now requests the html header for the rulestarball
and obtain the size of the file bevore downloading it.

After success the size of the downloaded file will be compared with
the requested one before. If they do not match, an error will be gained.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-18 14:16:13 +01:00
Stefan Schantl
1201c1e746 ids-functions.pl: Fix sub _cleanup_rulesdir() function
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-12-18 14:12:52 +01:00
Stefan Schantl
8cf04a1656 ids-functions.pl: Rework &_cleanup_rulesdir() function
* Use a directory listing and delete the files.
* Keep files with "config" as file extension.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-10-12 15:43:16 +02:00
Stefan Schantl
4ce4248849 ids-functions.pl: Fix typo
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-10-12 15:18:38 +02:00
Stefan Schantl
883820bdcb ids-functions.pl: Call &_cleanup_rulesdir() function before calling oinkmaster.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-10-12 15:16:32 +02:00
Stefan Schantl
b59cdbeea5 ids-functions.pl: Add private function to cleanup the rules directory.
This private function is used to remove any files which are stored in the
IDS rules directory and prevent from any old (unneeded or conflicting) files
after an update or complete change of the ruleset source.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-10-12 15:12:10 +02:00
Stefan Schantl
ed06bc811f ids-functions.pl: Add backend code to handle the "cron" function of suricatactrl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-09-26 14:09:53 +02:00
Stefan Schantl
21cab141ec suricata: Rule files are now located in /var/lib/suricata
Place the rulefiles from now in "/var/lib/suricata".

Fixes #11834

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2018-08-29 12:37:44 +02:00