Ensure that we check for pcaprub before doing much anything else for those modules that actually require it. In some cases, that means moving open_pcap() up to be the first method call, in others, insert check_pcaprub_loaded first. Also removes a few cases of redundant checking (the Capture mixin does all this already anyway).

git-svn-id: file:///home/svn/framework3/trunk@13381 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Tod Beardsley 2011-07-27 20:21:47 +00:00
parent 75c4553bb8
commit df52bfaa4f
22 changed files with 23 additions and 54 deletions

View File

@ -49,8 +49,8 @@ class Metasploit3 < Msf::Auxiliary
end
def run
print_status("Creating DHCP Request with 0-length ClientID")
open_pcap
print_status("Creating DHCP Request with 0-length ClientID")
p = PacketFu::UDPPacket.new
p.ip_daddr = "255.255.255.255"
p.udp_sport = 68

View File

@ -40,10 +40,10 @@ class Metasploit3 < Msf::Auxiliary
end
def run
print_status("Sending to #{rhost}")
open_pcap
print_status("Sending to #{rhost}")
p = PacketFu::UDPPacket.new
p.ip_saddr = "0.0.0.0"
p.ip_daddr = rhost

View File

@ -51,10 +51,10 @@ class Metasploit3 < Msf::Auxiliary
end
def run_host(ip)
print_status("Sending a mode 7 packet to host #{ip} from #{datastore['LHOST']}")
open_pcap
print_status("Sending a mode 7 packet to host #{ip} from #{datastore['LHOST']}")
p = PacketFu::UDPPacket.new
p.ip_saddr = datastore['LHOST']
p.ip_daddr = ip

View File

@ -40,8 +40,8 @@ class Metasploit3 < Msf::Auxiliary
end
def run
print_status("Creating DTLS ChangeCipherSpec Datagram...")
open_pcap
print_status("Creating DTLS ChangeCipherSpec Datagram...")
p = PacketFu::UDPPacket.new
p.ip_daddr = datastore['RHOST']
p.ip_src = rand(0x100000000)

View File

@ -43,11 +43,10 @@ class Metasploit3 < Msf::Auxiliary
end
def run
open_pcap
print_status("Sending packet to #{rhost}")
open_pcap
p = PacketFu::TCPPacket.new
p.ip_saddr = datastore['SHOST'] || Rex::Socket.source_address(rhost)
p.ip_daddr = dhost

View File

@ -43,12 +43,12 @@ class Metasploit3 < Msf::Auxiliary
def run
open_pcap
print_status("Sending malformed LDAP packet to #{rhost}")
m = Rex::Text.rand_text_alpha_lower(3)
open_pcap
p = PacketFu::TCPPacket.new
p.ip_saddr = datastore['SHOST'] || Rex::Socket.source_address(rhost)
p.ip_daddr = rhost

View File

@ -43,8 +43,7 @@ class Metasploit3 < Msf::Auxiliary
end
def run_batch(hosts)
check_pcaprub_loaded
open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
@netifaces = true
if not netifaces_implemented?
@ -62,8 +61,6 @@ class Metasploit3 < Msf::Auxiliary
smac ||= get_mac(datastore['INTERFACE']) if @netifaces
raise RuntimeError ,'SMAC should be defined' unless smac
open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
begin
hosts.each do |dhost|

View File

@ -46,16 +46,15 @@ class Metasploit3 < Msf::Auxiliary
end
def run_batch(hosts)
open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
print_status("Discovering IPv4 nodes via ARP...")
print_status("")
shost = datastore['SHOST']
smac = datastore['SMAC']
addrs = []
open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
begin
found = {}
hosts.each do |dhost|

View File

@ -39,13 +39,6 @@ class Metasploit3 < Msf::Auxiliary
'Version' => '$Revision$'
)
begin
require 'pcaprub'
@@havepcap = true
rescue ::LoadError
@@havepcap = false
end
register_options([
Opt::RPORT(80),
OptInt.new('TIMEOUT', [true, "The reply read timeout in milliseconds", 500]),
@ -66,7 +59,6 @@ class Metasploit3 < Msf::Auxiliary
def run_host(ip)
open_pcap
raise "Pcaprub is not available" if not @@havepcap
raise "SAMPLES option must be >= 2" if datastore['SAMPLES'] < 2
pcap = self.capture

View File

@ -30,13 +30,6 @@ class Metasploit3 < Msf::Auxiliary
'License' => MSF_LICENSE
)
begin
require 'pcaprub'
@@havepcap = true
rescue ::LoadError
@@havepcap = false
end
register_options([
OptString.new('PORTS', [true, "Ports to scan (e.g. 22-25,80,110-900)", "1-10000"]),
OptInt.new('TIMEOUT', [true, "The reply read timeout in milliseconds", 500]),
@ -54,8 +47,6 @@ class Metasploit3 < Msf::Auxiliary
def run_batch(hosts)
open_pcap
raise "Pcaprub is not available" if not @@havepcap
pcap = self.capture
ports = Rex::Socket.portspec_crack(datastore['PORTS'])

View File

@ -28,13 +28,6 @@ class Metasploit3 < Msf::Auxiliary
'License' => MSF_LICENSE
)
begin
require 'pcaprub'
@@havepcap = true
rescue ::LoadError
@@havepcap = false
end
register_options([
OptString.new('PORTS', [true, "Ports to scan (e.g. 22-25,80,110-900)", "1-10000"]),
OptInt.new('TIMEOUT', [true, "The reply read timeout in milliseconds", 500]),
@ -52,8 +45,6 @@ class Metasploit3 < Msf::Auxiliary
def run_batch(hosts)
open_pcap
raise "Pcaprub is not available" if not @@havepcap
pcap = self.capture
ports = Rex::Socket.portspec_crack(datastore['PORTS'])

View File

@ -30,13 +30,6 @@ class Metasploit3 < Msf::Auxiliary
'License' => MSF_LICENSE
)
begin
require 'pcaprub'
@@havepcap = true
rescue ::LoadError
@@havepcap = false
end
register_options([
OptString.new('PORTS', [true, "Ports to scan (e.g. 22-25,80,110-900)", "1-10000"]),
OptInt.new('TIMEOUT', [true, "The reply read timeout in milliseconds", 500]),
@ -54,8 +47,6 @@ class Metasploit3 < Msf::Auxiliary
def run_batch(hosts)
open_pcap
raise "Pcaprub is not available" if not @@havepcap
pcap = self.capture
ports = Rex::Socket.portspec_crack(datastore['PORTS'])

View File

@ -48,8 +48,8 @@ class Metasploit3 < Msf::Auxiliary
end
def run
print_status("Opening the capture interface...")
open_pcap('SNAPLEN' => 128, 'FILTER' => build_filter)
print_status("Opening the capture interface...")
print_status("Waiting for responses to rogue_send...")
begin

View File

@ -86,6 +86,7 @@ class Metasploit3 < Msf::Auxiliary
end
def run
check_pcaprub_loaded # Check first
# Load all of our existing protocols
load_protocols

View File

@ -59,6 +59,7 @@ class Metasploit3 < Msf::Auxiliary
end
def run
open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
@netifaces = true
if not netifaces_implemented?
print_error("WARNING : Pcaprub is not uptodate, some functionality will not be available")
@ -77,7 +78,6 @@ class Metasploit3 < Msf::Auxiliary
end
begin
open_pcap({'SNAPLEN' => 68, 'FILTER' => "arp[6:2] == 0x0002"})
@interface = datastore['INTERFACE'] || Pcap.lookupdev
@smac = datastore['SMAC']

View File

@ -160,6 +160,7 @@ class Metasploit3 < Msf::Auxiliary
end
def run
check_pcaprub_loaded # Check first
target = rhost()
source = Rex::Socket.source_address(target)
saddr = datastore['SRCADDR']

View File

@ -150,6 +150,8 @@ class Metasploit3 < Msf::Auxiliary
end
def run
check_pcaprub_loaded # Check first.
target = rhost()
source = Rex::Socket.source_address(target)
saddr = datastore['SRCADDR']

View File

@ -56,6 +56,7 @@ class Metasploit3 < Msf::Auxiliary
end
def run
check_pcaprub_loaded() # Check first since otherwise this is all for naught
# MacOS X workaround
::Socket.do_not_reverse_lookup = true

View File

@ -38,6 +38,7 @@ class Metasploit3 < Msf::Auxiliary
end
def run
check_pcaprub_loaded # Check first
pkt_delay = datastore['PKT_DELAY']
delay = datastore['DELAY']
loop = datastore['LOOP']

View File

@ -145,6 +145,7 @@ class Metasploit3 < Msf::Exploit::Remote
end
def exploit
check_pcaprub_loaded # Check first
ret_offset = target['RetOff']

View File

@ -155,6 +155,7 @@ class Metasploit3 < Msf::Exploit::Remote
end
def exploit
check_pcaprub_loaded # Check first
ret_offset = target['RetOff']

View File

@ -82,6 +82,7 @@ class Metasploit3 < Msf::Exploit::Remote
end
def exploit
check_pcaprub_loaded # Check first
ptype = "\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x23\x23"