Network Programming in Assembly: A Single-Pass Algorithm for Printing IP Addresses
When doing low-level network programming in Assembly, you experience firsthand the immense chaos running behind the scenes of operations we solve with a single line in high-level languages (Python, C, etc.). While developing the Nested-ICMP-Exploitation project, specifically an ICMP tunneling engine, I hit exactly this kind of wall: extracting an IP address from a packet header and printing it to the screen in the correct format.
Sounds simple, right? However, when x86 architecture and network protocols are involved, seeing 5.1.168.192 instead of 192.168.1.5 on your terminal is extremely common.
So why does this happen, and what kind of algorithm did I develop to overcome this issue during the debugging process? Let's dive into the background.