@@ -56,6 +56,7 @@ def initialize
56
56
self . thread = nil
57
57
self . sock = nil
58
58
end
59
+
59
60
def dispatch_request ( packet , addr )
60
61
rhost = addr [ 0 ]
61
62
src_port = addr [ 1 ]
@@ -90,6 +91,7 @@ def dispatch_request(packet, addr)
90
91
print_status ( "type: #{ llmnr_type . unpack ( 'n' ) } " )
91
92
print_status ( "class: #{ llmnr_class . unpack ( 'n' ) } " )
92
93
end
94
+
93
95
if ( llmnr_decodedname =~ /#{ datastore [ 'REGEX' ] } /i )
94
96
#Header
95
97
response = llmnr_transid
@@ -122,12 +124,15 @@ def dispatch_request(packet, addr)
122
124
p . recalc
123
125
124
126
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
126
130
close_pcap
127
131
else
128
132
vprint_status ( "Packet received from #{ rhost } with name #{ llmnr_decodedname } did not match REGEX \" #{ datastore [ 'REGEX' ] } \" " )
129
133
end
130
134
end
135
+
131
136
def monitor_socket
132
137
while true
133
138
rds = [ self . sock ]
@@ -143,6 +148,22 @@ def monitor_socket
143
148
end
144
149
end
145
150
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
+
146
167
def run
147
168
check_pcaprub_loaded ( )
148
169
::Socket . do_not_reverse_lookup = true
@@ -168,7 +189,9 @@ def run
168
189
while thread . alive?
169
190
select ( nil , nil , nil , 0.25 )
170
191
end
192
+
171
193
self . thread . kill
172
194
self . sock . close rescue nil
173
195
end
196
+
174
197
end
0 commit comments