faqts : Computers : Programming : Languages : Python : Snippets

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 22 people (50%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

Obfuscated IP-decoder

Jul 5th, 2000 09:59
Nathan Wallace, Hans Nowak, Snippet 15, Sven Havemann


"""
Packages: miscellaneous.obfuscated
"""

"""
I've found the following essentially single-line Python script useful in
decoding hexadecimal IP-Numbers (as given by /sbin/hostid on most unix
systems, I believe).
(For python newbies: The two lines at the bottom of the script should be
combined to one line)
"""

#!/usr/local/bin/python
from sys import *
if(len(argv)<2): 
  print "Usage: quadrupel fa04a404"
  exit()

print "%d.%d.%d.%d" % tuple(map(lambda
x,y=argv[1]:eval("0x"+y[2*x:2*x+2]),(0,1,2,3)))