Created
July 20, 2016 16:25
-
-
Save Tony3-sec/e2255acf11da13234514d0559645c916 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| ## Convert hexadecimal to IP address | |
| if len(sys.argv) < 2: | |
| print('Please type hexadecimal') | |
| else: | |
| i = 0 | |
| j = 2 | |
| ipaddr = '' | |
| data = sys.argv[1] | |
| while len(data[i:j]) != 0: | |
| hex_data = data[i:j] #pick two chars from arg | |
| octet = '0x' + str(hex_data) | |
| ipaddr += str(int(octet, 16)) + str('.') | |
| i += 2 | |
| j += 2 | |
| print(ipaddr.rstrip('.')) #strip last dot and print the IP address |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment