I have a weird bot pummeling my site. It COULD be some sort of low-level denial-of-service attack, but I think that's unlikely. I'm looking for suggestions on blocking it because it's rapidly chewing through all of my CPU and bandwidth allotments.
Here's what it does:
Roughly 650 page requests per minute, like clockwork, constantly, for weeks
Large list of IPs -- hundreds, rotating, with Geolocations randomly scattered all around the world
Rotating user agent strings, many of which are for legit browsers
HTTP_REFERER is often, but not always, filled with a spam site
And weirdest of all, the GET requests almost always generate 404 errors because most are for fully-qualified URLs which are NOT MY SITE. When they are not full URLs, they are for pages or resources that don't exist, never have, and don't even appear to be exploit attempts.
Here are some sample records from my server logs:
80.84.53.26 - - [24/Feb/2015:06:15:43 -0600] "GET http://www.proxy-listen.de/azenv.php HTTP/1.1" 404 - "http://www.google.co.uk/search?q=HTTP_HOST" "Opera/9.20 (Windows NT 6.0; U; en)"
54.147.200.126 - - [24/Feb/2015:06:15:44 -0600] "GET http://www.pinterest.com/jadajuicy07/ HTTP/1.1" 404 - "-" "Mozilla/4.0 (compatible; Ubuntu; MSIE 9.0; Trident/5.0; zh-CN)"
91.121.161.167 - - [24/Feb/2015:06:15:44 -0600] "GET http://78.37.100.242/search?tbo=d&filter=0&nfpr=1&source=hp&num=100&btnG=Search&q=%221%22+%2b+intitle%3a%22contact%22+%7efossil HTTP/1.1" 404 - "http://78.37.100.242/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
185.2.101.78 - - [24/Feb/2015:06:15:43 -0600] "GET http://mail.yahoo.com/ HTTP/1.1" 200 269726 "-" "Mozilla/4.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; MS-RTC LM 8; .NET CLR 3.0.30729)"
142.0.140.68 - - [24/Feb/2015:06:15:44 -0600] "GET http://ib.adnxs.com/ttj?id=4311122&cb=[CACHEBUSTER]&referrer=[REFERRER_URL] HTTP/1.0" 404 - "http://www.monetaryback.com/?p=1419" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/4.0.206.1 Safari/532.0"
This is the third time I've dealt with these same conditions. It last happened about six months ago. For reference, my site is a blog about baseball (on a blogging platform I built myself) with a few hundred regular visitors. I'm in the US, but my site contains no state secrets!
For now I've redirected all 404 errors to a script which dynamically modifies my .htaccess file to instantly ban IPs that make incoherent requests. That works, but I don't think it's sustainable.
What is this thing? And what's the best practice method of blocking it? Thanks.
Related
In the past few years I've sometimes ran into websites that don't work in Firefox on Linux, and I'm trying to understand why so I can notify the owners with more than just a vague “it doesn't work”.
Now this happens of course. While most web developers do test in Firefox, not many will have tested their products in Firefox on Linux, and some really don't care. Some only target Chrome/Webkit and don't bother with Firefox at all. That is not what this question is about though.
There is something here that makes me suspect that there is an underlying cause that is repeated on seemingly unrelated websites, and I suspect some repeated bit of configuration code or web content serving library or application that does this. Something is fishy.
The problem
The websites affected return only a plain HTML message with a 403 HTTP status code for any resource requested; it looks like this:
Forbidden
You don't have permission to access / on this server.
These websites do work when:
The operating system is not a Linux distribution
or
The browser is not Firefox
Example websites
While I normally wouldn't include a link to someone else's website, in this case I do because it is the website of a doctors office. These websites should be available to any patient at all times for anything short of a imminently life threatening emergency (in which case the national emergency number should be called of course) to provide contact information in times of need.
This website displays the symptoms described above: https://www.huisartsenpraktijkdehaan.nl/
There are more websites though, but the pattern is always the same.
The user-agent string
Trying to figure out what is actually causing this seems simple enough though. If I change the user-agent string to that of Chrome, it works.
So my tentative conclusion is that this is purely a user-agent driven bug/feature.
Some further testing yields this:
These work
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
Foo
Mozilla/5.0 (X11; Ubuntu; x86_64; rv:85.0) Gecko/20100101 Firefox/85.0
Mozilla/5.0 (X11; Ubuntu; inux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0
Mozilla/5.0 (X11; Ubuntu; Linu x86_64; rv:85.0) Gecko/20100101 Firefox/85.0
Mozilla/5.0 (X11; Xubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0
X11; Ubuntu; Linu
X11;Ubuntu;Linux
11; Ubuntu; Linux
These do not work
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0
X11; Ubuntu; Linux
x11; ubuntu; linux
Hypothesis
Having the literal string X11; Ubuntu; Linux (case insensitive but including spaces and semi-colons as-is) in the user-agent HTTP header of your request triggers the broken behaviour.
The conundrum
I could, of course, reach out the owners of these websites (and eventually I will), but there is a catch. They likely won't use Firefox on Linux (because you would notice your own website being broke), and if they pass on the message to whoever maintains or built the website, the response may very well be “well it works for you, and it works for me, that user must have some weird virus-ridden computer and an ancient browser with a Bonzy Buddy toolbar”, or something similar.
So I want some more ammunition, and preferably a cause I can explain to anyone with a website like this. Even better would be to find out why this happens, and fix it at the source.
So what is happening here? Some Apache of Nginx module/config/plugin written by someone who really hates people who use Firefox on Linux? Some weird bug repeated on multiple sites?
Does anyone recognize this peculiar website behaviour?
I saw the link to this post in forwarded emails.
ErrorDocument 503 "Your connection was refused"
SetEnvIfNoCase User-Agent "X11; Ubuntu; Linux" bad_user
Deny from env=bad_user
Was set in the .htaccess to block "WP-login bots", since I use Ubuntu myself this was rather easy to replicate.
I am facing strange and very serious problem with my website hosted accounts on hostgator reseller. since, march 23, 2018 my sites are being accessed by google's bot (userAgent: Mozilla/5.0 [compatible; Googlebot/2.1; +http://www.google.com/bot.html]). Their IP addresses are in range of 66.249.. and they change frequently. From my cPanel i can see as below;
66.249.79.79 /MzhmLzUxNzE5LzhmLzE2NjYvZmgz.asp 4/8/18, 5:30 AM 7377 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
66.249.79.75 /bXYtMzE2MS92b2svNzczODEtb2t3bw== 4/8/18, 5:29 AM 7377 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
66.249.79.75 /cTN1Lzc0ODQ3LzN1LzY0MzAvdXFi.asp 4/8/18, 5:29 AM 7377 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
66.249.79.75 /cGEwMGk2LzczODMvYTAvODU4MDEvMA== 4/8/18, 5:29 AM 7377 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
66.249.79.77 /eDItOTQ4NC8yYWIvMzMwNTctYWJtNA== 4/8/18, 5:29 AM 7377 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
66.249.79.79 /ZmlhLzc4NTk5L2lhLzMyNzcvYTVo.asp 4/8/18, 5:29 AM 7377 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
and there are tons of such. They are eating up my bandwidth and i am helpless from hostgator support team as they also don't have any specific solution to this.
Therefore, First i would like to know if there is any option or walkthrough to stop google temporarily to access my site? Secondly, can i do something to clear google's indexing urls list of my website?
Google will observe a crawl delay in seconds between requests that you can place in a robots.txt file in the root of your domain. See section called nonstandard extensions - https://en.m.wikipedia.org/wiki/Robots_exclusion_standard.
You can also use Google's search console (formally called web master tools i think) to request urls be removed from their indexes and control other behaviour / see any issues indexing your site. You will need to register and then complete a verification process to link your account to your domain. https://www.google.com/webmasters/tools/home?hl=en
Is there a way for Passport to check if request came from mobile or web app when doing authentication? Because if request came from the web I want to return a view otherwise return a json payload.
This is my opinion,you can check user-agent in the request header ,its look like this(came from windows):
user-agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
and this is came from my iPhone
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1
and this is Android
User-Agent:Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Mobile Safari/537.36
so you can figer it out from user-agent,which request came from mobile or pc
If you have two different clients expecting different results, then you should explicitly send different requests, not try to guess which response is wanted from some header that isn't necessarily reliable. Plus, there's nothing keeping a mobile device from also accessing the web interface. You can either vary the path or vary a query string.
So, from web, you might use /login and from mobile, you might use /login-json or some different path that indicates you want json.
Or from web, you might use /login and from mobile, you might use /login?type=json.
I would NOT recommend using the user-agent header to detect the intent of the request. Instead, specify the intent directly in the request.
I am using user-agent validation on the session. If user-agent is changing we are deleting the session.
But I am facing problem with IE9 with google oauth redirect.
When IE9 is hitting our site, IE is having valid IE9 user-agent
So user-agent is
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
but after redirection from user-agent is becoming
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)
so I logic for session validation is failing in this case.
Is there any way with ie9 to force IE to fallback to IE9 user-agent
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Adding a user agent check doesn't make your session more secure. There is no condition in which an attacker will have a session id and not have a user-agent. Your security system is identical to this: http://domain/?is_hacker=No. If you want to make your session more secure you should enable the cookie secuirty flags and remove this bullshit check.
Can we use Mobile Tools module in Drupal6 with Varnish?
I doubt varnish will cache the index page and will not allow redirection to mobile version of the page.
Any work arround?
You want to make your server return different responses based on the used device/browser. This means your pages 'vary' based on the used User-Agent http request header, and in theory you should instruct any http proxy/cache in between to only use a cached version if the User-Agent string is the same by adding a http response header:
Vary: User-Agent
However, because browsers like Internet Explorer (unlike Chrome) use many slightly different User-Agent headers, this will completely kill your cache hit ratio. You need a smarter cache to understand that Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0) for your purposes is equal to Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.0; Trident/4.0; InfoPath.1; SV1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 3.0.04506.30), or any other user-agent string used by a desktop browser.
There are two options for you to solve this with Varnish:
1: Do mobile user-agent detection yourself in varnish logic, the same way mobile tools does it. E.g.:
vcl_recv {
if (req.http.user-agent ~ 'ipad|ipod|iphone|android|mini opera|blackberry|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp|treo') {
hash += "mobile"
}
}
2: Or, always set a session cookie mobile=true or mobile=false after you've seen the first request, and only serve cached pages for requests with this cookie.
And after googling a bit, you should read: http://fangel.github.com/mobile-detection-varnish-drupal/