首页 > 其他 > 详细

捕捉攻击者

时间:2015-01-08 17:18:45      阅读:325      评论:0      收藏:0      [点我收藏+]

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

捕捉攻击者

原文:http://www.cnblogs.com/tuifeideyouran/p/4211230.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!