Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Ensnare is packaged as a gem plugin for Ruby on Rails and was developed to allow configuring and deploying a basic malicious behavior detection and response scheme in less than ten minutes.

Ensnare uses a combination of Honey Traps to entice malicious users, and a configurable suite of Trap Responses to confuse, allude, delay, or stop an attacker.

Already heard about the tool and want to try it out? Do it!


Add the gem to your project's Gemfile:

    gem 'ensnare', :git => ''

Install the gem:

    bundle install

Run the migrations for Ensnare:

    rake ensnare:install:migrations
    rake db:migrate

Enable parameter tampering for your application by changing the mass_assignment_sanitizer:

    vi config/environments/<ENVIRONMENT>.rb

Set config.active_record.mass_assignment_sanitizer to logger:

    config.active_record.mass_assignment_sanitizer = :logger 

Enable Ensnare in your application_controller.rb file:

    vi app/controllers/application_controller.rb

Append the following filter below protect_from_forgery in your application_controller.rb file:

    before_filter :ensnare

Add the following to the end of your routes.rb file:

    mount Ensnare::Engine => "/ensnare", :as => "ensnare_engine" 
    match "*_", :to => "ensnare::violations#routing_error"

Create an Ensnare config file:

    rails g ensnare:install

Take a look at the example ensnare.rb file:

    vi config/initializes/ensnare.rb

After you start your application, take a look at the dashboard:

In order to access the dashboard, this step needs to be performed.

To prevent unnecessary users from accessing the dashboard, add the following to the config/initalizers/ensnare.rb file:

  config.dashboard_user_method = :current_user
  config.dashboard_authorization_method = :admin?

NOTE: you need to have a method defined to check if the user is the admin.




Dashboard CSS Issues in Firefox

Resources trap mod security&f=false


Created by Andy Hoernecke and Scott Behrens.

Feel free to reach out to us if you have questions or want to contribute to the project!