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