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 = {
|
2009-11-02 17:59:45 +00:00
|
|
|
:get => /^GET\s+([^\n]+)\s+HTTP\/\d\.\d/i,
|
|
|
|
:webhost => /^HOST\:\s+([^\n\r]+)/i,
|
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
|
2011-07-26 01:29:21 +00:00
|
|
|
return unless pkt.is_tcp?
|
|
|
|
return if (pkt.tcp_sport != 80 and pkt.tcp_dport != 80)
|
|
|
|
s = find_session((pkt.tcp_sport == 80) ? get_session_src(pkt) : get_session_dst(pkt))
|
2009-07-17 20:39:06 +00:00
|
|
|
|
|
|
|
self.sigs.each_key do |k|
|
2009-11-02 17:59:45 +00:00
|
|
|
|
2009-07-17 20:39:06 +00:00
|
|
|
# There is only one pattern per run to test
|
|
|
|
matched = nil
|
|
|
|
matches = nil
|
|
|
|
|
2011-07-26 01:29:21 +00:00
|
|
|
if(pkt.payload =~ 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])
|
2009-11-02 17:59:45 +00:00
|
|
|
return
|
2009-07-17 20:39:06 +00:00
|
|
|
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
|
2009-11-02 17:59:45 +00:00
|
|
|
|