1## 2# This file is part of WhatWeb and may be subject to 3# redistribution and commercial restrictions. Please see the WhatWeb 4# web site for more information on licensing and terms of use. 5# http://www.morningstarsecurity.com/research/whatweb 6## 7# Version 0.5 # 2011-05-14 # Brendan Coles <bcoles@gmail.com> 8# Changed @cookies to @headers["set-cookie"] to support recursive mode 9## 10# Version 0.4 # 2011-04-08 # Brendan Coles <bcoles@gmail.com> 11# Added username and localfile path detection for cookies containing public_html 12## 13# Version 0.3 # 2011-01-30 # Brendan Coles <bcoles@gmail.com> 14# Fixed regex bug # Cookies were always split by "=" even when it wasn't present 15## 16# Version 0.2 17# removed :certainty=>100 18## 19Plugin.define "Cookies" do 20author "Andrew Horton" 21version "0.5" 22description "Display the names of cookies in the HTTP headers. The values are not returned to save on space." 23 24# ShodanHQ results as at 2011-04-08 # 25# 2,527,334 for set-cookie 26# 37 for set-cookie path home public_html 27# 17 for set-cookie path=/home/ /public_html 28 29# Passive # 30def passive 31 m=[] 32 33 unless @headers["set-cookie"].nil? or @headers["set-cookie"].empty? 34 35 # Extract cookie names 36 @headers["set-cookie"].split("\n").each do |cookie| 37 m << { :string=>cookie.split("=")[0] } if cookie =~ /=/ 38 end 39 40 # Detect local file paths containing public_html 41 if @headers["set-cookie"].to_s =~ /path=\/home[\d]*\/([^\/]+)\/public_html\// 42 m << { :account=>@headers["set-cookie"].to_s.scan(/path=\/home[\d]*\/([^\/]+)\/public_html\//).flatten } 43 m << { :filepath=>@headers["set-cookie"].to_s.scan(/path=(\/home[\d]*\/[^\/]+\/public_html\/)/).flatten } 44 end 45 46 end 47 48 # Return passive match 49 m 50end 51 52end 53 54