2009-10-30 07:36:00 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Capture
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Rogue Gateway Detection: Receiver',
|
|
|
|
'Description' => %q{
|
|
|
|
This module listens for replies to the requests sent by
|
|
|
|
the rogue_send module. The RPORT, CPORT, and ECHOID values
|
|
|
|
must match the rogue_send parameters used exactly.
|
|
|
|
},
|
|
|
|
'Author' => 'hdm',
|
|
|
|
'License' => MSF_LICENSE,
|
2010-01-26 20:12:13 +00:00
|
|
|
'Version' => '$Revision$',
|
2009-10-30 07:36:00 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://www.metasploit.com/research/projects/rogue_network/'],
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptPort.new("RPORT", [true, "The destination port for the TCP SYN packet", 80]),
|
|
|
|
OptPort.new("CPORT", [true, "The source port for the TCP SYN packet", 13832]),
|
|
|
|
OptInt.new("ECHOID", [true, "The unique ICMP ECHO ID to embed into the packet", 7893]),
|
|
|
|
])
|
2011-03-13 04:20:19 +00:00
|
|
|
deregister_options('RHOST')
|
2009-10-30 07:36:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def build_filter
|
2011-03-14 15:58:17 +00:00
|
|
|
"(icmp and icmp[0] == 0) or (" +
|
2009-10-30 07:36:00 +00:00
|
|
|
"tcp and (tcp[13] == 0x12 or (tcp[13] & 0x04) != 0) and " +
|
|
|
|
"src port #{datastore['RPORT']} and dst port #{datastore['CPORT']} " +
|
|
|
|
")"
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
print_status("Opening the capture interface...")
|
|
|
|
open_pcap('SNAPLEN' => 128, 'FILTER' => build_filter)
|
|
|
|
|
|
|
|
print_status("Waiting for responses to rogue_send...")
|
|
|
|
begin
|
|
|
|
each_packet do |pkt|
|
|
|
|
r = parse_reply(pkt)
|
|
|
|
next if not r
|
|
|
|
print_status("Reply from #{r[:internal]} using gateway #{r[:external]} (#{r[:type].to_s.upcase})")
|
|
|
|
end
|
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
|
|
|
ensure
|
|
|
|
close_pcap
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def parse_reply(r)
|
2011-07-26 01:29:21 +00:00
|
|
|
p = PacketFu::Packet.parse(r)
|
|
|
|
return unless p.is_eth?
|
|
|
|
if p.is_icmp?
|
|
|
|
return if(p.payload[0,2] != [datstore['ECHOID']].pack("n"))
|
|
|
|
return unless p.payload.size >= 8
|
|
|
|
reply = {:raw => p}
|
|
|
|
reply[:type] = :icmp
|
|
|
|
reply[:internal] = Rex::Socket.addr_nota(p.payload[4,4])
|
|
|
|
reply[:external] = p.ip_saddr
|
|
|
|
elsif p.is_tcp?
|
|
|
|
return if p.tcp_ack.zero?
|
|
|
|
reply = {:packet => p}
|
|
|
|
reply[:type] = :tcp
|
|
|
|
reply[:internal] = Rex::Socket.addr_itoa(p.tcp_ack - 1)
|
|
|
|
reply[:external] = p.ip_saddr
|
|
|
|
else
|
|
|
|
reply = nil
|
2009-10-30 07:36:00 +00:00
|
|
|
end
|
2011-07-26 01:29:21 +00:00
|
|
|
return reply
|
2009-10-30 07:36:00 +00:00
|
|
|
end
|
2011-07-26 01:29:21 +00:00
|
|
|
|
2009-10-30 07:36:00 +00:00
|
|
|
end
|
|
|
|
|