Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Another way of specifying an IP address in Cocoa apps Network
The Cocoa framework indeed has a lot of peculiar features. For example, you don't have to write IP addresses like everyone else does. Every segment of an IP address is a number between 0 and 255. (You could also say that they are a byte each). This can be translated into a number. So if you take the IP address of macosxhints.com, 207.44.210.206, and do this calculation:
   207*256*256*256
 + 44*256*256
 + 210*256
 + 206
You get 3,475,821,262. Now if you enter that number (without the commas -- 3475821262) into a Cocoa based browser (Firebird and Safari will do, Internet Explorer won't as it's a Carbon app), you will be at the macosxhints.com homepage. It seems to work in Cocoa based apps. I tried it with Safari, Firebird, and several CLI apps like traceroute, ping, telnet and ftp.

Practical? Maybe, but mostly as a gimmick. Of course, it can save you some typing. Anyone have any ideas for optimum usage?
    •    
  • Currently 3.00 / 5
  You rated: 4 / 5 (3 votes cast)
 
[8,631 views]  

Another way of specifying an IP address in Cocoa apps | 15 comments | Create New Account
Click here to return to the 'Another way of specifying an IP address in Cocoa apps' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another way of specifying an IP address in Cocoa apps
Authored by: pepito on May 28, '03 12:27:48PM

Also works in HEX http://0xCF2CD2CE

Works with anything that uses ip because it's just another way of expressing the address



[ Reply to This | # ]
its called an "obscured" ip address
Authored by: gelstudios on May 28, '03 12:31:58PM

The address is supposed to work with anything ip based.

Basically its the dword (double word) format of the dotted decimal ip address.

You can do it with any scientific calculator:
207*256+44=*256+210=*256+206=3475821262

You can use it to "hide" the ip, but a simple ping will reveal the standard ip.

The obscured format will usually get past most filtering/censoring software used in school and libraries, etc.



[ Reply to This | # ]
Another way of specifying an IP address in Cocoa apps
Authored by: jeb on May 28, '03 12:33:56PM
This isn't specific to Cocoa apps. I used to test this as an exploit to get around CyberNanny and similar software that blocked sites by name and x.x.x.x IP. They almost never blocked the denary IP. My method was a little different. I would turn each segment into binary, concatenate them, then convert that large string into a single denary number.

207.44.210.206

207 = 11001111
44   = 00101100 (note the "padding zeros")
210 = 11010010
206 = 11001110

207.44.210.206 --> 11001111001011001101001011001110
which converts to 3475821262.
Your way is easier. For those of you that get bent out of shape by these types of things:
denary
adj 1: containing ten or ten parts [syn: tenfold]
2: numbered or proceeding by tens; based on ten;
  "the decimal system" [syn: decimal]


[ Reply to This | # ]
Re: Those of us who get bent out of shape
Authored by: aogail on May 28, '03 01:05:14PM

You should have used 'who': "For those of you who get bent out of shape..." ;)



[ Reply to This | # ]
Re: Those of us who get bent out of shape
Authored by: craigsheppard on May 28, '03 05:49:36PM

Lol!



[ Reply to This | # ]
Another way of specifying an IP address in Cocoa apps
Authored by: notmatt on May 28, '03 12:39:32PM

IP address are just 32-bits of information, the "segments" are just for readability, and don't exist anywhere except for when they're displayed, so in that sense, using a 32-bit number for them makes sense.

However, I don't think this is a Cocoa feature; I remember this working just fine on windows IE browsers, and it was noted as a security risk, since you could get URLs like the following:

http://www.cnn.com@3475821262

which looked relatively innocuous to the unseasoned user, and could be used to spoof someone into downloading something nasty. I'm not entirely certain, but I actually think that it's one of the standard representations of an address, but I'd rather not wade through RFCs to confirm my suspicion. Anyone know for sure?



[ Reply to This | # ]
Another way of specifying an IP address in Cocoa apps
Authored by: greed on May 29, '03 11:17:39AM

If you're looking up RFCs, you'll want to go waaaaay back to the "class-based" addressing schemes. Remember class A, B and C addresses?

Anyway, parsing an IP number this way is an artifact of the inet_aton (or the older inet_addr) routines. Any program which converts an IP address string to an actual IP address value will get that conversion trick. And the "0x" bit comes from the C strtol family of routines. (Try a leading "0" for octal.)

Some of us recall the old MacTCP control panel where you had to enter the "network" and "host" part separately, and you couldn't use dots within the name, so you'd have to do (for my network) "network 10", get out Calculator and work out 12 * 65536 + 0 * 256 + 37 for the host part. And then realize that you were actually using a subnet, so you'd done that all wrong and it should be "10 * 65536 + 12 * 256 + 0" for the network....

So what's really happening in inet_ntoa? (This is backed up with tests on my Linux host.)

No dots --> No network address, 32 bit host address
1 dot --> 8-bit network, 24 bit host (class A)
2 dots --> 16-bit network, 16-bit host (class B)
3 dots --> 24-bit network, 8-bit host (class C)

So we usually use class C formatted IPs, even though we no longer use class-based routing. They're just easier to work with.

Try accessing Apple's site at 0x11.034114040. That'll tell you how versatile your parser is. It seems many browsers are now blocking "imaginative" IP encodings. which is too bad, as hex coding IP numbers is useful for network testing.

The practical upshot for programmers is that you CANNOT process IP addresses in text, you must convert to binary first. (You can convert back to a canonical text form if you like, I guess.)



[ Reply to This | # ]
Another way of specifying an IP address in Cocoa apps
Authored by: phillyclaude on May 28, '03 01:05:55PM

I just tried it on my win2k machine here at work. It works in Phoenix/Firebird, but not IE6
-Claude



[ Reply to This | # ]
Doesn't Work Behind a Proxy
Authored by: aogail on May 28, '03 01:10:07PM

I tried this with my university's proxy in use--no go. The proxy tried to resolve the address as it was. This may be because the proxy is configured to try to search its domain before reporting the domain wasn't found; I'm not sure. Either way, turning off the proxy caused this method to work.



[ Reply to This | # ]
A little more info...
Authored by: dagg on May 28, '03 01:20:48PM
Here's a web page with some more examples. The link at the bottom goes into great detail.

[ Reply to This | # ]
Sorry they have beat you to it.
Authored by: gxw on May 29, '03 12:49:43AM

<i>Anyone have any ideas for optimum usage?</i>

Sorry, the blankety blank spammers already know about this [grin].

Cannot think of a good use other than obfuscating URLs on spam mail.



[ Reply to This | # ]
Some ideas
Authored by: trekan on May 29, '03 09:57:48AM

Another idea is to use it for storing different values in cookies for a website. That could be practical for test purposes or if more than one person is using the computer.<BR>
I by the way played a bit more with it, and found out that you can use a single zero as a shortcut for localhost / 127.0.0.1, so now when I'm going to use on of the http-services on my mac, I just write 0 i Safari. Or 0:631 for the CUPS print service overview.



[ Reply to This | # ]
Some ideas
Authored by: trekan on May 29, '03 10:21:46AM

Oh well... multiple users would have separate logins instead... but you get the picture



[ Reply to This | # ]
Another way of specifying an IP address in Cocoa apps
Authored by: merlyn on May 29, '03 01:21:10PM
perl -le 'print unpack "L", (gethostbyname("www.macosxhints.com"))[4]' prints 3475821262 . No need for all those fancy steps.

[ Reply to This | # ]
Excellent Use of This
Authored by: Paul Burney on May 29, '03 02:57:32PM
You can download an optimized IP to Country Database free from:

http://ip-to-country.com/

Then you can grab visitors IP addresses and figure out what country they are from with 98% accurate country recognition. This is much better than just doing DNS lookups for countries because of the many IP addresses that don't have reverse-mapped DNS.

[ Reply to This | # ]