Skip to content

Commit 3fb00ec

Browse files
committed
refactored the code based on PR feedback
1 parent 4317114 commit 3fb00ec

File tree

8 files changed

+14
-69
lines changed

8 files changed

+14
-69
lines changed

lib/msf/core/auxiliary/ntp.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: binary -*-
22
require 'rex/proto/ntp'
3-
3+
require 'msf/core/exploit'
44
module Msf
55

66
###
@@ -10,6 +10,7 @@ module Msf
1010
###
1111
module Auxiliary::NTP
1212

13+
include Exploit::Capture
1314
include Auxiliary::Scanner
1415

1516
#
@@ -29,5 +30,15 @@ def initialize(info = {})
2930
OptInt.new('IMPLEMENTATION', [true, 'Use this NTP mode 7 implementation', 3])
3031
], self.class)
3132
end
33+
34+
# Called for each IP in the batch
35+
def scan_host(ip)
36+
if spoofed?
37+
datastore['ScannerRecvWindow'] = 0
38+
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
39+
else
40+
scanner_send(@probe, ip, datastore['RPORT'])
41+
end
42+
end
3243
end
3344
end

lib/msf/core/auxiliary/udp_scanner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def scanner_spoof_send(data, ip, port, srcip, num_packets=1)
8080
p.udp_dst = port
8181
p.payload = @probe
8282
p.recalc
83+
print_status("Sending #{num_packets} packet(s) to #{ip} from #{srcip}")
8384
1.upto(num_packets) do |x|
84-
print_status("Sending packet to #{ip} from #{srcip}")
8585
capture_sendto(p, ip)
8686
end
8787
close_pcap

modules/auxiliary/scanner/ntp/ntp_monlist.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Metasploit3 < Msf::Auxiliary
99

1010
include Msf::Auxiliary::Report
11-
include Msf::Exploit::Capture
1211
include Msf::Exploit::Remote::Udp
1312
include Msf::Auxiliary::UDPScanner
1413
include Msf::Auxiliary::NTP
@@ -47,17 +46,7 @@ def initialize
4746
], self.class)
4847
end
4948

50-
# Called for each IP in the batch
51-
def scan_host(ip)
52-
if spoofed?
53-
datastore['ScannerRecvWindow'] = 0
54-
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
55-
else
56-
scanner_send(@probe, ip, datastore['RPORT'])
57-
end
58-
end
59-
60-
# Called for each response packet
49+
# Called for each response packet
6150
def scanner_process(data, shost, sport)
6251
@results[shost] ||= { messages: [], peers: [] }
6352
@results[shost][:messages] << Rex::Proto::NTP::NTPPrivate.new(data)

modules/auxiliary/scanner/ntp/ntp_peer_list_dos.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Metasploit3 < Msf::Auxiliary
99

1010
include Msf::Auxiliary::Report
11-
include Msf::Exploit::Capture
1211
include Msf::Exploit::Remote::Udp
1312
include Msf::Auxiliary::UDPScanner
1413
include Msf::Auxiliary::NTP
@@ -35,16 +34,6 @@ def initialize
3534
)
3635
end
3736

38-
# Called for each IP in the batch
39-
def scan_host(ip)
40-
if spoofed?
41-
datastore['ScannerRecvWindow'] = 0
42-
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
43-
else
44-
scanner_send(@probe, ip, datastore['RPORT'])
45-
end
46-
end
47-
4837
# Called before the scan block
4938
def scanner_prescan(batch)
5039
@results = {}

modules/auxiliary/scanner/ntp/ntp_peer_list_sum_dos.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Metasploit3 < Msf::Auxiliary
99

1010
include Msf::Auxiliary::Report
11-
include Msf::Exploit::Capture
1211
include Msf::Exploit::Remote::Udp
1312
include Msf::Auxiliary::UDPScanner
1413
include Msf::Auxiliary::NTP
@@ -35,16 +34,6 @@ def initialize
3534
)
3635
end
3736

38-
# Called for each IP in the batch
39-
def scan_host(ip)
40-
if spoofed?
41-
datastore['ScannerRecvWindow'] = 0
42-
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
43-
else
44-
scanner_send(@probe, ip, datastore['RPORT'])
45-
end
46-
end
47-
4837
# Called for each response packet
4938
def scanner_process(data, shost, sport)
5039
@results[shost] ||= []

modules/auxiliary/scanner/ntp/ntp_req_nonce_dos.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Metasploit3 < Msf::Auxiliary
99

1010
include Msf::Auxiliary::Report
11-
include Msf::Exploit::Capture
1211
include Msf::Exploit::Remote::Udp
1312
include Msf::Auxiliary::UDPScanner
1413
include Msf::Auxiliary::NTP
@@ -36,16 +35,6 @@ def initialize
3635
)
3736
end
3837

39-
# Called for each IP in the batch
40-
def scan_host(ip)
41-
if spoofed?
42-
datastore['ScannerRecvWindow'] = 0
43-
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
44-
else
45-
scanner_send(@probe, ip, datastore['RPORT'])
46-
end
47-
end
48-
4938
# Called for each response packet
5039
def scanner_process(data, shost, sport)
5140
@results[shost] ||= []

modules/auxiliary/scanner/ntp/ntp_reslist_dos.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Metasploit3 < Msf::Auxiliary
99

1010
include Msf::Auxiliary::Report
11-
include Msf::Exploit::Capture
1211
include Msf::Exploit::Remote::Udp
1312
include Msf::Auxiliary::UDPScanner
1413
include Msf::Auxiliary::NTP
@@ -37,16 +36,6 @@ def initialize
3736
)
3837
end
3938

40-
# Called for each IP in the batch
41-
def scan_host(ip)
42-
if spoofed?
43-
datastore['ScannerRecvWindow'] = 0
44-
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
45-
else
46-
scanner_send(@probe, ip, datastore['RPORT'])
47-
end
48-
end
49-
5039
# Called for each response packet
5140
def scanner_process(data, shost, sport)
5241
@results[shost] ||= []

modules/auxiliary/scanner/ntp/ntp_unsettrap_dos.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Metasploit3 < Msf::Auxiliary
99

1010
include Msf::Auxiliary::Report
11-
include Msf::Exploit::Capture
1211
include Msf::Exploit::Remote::Udp
1312
include Msf::Auxiliary::UDPScanner
1413
include Msf::Auxiliary::NTP
@@ -35,16 +34,6 @@ def initialize
3534
)
3635
end
3736

38-
# Called for each IP in the batch
39-
def scan_host(ip)
40-
if spoofed?
41-
datastore['ScannerRecvWindow'] = 0
42-
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
43-
else
44-
scanner_send(@probe, ip, datastore['RPORT'])
45-
end
46-
end
47-
4837
# Called for each response packet
4938
def scanner_process(data, shost, sport)
5039
@results[shost] ||= []

0 commit comments

Comments
 (0)