捕捉攻击者

pip install django-admin-honeypot

Add admin_honeypot to INSTALLED_APPS

url(r'^admin/', include('admin_honeypot.urls', namespace='admin_honeypot')),
url(r'^secret/', include(admin.site.urls)),

 生成数据库.捕捉攻击者

如果有使用代理的系统会记录127.0.0.1可通过设置中间件来实现

Why is the IP address logged as 127.0.0.1?

Django-admin-honeypot pulls the users IP address from the REMOTE_ADDR request header. If your Django app is behind a load balancer or proxy web server, this may not be set and instead you will instead have an HTTP_X_FORWARDED_FOR header which contains the IP address in a comma-separated string.

The simple solution is to use a middleware to automatically set REMOTE_ADDR to the value ofHTTP_X_FORWARDED_FOR, like so:

class RemoteAddrMiddleware(object):
    def process_request(self, request):
        if 'HTTP_X_FORWARDED_FOR' in request.META:
            ip = request.META['HTTP_X_FORWARDED_FOR'].split(',')[0].strip()
            request.META['REMOTE_ADDR'] = ip

 

See also: http://docs.webfaction.com/software/django/troubleshooting.html#accessing-remote-addr

转载于:https://www.cnblogs.com/tuifeideyouran/p/4211230.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值