Created
September 11, 2018 14:38
-
-
Save ValentinH/24f906740482d3189f8ed2e62d0ad241 to your computer and use it in GitHub Desktop.
Javascript function to decrypt the BIGipServer cookie. Inspired from https://github.com/psmet/BIGip-cookie-decoder and https://www.jardinesoftware.net/2015/09/18/f5-bigip-decode-with-fiddler/
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
function decryptBigIpCookie(cookieValue) { | |
const [ipPart, portPart] = cookieValue.split('.') | |
const hexIp = parseInt(ipPart, 10) | |
.toString(16) | |
.padStart(8, '0') | |
const ip1 = parseInt(hexIp.toString().substring(6, 8), 16) | |
const ip2 = parseInt(hexIp.toString().substring(4, 6), 16) | |
const ip3 = parseInt(hexIp.toString().substring(2, 4), 16) | |
const ip4 = parseInt(hexIp.toString().substring(0, 2), 16) | |
const ip = `${ip1}.${ip2}.${ip3}.${ip4}` | |
const hexPort = parseInt(portPart, 10) | |
.toString(16) | |
.padStart(4, '0') | |
const port1 = hexPort.toString().substring(2, 4) | |
const port2 = hexPort.toString().substring(0, 2) | |
const port = parseInt(`${port1}${port2}`, 16) | |
return { | |
ip, | |
port, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment