Files
metasploit-gs/data/exploits/psnuffle/url.rb
T

48 lines
1.2 KiB
Ruby
Raw Normal View History

2009-08-19 14:07:33 +00:00
# Psnuffle password sniffer add-on class for HTTP GET URL's
# part of psnuffle sniffer auxiliary module
#
# Very simple example how to write sniffer extensions
#
2009-07-17 20:39:06 +00:00
# Sniffer class for GET URL's
class SnifferURL < BaseProtocolParser
def register_sigs
2009-08-19 14:07:33 +00:00
self.sigs = {
:get => /^GET\s+([^\n]+)\s+HTTP\/\d\.\d/si,
:webhost => /^HOST\:\s+([^\n\r]+)/si,
2009-07-17 20:39:06 +00:00
}
end
def parse(pkt)
2009-08-19 14:07:33 +00:00
# We want to return immediantly if we do not have a packet which is handled by us
2009-07-17 20:39:06 +00:00
return if not pkt[:tcp]
return if (pkt[:tcp].dst_port != 80)
2009-08-19 14:07:33 +00:00
s = find_session((pkt[:tcp].dst_port == 80) ? get_session_dst(pkt) : get_session_src(pkt))
2009-07-17 20:39:06 +00:00
self.sigs.each_key do |k|
# There is only one pattern per run to test
matched = nil
matches = nil
2009-07-25 14:11:55 +00:00
if(pkt[:tcp].payload_data =~ self.sigs[k])
2009-07-17 20:39:06 +00:00
matched = k
matches = $1
2009-08-19 14:07:33 +00:00
sessions[s[:session]].merge!({k => matches})
2009-07-17 20:39:06 +00:00
end
case matched
2009-08-19 14:07:33 +00:00
when :webhost
sessions[s[:session]].merge!({k => matches})
2009-07-17 20:39:06 +00:00
if(s[:get])
2009-08-19 14:07:33 +00:00
print_status("HTTP GET: #{s[:session]} http://#{s[:webhost]}#{s[:get]}")
2009-07-17 20:39:06 +00:00
sessions.delete(s[:session])
return
end
when nil
# No matches, no saved state
end # end case matched
end # end of each_key
end # end of parse
end # end of URL sniffer