mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
42b08db0b0
commit
7c2dc38819
4 changed files with 43 additions and 31 deletions
|
@ -100,7 +100,7 @@ func (s EventsStream) viewSynScanEvent(e session.Event) {
|
|||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
se.Port,
|
||||
core.Bold(se.Host.IpAddress))
|
||||
core.Bold(se.Address))
|
||||
}
|
||||
|
||||
func (s *EventsStream) View(e session.Event, refresh bool) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
|
@ -39,7 +38,9 @@ func NewSynScanner(s *session.Session) *SynScanner {
|
|||
ss.AddHandler(session.NewModuleHandler("syn.scan IP-RANGE START-PORT END-PORT", "syn.scan ([^\\s]+) (\\d+)([\\s\\d]*)",
|
||||
"Perform a syn port scanning against an IP address within the provided ports range.",
|
||||
func(args []string) error {
|
||||
var err error
|
||||
if ss.Running() == true {
|
||||
return fmt.Errorf("A scan is already running, wait for it to end before starting a new one.")
|
||||
}
|
||||
|
||||
list, err := iprange.Parse(args[0])
|
||||
if err != nil {
|
||||
|
@ -176,34 +177,15 @@ func (s *SynScanner) onPacket(pkt gopacket.Packet) {
|
|||
}
|
||||
|
||||
if host != nil {
|
||||
sports := strings.Split(host.Meta.Get("tcp-ports").(string), ",")
|
||||
ports := []int{port}
|
||||
|
||||
for _, s := range sports {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err == nil {
|
||||
ports = append(ports, n)
|
||||
}
|
||||
}
|
||||
|
||||
ports = core.UniqueInts(ports, true)
|
||||
list := make([]string, len(ports))
|
||||
for i, p := range ports {
|
||||
list[i] = fmt.Sprintf("%d", p)
|
||||
}
|
||||
|
||||
host.Meta.Set("tcp-ports", strings.Join(list, ","))
|
||||
|
||||
NewSynScanEvent(host, port).Push()
|
||||
ports := host.Meta.GetIntsWith("tcp-ports", port, true)
|
||||
host.Meta.SetInts("tcp-ports", ports)
|
||||
}
|
||||
|
||||
NewSynScanEvent(from, host, port).Push()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SynScanner) synScan() error {
|
||||
if s.Running() == true {
|
||||
return fmt.Errorf("A scan is already running, wait for it to end before starting a new one.")
|
||||
}
|
||||
|
||||
s.SetRunning(true, func() {
|
||||
defer s.SetRunning(false, nil)
|
||||
|
||||
|
|
|
@ -6,14 +6,16 @@ import (
|
|||
)
|
||||
|
||||
type SynScanEvent struct {
|
||||
Host *network.Endpoint
|
||||
Port int
|
||||
Address string
|
||||
Host *network.Endpoint
|
||||
Port int
|
||||
}
|
||||
|
||||
func NewSynScanEvent(h *network.Endpoint, port int) SynScanEvent {
|
||||
func NewSynScanEvent(address string, h *network.Endpoint, port int) SynScanEvent {
|
||||
return SynScanEvent{
|
||||
Host: h,
|
||||
Port: port,
|
||||
Address: address,
|
||||
Host: h,
|
||||
Port: port,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue