Python Script: IP Address to 10digit decimal to IP address
Friday, November 30, 2012
1 comments
When hacking android apps I learned today that you can convert a IP address into a 10digit decimal number. This number is still valid in any web browser. I wrote two python programs to go both ways ;)
Used http://www.iowight.com/iwindex/decimal.php3 for the math.
From 10digit decimal to ip address:
From IP Address to 10 digit decimal.
Used http://www.iowight.com/iwindex/decimal.php3 for the math.
From 10digit decimal to ip address:
#convert 10digit decimal formated ipaddress to normal ipaddress #by init6 #blog.init6.me import sys #read file and convert each line to ip address. Comment out to ask for input. with as infile: for line in infile: print ( ) #ask for input (dec format) Uncomment to ask for input. #decIn = input("Enter 10 digit decimal formated ipaddress: ") if == True: #convert dec to hex fullHex = . #Split hex number into four pairs hex1 = hex2 = hex3 = hex4 = #Convert each hex to decimal then to a string and return ip address. ipAddr = ( + '.' + + '.' + + '.' + ) return ipAddr #Checks to see if input is a 32bit int or less to make sure its a vaild ip address. try: bitstring= except (TypeError, ValuueError): return False if <= 32: return True else: print ("Not a vaild 32bit 10 digit decimal") return False
From IP Address to 10 digit decimal.
#convert ip address to a 10digit decimal formated ipaddress. #by init6 #blog.init6.me import sys ipAddr = print ( ) out = octets = hexNum = '{:02X}{:02X}{:02X}{:02X}'. return