line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# network::arp Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Network::Arp; |
7
|
1
|
|
|
1
|
|
801
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw(Metabrik::Network::Frame Metabrik::System::Package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
549
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable cache poison eui64 discover scan eui-64) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
try => [ qw(try_count) ], |
20
|
|
|
|
|
|
|
rtimeout => [ qw(timeout_seconds) ], |
21
|
|
|
|
|
|
|
count => [ qw(count) ], |
22
|
|
|
|
|
|
|
max_runtime => [ qw(max_runtime) ], |
23
|
|
|
|
|
|
|
device => [ qw(device) ], |
24
|
|
|
|
|
|
|
_pidfile => [ qw(INTERNAL) ], |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
attributes_default => { |
27
|
|
|
|
|
|
|
try => 2, |
28
|
|
|
|
|
|
|
rtimeout => 2, |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
commands => { |
31
|
|
|
|
|
|
|
install => [ ], # Inherited |
32
|
|
|
|
|
|
|
cache => [ ], |
33
|
|
|
|
|
|
|
half_poison => [ qw(gateway victim|OPTIONAL device|OPTIONAL) ], |
34
|
|
|
|
|
|
|
full_poison => [ qw(gateway victim|OPTIONAL device|OPTIONAL) ], |
35
|
|
|
|
|
|
|
mac2eui64 => [ qw(mac_address) ], |
36
|
|
|
|
|
|
|
scan => [ qw(subnet|OPTIONAL device[OPTIONAL) ], |
37
|
|
|
|
|
|
|
get_ipv4_neighbors => [ qw(subnet|OPTIONAL device|OPTIONAL) ], |
38
|
|
|
|
|
|
|
get_ipv6_neighbors => [ qw(subnet|OPTIONAL device|OPTIONAL) ], |
39
|
|
|
|
|
|
|
get_mac_neighbors => [ qw(subnet|OPTIONAL device|OPTIONAL) ], |
40
|
|
|
|
|
|
|
stop_poison => [ ], |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
require_modules => { |
43
|
|
|
|
|
|
|
'Net::Frame::Layer::ARP' => [ ], |
44
|
|
|
|
|
|
|
'Net::Libdnet::Arp' => [ ], |
45
|
|
|
|
|
|
|
'Metabrik::Network::Address' => [ ], |
46
|
|
|
|
|
|
|
'Metabrik::Network::Arp' => [ ], |
47
|
|
|
|
|
|
|
'Metabrik::Network::Read' => [ ], |
48
|
|
|
|
|
|
|
'Metabrik::Network::Write' => [ ], |
49
|
|
|
|
|
|
|
'Metabrik::Shell::Command' => [ ], |
50
|
|
|
|
|
|
|
'Metabrik::System::Process' => [ ], |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
optional_binaries => { |
53
|
|
|
|
|
|
|
arpspoof => [ ], |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
need_packages => { |
56
|
|
|
|
|
|
|
ubuntu => [ qw(dsniff libnet-libdnet-perl) ], |
57
|
|
|
|
|
|
|
debian => [ qw(dsniff libnet-libdnet-perl) ], |
58
|
|
|
|
|
|
|
kali => [ qw(dsniff libnet-libdnet-perl) ], |
59
|
|
|
|
|
|
|
freebsd => [ qw(libdnet) ], |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub brik_use_properties { |
65
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return { |
68
|
0
|
|
0
|
|
|
|
attributes_default => { |
69
|
|
|
|
|
|
|
device => defined($self->global) && $self->global->device || 'eth0', |
70
|
|
|
|
|
|
|
}, |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _loop { |
75
|
0
|
|
|
0
|
|
|
my ($entry, $data) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$data->{ip}->{$entry->{arp_pa}} = $entry->{arp_ha}; |
78
|
0
|
|
|
|
|
|
$data->{mac}->{$entry->{arp_ha}} = $entry->{arp_pa}; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $data; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub cache { |
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $dnet = Net::Libdnet::Arp->new; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my %data = (); |
89
|
0
|
|
|
|
|
|
$dnet->loop(\&_loop, \%data); |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return \%data; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub half_poison { |
95
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
96
|
0
|
|
|
|
|
|
my ($gateway, $victim, $device) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
if (! $self->brik_has_binary("arpspoof")) { |
99
|
0
|
|
|
|
|
|
return $self->log->error("half_poison: you have to install dsniff package"); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
0
|
|
|
|
$device ||= $self->device; |
103
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('half_poison', $gateway) or return; |
104
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('half_poison', $device) or return; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $cmd = "arpspoof -i $device -c both"; |
107
|
0
|
0
|
|
|
|
|
$cmd .= " -t $victim" if defined($victim); # Or default to all LAN hosts |
108
|
0
|
|
|
|
|
|
$cmd .= " $gateway"; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
my $sc = Metabrik::Shell::Command->new_from_brik_init($self) or return; |
111
|
0
|
0
|
|
|
|
|
my $sp = Metabrik::System::Process->new_from_brik_init($self) or return; |
112
|
0
|
|
|
0
|
|
|
my $pidfile = $sp->start(sub { $sc->system($cmd) }); |
|
0
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
$self->_pidfile($pidfile); |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$self->log->info("half_poison: daemonized to pidfile[$pidfile]"); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return 1; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub full_poison { |
121
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
122
|
0
|
|
|
|
|
|
my ($gateway, $victim, $device) = @_; |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if (! $self->brik_has_binary("arpspoof")) { |
125
|
0
|
|
|
|
|
|
return $self->log->error("full_poison: you have to install dsniff package"); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
0
|
|
|
|
$device ||= $self->device; |
129
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('full_poison', $gateway) or return; |
130
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('full_poison', $device) or return; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $cmd = "arpspoof -i $device -c both -r"; |
133
|
0
|
0
|
|
|
|
|
$cmd .= " -t $victim" if defined($victim); # Or default to all LAN hosts |
134
|
0
|
|
|
|
|
|
$cmd .= " $gateway"; |
135
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
my $sc = Metabrik::Shell::Command->new_from_brik_init($self) or return; |
137
|
0
|
0
|
|
|
|
|
my $sp = Metabrik::System::Process->new_from_brik_init($self) or return; |
138
|
0
|
|
|
0
|
|
|
my $pidfile = $sp->start(sub { $sc->system($cmd) }); |
|
0
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->_pidfile($pidfile); |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
$self->log->info("full_poison: daemonized to pidfile[$pidfile]"); |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
return 1; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# Taken from Net::SinFP3 |
147
|
|
|
|
|
|
|
sub mac2eui64 { |
148
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
149
|
0
|
|
|
|
|
|
my ($mac) = @_; |
150
|
|
|
|
|
|
|
|
151
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('mac2eui64', $mac) or return; |
152
|
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
|
if ($mac !~ /^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$/i) { |
154
|
0
|
|
|
|
|
|
return $self->log->error("mac2eui64: invalid MAC address [$mac]"); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
my @b = split(':', $mac); |
158
|
0
|
|
|
|
|
|
my $b0 = hex($b[0]) ^ 2; |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
return sprintf("fe80::%x%x:%xff:fe%x:%x%x", $b0, hex($b[1]), hex($b[2]), |
161
|
|
|
|
|
|
|
hex($b[3]), hex($b[4]), hex($b[5])); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub _get_arp_frame { |
165
|
0
|
|
|
0
|
|
|
my $self = shift; |
166
|
0
|
|
|
|
|
|
my ($dst_ip) = @_; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $eth = $self->eth; |
169
|
0
|
|
|
|
|
|
$eth->type(0x0806); # ARP |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
my $arp = $self->arp($dst_ip); |
172
|
0
|
|
|
|
|
|
my $frame = $self->frame([ $eth, $arp ]); |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return $frame; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub scan { |
178
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
179
|
0
|
|
|
|
|
|
my ($subnet, $device) = @_; |
180
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
$self->brik_help_run_must_be_root('scan') or return; |
182
|
|
|
|
|
|
|
|
183
|
0
|
|
0
|
|
|
|
$device ||= $self->device; |
184
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('scan', $device) or return; |
185
|
|
|
|
|
|
|
|
186
|
0
|
0
|
|
|
|
|
my $interface = $self->get_device_info($device) or return; |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
0
|
|
|
|
$subnet ||= $interface->{subnet4}; |
189
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('scan', $subnet) or return; |
190
|
|
|
|
|
|
|
|
191
|
0
|
0
|
|
|
|
|
my $arp_cache = $self->cache |
192
|
|
|
|
|
|
|
or return $self->log->error("scan: cache failed"); |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
my $scan_arp_cache = {}; |
195
|
0
|
|
|
|
|
|
for my $this (keys %{$arp_cache->{mac}}) { |
|
0
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my $mac = $this; |
197
|
0
|
|
|
|
|
|
my $ip = $arp_cache->{mac}{$this}; |
198
|
0
|
|
|
|
|
|
$self->log->verbose("scan: found MAC [$mac] in cache for IPv4 [$ip]"); |
199
|
0
|
|
|
|
|
|
$scan_arp_cache->{$ip} = $mac; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
|
my $na = Metabrik::Network::Address->new_from_brik_init($self) or return; |
203
|
|
|
|
|
|
|
|
204
|
0
|
0
|
|
|
|
|
my $ip_list = $na->ipv4_list($subnet) or return; |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
my $reply_cache = {}; |
207
|
0
|
|
|
|
|
|
my @frame_list = (); |
208
|
0
|
|
|
|
|
|
for my $ip (@$ip_list) { |
209
|
|
|
|
|
|
|
# We scan ARP for everyone but our own IP |
210
|
0
|
0
|
0
|
|
|
|
if (exists($interface->{ipv4}) && $ip eq $interface->{ipv4}) { |
211
|
0
|
|
|
|
|
|
next; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
0
|
0
|
|
|
|
|
if (exists($scan_arp_cache->{$ip})) { |
215
|
0
|
|
|
|
|
|
my $mac = $scan_arp_cache->{$ip}; |
216
|
0
|
|
|
|
|
|
$reply_cache->{$ip} = $mac; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
else { |
219
|
|
|
|
|
|
|
# If it is not in ARP cache yet |
220
|
0
|
|
|
|
|
|
push @frame_list, $self->_get_arp_frame($ip); |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
0
|
0
|
|
|
|
|
my $nw = Metabrik::Network::Write->new_from_brik_init($self) or return; |
225
|
|
|
|
|
|
|
|
226
|
0
|
0
|
|
|
|
|
my $write = $nw->open(2, $interface->{device}) or return; |
227
|
|
|
|
|
|
|
|
228
|
0
|
0
|
|
|
|
|
my $nr = Metabrik::Network::Read->new_from_brik_init($self) or return; |
229
|
0
|
|
|
|
|
|
$nr->rtimeout($self->rtimeout); |
230
|
0
|
|
0
|
|
|
|
$nr->count($self->count || 0); |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
my $filter = 'arp and src net '.$subnet.' and dst host '.$interface->{ipv4}; |
233
|
0
|
0
|
|
|
|
|
my $read = $nr->open(2, $interface->{device}, $filter) or return; |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
# We will send frames 3 times max |
236
|
0
|
|
|
|
|
|
my $try = $self->try; |
237
|
0
|
|
|
|
|
|
for my $t (1..$try) { |
238
|
|
|
|
|
|
|
# We send all frames |
239
|
0
|
|
|
|
|
|
for my $r (@frame_list) { |
240
|
0
|
|
|
|
|
|
$self->log->debug($r->print); |
241
|
0
|
|
|
|
|
|
my $dst_ip = $r->ref->{ARP}->dstIp; |
242
|
0
|
0
|
|
|
|
|
if (! exists($reply_cache->{$dst_ip})) { |
243
|
0
|
0
|
|
|
|
|
$nw->send($r->raw) |
244
|
|
|
|
|
|
|
or $self->log->warning("scan: send failed"); |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# Then we wait for all replies until a timeout occurs |
249
|
0
|
|
|
|
|
|
my $h_list = $nr->read_until_timeout; |
250
|
0
|
|
|
|
|
|
for my $h (@$h_list) { |
251
|
0
|
|
|
|
|
|
my $r = $self->from_read($h); |
252
|
|
|
|
|
|
|
#$self->log->verbose("scan: read next returned some stuff".$r->print); |
253
|
|
|
|
|
|
|
|
254
|
0
|
0
|
|
|
|
|
if ($r->ref->{ARP}->opCode != &Net::Frame::Layer::ARP::NF_ARP_OPCODE_REPLY) { |
255
|
0
|
|
|
|
|
|
next; |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
my $src_ip = $r->ref->{ARP}->srcIp; |
259
|
0
|
0
|
|
|
|
|
if (! exists($reply_cache->{$src_ip})) { |
260
|
0
|
|
|
|
|
|
my $mac = $r->ref->{ARP}->src; |
261
|
0
|
|
|
|
|
|
$self->log->info("scan: received MAC [$mac] for IPV4 [$src_ip]"); |
262
|
0
|
|
|
|
|
|
$reply_cache->{$src_ip} = $r->ref->{ARP}->src; |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# Put it in ARP cache table for next round |
265
|
0
|
|
|
|
|
|
$scan_arp_cache->{$src_ip} = $mac; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
0
|
|
|
|
|
|
$nr->reset_timeout; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
0
|
|
|
|
|
|
$nw->close; |
273
|
0
|
|
|
|
|
|
$nr->close; |
274
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
my %results = (); |
276
|
0
|
|
|
|
|
|
for (keys %$reply_cache) { |
277
|
0
|
|
|
|
|
|
my $mac = $reply_cache->{$_}; |
278
|
0
|
|
|
|
|
|
my $ip4 = $_; |
279
|
0
|
|
|
|
|
|
my $ip6 = $self->mac2eui64($mac); |
280
|
0
|
|
|
|
|
|
$self->log->verbose(sprintf("%-16s => %s [%s]", $ip4, $mac, $ip6)); |
281
|
0
|
|
|
|
|
|
$results{by_ipv4}{$ip4} = { ipv6 => $ip6, mac => $mac, ipv4 => $ip4 }; |
282
|
0
|
|
|
|
|
|
$results{by_mac}{$mac} = { ipv6 => $ip6, mac => $mac, ipv4 => $ip4 }; |
283
|
0
|
|
|
|
|
|
$results{by_ipv6}{$ip6} = { ipv6 => $ip6, mac => $mac, ipv4 => $ip4 }; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
0
|
|
|
|
|
|
return \%results; |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub get_ipv4_neighbors { |
290
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
291
|
0
|
|
|
|
|
|
my ($subnet, $device) = @_; |
292
|
|
|
|
|
|
|
|
293
|
0
|
0
|
|
|
|
|
my $scan = $self->scan($subnet, $device) or return; |
294
|
0
|
|
|
|
|
|
my $ipv4 = $scan->{by_ipv4}; |
295
|
0
|
0
|
|
|
|
|
if (! defined($ipv4)) { |
296
|
0
|
|
|
|
|
|
return $self->log->info("get_ipv4_neighbors: no IPv4 neighbor found"); |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
|
return $ipv4; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub get_ipv6_neighbors { |
303
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
304
|
0
|
|
|
|
|
|
my ($subnet, $device) = @_; |
305
|
|
|
|
|
|
|
|
306
|
0
|
0
|
|
|
|
|
my $scan = $self->scan($subnet, $device) or return; |
307
|
0
|
|
|
|
|
|
my $ipv6 = $scan->{by_ipv6}; |
308
|
0
|
0
|
|
|
|
|
if (! defined($ipv6)) { |
309
|
0
|
|
|
|
|
|
return $self->log->info("get_ipv6_neighbors: no IPv6 neighbor found"); |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
0
|
|
|
|
|
|
return $ipv6; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub get_mac_neighbors { |
316
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
317
|
0
|
|
|
|
|
|
my ($subnet, $device) = @_; |
318
|
|
|
|
|
|
|
|
319
|
0
|
0
|
|
|
|
|
my $scan = $self->scan($subnet, $device) or return; |
320
|
0
|
|
|
|
|
|
my $mac = $scan->{by_mac}; |
321
|
0
|
0
|
|
|
|
|
if (! defined($mac)) { |
322
|
0
|
|
|
|
|
|
return $self->log->info("get_mac_neighbors: no MAC neighbor found"); |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
0
|
|
|
|
|
|
return $mac; |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
sub stop_poison { |
329
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
330
|
|
|
|
|
|
|
|
331
|
0
|
|
|
|
|
|
my $pidfile = $self->_pidfile; |
332
|
0
|
0
|
|
|
|
|
if (defined($pidfile)) { |
333
|
0
|
0
|
|
|
|
|
my $sp = Metabrik::System::Process->new_from_brik_init($self) or return; |
334
|
0
|
|
|
|
|
|
$sp->force_kill(1); |
335
|
0
|
|
|
|
|
|
$sp->kill_from_pidfile($pidfile); |
336
|
0
|
|
|
|
|
|
$self->log->verbose("stop_poison: killing arpspoof process"); |
337
|
0
|
|
|
|
|
|
$self->_pidfile(undef); |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
|
340
|
0
|
|
|
|
|
|
return 1; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub brik_fini { |
344
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
345
|
|
|
|
|
|
|
|
346
|
0
|
|
|
|
|
|
return $self->stop_poison; |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
1; |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
__END__ |