├── MANIFEST.in
├── COPYRIGHT
├── pierky
├── blocklistsaggregator
│ ├── __init__.py
│ ├── version.py
│ ├── errors.py
│ ├── formatters
│ │ ├── __init__.py
│ │ ├── base_formatter.py
│ │ ├── json_fmt.py
│ │ ├── mikrotik.py
│ │ ├── lines.py
│ │ └── cisco.py
│ ├── lists
│ │ ├── bambenek.py
│ │ ├── spamhaus.py
│ │ ├── __init__.py
│ │ ├── base_list.py
│ │ └── abuse_ch.py
│ └── sanitisers.py
└── __init__.py
├── .gitignore
├── CHANGES.rst
├── apply_copyright
├── distrib
└── log.ini
├── setup.py
├── README.rst
├── scripts
└── blocklistsaggregator
└── LICENSE
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include LICENSE
2 | include README.rst
3 | include CHANGES.rst
4 | include MANIFEST.in
5 | recursive-include pierky *.py
6 | include distrib/log.ini
7 |
--------------------------------------------------------------------------------
/COPYRIGHT:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/version.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | __version__ = "0.5.1"
17 |
18 | COPYRIGHT_YEAR = 2016
19 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/errors.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 |
17 | class BlockListProcessingError(Exception):
18 | pass
19 |
--------------------------------------------------------------------------------
/pierky/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | try:
17 | __import__('pkg_resources').declare_namespace(__name__)
18 | except ImportError:
19 | from pkgutil import extend_path
20 | __path__ = extend_path(__path__, __name__)
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.cache
3 |
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 |
8 | # C extensions
9 | *.so
10 |
11 | # Distribution / packaging
12 | .Python
13 | env/
14 | build/
15 | develop-eggs/
16 | dist/
17 | downloads/
18 | eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | .eggs/
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .coverage
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 |
47 | # Translations
48 | *.mo
49 | *.pot
50 |
51 | # Django stuff:
52 | *.log
53 |
54 | # Sphinx documentation
55 | docs/_build/
56 |
57 | # PyBuilder
58 | target/
59 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/formatters/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | from .lines import LinesFormatter
17 | from .json_fmt import JSONFormatter
18 | from .cisco import CiscoFormatter
19 | from .mikrotik import MikrotikFormatter
20 |
21 | Formatters = [LinesFormatter, JSONFormatter, CiscoFormatter, MikrotikFormatter]
22 |
23 |
24 | def get_formatter_from_id(id):
25 | return [fmt_class for fmt_class in Formatters if fmt_class.ID == id][0]
26 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/lists/bambenek.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | from .base_list import BlockList
17 |
18 | from netaddr import IPNetwork
19 |
20 |
21 | class Bambenek_C2_List(BlockList):
22 | ID = "bambenek_c2"
23 | URL = "http://osint.bambenekconsulting.com/feeds/c2-ipmasterlist.txt"
24 | NAME = "Bambenek Consulting C2 master feed"
25 |
26 | def parse_entry(self, entry):
27 | ip = IPNetwork(entry.split(",")[0])
28 | self.entries.append(ip)
29 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/formatters/base_formatter.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 |
17 | class Formatter(object):
18 |
19 | ID = None
20 |
21 | @staticmethod
22 | def add_args(parser):
23 | pass
24 |
25 | def __init__(self, args):
26 | self.args = args
27 |
28 | # The main program calls the init() function first;
29 | # if it returns True, it processes the block lists
30 | # entries and then it calls emit().
31 |
32 | def init(self):
33 | return True
34 |
35 | def emit(self, entries, output):
36 | raise NotImplementedError()
37 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/formatters/json_fmt.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | import json
17 |
18 | from .base_formatter import Formatter
19 |
20 |
21 | class JSONFormatter(Formatter):
22 |
23 | ID = "json"
24 |
25 | def _get_entries(self, entries, ip_ver):
26 | res = {}
27 | for e in entries[ip_ver]:
28 | s = str(e)
29 | res[s] = {"bl_ids": list(entries["unique"][s]["bl_ids"])}
30 | return res
31 |
32 | def emit(self, entries, output):
33 | results = {
34 | "v4": self._get_entries(entries, "v4"),
35 | "v6": self._get_entries(entries, "v6")
36 | }
37 | json.dump(results, output)
38 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/sanitisers.py:
--------------------------------------------------------------------------------
1 | # Stolen from https://github.com/RIPE-NCC/ripe-atlas-tools
2 | # Copyright (c) 2016 RIPE NCC
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 | import six
18 |
19 | FORBIDDEN = dict((i, None) for i in list(range(0, 32)) + [127])
20 |
21 |
22 | def sanitise(s, strip_newlines=True):
23 | """
24 | Strip out control characters to prevent people from screwing with the
25 | output
26 | """
27 |
28 | if not isinstance(s, six.string_types):
29 | return s
30 |
31 | if six.PY2:
32 | s = unicode(s)
33 |
34 | if not strip_newlines:
35 | return s.translate(
36 | dict((k, v) for k, v in FORBIDDEN.items() if not k == 10))
37 |
38 | return s.translate(FORBIDDEN)
39 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/lists/spamhaus.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | from .base_list import BlockList
17 |
18 | from netaddr import IPNetwork
19 |
20 |
21 | class Spamhaus_List(BlockList):
22 | COMMENT = ";"
23 |
24 | def parse_entry(self, entry):
25 | ip = IPNetwork(entry.split(" ")[0])
26 | self.entries.append(ip)
27 |
28 |
29 | class Spamhaus_DROP_List(Spamhaus_List):
30 | ID = "drop"
31 | URL = "https://www.spamhaus.org/drop/drop.lasso"
32 | NAME = "Spamhaus DROP"
33 |
34 |
35 | class Spamhaus_DROPv6_List(Spamhaus_List):
36 | ID = "drop_v6"
37 | URL = "https://www.spamhaus.org/drop/dropv6.txt"
38 | NAME = "Spamhaus DROPv6"
39 |
40 |
41 | class Spamhaus_EDROP_List(Spamhaus_List):
42 | ID = "edrop"
43 | URL = "https://www.spamhaus.org/drop/edrop.lasso"
44 | NAME = "Spamhaus EDROP"
45 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/lists/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | from .spamhaus import Spamhaus_DROP_List, Spamhaus_DROPv6_List, \
17 | Spamhaus_EDROP_List
18 | from .abuse_ch import Feodo_BadIP_List, Feodo_IP_List, Palevo_CC_List, \
19 | Zeus_IP_List, RW_IPBL_List, RW_DomBL_List, RW_URLBL_List
20 | from .bambenek import Bambenek_C2_List
21 |
22 | BlockLists = [RW_IPBL_List, RW_DomBL_List, RW_URLBL_List,
23 | Spamhaus_DROP_List, Spamhaus_DROPv6_List, Spamhaus_EDROP_List,
24 | Feodo_BadIP_List, Feodo_IP_List, Palevo_CC_List, Zeus_IP_List,
25 | Bambenek_C2_List]
26 |
27 |
28 | def get_bl_from_id(id):
29 | return [bl_class for bl_class in BlockLists if bl_class.ID == id][0]
30 |
31 |
32 | def get_bl_names(bl_ids):
33 | ret = []
34 | for bl_class in BlockLists:
35 | if bl_class.ID in bl_ids:
36 | ret.append(bl_class.NAME)
37 | return ret
38 |
--------------------------------------------------------------------------------
/CHANGES.rst:
--------------------------------------------------------------------------------
1 | Changelog
2 | =========
3 |
4 | 0.5.1
5 | -----
6 |
7 | - Fix a bug in the packaging system.
8 |
9 | 0.5.0
10 | -----
11 |
12 | - Better empty lines detection for RW_IPBL.
13 | - Add `--lists-include` and `--lists-exclude` arguments.
14 | - Add `rw_dombl` and `rw_urlbl` lists (`Ransomware Tracker RW_DOMBL and RW_URLBL `_).
15 |
16 | Warning: the program extracts the domain names reported into these lists to resolve the IP addresses and uses them for the output. This may result in an overblocking behaviour because these filters should be applied with a more granular level than layer-3 addresses. These lists are not used by default unless explicitly given via the command line `--lists` or `--lists-include` arguments.
17 |
18 | 0.4.1
19 | -----
20 |
21 | - Fix issue with RW_IPBL entries counter.
22 |
23 | It seems that RW_IPBL is having some issues with the number of entries reported in the last line.
24 | If an empty line is found it's counted as an entry, so last line's counter reports a wrong number.
25 | Trying to mitigate this behaviour.
26 |
27 | 0.4.0
28 | -----
29 |
30 | - Add `drop_v6` list (`Spamhaus DROPv6 `_).
31 |
32 | 0.3.0
33 | -----
34 |
35 | - Add `--lists-storage-dir` and `--recover-from-file` arguments to save lists into files and reuse them in case of failure of next updates.
36 |
37 | 0.2.0
38 | -----
39 |
40 | Please note: JSON files saved with the previous version are not compatible with this one; blocklists must be downloaded and saved again to work.
41 |
42 | - Keep track of source blocklist for each entry.
43 | - Add `bl_ids` and `bl_names` macros to the `lines` formatter.
44 | - Add a comment containing the source blocklist to each Mikrotik RouterOS address-list entry.
45 |
46 | 0.1.0
47 | -----
48 |
49 | First release (beta)
50 |
--------------------------------------------------------------------------------
/apply_copyright:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | LEN=`wc -l COPYRIGHT | cut -d " " -f 1`
3 | FIRST_LINE="`head -n 1 COPYRIGHT`"
4 |
5 | function apply_to_file() {
6 | F="$1"
7 | cat COPYRIGHT "$F" > "$F.copyright"
8 | mv "$F.copyright" "$F"
9 | echo "$F - added"
10 | }
11 |
12 | function update_file() {
13 | # update file if only the first line is different
14 | F="$1"
15 |
16 | head -n 1 "$F" | grep "$FIRST_LINE" &>/dev/null
17 |
18 | if [ $? -ne 0 ]; then
19 | DIFF_LINES_NUM=`head -n $LEN "$F" | diff COPYRIGHT - | egrep "^<" | wc -l`
20 |
21 | if [ "$DIFF_LINES_NUM" == "1" ]; then
22 | head -n 1 COPYRIGHT > "$F.copyright"
23 | tail -n +2 "$F" >> "$F.copyright"
24 | mv "$F.copyright" "$F"
25 | echo "$F - updated"
26 | return
27 | fi
28 | fi
29 |
30 | echo "$F - !!!!!!!!!!!!!!!!!!!!!! CAN'T UPDATE !!!!!!!!!!!!!!!!!!!!!!"
31 | }
32 |
33 | function do_file() {
34 | F="$1"
35 |
36 | head -n 1 "$F" | grep "Copyright" | grep "Pier Carlo Chiodi" &>/dev/null
37 |
38 | if [ $? -eq 0 ]; then
39 | # copyright statement already there
40 |
41 | # is the current one?
42 | head -n 1 "$F" | grep "$FIRST_LINE" &>/dev/null
43 |
44 | if [ $? -eq 0 ]; then
45 | echo "$F - ok"
46 | else
47 | # copyright statement outdated
48 | update_file "$F"
49 | fi
50 | else
51 | # copyright statement missing
52 | head -n 1 "$F" | egrep "^#" &>/dev/null
53 |
54 | if [ $? -eq 0 ]; then
55 | echo "$F - !!!!!!!!!!!!!!!!!!!!!! SPECIAL ATTENTION NEEDED !!!!!!!!!!!!!!!!!!!!!!"
56 | else
57 | apply_to_file "$F"
58 | fi
59 | fi
60 | }
61 |
62 | function do_dir() {
63 | DIR="$1"
64 | PATTERN="$2"
65 |
66 | for f in $DIR/$PATTERN
67 | do
68 | if [ -f "$f" ]; then
69 | do_file "$f"
70 | fi
71 | done
72 | }
73 |
74 | function do_subdirs() {
75 | DIR="$1"
76 | PATTERN="$2"
77 |
78 | for d in `find "$DIR" -type d`
79 | do
80 | do_dir "$d" "$PATTERN"
81 | done
82 | }
83 |
84 | do_subdirs "pierky" "*.py"
85 | do_subdirs "scripts" "*"
86 |
--------------------------------------------------------------------------------
/distrib/log.ini:
--------------------------------------------------------------------------------
1 | [loggers]
2 | keys=root
3 |
4 | [formatters]
5 | keys=simple,syslog,file
6 |
7 | [handlers]
8 | keys=stderr,smtp,syslog_udp,syslog_local,file
9 |
10 | [logger_root]
11 | # PLEASE CONFIGURE THE HANDLERS YOU WANT TO USE TO LOG MESSAGES
12 | # AND THE DESIRED LOGGING LEVEL
13 | #
14 | # Custom handlers and formatters are allowed too, within the limits of
15 | # Python's logging facility (https://docs.python.org/2/library/logging.config.html)
16 |
17 | # levels: DEBUG, INFO, WARN, ERROR, CRITICAL
18 | level=INFO
19 |
20 | # one or more (comma delimited) of the following handlers:
21 | #
22 | # stderr, smtp, syslog_udp, syslog_local, file,
23 | #
24 | handlers=stderr
25 |
26 | [formatter_simple]
27 | format=BlockListsAggregator %(asctime)s %(levelname)s %(message)s
28 |
29 | [formatter_syslog]
30 | format=BlockListsAggregator[%(process)d]: %(levelname)s %(message)s
31 |
32 | [formatter_file]
33 | format=%(asctime)s %(levelname)s %(message)s
34 |
35 | [handler_stderr]
36 | class=StreamHandler
37 | formatter=simple
38 | args=(sys.stderr,)
39 |
40 | [handler_smtp]
41 | class=handlers.SMTPHandler
42 | level=WARN
43 | formatter=simple
44 |
45 | # PLEASE CONFIGURE THE FOLLOWING ARGUMENTS
46 | # (if you add 'smtp' to the root logger's handlers)
47 | # -------------------------------------------------
48 |
49 | # without TLS:
50 | args=(('SMTP_SERVER', 25), 'from@yourdomain.tld', ['to@yourdomain.tld'], 'BlockLists Aggregator error', ('username', 'password'))
51 |
52 | # with TLS:
53 | #args=(('SMTP_SERVER', 25), 'from@yourdomain.tld', ['to@yourdomain.tld'], 'BlockLists Aggregator error', ('username', 'password'), ())
54 |
55 | [handler_syslog_udp]
56 | class=handlers.SysLogHandler
57 | level=WARN
58 | formatter=syslog
59 |
60 | # PLEASE CONFIGURE THE FOLLOWING ARGUMENTS
61 | # (if you add 'syslog_udp' to the root logger's handlers)
62 | # -------------------------------------------------------
63 |
64 | args=(('SYSLOG_SERVER_HOST', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
65 |
66 | [handler_syslog_local]
67 | class=handlers.SysLogHandler
68 | level=WARN
69 | formatter=syslog
70 |
71 | # PLEASE CONFIGURE THE FOLLOWING ARGUMENTS
72 | # (if you add 'syslog_local' to the root logger's handlers)
73 | # ---------------------------------------------------------
74 | args=('/dev/log', handlers.SysLogHandler.LOG_USER)
75 |
76 | [handler_file]
77 | class=FileHandler
78 | formatter=file
79 |
80 | # PLEASE CONFIGURE THE FOLLOWING ARGUMENTS
81 | # (if you add 'file' to the root logger's handlers)
82 | # -------------------------------------------------
83 | args=('blocklistsaggregator.log', 'a')
84 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/formatters/mikrotik.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | from .base_formatter import Formatter
17 | from ..lists import get_bl_names
18 |
19 |
20 | class MikrotikFormatter(Formatter):
21 |
22 | ID = "mikrotik"
23 |
24 | def __init__(self, args):
25 | self.address_list_name = args.mikrotik_address_list_name
26 | self.remove_before_adding = args.mikrotik_remove_before_adding
27 |
28 | @staticmethod
29 | def add_args(parser):
30 | group = parser.add_argument_group(
31 | title="Mikrotik RouterOS output options"
32 | )
33 |
34 | group.add_argument(
35 | "--mikrotik-address-list-name",
36 | help="Address list name. Default: 'block_list'.",
37 | default="block_list"
38 | )
39 |
40 | group.add_argument(
41 | "--mikrotik-remove-before-adding",
42 | help="Add a 'remove' statement before the 'add'. "
43 | "Default: False.",
44 | action="store_true",
45 | default=False
46 | )
47 |
48 | def emit(self, entries, output):
49 | for v4v6 in (4, 6):
50 | output.write("/{} firewall address-list\n".format(
51 | "ip" if v4v6 == 4 else "ipv6"
52 | ))
53 |
54 | if self.remove_before_adding:
55 | output.write("remove [find list=""{}""]\n".format(
56 | self.address_list_name
57 | ))
58 | for entry in entries["v{}".format(v4v6)]:
59 | output.write(
60 | """add list={} address="{}" comment="{}"\n""".format(
61 | self.address_list_name, str(entry),
62 | ", ".join(
63 | get_bl_names(
64 | entries["unique"][str(entry)]["bl_ids"]
65 | )
66 | )
67 | )
68 | )
69 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | import os
2 | from os.path import abspath, dirname, join
3 | from setuptools import setup, find_packages
4 |
5 | """
6 | New release procedure
7 |
8 | - edit pierky/blocklistsaggregator/version.py
9 |
10 | - edit CHANGES.rst
11 |
12 | - verify RST syntax is ok
13 | python setup.py --long-description | rst2html.py --strict
14 |
15 | - new files to be added to MANIFEST.in?
16 |
17 | - python setup.py sdist
18 |
19 | - twine upload dist/*
20 |
21 | - git push
22 |
23 | - edit new release on GitHub
24 | """
25 |
26 | __version__ = None
27 |
28 | # Allow setup.py to be run from any path
29 | os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
30 |
31 | # Get proper long description for package
32 | current_dir = dirname(abspath(__file__))
33 | description = open(join(current_dir, "README.rst")).read()
34 | changes = open(join(current_dir, "CHANGES.rst")).read()
35 | long_description = '\n\n'.join([description, changes])
36 | exec(open(join(current_dir, "pierky/blocklistsaggregator/version.py")).read())
37 |
38 | # Get the long description from README.md
39 | setup(
40 | name="blocklistsaggregator",
41 | version=__version__,
42 |
43 | packages=["pierky", "pierky.blocklistsaggregator"],
44 | namespace_packages=["pierky"],
45 | include_package_data=True,
46 |
47 | license="GPLv3",
48 | description="A Python tool that downloads IP block lists from various sources and builds configurations for network equipments and firewalls.",
49 | long_description=long_description,
50 | url="https://github.com/pierky/blocklistsaggregator",
51 | download_url="https://github.com/pierky/blocklistsaggregator",
52 |
53 | author="Pier Carlo Chiodi",
54 | author_email="pierky@pierky.com",
55 | maintainer="Pier Carlo Chiodi",
56 | maintainer_email="pierky@pierky.com",
57 |
58 | install_requires=[
59 | "netaddr",
60 | "six"
61 | ],
62 |
63 | scripts=["scripts/blocklistsaggregator"],
64 |
65 | keywords=['Malware', 'Spam', 'BlockList', 'Networking'],
66 |
67 | classifiers=[
68 | "Development Status :: 4 - Beta",
69 |
70 | "Environment :: Console",
71 |
72 | "Intended Audience :: Information Technology",
73 | "Intended Audience :: System Administrators",
74 | "Intended Audience :: Telecommunications Industry",
75 |
76 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
77 |
78 | "Operating System :: POSIX",
79 | "Operating System :: Unix",
80 |
81 | "Programming Language :: Python",
82 | "Programming Language :: Python :: 2.7",
83 | "Programming Language :: Python :: 3.4",
84 |
85 | "Topic :: Internet :: WWW/HTTP",
86 | "Topic :: System :: Networking",
87 | "Topic :: System :: Networking :: Firewalls",
88 | "Topic :: Security"
89 | ],
90 | )
91 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/lists/base_list.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | try:
17 | # For Python 3.0 and later
18 | from urllib.request import urlopen
19 | except ImportError:
20 | # Fall back to Python 2's urllib2
21 | from urllib2 import urlopen
22 |
23 | from netaddr import IPNetwork
24 |
25 | from ..errors import BlockListProcessingError
26 |
27 |
28 | class BlockList(object):
29 | ID = None
30 | URL = None
31 | NAME = None
32 | COMMENT = "#"
33 | USE_BY_DEFAULT = True
34 |
35 | def __init__(self):
36 | self.raw_data = None
37 | self.raw_entries = []
38 | self.entries = []
39 |
40 | def load(self):
41 | try:
42 | self.fetch()
43 | except Exception as e:
44 | raise BlockListProcessingError(
45 | "Error while fetching the blocklist's data - {}".format(
46 | str(e)
47 | )
48 | )
49 |
50 | try:
51 | self.parse()
52 | except Exception as e:
53 | raise BlockListProcessingError(
54 | "Error while processing the blocklist's data - {}".format(
55 | str(e)
56 | )
57 | )
58 |
59 | try:
60 | self.verify()
61 | except Exception as e:
62 | raise BlockListProcessingError(
63 | "Error while verifying the blocklist's data - {}".format(
64 | str(e)
65 | )
66 | )
67 |
68 | def fetch(self):
69 | if not self.URL:
70 | raise NotImplementedError()
71 | response = urlopen(self.URL)
72 | self.raw_data = response.read().decode("utf-8")
73 | self.raw_entries = self.raw_data.split("\n")
74 |
75 | def parse(self):
76 | for entry in self.raw_entries:
77 | entry = entry.strip()
78 | if not entry or entry[0] == self.COMMENT:
79 | continue
80 | self.parse_entry(entry)
81 |
82 | def parse_entry(self, entry):
83 | try:
84 | ip = IPNetwork(entry)
85 | except:
86 | raise ValueError("Incorrect IP address/net: {}".format(entry))
87 | self.entries.append(ip)
88 |
89 | def _verify(self):
90 | pass
91 |
92 | def verify(self):
93 | try:
94 | if not self.raw_data:
95 | raise ValueError("No data")
96 |
97 | if len([_ for _ in self.raw_entries if _]) == 0:
98 | raise ValueError("Empty list of raw entries")
99 |
100 | self._verify()
101 |
102 | except Exception as e:
103 | raise ValueError(
104 | "Can't determine the expected num. of entries - {}.".format(
105 | str(e)
106 | )
107 | )
108 |
109 | def load_from_file(self, path):
110 | with open(path, "r") as f:
111 | lines = f.readlines()
112 | for line in lines:
113 | if not line:
114 | continue
115 | self.entries.append(IPNetwork(line))
116 |
117 | def save_to_file(self, path):
118 | with open(path, "w") as f:
119 | for entry in self.entries:
120 | f.write("{}\n".format(str(entry)))
121 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/formatters/lines.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | from .base_formatter import Formatter
17 | from ..lists import get_bl_names
18 |
19 |
20 | class LinesFormatter(Formatter):
21 |
22 | ID = "lines"
23 |
24 | def __init__(self, args):
25 | self.line_format = args.lines_format
26 | self.show_macros = args.lines_show_macros
27 |
28 | @staticmethod
29 | def add_args(parser):
30 | group = parser.add_argument_group(
31 | title="Lines output options"
32 | )
33 |
34 | group.add_argument(
35 | "--lines-format",
36 | help="Output line format: can contain a list of macros that "
37 | "are expanded with block list entries' properties. The "
38 | "list of these macros can be viewed using the "
39 | "--lines-show-macros option. Default: '{prefix}'.",
40 | default="{prefix}",
41 | metavar="LINE_FORMAT"
42 | )
43 |
44 | group.add_argument(
45 | "--lines-show-macros",
46 | help="Do not process block lists but only display all the "
47 | "macros that can be used to form the output lines.",
48 | action="store_true"
49 | )
50 |
51 | def init(self):
52 | if self.show_macros:
53 | print("""
54 | {prefix} IPv4 or IPv6 prefix, in CIDR format.
55 | Ex.: 192.0.2.0/24, 2001:db8::/32
56 |
57 | {ip} IPv4 or IPv6 address.
58 | Ex.: 192.0.2.1, 2001:db8::1
59 |
60 | {network} IPv4 or IPv6 network ID.
61 | Ex.: 192.0.2.0, 2001:db8::
62 |
63 | {netmask} IPv4 or IPv6 netmask.
64 | Ex.: 255.255.255.0, ffff:ffff::
65 |
66 | {prefixlen} IPv4 or IPv6 CIDR prefix length.
67 | Ex.: 32, 24, 128, 64
68 |
69 | {hostmask} IPv4 or IPv6 hostmask (wildcard).
70 | Ex.: 0.0.0.255, ::ffff:ffff:ffff:ffff:ffff:ffff
71 |
72 | {broadcast} IPv4 or IPv6 broadcast address.
73 | Ex.: 192.0.2.255, 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff
74 |
75 | {version} IP version, 4 or 6.
76 |
77 | {ip_ipv6} 'ip' string in case of an IPv6 entry, 'ipv6' otherwise.
78 |
79 | {bl_ids} List of blocklist IDs where the prefix has been found.
80 |
81 | {bl_names} List of blocklist names where the prefix has been found.
82 | """)
83 | return False
84 |
85 | return True
86 |
87 | def emit(self, entries, output):
88 | tpl = self.line_format + "\n"
89 | try:
90 | for v4v6 in (4, 6):
91 | for entry in entries["v{}".format(v4v6)]:
92 | bl_ids = entries["unique"][str(entry)]["bl_ids"]
93 |
94 | output.write(tpl.format(
95 | prefix=str(entry),
96 | ip=str(entry.ip),
97 | network=str(entry.network),
98 | netmask=str(entry.netmask),
99 | prefixlen=str(entry.prefixlen),
100 | hostmask=str(entry.hostmask),
101 | broadcast=str(entry.broadcast),
102 | version=str(entry.version),
103 | ip_ipv6="ip" if entry.version == 4 else "ipv6",
104 | bl_ids=", ".join(bl_ids),
105 | bl_names=", ".join(get_bl_names(bl_ids))
106 | ))
107 | except KeyError as e:
108 | raise ValueError("Unknown macro: {}".format(str(e)))
109 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | IP Block Lists Aggregator
2 | =========================
3 |
4 | A Python tool that downloads IP block lists from various sources and builds configurations for network equipments and firewalls.
5 |
6 | Installation
7 | ------------
8 |
9 | Installation using ``pip``:
10 |
11 | .. code:: bash
12 |
13 | $ pip install blocklistsaggregator
14 |
15 | Editable Installation using your GitHub forked repository and ``virtualenv``:
16 |
17 | .. code:: bash
18 |
19 | $ mkdir blocklistsaggregator
20 | $ cd blocklistsaggregator
21 | $ virtualenv venv
22 | $ source venv/bin/activate
23 | $ pip install -e git+https://github.com/YOUR_USERNAME/blocklistsaggregator.git#egg=blocklistsaggregator
24 |
25 | Usage
26 | -----
27 |
28 | It's a command line tool, the ``--help`` is your friend! Some examples are worth a thousand words.
29 |
30 | - Download and display entries from all the configured block lists:
31 |
32 | .. code:: bash
33 |
34 | $ blocklistsaggregator.py
35 |
36 | - Only from `Ransomware Tracker RW_IPBL `_ and `DROP `_:
37 |
38 | .. code:: bash
39 |
40 | $ blocklistsaggregator.py --lists rw_ipbl drop
41 |
42 | - Download entries from all the configured lists and save them in JSON format into ``all.json``:
43 |
44 | .. code:: bash
45 |
46 | $ blocklistsaggregator.py -f json -o all.json
47 |
48 | - Read the previously saved entries from ``all.json`` and display them in a Cisco IOS prefix-list style:
49 |
50 | .. code:: bash
51 |
52 | $ blocklistsaggregator.py -i all.json -f cisco-ios
53 |
54 | - From the previously saved entries, filter out those falling in 6.0.0.0/8 and those with a prefix-len shorter than /24 and save them into ``cisco.acl`` in a Cisco ACL style with name *BADGUYS*:
55 |
56 | .. code:: bash
57 |
58 | $ blocklistsaggregator.py -i all.json --exclude 6.0.0.0/8 --exclude-ipv4-shorter-than 24 -o cisco.acl -f cisco-ios --cisco-cfg-element acl_source --cisco-cfg-element-name BADGUYS
59 |
60 | - Prepare an ``ip route null0`` command for each IPv4 entry in `DROP `_:
61 |
62 | .. code:: bash
63 |
64 | $ blocklistsaggregator.py --lists drop -4 --lines-format "ip route {network} {netmask} null0"
65 |
66 | - Download standard block lists and output them in a Mikrotik address-list format into ``addMalwareIPs.rsc``; save lists into ``/tmp`` and, in case of failure during one of the next executions, reuse them to build the output:
67 |
68 | .. code:: bash
69 |
70 | $ blocklistsaggregator --output addMalwareIPs.rsc --output-format mikrotik --mikrotik-address-list-name addressListMalware --lists-storage-dir /tmp/ --recover-from-file
71 |
72 | Logging
73 | +++++++
74 |
75 | Error logging and reporting can be configured in order to have feedback about BlockListsAggregator's activity. The ``--logging-config-file`` option can be set to the path of a configuration file in `Python's logging.fileConfig() format `_. An example is provided within the ``distrib/log.ini`` file (`here the file hosted on GitHub `_).
76 |
77 | Source block lists
78 | ++++++++++++++++++
79 |
80 | The following block lists are currenly implemented:
81 |
82 | - rw_ipbl, `Ransomware Tracker RW_IPBL `_
83 | - rw_dombl, `Ransomware Tracker RW_DOMBL `_ (please read below)
84 | - rw_urlbl, `Ransomware Tracker RW_URLBL `_ (please read below)
85 | - drop, `Spamhaus DROP `_
86 | - drop_v6, `Spamhaus DROPv6 `_
87 | - edrop, `Spamhaus EDROP `_
88 | - feodo_badip, `Feodo BadIP `_
89 | - feodo_ip, `Feodo IP `_
90 | - palevo, `Palevo C&C `_
91 | - zeus, `ZeuS `_
92 | - bambenek_c2, `Bambenek Consulting C2 master feed `_
93 |
94 | **Warning for RW_DOMBL and RW_URLBL**: the program extracts the domain names reported into these lists to resolve the IP addresses and uses them for the output. This may result in an overblocking behaviour because these filters should be applied with a more granular level than layer-3 addresses. These lists are not used by default unless explicitly given via the command line `--lists` or `--lists-include` arguments.
95 |
96 | A list of block-lists can be found on http://iplists.firehol.org/
97 |
98 | Output options
99 | ++++++++++++++
100 |
101 | The following output formats are currenly implemented:
102 |
103 | - JSON
104 | - lines (with macros)
105 | - Cisco IOS prefix-list
106 | - Cisco IOS ACL (source-based, destination-based, permit/deny actions)
107 | - Mikrotik RouterOS address-list
108 |
109 | Status
110 | ------
111 |
112 | This tool is currently in **beta**: some field tests have been done but it needs to be tested deeply and on more scenarios.
113 |
114 | Moreover, contributions (fixes to code and to grammatical errors, typos, new features) are very much appreciated.
115 |
116 | Bug? Issues?
117 | ------------
118 |
119 | But also suggestions? New ideas?
120 |
121 | Please create an issue on GitHub at https://github.com/pierky/blocklistsaggregator/issues
122 |
123 | Author
124 | ------
125 |
126 | Pier Carlo Chiodi - https://pierky.com
127 |
128 | Blog: https://blog.pierky.com Twitter: `@pierky `_
129 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/formatters/cisco.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | from .base_formatter import Formatter
17 |
18 |
19 | class CiscoFormatter(Formatter):
20 |
21 | ID = "cisco-ios"
22 |
23 | def __init__(self, args):
24 | self.cfg_element = args.cisco_cfg_element
25 | self.cfg_element_name = args.cisco_cfg_element_name
26 | self.cfg_element_action = args.cisco_cfg_element_action
27 | self.remove_before_adding = args.cisco_remove_before_adding
28 |
29 | @staticmethod
30 | def add_args(parser):
31 | group = parser.add_argument_group(
32 | title="Cisco IOS output options"
33 | )
34 |
35 | group.add_argument(
36 | "--cisco-cfg-element",
37 | help="Type of configuration element to build. "
38 | "Default: 'prefix-list'.",
39 | choices=["prefix-list", "acl_source", "acl_dest"],
40 | default="prefix-list"
41 | )
42 |
43 | group.add_argument(
44 | "--cisco-cfg-element-name",
45 | help="Name of the configuration element to build. "
46 | "Default: 'block_list'.",
47 | default="block_list"
48 | )
49 |
50 | group.add_argument(
51 | "--cisco-cfg-element-action",
52 | help="Action of the prefix-list/ACL. Default: 'permit'.",
53 | choices=["permit", "deny"],
54 | default="deny"
55 | )
56 |
57 | group.add_argument(
58 | "--cisco-remove-before-adding",
59 | help="Add a 'no ' statement before the "
60 | "statements that build the new configuration block. "
61 | "Default: False.",
62 | action="store_true",
63 | default=False
64 | )
65 |
66 | def _emit_prefix_list(self, entries, output, v4v6):
67 | ip_or_ipv6 = "ip" if v4v6 == 4 else "ipv6"
68 |
69 | if self.remove_before_adding:
70 | output.write("no {} prefix-list {}\n".format(
71 | ip_or_ipv6, self.cfg_element_name
72 | ))
73 |
74 | for entry in entries["v{}".format(v4v6)]:
75 | output.write("{} prefix-list {} {} {}\n".format(
76 | ip_or_ipv6,
77 | self.cfg_element_name,
78 | self.cfg_element_action,
79 | str(entry)
80 | ))
81 |
82 | def _emit_acl(self, entries, output, v4v6, src_or_dst):
83 | tpl_remove = ""
84 | tpl_create = ""
85 | tpl_ace = ""
86 | tpl_last_ace = ""
87 |
88 | if v4v6 == 4 and src_or_dst == "src":
89 | tpl_remove = "no ip access-list standard {name}\n"
90 | tpl_create = "ip access-list standard {name}\n"
91 | tpl_ace = "{action} {host_addr_or_net_wildcard}\n"
92 | if self.cfg_element_action == "deny":
93 | tpl_last_ace = "permit any\n"
94 | elif v4v6 == 4 and src_or_dst == "dst":
95 | tpl_remove = "no ip access-list extended {name}\n"
96 | tpl_create = "ip access-list extended {name}\n"
97 | tpl_ace = "{action} ip any {host_addr_or_net_wildcard}\n"
98 | if self.cfg_element_action == "deny":
99 | tpl_last_ace = "permit ip any any\n"
100 | elif v4v6 == 6:
101 | tpl_remove = "no ipv6 access-list {name}\n"
102 | tpl_create = "ipv6 access-list {name}\n"
103 | if src_or_dst == "src":
104 | tpl_ace = "{action} {prefix} any\n"
105 | else:
106 | tpl_ace = "{action} any {prefix}\n"
107 | if self.cfg_element_action == "deny":
108 | tpl_last_ace = "permit any any\n"
109 |
110 | if self.remove_before_adding:
111 | output.write(tpl_remove.format(name=self.cfg_element_name))
112 |
113 | output.write(tpl_create.format(name=self.cfg_element_name))
114 |
115 | for entry in entries["v{}".format(v4v6)]:
116 | host_addr_or_net_wildcard = ""
117 | if entry.version == 4:
118 | if entry.prefixlen == 32:
119 | host_addr_or_net_wildcard = "host {}".format(str(entry.ip))
120 | else:
121 | host_addr_or_net_wildcard = "{} {}".format(
122 | str(entry.ip), str(entry.hostmask)
123 | )
124 |
125 | output.write(tpl_ace.format(
126 | action=self.cfg_element_action,
127 | host_addr_or_net_wildcard=host_addr_or_net_wildcard,
128 | prefix=str(entry)
129 | ))
130 |
131 | output.write(tpl_last_ace)
132 |
133 | def emit(self, entries, output):
134 | for v4v6 in (4, 6):
135 | if self.cfg_element == "prefix-list":
136 | self._emit_prefix_list(entries, output, v4v6)
137 | elif self.cfg_element == "acl_source":
138 | self._emit_acl(entries, output, v4v6, "src")
139 | elif self.cfg_element == "acl_dest":
140 | self._emit_acl(entries, output, v4v6, "dst")
141 |
--------------------------------------------------------------------------------
/pierky/blocklistsaggregator/lists/abuse_ch.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2016 Pier Carlo Chiodi
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | import os
17 | import socket
18 | import sys
19 | try:
20 | # For Python 3.0 and later
21 | from urllib.parse import urlparse
22 | except ImportError:
23 | # Fall back to Python 2's urllib2
24 | from urlparse import urlparse
25 |
26 | from netaddr import IPNetwork
27 |
28 | from .base_list import BlockList
29 | from ..sanitisers import sanitise
30 |
31 |
32 | class Feodo_List(BlockList):
33 |
34 | def _verify(self):
35 | last_entry = [line for line in self.raw_entries if line][-1]
36 | if last_entry.startswith("# END"):
37 | cnt = last_entry.split("(")[1].split(" ")[0]
38 |
39 | if not cnt.isdigit():
40 | raise ValueError(
41 | "Can't parse entries summary: {}".format(last_entry)
42 | )
43 |
44 | if int(cnt) != len(self.entries):
45 | raise ValueError(
46 | "The number of parsed entries ({}) does not "
47 | "match the expected one ({})".format(
48 | len(self.entries),
49 | int(cnt)
50 | )
51 | )
52 | else:
53 | return
54 |
55 | raise ValueError("Can't find entries summary")
56 |
57 |
58 | class Feodo_BadIP_List(Feodo_List):
59 | ID = "feodo_badip"
60 | URL = "https://feodotracker.abuse.ch/blocklist/?download=badips"
61 | NAME = "Feodo BadIP"
62 |
63 |
64 | class Feodo_IP_List(Feodo_List):
65 | ID = "feodo_ip"
66 | URL = "https://feodotracker.abuse.ch/blocklist/?download=ipblocklist"
67 | NAME = "Feodo IP"
68 |
69 |
70 | class RW_List(BlockList):
71 |
72 | def __init__(self):
73 | BlockList.__init__(self)
74 |
75 | self._expected_entries = None
76 |
77 | @property
78 | def expected_entries(self):
79 | if self._expected_entries:
80 | return self._expected_entries
81 |
82 | self._expected_entries = self._get_entries_summary()
83 | return self._expected_entries
84 |
85 | def _get_entries_summary(self):
86 | last_entry = [line for line in self.raw_entries if line][-1]
87 | if last_entry[0] == self.COMMENT:
88 | if "entries" in last_entry:
89 | cnt = last_entry.split(" ")[1]
90 | if not cnt.isdigit():
91 | raise ValueError(
92 | "Can't parse entries summary: {}".format(
93 | last_entry
94 | )
95 | )
96 | cnt = int(cnt)
97 |
98 | # It seems that RW_IPBL is having some issues with the
99 | # number of entries reported in the last line.
100 | # If an empty line is found it's counted as an entry, so
101 | # last line's counter reports a wrong number.
102 | # Trying to mitigate this behaviour.
103 |
104 | # raw data format block_idx
105 | #
106 | # ############################################ block_idx = 1
107 | # # comments block_idx = 2
108 | # ############################################ block_idx = 3
109 | # entries block_idx = 4
110 | # # xxx entries block_idx = 5
111 |
112 | empty_entry_found = False
113 | block_idx = 0
114 | for entry in self.raw_entries:
115 | entry = entry.strip()
116 | if entry.startswith(self.COMMENT * 10):
117 | if block_idx == 0:
118 | block_idx = 1
119 | elif block_idx == 2:
120 | block_idx = 3
121 | elif entry.startswith(self.COMMENT):
122 | if "entries" not in entry and block_idx == 1:
123 | block_idx = 2
124 | elif "entries" in entry and block_idx == 4:
125 | block_idx = 5
126 | elif block_idx == 3:
127 | block_idx = 4
128 |
129 | if not entry and block_idx == 4:
130 | empty_entry_found = True
131 | break
132 |
133 | if empty_entry_found:
134 | cnt = cnt - 1
135 |
136 | return cnt
137 |
138 | raise ValueError("Can't find entries summary")
139 |
140 | def _get_parsed_entries_cnt(self):
141 | return len(self.entries)
142 |
143 | def _verify(self):
144 | parsed_entries_cnt = self._get_parsed_entries_cnt()
145 |
146 | if self.expected_entries != parsed_entries_cnt:
147 | raise ValueError(
148 | "The number of parsed entries ({}) does not "
149 | "match the expected one ({})".format(
150 | parsed_entries_cnt,
151 | self.expected_entries
152 | )
153 | )
154 |
155 |
156 | class RW_IPBL_List(RW_List):
157 | ID = "rw_ipbl"
158 | URL = "https://ransomwaretracker.abuse.ch/downloads/RW_IPBL.txt"
159 | NAME = "Ransomware tracker RW_IPBL"
160 |
161 |
162 | class RW_DomBL_List(RW_List):
163 | ID = "rw_dombl"
164 | URL = "https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt"
165 | NAME = "Ransomware tracker RW_DOMBL"
166 | USE_BY_DEFAULT = False
167 |
168 | def __init__(self):
169 | RW_List.__init__(self)
170 | self.parsed_entries = 0
171 | self.processed_entries = 0
172 | self.resolved_domainnames = []
173 |
174 | def _get_parsed_entries_cnt(self):
175 | return self.parsed_entries
176 |
177 | def _resolve_domainname(self, domainname):
178 | if domainname in self.resolved_domainnames:
179 | return
180 |
181 | self.resolved_domainnames.append(domainname)
182 |
183 | try:
184 | for info in socket.getaddrinfo(
185 | domainname,
186 | None, 0, socket.IPPROTO_TCP
187 | ):
188 | resolved_addr = info[4][0]
189 |
190 | try:
191 | ip = IPNetwork(resolved_addr)
192 | self.entries.append(ip)
193 | except:
194 | raise ValueError(
195 | "Resolved IP address is invalid: {}".format(
196 | resolved_addr
197 | )
198 | )
199 |
200 | except socket.gaierror:
201 | pass
202 |
203 | except Exception as e:
204 | raise ValueError(
205 | "Can't resolve {} - {}".format(domainname, str(e))
206 | )
207 |
208 | def _provide_processing_entry_feedback(self, entry):
209 | self.processed_entries += 1
210 | if os.isatty(sys.stdout.fileno()):
211 | if self.processed_entries > 1:
212 | sys.stdout.write("\033[F")
213 | sys.stdout.write("\r\033[KProcessing entry {}/{} ({})...\n".format(
214 | self.processed_entries,
215 | self.expected_entries,
216 | sanitise(entry)
217 | ))
218 |
219 | def parse_entry(self, entry):
220 | self._provide_processing_entry_feedback(entry)
221 | self._resolve_domainname(entry)
222 | self.parsed_entries += 1
223 |
224 |
225 | class RW_URLBL_List(RW_DomBL_List):
226 | ID = "rw_urlbl"
227 | URL = "https://ransomwaretracker.abuse.ch/downloads/RW_URLBL.txt"
228 | NAME = "Ransomware tracker RW_URLBL"
229 | USE_BY_DEFAULT = False
230 |
231 | def parse_entry(self, entry):
232 | self._provide_processing_entry_feedback(entry)
233 |
234 | try:
235 | url_parts = urlparse(entry)
236 |
237 | if not url_parts.netloc:
238 | raise ValueError("Can't extract netloc from URL {}".format(
239 | entry
240 | ))
241 |
242 | if ":" in url_parts.netloc:
243 | domainname = url_parts.split(":")[0]
244 | else:
245 | domainname = url_parts.netloc
246 |
247 | self._resolve_domainname(domainname)
248 | self.parsed_entries += 1
249 |
250 | except Exception as e:
251 | raise ValueError("Can't parse URL {} - {}".format(entry, str(e)))
252 |
253 |
254 | class Palevo_CC_List(BlockList):
255 | ID = "palevo"
256 | URL = "https://palevotracker.abuse.ch/blocklists.php?download=ipblocklist"
257 | NAME = "Palevo C&C"
258 |
259 |
260 | class Zeus_IP_List(BlockList):
261 | ID = "zeus"
262 | URL = "https://zeustracker.abuse.ch/blocklist.php?download=ipblocklist"
263 | NAME = "Zeus IP"
264 |
--------------------------------------------------------------------------------
/scripts/blocklistsaggregator:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # Copyright (C) 2016 Pier Carlo Chiodi
4 | #
5 | # This program is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import argparse
19 | import json
20 | import logging
21 | from logging.config import fileConfig
22 | import os.path
23 |
24 | from netaddr import IPNetwork
25 |
26 | from pierky.blocklistsaggregator.lists import BlockLists, get_bl_from_id
27 | from pierky.blocklistsaggregator.formatters import Formatters, \
28 | get_formatter_from_id
29 | from pierky.blocklistsaggregator.version import __version__, COPYRIGHT_YEAR
30 |
31 | logging.basicConfig(level=logging.INFO)
32 | logger = logging.getLogger()
33 |
34 |
35 | def validate_prefix(prefix):
36 | try:
37 | ip = IPNetwork(prefix)
38 | return ip
39 | except:
40 | raise argparse.ArgumentTypeError(
41 | "Invalid IP prefix: {}".format(prefix)
42 | )
43 |
44 |
45 | def add_prefix(args, ipnetwork_or_string, bl_ids, entries):
46 | try:
47 | if ipnetwork_or_string is IPNetwork:
48 | prefix = ipnetwork_or_string
49 | else:
50 | prefix = IPNetwork(ipnetwork_or_string)
51 |
52 | if str(prefix) in entries["unique"]:
53 | if isinstance(bl_ids, list):
54 | entries["unique"][str(prefix)]["bl_ids"].update(bl_ids)
55 | else:
56 | entries["unique"][str(prefix)]["bl_ids"].add(bl_ids)
57 | return "duplicate"
58 |
59 | if prefix.version == 4 and args.v6_only:
60 | return "filtered"
61 | if prefix.version == 6 and args.v4_only:
62 | return "filtered"
63 |
64 | if args.only_global_unicast_addresses:
65 | if not prefix.is_unicast() or prefix.is_private():
66 | return "filtered"
67 |
68 | if prefix.version == 4:
69 | if prefix.prefixlen < args.exclude_ipv4_shorter_than:
70 | return "filtered"
71 | elif prefix.version == 6:
72 | if prefix.prefixlen < args.exclude_ipv6_shorter_than:
73 | return "filtered"
74 |
75 | for excluded_prefix in args.exclude:
76 | if prefix in excluded_prefix or prefix == excluded_prefix:
77 | return "filtered"
78 |
79 | entries["v{}".format(prefix.version)].append(prefix)
80 | entries["unique"][str(prefix)] = {
81 | "bl_ids": set()
82 | }
83 | if isinstance(bl_ids, list):
84 | entries["unique"][str(prefix)]["bl_ids"] = set(bl_ids)
85 | else:
86 | entries["unique"][str(prefix)]["bl_ids"].add(bl_ids)
87 | except Exception as e:
88 | logger.info("Error processing entry '{}', skipping it - {}".format(
89 | str(e), ipnetwork_or_string
90 | ))
91 | return "error"
92 |
93 | return "ok"
94 |
95 |
96 | def main():
97 | parser = argparse.ArgumentParser(
98 | description="IP Block Lists Aggregator v{}".format(__version__),
99 | epilog="Copyright (c) {} - Pier Carlo Chiodi - "
100 | "https://pierky.com".format(COPYRIGHT_YEAR))
101 |
102 | parser.add_argument(
103 | "-i", "--input",
104 | help="JSON file to read entries from (instead of fetching them "
105 | "from online block lists feeds). Use '-' to read from stdin.",
106 | type=argparse.FileType("r")
107 | )
108 |
109 | parser.add_argument(
110 | "-o", "--output",
111 | help="Output file. Default: '-' (stdout).",
112 | type=argparse.FileType("w"),
113 | default="-"
114 | )
115 |
116 | output_formats = []
117 | for formatter_class in Formatters:
118 | output_formats.append(formatter_class.ID)
119 |
120 | parser.add_argument(
121 | "-f", "--output-format",
122 | help="Output format. Default: 'lines'.",
123 | choices=output_formats,
124 | default="lines"
125 | )
126 |
127 | parser.add_argument(
128 | "--logging-config-file",
129 | help="Logging configuration file, in Python fileConfig() format ("
130 | "https://docs.python.org/2/library/logging.config.html"
131 | "#configuration-file-format)"
132 | )
133 |
134 | parser.add_argument(
135 | "--lists-storage-dir",
136 | help="Save parsed lists into the DIR directory.",
137 | metavar="DIR"
138 | )
139 | parser.add_argument(
140 | "--recover-from-file",
141 | help="In case of failure while processing new lists load entries "
142 | "from previously saved files. Requires --lists-storage-dir.",
143 | action="store_true"
144 | )
145 |
146 | # ----------------------------------------
147 | group = parser.add_argument_group(
148 | title="Source lists"
149 | )
150 |
151 | list_ids = [bl_class.ID for bl_class in BlockLists]
152 | use_by_default_list_ids = [bl_class.ID
153 | for bl_class in BlockLists
154 | if bl_class.USE_BY_DEFAULT]
155 | group.add_argument(
156 | "--lists",
157 | help="Block lists to use. One or more of the following: {}. "
158 | "Default: all except {}.".format(
159 | ", ".join(list_ids),
160 | ", ".join([bl_id
161 | for bl_id in list_ids
162 | if bl_id not in use_by_default_list_ids])
163 | ),
164 | nargs="*",
165 | choices=list_ids,
166 | default=use_by_default_list_ids,
167 | dest="lists",
168 | metavar="LIST_ID"
169 | )
170 |
171 | group.add_argument(
172 | "--lists-include",
173 | help="Add the given LIST_ID to the block lists set "
174 | "expected for --lists.",
175 | nargs="*",
176 | choices=list_ids,
177 | dest="lists_include",
178 | metavar="LIST_ID"
179 | )
180 |
181 | group.add_argument(
182 | "--lists-exclude",
183 | help="Remove the given LIST_ID from the block lists set "
184 | "expected for --lists.",
185 | nargs="*",
186 | choices=list_ids,
187 | dest="lists_exclude",
188 | metavar="LIST_ID"
189 | )
190 |
191 | # ----------------------------------------
192 | group = parser.add_argument_group(
193 | title="Filters"
194 | )
195 |
196 | group.add_argument(
197 | "-4", "--ipv4-only",
198 | help="Only IPv4 entries will be processed.",
199 | action="store_true",
200 | dest="v4_only"
201 | )
202 |
203 | group.add_argument(
204 | "-6", "--ipv6-only",
205 | help="Only IPv6 entries will be processed.",
206 | action="store_true",
207 | dest="v6_only"
208 | )
209 |
210 | group.add_argument(
211 | "--exclude-ipv4-shorter-than",
212 | help="Exclude IPv4 prefixes whose length is shorter than X. "
213 | "Default: 0.",
214 | default=0,
215 | type=int,
216 | metavar="X"
217 | )
218 |
219 | group.add_argument(
220 | "--exclude-ipv6-shorter-than",
221 | help="Exclude IPv6 prefixes whose length is shorter than X. "
222 | "Default: 0.",
223 | default=0,
224 | type=int,
225 | metavar="X"
226 | )
227 |
228 | group.add_argument(
229 | "--exclude",
230 | help="Exclude block list entries whose prefix falls whithin one of "
231 | "the prefixes that are listed here. Default: FE80::/10.",
232 | nargs="*",
233 | default=[IPNetwork("FE80::/10")],
234 | type=validate_prefix
235 | )
236 |
237 | group.add_argument(
238 | "--only-global-unicast-addresses",
239 | help="Exclude any IP address/prefix that is not unicast and global. "
240 | "Default: False.",
241 | action="store_true",
242 | default=False
243 | )
244 |
245 | for formatter_class in Formatters:
246 | formatter_class.add_args(parser)
247 |
248 | args = parser.parse_args()
249 |
250 | if args.logging_config_file:
251 | try:
252 | fileConfig(args.logging_config_file)
253 | except Exception as e:
254 | logger.error(
255 | "Error processing the --logging-config-file - {}".format(
256 | str(e)
257 | )
258 | )
259 | return
260 |
261 | if args.lists_storage_dir:
262 | if not os.path.isdir(args.lists_storage_dir):
263 | logger.error(
264 | "The directory {} does not exist.".format(
265 | args.lists_storage_dir
266 | )
267 | )
268 | return
269 |
270 | if args.recover_from_file:
271 | if not args.lists_storage_dir:
272 | logger.error(
273 | "The --recover-from-file argument requires the "
274 | "--lists-storage-dir."
275 | )
276 | return
277 |
278 | formatter_class = get_formatter_from_id(args.output_format)
279 | formatter = formatter_class(args)
280 |
281 | if not formatter.init():
282 | return
283 |
284 | lists = args.lists
285 |
286 | if args.lists_include:
287 | for bl_id in args.lists_include:
288 | if bl_id not in lists:
289 | lists.append(bl_id)
290 |
291 | if args.lists_exclude:
292 | for bl_id in args.lists_exclude:
293 | if bl_id in lists:
294 | lists.remove(bl_id)
295 |
296 | if not lists:
297 | logger.error("The given --lists, --lists-include and --lists-exclude "
298 | "argumets result into an empty set of block lists.")
299 | return
300 |
301 | # v4 and v6: lists of IPNetwork() objects
302 | # unique: dict of string representation of the same prefixes which are
303 | # added to v4 and v6; used to speed up the lookup that avoids
304 | # duplicated entries in add_prefix()
305 | # format:
306 | # ": { "bl_ids": set("", "") }
307 | entries = {
308 | "v4": [],
309 | "v6": [],
310 | "unique": {}
311 | }
312 |
313 | stats = {
314 | "ok": 0,
315 | "duplicate": 0,
316 | "filtered": 0,
317 | "error": 0
318 | }
319 |
320 | if args.input:
321 | logger.info("Reading entries from input file...")
322 |
323 | try:
324 | from_file = json.loads(args.input.read())
325 | except Exception as e:
326 | logger.error("Error while loading input file - {}".format(str(e)))
327 | return
328 |
329 | logger.info("Processing entries...")
330 |
331 | for v4v6 in (4, 6):
332 | for entry in from_file["v{}".format(v4v6)]:
333 | bl_ids = from_file["v{}".format(v4v6)][entry]["bl_ids"]
334 | stats[add_prefix(args, entry, bl_ids, entries)] += 1
335 | else:
336 | for bl_class_id in lists:
337 | blocklist_class = get_bl_from_id(bl_class_id)
338 |
339 | logger.info("Downloading and parsing {}...".format(
340 | blocklist_class.NAME
341 | ))
342 |
343 | bl = blocklist_class()
344 |
345 | try:
346 | bl.load()
347 | if args.lists_storage_dir:
348 | path = os.path.join(args.lists_storage_dir, bl_class_id)
349 | try:
350 | bl.save_to_file(path)
351 | except Exception as e:
352 | logger.warning(
353 | "Error while saving {} into {} - {}".format(
354 | bl.NAME, path, str(e)
355 | )
356 | )
357 | except Exception as e:
358 | path = None
359 | if args.recover_from_file:
360 | path = os.path.join(args.lists_storage_dir, bl_class_id)
361 | if path and os.path.isfile(path):
362 | logger.warning(
363 | "Error while processing {} - {} - "
364 | "recovering from file {}".format(
365 | bl.NAME, str(e), path
366 | )
367 | )
368 | try:
369 | bl.load_from_file(path)
370 | except Exception as e:
371 | logger.warning(
372 | "Error while recovering {} from "
373 | "file {} - {} - skipping it".format(
374 | bl.NAME, path, str(e)
375 | )
376 | )
377 | else:
378 | logger.warning(
379 | "Error while processing {} - {} - "
380 | "skipping it".format(
381 | bl.NAME, str(e)
382 | )
383 | )
384 |
385 | for prefix in bl.entries:
386 | stats[add_prefix(args, prefix, bl_class_id, entries)] += 1
387 |
388 | logger.info(
389 | "Stats: {} ok, {} duplicate, {} filtered, {} errors - "
390 | "total: {} entries".format(
391 | stats["ok"], stats["duplicate"], stats["filtered"], stats["error"],
392 | stats["ok"] + stats["duplicate"] + stats["filtered"] + \
393 | stats["error"]
394 | )
395 | )
396 | if stats["error"] > 0:
397 | logger.warning("Can't process one or more block list entries")
398 |
399 | try:
400 | formatter.emit(entries, args.output)
401 | except Exception as e:
402 | logger.error("Error while writing output ('{}') - {}".format(
403 | args.output_format, str(e)
404 | ))
405 | return
406 |
407 | main()
408 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
--------------------------------------------------------------------------------