首页 > 代码库 > 捕捉攻击者
捕捉攻击者
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
捕捉攻击者
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。