BigIP Cookie 解码获取真实IP (python2)

2021/12/1 22:10:21

本文主要是介绍BigIP Cookie 解码获取真实IP (python2),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  

 

  BIGip是对负载均衡的实现,主要通过Virtual Server、iRules、Pool、Node、Monitor和Persistent(会话保持)实现。BIGip在实现会话保持机制时会在用户首次发起请求时,会为用户设置一个cookie,即服务端会添加set-cookie响应头头(比如:Set-Cookie: BIGipServerFinanceAndAdminWebfo.unc.edu=105389996.20480.0000 )。后续的请求会判断并使用这个cookie值,服务端解码该cookie并使用服务器
  

 

工具需要python2的环境,使用方法:

    python 1.py 110536896.20480.0000

1.py内容为以下代码
#!/usr/bin/python
#python2
# 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])

print "[*] Decoded Host and Port: %s.%s.%s.%s:%s\n" % (a,b,c,d, int(port,16))

 



这篇关于BigIP Cookie 解码获取真实IP (python2)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程