Skip to content

Commit 7031449

Browse files
committed
test nil of port & host
1 parent fe3f7fd commit 7031449

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

modules/auxiliary/gather/f5_bigip_cookie_disclosure.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ def cookie_decode(cookie_value)
3737
m = cookie_value.match(/(\d+)\.(\d+)\./)
3838
host = (m.nil?) ? nil : m[1]
3939
port = (m.nil?) ? nil : m[2]
40-
port = (("%04X" % port).slice(2,4) << ("%04X" % port).slice(0,2)).hex.to_s
41-
byte1 = ("%08X" % host).slice(6..7).hex.to_s
42-
byte2 = ("%08X" % host).slice(4..5).hex.to_s
43-
byte3 = ("%08X" % host).slice(2..3).hex.to_s
44-
byte4 = ("%08X" % host).slice(0..1).hex.to_s
45-
host = byte1 << "." << byte2 << "." << byte3 << "." << byte4
40+
unless host.nil? && port.nil?
41+
port = (("%04X" % port).slice(2,4) << ("%04X" % port).slice(0,2)).hex.to_s
42+
byte1 = ("%08X" % host).slice(6..7).hex.to_s
43+
byte2 = ("%08X" % host).slice(4..5).hex.to_s
44+
byte3 = ("%08X" % host).slice(2..3).hex.to_s
45+
byte4 = ("%08X" % host).slice(0..1).hex.to_s
46+
host = byte1 << "." << byte2 << "." << byte3 << "." << byte4
47+
end
4648
return host,port
4749
end
4850

0 commit comments

Comments
 (0)