Created
November 18, 2016 23:09
-
-
Save sodejm/f4289906ff9eece48203e6a783960eeb to your computer and use it in GitHub Desktop.
Simple decoder for the big ip info disclosure
This file contains 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/env python3 | |
# decoder based on details from: https://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html | |
# Author: Justin Soderberg | |
import sys | |
if len(sys.argv) != 2 or sys.argv[1] == '-h' or sys.argv[1] == '--help': | |
print ('\nUsage: python %s <encoded address>\n' % (sys.argv[0])) | |
print ('Example:\n python %s 1677787402.36895.0000\n' % (sys.argv[0])) | |
exit() | |
# ip and port from args | |
orig_encoded_ip_port = sys.argv[1].split('.') | |
orig_encoded_ip = orig_encoded_ip_port[0] | |
orig_encoded_port = orig_encoded_ip_port[1] | |
# formatted ip and port to hex and trim uneeded value | |
formatted_ip = hex(int(orig_encoded_ip))[2:] # trim 0x and convert to hex | |
formatted_port = hex(int(orig_encoded_port))[2:] # trim 0x and convert to hex | |
decoded_ip = list() | |
decoded_port = list() | |
# split into ip groups | |
for i in range(0, len(formatted_ip), 2): | |
decoded_ip.append(str(int(formatted_ip[i:i + 2], base=16))) | |
# fix order of bytes | |
for i in range(0, len(formatted_port), 2): | |
decoded_port.append(str(formatted_port[i:i + 2])) | |
# reverse the order | |
decoded_ip.reverse() | |
decoded_port.reverse() | |
decoded_port = ''.join(decoded_port) | |
print ("--- BigIP Decoded --- \nIP Address: %s \nPort:%s" % ('.'.join(decoded_ip), int(str(decoded_port), base=16))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment