#!/usr/bin/env python
# example string: 110536896.20480.0000
import struct
import sys
if len(sys.argv) != 2:
print "Usage: %s encoded_string" % sys.argv[0]
exit(1)
encoded_string = sys.argv[1]
print "\n[*] String to decode: %s\n" % encoded_string
(host, port, end) = encoded_string.split('.')
(a, b, c, d) = [ord(i) for i in struct.pack("<I", int(host))]
(e) = [ord(e) for e in struct.pack("<H", int(port))]
port = "0x%02X%02X" % (e[0],e[1])
#!/usr/bin/perl
use strict;
use warnings;
my ($ip,$port) = split(‘.’,$ARGV[0]);
#Convert to IP to hex
my $ip_hex = sprintf(“%x”,$ip);
#Prepend extra 0 if hex value is only 7 char
$ip_hex = “0”.”$ip_hex” if (length $ip_hex ==7);
#Decode hex to IP
my $d_ip = join (‘.’,map {hex $_} reverse ($ip_hex =~ m/../g));
#Decode hex to port
my $d_port = hex join(“”,reverse( sprintf(“%x”,$port) =~ m/../g) );
print “The persistence cookie decoded: $d_ip:$d_portn”;