bug/bundler_fix
jvazquez-r7 2013-07-10 14:04:46 -05:00
commit b8ce98b896
7 changed files with 544 additions and 577 deletions

View File

@ -23,6 +23,7 @@ group :db do
end end
group :pcap do group :pcap do
gem 'network_interface', '~> 0.0.1'
# For sniffer and raw socket modules # For sniffer and raw socket modules
gem 'pcaprub' gem 'pcaprub'
end end

View File

@ -31,6 +31,7 @@ GEM
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
msgpack (0.5.4) msgpack (0.5.4)
multi_json (1.0.4) multi_json (1.0.4)
network_interface (0.0.1)
nokogiri (1.5.9) nokogiri (1.5.9)
packetfu (1.1.8) packetfu (1.1.8)
pcaprub (0.11.3) pcaprub (0.11.3)
@ -68,6 +69,7 @@ DEPENDENCIES
json json
metasploit_data_models (~> 0.16.1) metasploit_data_models (~> 0.16.1)
msgpack msgpack
network_interface (~> 0.0.1)
nokogiri nokogiri
packetfu (= 1.1.8) packetfu (= 1.1.8)
pcaprub pcaprub

View File

@ -13,8 +13,8 @@ module Msf
# #
### ###
class Exploit class Exploit
module Capture module Capture
# #
# Initializes an instance of an exploit module that captures traffic # Initializes an instance of an exploit module that captures traffic
@ -53,20 +53,28 @@ module Capture
@pcaprub_error = e @pcaprub_error = e
end end
begin
require 'network_interface'
@network_interface_loaded = true
rescue ::Exception => e
@network_interface_loaded = false
@network_interface_error = e
end
end end
def stats_recv(pcap=self.capture) def stats_recv(pcap=self.capture)
return(0) if not pcap return(0) unless pcap
pcap.stats['recv'] pcap.stats['recv']
end end
def stats_drop(pcap=self.capture) def stats_drop(pcap=self.capture)
return(0) if not pcap return(0) unless pcap
pcap.stats['drop'] pcap.stats['drop']
end end
def stats_ifdrop(pcap=self.capture) def stats_ifdrop(pcap=self.capture)
return(0) if not pcap return(0) unless pcap
pcap.stats['ifdrop'] pcap.stats['ifdrop']
end end
@ -94,8 +102,8 @@ module Capture
# Look for a PCAP file # Look for a PCAP file
cap = datastore['PCAPFILE'] || '' cap = datastore['PCAPFILE'] || ''
if(not cap.empty?) if (not cap.empty?)
if(not File.exists?(cap)) if (not File.exists?(cap))
raise RuntimeError, "The PCAP file #{cap} could not be found" raise RuntimeError, "The PCAP file #{cap} could not be found"
end end
self.capture = ::Pcap.open_offline(cap) self.capture = ::Pcap.open_offline(cap)
@ -125,7 +133,7 @@ module Capture
end end
def close_pcap def close_pcap
return if not self.capture return unless self.capture
self.capture = nil self.capture = nil
self.arp_capture = nil self.arp_capture = nil
GC.start() GC.start()
@ -139,9 +147,9 @@ module Capture
while (idx < raw.length) while (idx < raw.length)
len = raw[idx+1] len = raw[idx+1]
return set if not len return set unless len
set[ raw[idx] ] ||= [] set[raw[idx]] ||= []
set[ raw[idx] ].push(raw[idx + 2, len]) set[raw[idx]].push(raw[idx + 2, len])
idx += len + 2 idx += len + 2
end end
@ -153,7 +161,7 @@ module Capture
# signal handling of Ruby 1.9 # signal handling of Ruby 1.9
# #
def each_packet def each_packet
return if not capture return unless capture
begin begin
@capture_count = 0 @capture_count = 0
reader = framework.threads.spawn("PcapReceiver", false) do reader = framework.threads.spawn("PcapReceiver", false) do
@ -175,7 +183,7 @@ module Capture
# Injects a packet on the wire. For all injection-related functions, it's # Injects a packet on the wire. For all injection-related functions, it's
# on the module to open up a capture device first (this way, we don't # on the module to open up a capture device first (this way, we don't
# needlessly spawn new capture devices). # needlessly spawn new capture devices).
def inject(pkt="",pcap=self.capture) def inject(pkt="", pcap=self.capture)
check_pcaprub_loaded check_pcaprub_loaded
if not pcap if not pcap
raise RuntimeError, "Could not access the capture process (remember to open_pcap first!)" raise RuntimeError, "Could not access the capture process (remember to open_pcap first!)"
@ -205,20 +213,20 @@ module Capture
p.payload = payload.to_s p.payload = payload.to_s
end end
end end
inject p.to_s,pcap inject p.to_s, pcap
end end
def inject_pcap(pcap_file, filter=nil, delay = 0, pcap=self.capture) def inject_pcap(pcap_file, filter=nil, delay = 0, pcap=self.capture)
check_pcaprub_loaded check_pcaprub_loaded
if not pcap unless pcap
raise RuntimeError, "Could not access the capture process (remember to open_pcap first!)" raise RuntimeError, "Could not access the capture process (remember to open_pcap first!)"
end end
if(not File.exists?(pcap_file)) if (not File.exists?(pcap_file))
raise RuntimeError, "The PCAP file #{pcap_file} could not be found" raise RuntimeError, "The PCAP file #{pcap_file} could not be found"
end end
if(pcap_file.empty?) if (pcap_file.empty?)
raise RuntimeError, "The PCAP file #{pcap_file} is empty" raise RuntimeError, "The PCAP file #{pcap_file} is empty"
end end
@ -226,7 +234,7 @@ module Capture
capture_file.setfilter(filter) if filter capture_file.setfilter(filter) if filter
while (pkt = capture_file.next) do while (pkt = capture_file.next) do
pcap.inject(pkt) pcap.inject(pkt)
Kernel.select(nil, nil, nil, (delay * 1.0)/1000) Rex.sleep((delay * 1.0)/1000)
end end
GC.start GC.start
end end
@ -239,7 +247,7 @@ module Capture
raise RuntimeError, "Could not access the capture process (remember to open_pcap first!)" unless self.capture raise RuntimeError, "Could not access the capture process (remember to open_pcap first!)" unless self.capture
raise RuntimeError, "Must specify a host to sendto" unless dhost raise RuntimeError, "Must specify a host to sendto" unless dhost
dev ||= datastore['INTERFACE'] dev ||= datastore['INTERFACE']
dst_mac,src_mac = lookup_eth(dhost,dev) dst_mac, src_mac = lookup_eth(dhost, dev)
if dst_mac == nil and not bcast if dst_mac == nil and not bcast
return false return false
end end
@ -247,7 +255,7 @@ module Capture
end end
# The return value either be a PacketFu::Packet object, or nil # The return value either be a PacketFu::Packet object, or nil
def inject_reply(proto=:udp,pcap=self.capture) def inject_reply(proto=:udp, pcap=self.capture)
reply = nil reply = nil
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0 to = (datastore['TIMEOUT'] || 500).to_f / 1000.0
if not pcap if not pcap
@ -257,7 +265,7 @@ module Capture
::Timeout.timeout(to) do ::Timeout.timeout(to) do
pcap.each do |r| pcap.each do |r|
packet = PacketFu::Packet.parse(r) packet = PacketFu::Packet.parse(r)
next unless packet.proto.map {|x| x.downcase.to_sym}.include? proto next unless packet.proto.map { |x| x.downcase.to_sym }.include? proto
reply = packet reply = packet
break break
end end
@ -274,8 +282,8 @@ module Capture
# do inject and capture packets, and will always first fire off a # do inject and capture packets, and will always first fire off a
# UDP packet using the regular socket to learn the source host's # UDP packet using the regular socket to learn the source host's
# and gateway's mac addresses. # and gateway's mac addresses.
def lookup_eth(addr=nil,iface=nil) def lookup_eth(addr=nil, iface=nil)
raise RuntimeError, "Could not access the capture process." if not self.arp_capture raise RuntimeError, "Could not access the capture process." unless self.arp_capture
self.arp_cache ||= {} self.arp_cache ||= {}
self.dst_cache ||= {} self.dst_cache ||= {}
@ -293,7 +301,7 @@ module Capture
dst_mac = self.arp_cache[:gateway] dst_mac = self.arp_cache[:gateway]
end end
self.dst_cache[addr] = [dst_mac,src_mac] self.dst_cache[addr] = [dst_mac, src_mac]
end end
def probe_gateway(addr) def probe_gateway(addr)
@ -301,15 +309,15 @@ module Capture
dst_port = rand(30000)+1024 dst_port = rand(30000)+1024
preamble = [datastore['UDP_SECRET']].pack("N") preamble = [datastore['UDP_SECRET']].pack("N")
secret = "#{preamble}#{Rex::Text.rand_text(rand(0xff)+1)}" secret = "#{preamble}#{Rex::Text.rand_text(rand(0xff)+1)}"
UDPSocket.open.send(secret,0,dst_host,dst_port) UDPSocket.open.send(secret, 0, dst_host, dst_port)
begin begin
to = (datastore['TIMEOUT'] || 1500).to_f / 1000.0 to = (datastore['TIMEOUT'] || 1500).to_f / 1000.0
::Timeout.timeout(to) do ::Timeout.timeout(to) do
while(my_packet = inject_reply(:udp,self.arp_capture)) while (my_packet = inject_reply(:udp, self.arp_capture))
if my_packet.payload == secret if my_packet.payload == secret
dst_mac = self.arp_cache[:gateway] = my_packet.eth_daddr dst_mac = self.arp_cache[:gateway] = my_packet.eth_daddr
src_mac = self.arp_cache[Rex::Socket.source_address(addr)] = my_packet.eth_saddr src_mac = self.arp_cache[Rex::Socket.source_address(addr)] = my_packet.eth_saddr
return [dst_mac,src_mac] return [dst_mac, src_mac]
else else
next next
end end
@ -328,8 +336,8 @@ module Capture
return self.arp_cache[target_ip] if self.arp_cache[target_ip] return self.arp_cache[target_ip] if self.arp_cache[target_ip]
return self.arp_cache[:gateway] unless should_arp? target_ip return self.arp_cache[:gateway] unless should_arp? target_ip
source_ip = Rex::Socket.source_address(target_ip) source_ip = Rex::Socket.source_address(target_ip)
raise RuntimeError, "Could not access the capture process." if not self.arp_capture raise RuntimeError, "Could not access the capture process." unless self.arp_capture
p = arp_packet(target_ip,source_ip) p = arp_packet(target_ip, source_ip)
inject_eth(:eth_type => 0x0806, inject_eth(:eth_type => 0x0806,
:payload => p, :payload => p,
:pcap => self.arp_capture, :pcap => self.arp_capture,
@ -338,7 +346,7 @@ module Capture
begin begin
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0 to = (datastore['TIMEOUT'] || 500).to_f / 1000.0
::Timeout.timeout(to) do ::Timeout.timeout(to) do
while(my_packet = inject_reply(:arp,self.arp_capture)) while (my_packet = inject_reply(:arp, self.arp_capture))
if my_packet.arp_saddr_ip == target_ip if my_packet.arp_saddr_ip == target_ip
self.arp_cache[target_ip] = my_packet.eth_saddr self.arp_cache[target_ip] = my_packet.eth_saddr
return self.arp_cache[target_ip] return self.arp_cache[target_ip]
@ -352,7 +360,7 @@ module Capture
end end
# Creates a full ARP packet, mainly for use with inject_eth() # Creates a full ARP packet, mainly for use with inject_eth()
def arp_packet(target_ip=nil,source_ip=nil) def arp_packet(target_ip=nil, source_ip=nil)
p = PacketFu::ARPPacket.new p = PacketFu::ARPPacket.new
p.arp_opcode = 1 p.arp_opcode = 1
p.arp_daddr_ip = target_ip || datastore['RHOST'] p.arp_daddr_ip = target_ip || datastore['RHOST']
@ -376,6 +384,9 @@ module Capture
if not @pcaprub_loaded if not @pcaprub_loaded
print_status("The Pcaprub module is not available: #{@pcaprub_error}") print_status("The Pcaprub module is not available: #{@pcaprub_error}")
raise RuntimeError, "Pcaprub not available" raise RuntimeError, "Pcaprub not available"
elsif not @network_interface_loaded
print_status("The NetworkInterface module is not available: #{@network_interface_error}")
raise RuntimeError, "NetworkInterface not available"
else else
true true
end end
@ -406,29 +417,24 @@ module Capture
#Netifaces code #Netifaces code
# netifaces code is not available in pcaprub 0.9.2 and prior,
# which is going to be installed in a lot of places. Modules
# which want it should check explicitly for it. TODO: Bug upstream
# to release it for real in 0.9.3
def netifaces_implemented? def netifaces_implemented?
@pcaprub_loaded and @network_interface_loaded and
Pcap.respond_to?(:lookupaddrs) and NetworkInterface.respond_to?(:interfaces) and
Pcap.respond_to?(:interfaces) and NetworkInterface.respond_to?(:addresses)
Pcap.respond_to?(:addresses)
end end
def list_interfaces def list_interfaces
check_pcaprub_loaded check_pcaprub_loaded
Pcap.interfaces NetworkInterface.interfaces
end end
def is_interface?(dev) def is_interface?(dev)
check_pcaprub_loaded check_pcaprub_loaded
if RUBY_PLATFORM == "i386-mingw32" if RUBY_PLATFORM == "i386-mingw32"
if dev =~ /\\Device\\NPF_\{[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}\}/ if dev =~ /\\Device\\NPF_\{[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}\}/
return Pcap.interfaces.include?(dev) return NetworkInterface.interfaces.include?(dev)
elsif dev.to_s =~ /^[0-9]{1,2}$/ elsif dev.to_s =~ /^[0-9]{1,2}$/
if (dev.to_i <= Pcap.interfaces.length) and (dev.to_i >= 0) if (dev.to_i <= NetworkInterface.interfaces.length) and (dev.to_i >= 0)
return true return true
else else
return false return false
@ -437,7 +443,7 @@ module Capture
return false return false
end end
else else
return Pcap.interfaces.include?(dev) return NetworkInterface.interfaces.include?(dev)
end end
end end
@ -447,7 +453,7 @@ module Capture
if RUBY_PLATFORM == "i386-mingw32" if RUBY_PLATFORM == "i386-mingw32"
if dev.to_s =~ /^[0-9]{1,2}$/ if dev.to_s =~ /^[0-9]{1,2}$/
if is_interface?(dev) if is_interface?(dev)
Pcap.interfaces[(dev.to_i) - 1] NetworkInterface.interfaces[(dev.to_i) - 1]
else else
return dev return dev
end end
@ -462,90 +468,90 @@ module Capture
def get_mac(dev) def get_mac(dev)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} does not exist" if !addrs raise RuntimeError, "Interface #{dev} does not exist" if !addrs
raise RuntimeError, "Can not get mac address for interface #{dev}" if !addrs[Pcap::AF_LINK][0]['addr'] raise RuntimeError, "Can not get mac address for interface #{dev}" if !addrs[NetworkInterface::AF_LINK][0]['addr']
addrs[Pcap::AF_LINK][0]['addr'] addrs[NetworkInterface::AF_LINK][0]['addr']
end end
def get_ipv4_addr_count(dev) def get_ipv4_addr_count(dev)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} does not exist" if !addrs raise RuntimeError, "Interface #{dev} does not exist" if !addrs
addrs[Pcap::AF_INET].length addrs[NetworkInterface::AF_INET].length
end end
def get_ipv4_addr(dev, num=0) def get_ipv4_addr(dev, num=0)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} do not exists" if !addrs raise RuntimeError, "Interface #{dev} do not exists" if !addrs
raise RuntimeError, "Interface #{dev} do not have an ipv4 address at position #{num}" if addrs[Pcap::AF_INET].length < num + 1 raise RuntimeError, "Interface #{dev} do not have an ipv4 address at position #{num}" if addrs[NetworkInterface::AF_INET].length < num + 1
raise RuntimeError, "Can not get the IPv4 address for interface #{dev}" if !addrs[Pcap::AF_INET][num]['addr'] raise RuntimeError, "Can not get the IPv4 address for interface #{dev}" if !addrs[NetworkInterface::AF_INET][num]['addr']
addrs[Pcap::AF_INET][num]['addr'] addrs[NetworkInterface::AF_INET][num]['addr']
end end
def get_ipv4_netmask(dev, num=0) def get_ipv4_netmask(dev, num=0)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} do not exists" if !addrs raise RuntimeError, "Interface #{dev} do not exists" if !addrs
raise RuntimeError, "Interface #{dev} do not have an ipv4 address at position #{num}" if addrs[Pcap::AF_INET].length < num + 1 raise RuntimeError, "Interface #{dev} do not have an ipv4 address at position #{num}" if addrs[NetworkInterface::AF_INET].length < num + 1
raise RuntimeError, "Can not get IPv4 netmask for interface #{dev}" if !addrs[Pcap::AF_INET][num]['netmask'] raise RuntimeError, "Can not get IPv4 netmask for interface #{dev}" if !addrs[NetworkInterface::AF_INET][num]['netmask']
addrs[Pcap::AF_INET][num]['netmask'] addrs[NetworkInterface::AF_INET][num]['netmask']
end end
def get_ipv4_broadcast(dev, num=0) def get_ipv4_broadcast(dev, num=0)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} do not exists" if !addrs raise RuntimeError, "Interface #{dev} do not exists" if !addrs
raise RuntimeError, "Interface #{dev} do not have an ipv4 address at position #{num}" if addrs[Pcap::AF_INET].length < num + 1 raise RuntimeError, "Interface #{dev} do not have an ipv4 address at position #{num}" if addrs[NetworkInterface::AF_INET].length < num + 1
raise RuntimeError, "Can not get IPv4 broadcast address for interface #{dev}" if !addrs[Pcap::AF_INET][num]['broadcast'] raise RuntimeError, "Can not get IPv4 broadcast address for interface #{dev}" if !addrs[NetworkInterface::AF_INET][num]['broadcast']
addrs[Pcap::AF_INET][num]['broadcast'] addrs[NetworkInterface::AF_INET][num]['broadcast']
end end
def get_ipv6_addr_count(dev) def get_ipv6_addr_count(dev)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
raise RuntimeError, "IPv6 information is not available on this platform" if not ::Pcap.const_defined?(:AF_INET6) raise RuntimeError, "IPv6 information is not available on this platform" unless ::NetworkInterface.const_defined?(:AF_INET6)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} do not exists" if !addrs raise RuntimeError, "Interface #{dev} do not exists" if !addrs
addrs[Pcap::AF_INET6].length addrs[NetworkInterface::AF_INET6].length
end end
# NOTE: IPv6 is not implemented on Windows # NOTE: IPv6 is not implemented on Windows
def get_ipv6_addr(dev, num=0) def get_ipv6_addr(dev, num=0)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
raise RuntimeError, "IPv6 information is not available on this platform" if not ::Pcap.const_defined?(:AF_INET6) raise RuntimeError, "IPv6 information is not available on this platform" unless ::NetworkInterface.const_defined?(:AF_INET6)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} do not exists" if !addrs raise RuntimeError, "Interface #{dev} do not exists" if !addrs
raise RuntimeError, "Interface #{dev} do not have an ipv6 address at position #{num}" if addrs[Pcap::AF_INET6].length < num + 1 raise RuntimeError, "Interface #{dev} do not have an ipv6 address at position #{num}" if addrs[NetworkInterface::AF_INET6].length < num + 1
raise RuntimeError, "Can not get ipv6 address for interface #{dev}" if !addrs[Pcap::AF_INET6][num]['addr'] raise RuntimeError, "Can not get ipv6 address for interface #{dev}" if !addrs[NetworkInterface::AF_INET6][num]['addr']
addrs[Pcap::AF_INET6][num]['addr'].gsub(/%(.)*$/,'') addrs[NetworkInterface::AF_INET6][num]['addr'].gsub(/%(.)*$/, '')
end end
def get_ipv6_netmask(dev, num=0) def get_ipv6_netmask(dev, num=0)
check_pcaprub_loaded check_pcaprub_loaded
dev = get_interface_guid(dev) dev = get_interface_guid(dev)
raise RuntimeError, "IPv6 information is not available on this platform" if not ::Pcap.const_defined?(:AF_INET6) raise RuntimeError, "IPv6 information is not available on this platform" unless ::NetworkInterface.const_defined?(:AF_INET6)
addrs = Pcap.addresses(dev) addrs = NetworkInterface.addresses(dev)
raise RuntimeError, "Interface #{dev} do not exists" if !addrs raise RuntimeError, "Interface #{dev} do not exists" if !addrs
raise RuntimeError, "Interface #{dev} do not have an ipv6 address at position #{num}" if addrs[Pcap::AF_INET6].length < num + 1 raise RuntimeError, "Interface #{dev} do not have an ipv6 address at position #{num}" if addrs[NetworkInterface::AF_INET6].length < num + 1
raise RuntimeError, "Can not get ipv6 netmask address for interface #{dev}" if !addrs[Pcap::AF_INET6][num]['netmask'] raise RuntimeError, "Can not get ipv6 netmask address for interface #{dev}" if !addrs[NetworkInterface::AF_INET6][num]['netmask']
addrs[Pcap::AF_INET6][num]['netmask'] addrs[NetworkInterface::AF_INET6][num]['netmask']
end end
# Protocol-specific encoding/decoding methods until more # Protocol-specific encoding/decoding methods until more
# application protos get into PacketFu proper # application protos get into PacketFu proper
# Intended to be used as the payload to an ICMP echo request's payload # Intended to be used as the payload to an ICMP echo request's payload
def capture_icmp_echo_pack(id=nil,seq=nil,payload=nil) def capture_icmp_echo_pack(id=nil, seq=nil, payload=nil)
id ||= rand(0x10000) id ||= rand(0x10000)
seq ||= rand(0x10000) seq ||= rand(0x10000)
[id,seq,payload.to_s].pack("nna*") [id, seq, payload.to_s].pack("nna*")
end end
# Decodes and ICMP echo request or response. # Decodes and ICMP echo request or response.
@ -553,8 +559,8 @@ module Capture
data.unpack("nna*") data.unpack("nna*")
end end
end end
end end
end end

View File

@ -793,49 +793,6 @@ module Text
buf << "\n" buf << "\n"
end end
#
# Converts a string a nicely formatted and addressed ex dump
#
def self.to_addr_hex_dump(str, start_addr=0, width=16)
buf = ''
idx = 0
cnt = 0
snl = false
lst = 0
addr = start_addr
while (idx < str.length)
buf << "%08x" % addr
buf << " " * 4
chunk = str[idx, width]
line = chunk.unpack("H*")[0].scan(/../).join(" ")
buf << line
if (lst == 0)
lst = line.length
buf << " " * 4
else
buf << " " * ((lst - line.length) + 4).abs
end
chunk.unpack("C*").each do |c|
if (c > 0x1f and c < 0x7f)
buf << c.chr
else
buf << "."
end
end
buf << "\n"
idx += width
addr += width
end
buf << "\n"
end
# #
# Converts a hex string to a raw string # Converts a hex string to a raw string
# #

View File

@ -184,7 +184,7 @@ class Metasploit3 < Msf::Auxiliary
print_status("#{rhost}:#{rport} - Recovering Hashes...") print_status("#{rhost}:#{rport} - Recovering Hashes...")
json_info["result"]["resultSet"].each { |result| json_info["result"]["resultSet"].each { |result|
vprint_good("#{rhost}:#{rport} - Found cred: #{result["username"]}:#{result["password"]}") print_good("#{rhost}:#{rport} - Found cred: #{result["username"]}:#{result["password"]}")
report_auth_info( report_auth_info(
:host => rhost, :host => rhost,
:port => rport, :port => rport,

View File

@ -44,7 +44,7 @@ class Metasploit3 < Msf::Auxiliary
@netifaces = true @netifaces = true
if not netifaces_implemented? if not netifaces_implemented?
print_error("WARNING : Pcaprub is not uptodate, some functionality will not be available") print_error("WARNING : NetworkInterface is not up-to-date, some functionality will not be available")
@netifaces = false @netifaces = false
end end

View File

@ -23,37 +23,40 @@ $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
if RUBY_PLATFORM == "i386-mingw32" if RUBY_PLATFORM == "i386-mingw32"
begin begin
require 'pcaprub' require 'network_interface'
rescue ::Exception => e rescue ::Exception => e
$stderr.puts "Error: pcaprub is not installed..." $stderr.puts "Error: NetworkInterface is not installed..."
exit exit
end end
unless (Pcap.respond_to?(:lookupaddrs) and
Pcap.respond_to?(:interfaces) and unless (
Pcap.respond_to?(:addresses)) NetworkInterface.respond_to?(:interfaces) and
$stderr.puts "Error: Looks like you are not running the latest version of pcaprub" NetworkInterface.respond_to?(:addresses) and
NetworkInterface.respond_to?(:interface_info)
)
$stderr.puts "Error: Looks like you are not running the latest version of NetworkInterface"
exit exit
end end
found = false found = false
Pcap.interfaces.each_with_index do |iface, i| NetworkInterface.interfaces.each_with_index do |iface, i|
found = true found = true
detail = Pcap.interface_info(iface) detail = NetworkInterface.interface_info(iface)
addr = Pcap.addresses(iface) addr = NetworkInterface.addresses(iface)
puts "#" * 70 puts "#" * 70
puts "" puts ""
puts "INDEX : " + (i + 1).to_s puts "INDEX : " + (i + 1).to_s
puts "NAME : " + detail["name"] puts "NAME : " + detail["name"]
puts "DESCRIPTION : " + detail["description"] puts "DESCRIPTION : " + detail["description"]
puts "GUID : " + detail["guid"] puts "GUID : " + detail["guid"]
if addr[Pcap::AF_LINK][0]['addr'] if addr[NetworkInterface::AF_LINK][0]['addr']
puts "MAC ADDRESSE : #{addr[Pcap::AF_LINK][0]['addr']}" puts "MAC ADDRESS : #{addr[NetworkInterface::AF_LINK][0]['addr']}"
else else
puts "MAC ADDRESSE : NONE" puts "MAC ADDRESS : NONE"
end end
if addr[Pcap::AF_INET][0]['addr'] and addr[Pcap::AF_INET][0]['netmask'] if addr[NetworkInterface::AF_INET][0]['addr'] and addr[NetworkInterface::AF_INET][0]['netmask']
puts "IP ADDRESSE : #{addr[Pcap::AF_INET][0]['addr']}/#{addr[Pcap::AF_INET][0]['netmask']}" puts "IP ADDRESS : #{addr[NetworkInterface::AF_INET][0]['addr']}/#{addr[NetworkInterface::AF_INET][0]['netmask']}"
else else
puts "IP ADDRESSE : NONE" puts "IP ADDRESS : NONE"
end end
puts "" puts ""
end end
@ -63,8 +66,6 @@ if RUBY_PLATFORM == "i386-mingw32"
$stderr.puts "Error, no network interfaces have been detected" $stderr.puts "Error, no network interfaces have been detected"
end end
else else
$stderr.puts "Error: This script is usefull only on Windows, under other OS just use the built-in commands (ifconfig, ip link show, ...)" $stderr.puts "Error: This script is useful only on Windows, under other OS just use the built-in commands (ifconfig, ip link show, ...)"
exit exit
end end