PHPackages                             alahaxe/honeypot-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. alahaxe/honeypot-bundle

ActiveLibrary[Security](/categories/security)

alahaxe/honeypot-bundle
=======================

Honeypot bundle for SF

v2.0.3(1y ago)24.7k[6 PRs](https://github.com/lahaxearnaud/honeypot-bundle/pulls)MITPHPPHP ^8.2CI passing

Since Sep 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/lahaxearnaud/honeypot-bundle)[ Packagist](https://packagist.org/packages/alahaxe/honeypot-bundle)[ RSS](/packages/alahaxe-honeypot-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (21)Versions (15)Used By (0)

Honeypot Bundle
===============

[](#honeypot-bundle)

Purpose of this bundle
----------------------

[](#purpose-of-this-bundle)

Detect and react to directory scanning of your website.

Features
--------

[](#features)

- Detect scanning
- Log information about the attacker
- Block locally attacker ip
- Block / force a challenge on cloudflare firewall

Install
-------

[](#install)

```
composer require alahaxe/honeypot-bundle
```

Configuration
-------------

[](#configuration)

```
honeypot:
    # ------------------
    # | Required part, Policies are just some preset of counterMeasures
    # | You can activate several policies
    # ------------------
    policies: # values: debug, log, local_lock, cloudflare_lock
        - 'local_lock' # local lock, based on filesystem cache
        - 'cloudflare_lock' # lock on cloudflare's firewall using API
        - 'debug' # only used in unit tests
        - 'log' # enabled by default, just add a log when an honeypot is called

    # ------------------
    # | Optional part, if you create you own counter measure
    # ------------------
    counterMeasures: # All class listed here must also be symfony service with tag: alahaxe.honeypot.countermeasure
        - Alahaxe\HoneypotBundle\Services\CounterMeasures\DebugCounterMeasure

    # ------------------
    # | Optional part, but you should add your IP here
    # ------------------
    ipWhitelist:
        - 127.0.0.1

    # ------------------
    # | Optional part, used only for local lock
    # ------------------
    localLock:
        # (default: 60) duration in s of the local lock, this config is not used for cloudflare lock
        lockTtl: 60
        # Service that implements LockedResponseGeneratorInterface
        # default is Alahaxe\HoneypotBundle\Services\LockedResponseGenerator\SimpleResponseGenerator
        # but if you want a foncy page you can use TwigResponseGenerator
        renderService: 'Alahaxe\HoneypotBundle\Services\LockedResponseGenerator\TwigResponseGenerator'
        # If you use TwigResponseGenerator you may change the default template
        twigTemplate: 'YouTwigTemplateFile.html.twig'

    # ------------------
    # | Optional part, used only if you enable cloudflare policy
    # ------------------
    cloudflare:
        email: 'your cloudflare email' # you should use env var for this one
        token: 'your cloudflare api token' # you should use env var for this one
        mode: 'challenge' # One of : block, challenge, js_challenge, managed_challenge see

    # ------------------
    # | Optional part, default file contains commons scanned url
    # ------------------
    patternsFile: 'src/Resources/patterns.txt'
```

If you use twig render you need you register the namespace in you twig configuration:

```
twig:
    paths:
        '%kernel.project_dir%/templates': ''
        '%kernel.project_dir%/vendor/alahaxe/honeypot-bundle/Resources/views': 'HoneypotBundle'
```

Add you own counter measure
---------------------------

[](#add-you-own-counter-measure)

### Implements your own service

[](#implements-your-own-service)

A counter measure is a simple symfony service that implements `Alahaxe\HoneypotBundle\Services\CounterMeasureInterface`.

For example:

```
