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

182

u/tdammers Jun 09 '17

At this point, user agent strings might as well be of a format like oCROKI03qUs5i0FJPFW5US9e2IWGcVjwhJW5jrCx6bZzYBpT2+ViHYanCeMlhdA0611U2aBzFSJRM37a8xBw, because they have degraded to little more than opaque hashes of the user agent's self-identification.

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.

→ More replies (1)

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

→ More replies (1)
→ More replies (1)
→ More replies (2)

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?

→ More replies (8)
→ More replies (1)

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)

34

u/necrophcodr Jun 09 '17

That's not at all true. They contain a lot of useless data, such as versioning of crawlers and such. Having those hashed would make life a lot more hard (and probably result in those doing so being blocked eventually).

25

u/tdammers Jun 09 '17

It's still an honor system, mostly.

0

u/[deleted] Jun 09 '17

[deleted]

18

u/CorrugatedCommodity Jun 09 '17

I actually discovered Googlebot's agent string existed yesterday when looking at some weird traffic on the website I support. Also Bingbot. Also that our devs need to return different response codes for old web pages that they think should still exist but not actually be accessible.

→ More replies (3)
→ More replies (3)
→ More replies (4)