Skip to main content

find2deny

Tools to build Firewall Command for UFW from List of (Apache)-Log-files.

It creates a file block-ip.sh which contains Linux UWF-Command to block IP-network, but it does not change any Firewall-rules on your computer.

Installation

To install the latest release on PyPI, simply run:

pip install find2deny

Or to install the latest development version, run:

git clone [TODO]
cd find2deny
python setup.py install

Quick Tutorial

For example, you have a set of Apache Log-files in a directory apache2 like

  • access.log

  • access.log.1,

  • access.log.2.gz,

  • …

The python script find2deny-cli can create a shell-Script block-ip.sh which contains commands like

#!/bin/bash
ufw deny from 1.2.3.4/0 to any
ufw deny from 1.2.3.4/1 to any
...
  1. Make a Configuration-File: Simple copy this configuration to a file, say config.toml:

    verbosity = "INFO"
    # Path to apache log files in system
    log_files = ["apache2/access.log.*"]
    # Log Pattern
    log_pattern = '%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"'
    # temporary sqlite database
    database_path="./blocked-ip.sqlite"
    
    
    [[judgment]]
        name = "path-based-judgment"
        [judgment.rules]
            bot_request = [
                "/?XDEBUG_SESSION_START=phpstorm",
                "/phpMyAdmin/",
                "/pma/",
                "/myadmin/",
                "/MyAdmin/",
                "/mahua/",
                "/wp-login",
                "/webdav/",
                "/help.php",
                "/java.php",
                "/db_pma.php",
                "/logon.php",
                "/help-e.php",
                "/hell.php",
                "/defect.php",
                "/webslee.php",
                "http://www.123cha.com/",
                "http://www.wujieliulan.com/",
                "http://www.epochtimes.com/",
                "http://www.ip.cn/",
                "www.baidu.com:443"
            ]
    
    [[judgment]]
        name = "time-based-judgment"
        [judgment.rules]
            max_request = 501
            interval_seconds = 10
    
    
    [[execution]]
        name = "ufw_cmd_script"
        [execution.rules]
            script = "./block-ip.sh"
  2. Run script:

    find2deny-init-db blocked-ip.sqlite

    to create a Sqlite-Database in file blocked-ip.sqlite. The filename must match the configuration database_path in the file config.toml.

  3. Run:

    find2deny-cli config.toml

    to create file block-ip.sh. Then you can examinate the file block-ip.sh and run it from your shell to update your firewall.

Configuration

The syntax used in configuration file ist Toml. There are three sections in a configuration files, as you see above

Common Configuration

This section defines common configurations, such as how much infos should be printed onto console, ect.

Judgment

This section defines a list of Judgments. They are identified by name. At this time there are only two judments: path-based-judgment and time-based-judgment. Each judgment has its owns configuration.

Judgments are classes, which use rules defined in configuration to decide which IPs should be blocked. They extend the class AbstractIpJudgment.

Execution

This section defines a list of executions. At this time there is only one execution. Executions are classes which create firewall-rules or execute something, which nessesary to block an IP, or , in this implementation, block the network, to which the ip belongs.

Metadata

Release files for find2deny 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for find2deny 0.2.10
File Size Uploaded Provenance Actions
find2deny-0.2.10.tar.gz 13.9 kB Without provenance Details for find2deny-0.2.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for find2deny 0.2.10
File Interpreter ABI Platform Actions
find2deny-0.2.10-py3-none-any.whl Python 3 none any Details for find2deny-0.2.10-py3-none-any.whl

Total release size: 30.8 kB

Release files / find2deny-0.2.10.tar.gz

Download URL find2deny-0.2.10.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
60d73c0288b97048c1cde6b07848496be8809fd221bce88b1fadaca734d8e737
BLAKE2b-256 checksum
How to use checksums
b7cac2c88fef2b6cf440d7647b4200900f588ec94464a8e3fd111cd6edb7e302
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release files / find2deny-0.2.10-py3-none-any.whl

Download URL find2deny-0.2.10-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ba4ae69a80cecec97704116d8f1684de1ad8927c961f808f5c0db9606e0f3a9
BLAKE2b-256 checksum
How to use checksums
210ec548318f670be0f233e9be0636efbde7962c022e43103c183eaac0b18601
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Security for find2deny 0.2.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page