From 0ca87b80840f86a95f2d591da5b0e499292edca4 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 25 Jan 2018 14:12:42 +0100 Subject: [PATCH] new: added new dns.spoof.all option, default to false. --- modules/dns_spoof.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/dns_spoof.go b/modules/dns_spoof.go index 0fbe3576..4a14a9a8 100644 --- a/modules/dns_spoof.go +++ b/modules/dns_spoof.go @@ -21,12 +21,14 @@ type DNSSpoofer struct { Handle *pcap.Handle Domains []string Address net.IP + All bool } func NewDNSSpoofer(s *session.Session) *DNSSpoofer { spoof := &DNSSpoofer{ SessionModule: session.NewSessionModule("dns.spoof", s), Handle: nil, + All: false, } spoof.AddParam(session.NewStringParameter("dns.spoof.domains", @@ -39,6 +41,10 @@ func NewDNSSpoofer(s *session.Session) *DNSSpoofer { session.IPv4Validator, "IP address to map the domains to.")) + spoof.AddParam(session.NewBoolParameter("dns.spoof.all", + "false", + "If true the module will reply to every DNS request, otherwise it will only reply to the one targeting the local pc.")) + spoof.AddHandler(session.NewModuleHandler("dns.spoof on", "", "Start the DNS spoofer in the background.", func(args []string) error { @@ -79,6 +85,10 @@ func (s *DNSSpoofer) Configure() error { return err } + if err, s.All = s.BoolParam("dns.spoof.all"); err != nil { + return err + } + if err, s.Domains = s.ListParam("dns.spoof.domains"); err != nil { return err } @@ -223,7 +233,7 @@ func (s *DNSSpoofer) onPacket(pkt gopacket.Packet) { udp := pkt.Layer(layers.LayerTypeUDP).(*layers.UDP) // DNS request for us? - if bytes.Compare(eth.DstMAC, s.Session.Interface.HW) == 0 { + if s.All == true || bytes.Compare(eth.DstMAC, s.Session.Interface.HW) == 0 { dns, parsed := pkt.Layer(layers.LayerTypeDNS).(*layers.DNS) if parsed == true && dns.OpCode == layers.DNSOpCodeQuery && len(dns.Questions) > 0 && len(dns.Answers) == 0 { for _, q := range dns.Questions {