Created
March 26, 2023 09:21
-
-
Save faisalfs10x/52356016cb3fd2eb31df224b3a04f152 to your computer and use it in GitHub Desktop.
Obfuscate IP address to decimal
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
#!/usr/bin/python3 | |
# Obfuscate IP address to decimal | |
import sys | |
ip_address = sys.argv[1] | |
# Convert IP address, split into 4 list as a zero-padded 2-digit hex and join list with no separator. | |
hex_ip = ''.join(['{:02x}'.format(int(i)) for i in ip_address.split('.')]) | |
# Convert hex_ip to int with base 16 since hexadecimal is base 16 | |
decimal_ip = int(hex_ip, 16) | |
print('Original IP:', ip_address) | |
print('Decimal IP:', decimal_ip) | |
# PS C:\Users\fs10x> python.exe .\ip2dec.py 8.8.8.8 | |
# Original IP: 8.8.8.8 | |
# Decimal IP: 134744072 | |
# | |
# PS C:\Users\fs10x> ping -n 2 134744072 | |
# | |
# Pinging 8.8.8.8 with 32 bytes of data: | |
# Reply from 8.8.8.8: bytes=32 time=7ms TTL=116 | |
# Reply from 8.8.8.8: bytes=32 time=7ms TTL=116 | |
# | |
# Ping statistics for 8.8.8.8: | |
# Packets: Sent = 2, Received = 2, Lost = 0 (0% loss), | |
# Approximate round trip times in milli-seconds: | |
# Minimum = 7ms, Maximum = 7ms, Average = 7ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment