2011-04-22 18:25:19 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-04-22 18:25:19 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::Capture
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Pcap Replay Utility',
|
|
|
|
'Description' => %q{
|
|
|
|
Replay a pcap capture file
|
|
|
|
},
|
|
|
|
'Author' => 'amaloteaux',
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptPath.new('FILENAME', [true, "The local pcap file to process"]),
|
|
|
|
OptString.new('FILE_FILTER', [false, "The filter string to apply on the file"]),
|
|
|
|
OptInt.new('LOOP', [true, "The number of times to loop through the file",1]),
|
|
|
|
OptInt.new('DELAY', [true, "the delay in millisecond between each loop",0]),
|
|
|
|
OptInt.new('PKT_DELAY', [true, "the delay in millisecond between each packet",0]),
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
|
2014-12-04 21:26:16 +00:00
|
|
|
deregister_options('SNAPLEN','FILTER','PCAPFILE','RHOST','TIMEOUT','SECRET','GATEWAY_PROBE_HOST','GATEWAY_PROBE_PORT')
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
check_pcaprub_loaded # Check first
|
|
|
|
pkt_delay = datastore['PKT_DELAY']
|
|
|
|
delay = datastore['DELAY']
|
|
|
|
loop = datastore['LOOP']
|
|
|
|
infinity = true if loop <= 0
|
|
|
|
file_filter = datastore['FILE_FILTER']
|
|
|
|
filename = datastore['FILENAME']
|
|
|
|
verbose = datastore['VERBOSE']
|
|
|
|
count = 0
|
2016-04-20 12:11:34 +00:00
|
|
|
unless File.exist? filename and File.file? filename
|
2013-08-30 21:28:54 +00:00
|
|
|
print_error("Pcap File does not exist")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
open_pcap
|
|
|
|
print_status("Sending file...") unless verbose
|
|
|
|
while (loop > 0 or infinity) do
|
2015-06-18 08:27:01 +00:00
|
|
|
vprint_status("Sending file (loop: #{count = count + 1})")
|
2013-08-30 21:28:54 +00:00
|
|
|
inject_pcap(filename, file_filter, pkt_delay )
|
|
|
|
loop -= 1 unless infinity
|
|
|
|
Kernel.select(nil, nil, nil, (delay * 1.0)/1000) if loop > 0 or infinity
|
|
|
|
end
|
|
|
|
close_pcap
|
|
|
|
end
|
2011-04-22 18:25:19 +00:00
|
|
|
end
|