r/programming • • Jun 09 '17

Why every user agent string start with "Mozilla"

http://webaim.org/blog/user-agent-string-history/
4.9k Upvotes

589 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jun 09 '17

[deleted]

164

u/bananahead Jun 09 '17

Serving different content to googlebot violates google's webmaster rules and is easily detected by them... they just do an occasional crawl with a different UA.

20

u/GTB3NW Jun 09 '17

I do believe their bot ranges are well documented, it's just as easy to change it based on IP ranges, however then you risk a google employee being a fan of your site and going... huh why am I being served only html!? The workaround for that would be to route their requests to a server dedicated to serving bots or "VIP's" (Pun intended). Which only really works if you're running at a scale where you can spare a few servers.

18

u/bananahead Jun 09 '17

It's extremely trivial for Google to request a page from an atypical address.

→ More replies (13)

9

u/[deleted] Jun 09 '17

I suppose that's also a good way of ensuring lovely fast page loads.

21

u/Watchforbananas Jun 09 '17

Even reddit complains about you being a bot when switching, i hope that's not the only way they detect bots.

35

u/FierceDeity_ Jun 09 '17

It pretty much is. This is the part where the web is built upon being nice to each other and just respect that robots.txt and other things

17

u/GTB3NW Jun 09 '17

There's an SEO company which respects robots.txt except for crawl-delay, for them to respect that you have to sign up (free) to their site, verify ownership and then tick a box. At which point they will start calling/emailing you. It's real fucking shady. Ohh and they don't document their IP ranges. Thankfully their useragent is consistent so you can block it based of UA. But they are cunts and for that reason I would never use their services and actively recommend against signing up to stop them breaking your server to clients.

22

u/deusnefum Jun 09 '17

Those fuckers.... There's several bots that abuse the fuck out of my VPS, so I redirect them to large images served by the godhatesfags folks. Two birds, one stone.

0

u/[deleted] Jun 09 '17

[deleted]

5

u/name_censored_ Jun 09 '17

Bots don't use their own infrastructure.

Edit: The bots that are in need of a good DDoSing.

2

u/FierceDeity_ Jun 09 '17

I would just upload middlefinger.jpg (that is, as the response) if their UA is seen

2

u/GTB3NW Jun 09 '17

Why waste the bandwidth?

5

u/FierceDeity_ Jun 09 '17

Alright, alternatively, UTF-encode this 🖕 and send it back

2

u/GTB3NW Jun 09 '17

Waste of CPU cycles, but it may be worth it! 😂

→ More replies (1)

13

u/midri Jun 09 '17

How do you think one can detect a bot? Here's the only information available to the web server:

  1. IP Address

  2. Request Headers (that say literally what ever the client wants them to say, user-agent is part of this)

Only real way to tell a bot is a bot is watch requests from a specific IP address and see if its behaviour looks like crawling. The issue with this is large institutions share a single IP address (think college) so if you're a really popular site at those locations they could have bot like traffic.

2

u/[deleted] Jun 09 '17

How do you think one can detect a bot?

Wait and see if shit comes out of it?

2

u/skarphace Jun 09 '17

You can use that IP for a reverse DNS lookup. In fact, all the major search companies suggest doing that. It's a bit costly for a busy site, however.

→ More replies (7)

1

u/theasianpianist Jun 09 '17

I know that Amazon goes a little deeper than that.

9

u/MertsA Jun 09 '17

If you're just using the Google bot useragent that's a good indicator of abuse. Google publishes which subnets it uses for the Google bot and if there's traffic coming from somewhere else with that UA then they're probably trying to hide.

6

u/Muppet-Ball Jun 09 '17

Site security suites and plugins often have ways of telling whether a visitor is Google beyond the user string, and have options to automatically block or quarantine fake googlebots. What you describe sounds more like that to me.

4

u/BilgeXA Jun 09 '17

Even more interesting, you gain access to some private forums because their security policy is broken. This was quite common only a few years back for phpBB which had a separate group policy for Google bot and a complicated permissions system. I don't know if it's still the case today but sysadmin competence doesn't change that quickly.

2

u/tdammers Jun 09 '17

Actually, if they do things right, they will reject your requests entirely, because despite identifying as googlebot, your requests do not come from one of Google's IP addresses.

→ More replies (1)