I would have to agree with @Mark in that there are two questions being asked.
1) Are websites allowed to detect what the browser is running (plugins, adblock, ect)?
They are allowed to detect anything that you as a browser tell them. Many sites back in the early 2000 would serve up different content for mobile users, firefox users, IE users, any other type of users. Many sites still do, but the web is moving to a tell me what you can do as a browser. Something that many people forget is that you are going to their server and accessing their data.
2) Is it illegal to serve different content based on if they are serving ads?
No, not at all. The reason is that you have the way you interacted with the website first.
A point to make and question, are you doing something wrong by having an ad blocker?
You are breaking their website intentionally by having an ad blocker on. A website has a right to protect themselves against an attack. Now, and ad blocker may not be an attack, but you are actually doing something against the website to deprive them of their money. In effect, when you add an adblocker, you are blocking someone's source of income.
It is a funny way to look at it. Assume the site uses a CPM for there ad revenue, and lets say normal rate is $1.00 / 1000 Page views. You spend some time on the site over the month and view 100 pages. You have deprived the site of $0.10 for that month if you did not have your ad blocker on.
It may not seem like that much, but If 5 percent of your users block ads, it's not a big deal. If 95 percent come, take your content, but block your revenue, it's a big deal.