Skip to content

Commit a6fd0fe

Browse files
committed
Fix up notification to not spam or hide
Instead of hiding the success notification in vprint, it should print, but not every time. This fix thottles the notification to ten seconds per host. [Fixes rapid7#731]
1 parent 6cd5b79 commit a6fd0fe

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

modules/auxiliary/spoof/llmnr/llmnr_response.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def initialize
5656
self.thread = nil
5757
self.sock = nil
5858
end
59+
5960
def dispatch_request(packet, addr)
6061
rhost = addr[0]
6162
src_port = addr[1]
@@ -90,6 +91,7 @@ def dispatch_request(packet, addr)
9091
print_status("type: #{llmnr_type.unpack('n')}")
9192
print_status("class: #{llmnr_class.unpack('n')}")
9293
end
94+
9395
if (llmnr_decodedname =~ /#{datastore['REGEX']}/i)
9496
#Header
9597
response = llmnr_transid
@@ -122,12 +124,15 @@ def dispatch_request(packet, addr)
122124
p.recalc
123125

124126
capture_sendto(p, rhost,true)
125-
vprint_good("Reply for #{llmnr_decodedname} sent to #{rhost} with spoofed IP #{datastore['SPOOFIP']}")
127+
if should_print_reply?(llmnr_decodedname)
128+
print_good("#{Time.now.utc} : Reply for #{llmnr_decodedname} sent to #{rhost} with spoofed IP #{datastore['SPOOFIP']}")
129+
end
126130
close_pcap
127131
else
128132
vprint_status("Packet received from #{rhost} with name #{llmnr_decodedname} did not match REGEX \"#{datastore['REGEX']}\"")
129133
end
130134
end
135+
131136
def monitor_socket
132137
while true
133138
rds = [self.sock]
@@ -143,6 +148,22 @@ def monitor_socket
143148
end
144149
end
145150
end
151+
152+
153+
# Don't spam with success, just throttle to every 10 seconds
154+
# per host
155+
def should_print_reply?(host)
156+
@notified_times ||= {}
157+
now = Time.now.utc
158+
@notified_times[host] ||= now
159+
last_notified = now - @notified_times[host]
160+
if last_notified == 0 or last_notified > 10
161+
@notified_times[host] = now
162+
else
163+
false
164+
end
165+
end
166+
146167
def run
147168
check_pcaprub_loaded()
148169
::Socket.do_not_reverse_lookup = true
@@ -168,7 +189,9 @@ def run
168189
while thread.alive?
169190
select(nil, nil, nil, 0.25)
170191
end
192+
171193
self.thread.kill
172194
self.sock.close rescue nil
173195
end
196+
174197
end

0 commit comments

Comments
 (0)