💡 Looking for inspiration for your next open source project? Or perhaps you've got a brilliant idea you can't wait to share with others? Open Source Ideas is a community built specifically for this! 👋
6.59k
stars
220
forks
source link
Complaint Reporting Tool for Abuse/Hacking | Django #113
If one were to create a new basic webserver, listening on :80, it would not take long for hacker attempts to be made against that site. For example, one may see an HTTP GET Request for /.bitcoin/wallet.dat or /admin/config.php or /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax. These are clear attempts to access the website in a non-authorized way. This is especially true if the site is not BitCoin mining related, a PHP website or a Drupal site.
Although there is little harm for these types of Kiddie Scripting attempts, they often can be annoying for a website using Django technology.
In Django on an AWS node behind a load balancer, the HTTP_X_FORWARDED_FOR header contain a list of IP addresses. The first is the source IP, for example: 2.203.36.157.
Thus, we can know that this IP address (randomly chosen) 2.203.36.157 has made an access request to one of the URLs in the table below. By Reverse IP Lookup, we can determine the source of the original sender. In this particular case it is: Vodophone DSL in Solingen, North Rhine-Westphalia, Germany, Europe.
Often there are multiple simultaneous requests from users that hit a URL from the table below. If there are many attempts (for example, if all three of these URLs were accessed) /.bitcoin/wallet.dat and /admin/config.php and /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax we can safely assume this is a non-authorized attempt (especially if the site is a Django site).
This project is a Django Middleware that:
Efficiently checks incoming IP address against a black list of IP addresses. Return 403 if on list.
Efficiently checks URLs against the URLs in Table 1.1 below
All hits are registered in a configurable backend with IP address and URL from Table 1.1. This backend can be efficient (such as a Redis node) or Simple (such as a database table).
If there are more than a BAD_URL_NUM_THRESHOLD (or similar configurable variable), then this IP address is listed in the efficient list for returning 403s as shown in step 1 above
There are additional manage.py commands that can be run on a regular basis to:
Write out the 403 Black List (from step 1 of previous MIddleware) in either Nginx or Apache Deny format so that this can be 403'd on the Web Server level in the future
Collate an "Abuse Report" from this IP address. The format should include questions such as the following: https://aws.amazon.com/forms/report-abuse. The purpose of this report is to be a standard for submitting to Amazon - including logs and times needed to report the abuse. One may consider an option for Reverse Lookup of IP address (such as https://www.maxmind.com/en/geoip-demo.). A database of abuse@.. email addresses for the report would be very handy (and may be its own project)
Alert when new abuse reports are available (from steps 1 and 2 above)
Often we don't complain because the information is too hard to collate in order to make the report. And, there are some companies, such as Amazon and Google who would respond to such complaints.
One should always be able to choose to manually review any reports before they are submitted. There may be some reports that we do not wish to send.
Table 1.1: Sample unauthorized URL patterns that I have seen against a Django site:
[ ] Beginner - This project requires no or little prior knowledge of the technolog(y|ies) specified to contribute to the project
[x] Intermediate - The user should have some prior knowledge of the technolog(y|ies) to the point where they know how to use it, but not necessarily all the nooks and crannies of the technology
[ ] Advanced - The project requires the user to have a good understanding of all components of the project to contribute
One could argue that an Advanced level of complexity is helpful to prevent Webpage slow downs as there are components in the Django Middleware that may be seen by every web request.
Required time (ETA)
[ ] Little work - A couple of days
[x] Medium work - A week or two
[ ] Much work - The project will take more than a couple of weeks and serious planning is required
Project description
If one were to create a new basic webserver, listening on :80, it would not take long for hacker attempts to be made against that site. For example, one may see an HTTP GET Request for
/.bitcoin/wallet.dat
or/admin/config.php
or/user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax
. These are clear attempts to access the website in a non-authorized way. This is especially true if the site is not BitCoin mining related, a PHP website or a Drupal site.Although there is little harm for these types of Kiddie Scripting attempts, they often can be annoying for a website using Django technology.
In Django on an AWS node behind a load balancer, the
HTTP_X_FORWARDED_FOR
header contain a list of IP addresses. The first is the source IP, for example: 2.203.36.157.Thus, we can know that this IP address (randomly chosen) 2.203.36.157 has made an access request to one of the URLs in the table below. By Reverse IP Lookup, we can determine the source of the original sender. In this particular case it is: Vodophone DSL in Solingen, North Rhine-Westphalia, Germany, Europe.
Often there are multiple simultaneous requests from users that hit a URL from the table below. If there are many attempts (for example, if all three of these URLs were accessed)
/.bitcoin/wallet.dat
and/admin/config.php
and/user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax
we can safely assume this is a non-authorized attempt (especially if the site is a Django site).This project is a Django Middleware that:
There are additional manage.py commands that can be run on a regular basis to:
abuse@..
email addresses for the report would be very handy (and may be its own project)Often we don't complain because the information is too hard to collate in order to make the report. And, there are some companies, such as Amazon and Google who would respond to such complaints.
One should always be able to choose to manually review any reports before they are submitted. There may be some reports that we do not wish to send.
Table 1.1: Sample unauthorized URL patterns that I have seen against a Django site:
Relevant Technology
Django Middleware on any platform
Complexity and required time
Complexity
One could argue that an Advanced level of complexity is helpful to prevent Webpage slow downs as there are components in the Django Middleware that may be seen by every web request.
Required time (ETA)