196 points · by lcedp · 13y ago · 95 comments
Here's some other encodings you can use for the same address, they're all valid and recognised by most browsers and other software:
The source for this comment is an XSS filtering bypass tool by RSnake — http://ha.ckers.org/xsscalc.html
http://184.11274826/ http://184.172.2634/
The rule here is that the last (but apparently only the last) numeric component may encode multiple bytes.
This small ruby script
#!/usr/bin/ruby
a, b, c, d = $*[0].split('.').map(&:to_i)
i = a * 256**3 + b * 256**2 + c * 256 + d
puts "dec: http://#{i}"
puts "hex: http://0x#{i.to_s(16)}"
puts "oct: http://0#{i.to_s(8)}"
..yields the following: % ip2dword 184.172.10.74
dec: http://3098282570
hex: http://0xb8ac0a4a
oct: http://027053005112Edit: I highly doubt that this is standard behavior. I suspect that implementations that permit this are storing the number in a 32 bit integer and not checking to see that it was truncated.
$ ping 7393249866
PING 7393249866 (184.172.10.74): 56 data bytes
64 bytes from 184.172.10.74: icmp_seq=0 ttl=47 time=259.042 ms4.2.2.1 or 0x04020201?
Mostly readability and speed of typing, I would think.
Does anyone know why Facebook does that?
http://[0:0:0:0:0:ffff:b8ac:a4a]
http://asdf:qwerty@3098282570/
http://asdf:qwerty@[0:0:0:0:0:ffff:b8ac:a4a]:80
(Might get a security/phishing warning on the last two links in some browsers.)
All IPv4 address are 32 bit addresses. That's why each number of an IPv4 address that people are familiar with are called octets. They represent 8 bits of the 32 bit address. So if you have 127.0.0.1, then the first octet is 127, the second is 0 and so on.
Any representation of this 32 bit number (including the most familiar A.B.C.D format) is a kind of short-hand for representing that 32 bit number.
I tried finding a link to a particular site that was phenomenal for learning the entire TCP/IP stack but I haven't seen that site since at least 1998.
But basically, if you want to spend time learning about IPv4 right before IPv6 becomes the dominant standard, then look into how hosts use the combination of IP address and subnet mask to determine if something is on the local network, how hosts use ARP to translate a 32 bit IP address into a MAC address and all the other low level protocols.
At best, you seem to be picking nits. More likely though I think you just have a very surface level understanding of what is going on here.
The bottom line is that, as I said already, an IPv4 address is a 32 bit number. It's also true that various tools that communicate with IP addresses utilize different methods to arrive at the underlying 32 bit number. But it's not right to say that "this only applies to systems using ping from iptools and glibc" as the article you linked says. Many of these "tricks" worked in all manner of operating systems and applications. I was discussing many of them in IRC using Windows 3.1 and Trumpet Winsock before 1994.
Again, the bottom line is that an IPv4 IP address is a 32 bit number and there are dozens of ways that various applications allow you to arrive at that number. It's silly for an article or someone quoting it to attempt to say it only applies to one implementation.
Not as much is changing as you think, at least for basic concepts and intro level stuff. Simpler in some ways.
To kick over a real bee hive, as I guy who's used ipv6 for I donno a decade or so now, the main issues are NAT6 love it (noobs) or hate it (folks who know what they're doing), believe it or not its easier to make a statefull firewall than to do NAT, some folks have bizarre ideas about ipv6 netmasks and what other people should be permitted to have, the concept of RFC1918 in ipv6 is more complicated, router advertisements RA love them or filter them, you probably need DHCPv6 or maybe not, and some firewall nuts filter DNS traffic into packets too small to hold AAAA records (but large enough to hold A records) Other than that ipv6 is just obese ipv4, the concepts of subnet and mask aren't changing, you've still got ARP just different address family in the protocol...
(edited to add my favorite topic, hand editing text zone files is probably not the most scalable way to implement reverse (or forward!) DNS for ipv6 from pure PITA perspective. Then again doing things by hand instead of automating is a PITA for ipv4 not just ipv6.)
Edited to Add:
Don't think good penetration testers (and malware writers, alas) don't already know about this trick. But, as http://xkcd.com/1053/ pointed out, it's always great to teach new people old things.
This was also a popular trick among kids at my high school to work around the web content filter and get on social networks
0x0a000001 = 10.0.0.1
0xc0a80001 = 192.168.0.1#!/usr/bin/env python
import socket
import struct
def ip2long(ip):
packedIP = socket.inet_aton(ip)
return struct.unpack("!L", packedIP)[0]
print ip2long('192.241.224.102') # your website ip address# or download it on github: https://gist.github.com/Leask/7075483
import ipaddress
print(int(ipaddress.ip_address('192.241.224.102')))~tomsyt-balsen/try=> `@p`3.098.282.570
~lanben-dibnup
184 * 256^3 + 172 * 256^2 + 10 * 256^1 + 74 * 256^0 == 3098282570At least it's good to know that the radical, ridiculous, Reddity mentality that's been plaguing HN as of late is coming from a clearly different group of people than those who used to comment. Looks like it's time to move on to greener pastures.
I notice that you haven't submitted any links. Is there any particular reason why? If you're not pleased with the content on the site, why don't you submit better content?
(For what it's worth: this content is news for me. I never spent much time thinking about IP addresses before clicking the link and getting confused for a solid minute. I understand what binary is, though, I promise!)
This totally confused me for a minute until I started reading the comments, what on earth does that say about my intellect?!
frets madly