Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.pyc
csv/
www/static/
.idea/
*.DS_Store

19 changes: 19 additions & 0 deletions BruteBuster.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Metadata-Version: 1.1
Name: BruteBuster
Version: 0.2.1
Summary: BruteBuster is a simple, pluggable Django app that can help you protect against password bruteforcing attempts.
Home-page: https://github.com/gutyril/django-brutebuster
Author: UNKNOWN
Author-email: UNKNOWN
License: The Python Packaging Authority
Description: UNKNOWN
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: DjangoFramework :: Django :: 1.8.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: The Python Packaging Authority
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
16 changes: 16 additions & 0 deletions BruteBuster.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
LICENSE
MANIFEST.in
README.md
setup.py
BruteBuster/__init__.py
BruteBuster/admin.py
BruteBuster/apps.py
BruteBuster/decorators.py
BruteBuster/middleware.py
BruteBuster/models.py
BruteBuster.egg-info/PKG-INFO
BruteBuster.egg-info/SOURCES.txt
BruteBuster.egg-info/dependency_links.txt
BruteBuster.egg-info/top_level.txt
BruteBuster/migrations/0001_initial.py
BruteBuster/migrations/__init__.py
1 change: 1 addition & 0 deletions BruteBuster.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions BruteBuster.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BruteBuster
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions decorators.py → BruteBuster/decorators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# BruteBuster by Cyber Security Consulting (www.csc.bg)

"""Decorators used by BruteBuster"""

from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _

def protect_and_serve(auth_func):
"""
Expand All @@ -16,7 +17,7 @@ def protect_and_serve(auth_func):

def decor(*args, **kwargs):
# Import here to avoid AppRegistryNotReady("Apps aren't loaded yet.") Exception
from BruteBuster.models import FailedAttempt
from BruteBuster.models import FailedAttempt, BB_BLOCK_INTERVAL
from BruteBuster.middleware import get_request
"""
This is the wrapper that gets installed around the default
Expand All @@ -42,7 +43,7 @@ def decor(*args, **kwargs):
# of too many recent failures
fa.failures += 1
fa.save()
return None
raise ValidationError(_("User has been blocked after too many failed login attempts. Please retry in {} minutes").format(BB_BLOCK_INTERVAL))
else:
# the block interval is over, so let's start
# with a clean sheet
Expand Down
37 changes: 37 additions & 0 deletions BruteBuster/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# BruteBuster by Cyber Security Consulting (www.csc.bg)

"""
Brutebuster needs access to the REMOTE_IP of the incoming request. We're doing
this by adding the request object to the thread_local space
"""

try:
from threading import local
except ImportError:
from django.utils.threading_local import local

_thread_locals = local()


def get_request():
return getattr(_thread_locals, 'request', None)


class RequestMiddleware(object):
"""Provides access to the request object via thread locals"""

def __init__(self, get_response):
self.get_response = get_response
# One-time configuration and initialization.

def __call__(self, request):
_thread_locals.request = request
# Code to be executed for each request before
# the view (and later middleware) are called.

response = self.get_response(request)

# Code to be executed for each request/response after
# the view is called.

return response
30 changes: 30 additions & 0 deletions BruteBuster/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='FailedAttempt',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('username', models.CharField(max_length=255, verbose_name=b'Username')),
('IP', models.GenericIPAddressField(null=True, verbose_name=b'IP Address')),
('failures', models.PositiveIntegerField(default=0, verbose_name=b'Failures')),
('timestamp', models.DateTimeField(auto_now=True, verbose_name=b'Last failed attempt')),
],
options={
'ordering': ['-timestamp'],
},
),
migrations.AlterUniqueTogether(
name='failedattempt',
unique_together=set([('username', 'IP')]),
),
]
Empty file.
1 change: 0 additions & 1 deletion models.py → BruteBuster/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# BruteBuster by Cyber Security Consulting (www.csc.bg)

"""
BruteBuster DB model.
Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include LICENSE
include README.rst
recursive-include docs *
recursive-include promotion/fixtures *
26 changes: 0 additions & 26 deletions middleware.py

This file was deleted.

35 changes: 35 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
from setuptools import find_packages, setup

# with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
# README = readme.read()

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

setup(
name='BruteBuster',
version='0.2.1',
packages=find_packages(),
include_package_data=True,
license='The Python Packaging Authority',
description='BruteBuster is a simple, pluggable Django app that can help you protect against password bruteforcing attempts.',
long_description="",
url='https://github.com/gutyril/django-brutebuster',
author='',
author_email='',
classifiers=[
'Environment :: Web Environment',
'Framework :: Django'
'Framework :: Django :: 1.8.2', # replace "X.Y" as appropriate
'Intended Audience :: Developers',
'License :: OSI Approved :: The Python Packaging Authority', # example license
'Operating System :: OS Independent',
'Programming Language :: Python',
# Replace these appropriately if you are stuck on Python 2.
'Programming Language :: Python :: 2.7',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
)