From 28f167285ac52357a49b5d66e2a82db1b9b6537b Mon Sep 17 00:00:00 2001 From: evilsocket Date: Mon, 12 Feb 2018 19:16:44 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- modules/arp_spoof.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/arp_spoof.go b/modules/arp_spoof.go index 3216f050..850f0185 100644 --- a/modules/arp_spoof.go +++ b/modules/arp_spoof.go @@ -144,13 +144,21 @@ func (p *ArpSpoofer) pktRouter(eth *layers.Ethernet, ip4 *layers.IPv4, pkt gopac return } + // check if this packet is from or to one of the spoofing targets + // and therefore needs patching and forwarding. + doForward := false for _, target := range p.addresses { - if bytes.Compare(ip4.SrcIP, target) == 0 { - // TODO: get real mac && patch - } else if bytes.Compare(ip4.DstIP, target) == 0 { - // TODO: get real mac && patch + if bytes.Compare(ip4.SrcIP, target) == 0 || bytes.Compare(ip4.DstIP, target) == 0 { + doForward = true + break } } + + if doForward == false { + return + } + + // TODO: update mac address either in src or in dst and reinject the packet. } func (p *ArpSpoofer) Configure() error {