CodeSOD: A Well Known Address

This post was originally published on this site

The Daily WTF

Amanda‘s company wanted to restrict access to a service by filtering on the requestor’s IP address. Yes, this is a terrible idea. So they wanted to make it a bit smarter, and also filter on various subnets. But they had a LOT of different subnets.

So the result was this:

ok = 0 ip = Request.ServerVariables(“REMOTE_ADDR”) if ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” or ip = “xxx.xxx.xxx.xxx” then ok = 1 end if ip2 = Split(ip,”.”) ip3 = ip2(0) &”.”& ip2(1) &”.”& ip2(2) if ip3 = “xxx.xxx.xxx” or ip3 = “xxx.xxx.xxx” or ip3 = “xxx.xxx.xxx” or ip3 = “xxx.xxx.xxx” or ip3 = “xxx.xxx.xxx” or ip3 = “xxx.xxx.xxx” or ip3 = “xxx.xxx.xxx” or ip3 = “xxx.xxx.xxx” or ip3

To read the full article click on the 'post' link at the top.