1. 程式人生 > 其它 >BigIP Cookie 解碼獲取真實IP (python2)

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))
本人小白,不接受任何合作,文章多為轉載,如有侵權請聯絡。