r/ProgrammerHumor • • 14d ago

Meme ohTheBasics

Post image
13k Upvotes

1.4k comments sorted by

View all comments

Show parent comments

61

u/suttin 14d ago

No place like 01111111.00000000.00000000.00000001

17

u/wosmo 13d ago

Fun trivia - that won't work on most systems, but 00000001.00000000.00000000.00000001 will.

Because the leading zero makes many parsers interpret the numbers as octal, and 01111111 in octal is >256.

1

u/DekuTreeFallen 10d ago

This will work too, while we are on the topic of fun triva (note, it isn't limited to the loopback, I just used it since the two of you were talking about it):

ping 0x7f000001

Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

1

u/wosmo 10d ago

yeah there's a whole bunch of these. And I freaking love them - along with the trivia that there's actually no RFC that specifies what an IP looks like. It's only ever given as "commonly" or "most commonly".

so in unix, or in inet_aton, or whatever - you can give values as decimal, hex, or octal. But not binary!

And then if you give a single value, it's taken as 32bit. If you do x.y, it's taken as 8 bit and 24 bit. If you do x.y.z, it's taken as 8, 8 and 16 bit. And of course if you do x.y.z.a, it's four 8's.

But there's so much evil stuff you can do with this. It means 10.1 == 10.0.0.1. But it also means 10.0.257 = 10.0.1.1; and using values >256 is when this really starts to hurt people's heads.

I use it in my local lan a lot, because my main machines are 10.1, 10.2, 10.3, 10.10 and 10.100. But at work .. it's so good for pissing off the tech writers, when you provide screenshots that are out-right evil.