mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
Merge branch 'master' of github.com:bettercap/bettercap
This commit is contained in:
commit
f5fb86da48
9 changed files with 24 additions and 13 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/bettercap/bettercap/packets"
|
||||
|
@ -20,6 +21,7 @@ type DNSSpoofer struct {
|
|||
session.SessionModule
|
||||
Handle *pcap.Handle
|
||||
Hosts Hosts
|
||||
TTL uint32
|
||||
All bool
|
||||
waitGroup *sync.WaitGroup
|
||||
pktSourceChan chan gopacket.Packet
|
||||
|
@ -31,6 +33,7 @@ func NewDNSSpoofer(s *session.Session) *DNSSpoofer {
|
|||
Handle: nil,
|
||||
All: false,
|
||||
Hosts: Hosts{},
|
||||
TTL: 1024,
|
||||
waitGroup: &sync.WaitGroup{},
|
||||
}
|
||||
|
||||
|
@ -55,6 +58,11 @@ func NewDNSSpoofer(s *session.Session) *DNSSpoofer {
|
|||
"false",
|
||||
"If true the module will reply to every DNS request, otherwise it will only reply to the one targeting the local pc."))
|
||||
|
||||
mod.AddParam(session.NewStringParameter("dns.spoof.ttl",
|
||||
"1024",
|
||||
"^[0-9]+$",
|
||||
"TTL of spoofed DNS replies."))
|
||||
|
||||
mod.AddHandler(session.NewModuleHandler("dns.spoof on", "",
|
||||
"Start the DNS spoofer in the background.",
|
||||
func(args []string) error {
|
||||
|
@ -84,6 +92,7 @@ func (mod DNSSpoofer) Author() string {
|
|||
|
||||
func (mod *DNSSpoofer) Configure() error {
|
||||
var err error
|
||||
var ttl string
|
||||
var hostsFile string
|
||||
var domains []string
|
||||
var address net.IP
|
||||
|
@ -102,6 +111,8 @@ func (mod *DNSSpoofer) Configure() error {
|
|||
return err
|
||||
} else if err, hostsFile = mod.StringParam("dns.spoof.hosts"); err != nil {
|
||||
return err
|
||||
} else if err, ttl = mod.StringParam("dns.spoof.ttl"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mod.Hosts = Hosts{}
|
||||
|
@ -131,6 +142,9 @@ func (mod *DNSSpoofer) Configure() error {
|
|||
mod.Session.Firewall.EnableForwarding(true)
|
||||
}
|
||||
|
||||
_ttl, _ := strconv.Atoi(ttl)
|
||||
mod.TTL = uint32(_ttl)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -184,7 +198,7 @@ func (mod *DNSSpoofer) dnsReply(pkt gopacket.Packet, peth *layers.Ethernet, pudp
|
|||
Name: []byte(q.Name),
|
||||
Type: q.Type,
|
||||
Class: q.Class,
|
||||
TTL: 1024,
|
||||
TTL: mod.TTL,
|
||||
IP: address,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ func (mod *EventsStream) dumpForm(body []byte) string {
|
|||
if err != nil {
|
||||
value = v
|
||||
}
|
||||
form = append(form, fmt.Sprintf("%s", tui.Bold(tui.Red(value))))
|
||||
form = append(form, tui.Bold(tui.Red(value)))
|
||||
}
|
||||
}
|
||||
return "\n" + strings.Join(form, "&") + "\n"
|
||||
|
@ -113,7 +113,7 @@ func (mod *EventsStream) dumpJSON(body []byte) string {
|
|||
if err := json.Indent(&buf, body, "", " "); err != nil {
|
||||
pretty = string(body)
|
||||
} else {
|
||||
pretty = string(buf.Bytes())
|
||||
pretty = buf.String()
|
||||
}
|
||||
|
||||
return "\n" + reJsonKey.ReplaceAllString(pretty, tui.Green(`$1:`)) + "\n"
|
||||
|
|
|
@ -121,7 +121,7 @@ func (mod *MySQLServer) Start() error {
|
|||
if _, err := conn.Write(packets.MySQLGreeting); err != nil {
|
||||
mod.Warning("error while writing server greeting: %s", err)
|
||||
continue
|
||||
} else if read, err = reader.Read(readBuffer); err != nil {
|
||||
} else if _, err = reader.Read(readBuffer); err != nil {
|
||||
mod.Warning("error while reading client message: %s", err)
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||
if data := packets.UPNPGetMeta(pkt); data != nil && len(data) > 0 {
|
||||
if data := packets.UPNPGetMeta(pkt); len(data) > 0 {
|
||||
s := ""
|
||||
for name, value := range data {
|
||||
s += fmt.Sprintf("%s:%s ", tui.Blue(name), tui.Yellow(value))
|
||||
|
|
|
@ -227,8 +227,8 @@ func (mod *SynScanner) synScan() error {
|
|||
mod.State.Store("progress", 0.0)
|
||||
|
||||
// start the collector
|
||||
mod.waitGroup.Add(1)
|
||||
go func() {
|
||||
mod.waitGroup.Add(1)
|
||||
defer mod.waitGroup.Done()
|
||||
|
||||
for packet := range mod.packets {
|
||||
|
|
|
@ -88,9 +88,8 @@ func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
|
|||
}
|
||||
return fmt.Errorf("%s is an unknown BSSID or it is in the association skip list.", to.String())
|
||||
}
|
||||
|
||||
mod.writes.Add(1)
|
||||
go func() {
|
||||
mod.writes.Add(1)
|
||||
defer mod.writes.Done()
|
||||
|
||||
// since we need to change the wifi adapter channel for each
|
||||
|
|
|
@ -113,8 +113,8 @@ func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
|||
return fmt.Errorf("%s is an unknown BSSID, is in the deauth skip list, or doesn't have detected clients.", to.String())
|
||||
}
|
||||
|
||||
mod.writes.Add(1)
|
||||
go func() {
|
||||
mod.writes.Add(1)
|
||||
defer mod.writes.Done()
|
||||
|
||||
// since we need to change the wifi adapter channel for each
|
||||
|
|
|
@ -92,7 +92,7 @@ func (mod *WiFiModule) channelHopper() {
|
|||
}
|
||||
|
||||
select {
|
||||
case _ = <-mod.hopChanges:
|
||||
case <-mod.hopChanges:
|
||||
mod.Debug("hop changed")
|
||||
break loopCurrentChannels
|
||||
case <-time.After(delay):
|
||||
|
|
|
@ -65,9 +65,7 @@ func (p *EventPool) Listen() <-chan Event {
|
|||
go func() {
|
||||
for i := len(p.events) - 1; i >= 0; i-- {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
|
||||
}
|
||||
recover()
|
||||
}()
|
||||
l <- p.events[i]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue