🌐 IPv4 Address — Different Representations & Normalization Using Java
When working with networks, operating systems, or low-level protocols, an IPv4 address may not always appear in the familiar dotted-decimal form like:
An IPv4 address is fundamentally a 32-bit integer, and therefore it can be represented in multiple notations:
| Representation Format | Example | Description |
|---|---|---|
| Dotted Decimal | 192.0.2.235 | Standard human-friendly format |
| Dotted Hexadecimal | 0xC0.0x00.0x02.0xEB | Each octet represented in base-16 |
| Dotted Octal | 0300.0000.0002.0353 | Each octet represented in base-8 |
| Hexadecimal (no dots) | 0xC00002EB | Full 32-bit value as a single hex number |
| Decimal (no dots) | 3221226219 | Full 32-bit value represented as decimal |
| Octal (no dots) | 030000001353 | Full 32-bit value represented as octal |
👉 All of the above represent the same IPv4 address:
✅ 192.0.2.235
🧠 Why does this matter?
Some operating systems, browsers, and networking libraries accept alternative representations of IP addresses.
This can be exploited:
-
To evade security filters (firewalls, validation rules).
-
To bypass URL allow/block lists (e.g., app allows only whitelisted domain IP).
Example:
✅ Java Program — Normalize any IPv4 Representation
The following Java program accepts an IPv4 address in any supported notation (hex, octal, dotted, decimal), normalizes it, and prints it back in standard dotted decimal format.
No comments:
Post a Comment