mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
new: implementing IsForwardingEnabled for windows firewall
This commit is contained in:
parent
c87e1e7f1d
commit
5887883683
4 changed files with 14 additions and 6 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/evilsocket/bettercap-ng/core"
|
"github.com/evilsocket/bettercap-ng/core"
|
||||||
|
"github.com/evilsocket/bettercap-ng/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -18,12 +19,14 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type PfFirewall struct {
|
type PfFirewall struct {
|
||||||
|
iface *net.Endpoint
|
||||||
filename string
|
filename string
|
||||||
forwarding bool
|
forwarding bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func Make() FirewallManager {
|
func Make(iface *net.Endpoint) FirewallManager {
|
||||||
firewall := &PfFirewall{
|
firewall := &PfFirewall{
|
||||||
|
iface: iface,
|
||||||
filename: pfFilePath,
|
filename: pfFilePath,
|
||||||
forwarding: false,
|
forwarding: false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,11 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/evilsocket/bettercap-ng/core"
|
"github.com/evilsocket/bettercap-ng/core"
|
||||||
|
"github.com/evilsocket/bettercap-ng/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LinuxFirewall struct {
|
type LinuxFirewall struct {
|
||||||
|
iface *net.Endpoint
|
||||||
forwarding bool
|
forwarding bool
|
||||||
redirections map[string]*Redirection
|
redirections map[string]*Redirection
|
||||||
}
|
}
|
||||||
|
@ -17,8 +19,9 @@ const (
|
||||||
IPV4ForwardingFile = "/proc/sys/net/ipv4/ip_forward"
|
IPV4ForwardingFile = "/proc/sys/net/ipv4/ip_forward"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Make() FirewallManager {
|
func Make(iface *net.Endpoint) FirewallManager {
|
||||||
firewall := &LinuxFirewall{
|
firewall := &LinuxFirewall{
|
||||||
|
iface: iface,
|
||||||
forwarding: false,
|
forwarding: false,
|
||||||
redirections: make(map[string]*Redirection, 0),
|
redirections: make(map[string]*Redirection, 0),
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,18 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/evilsocket/bettercap-ng/core"
|
"github.com/evilsocket/bettercap-ng/core"
|
||||||
"github.com/evilsocket/bettercap-ng/session"
|
"github.com/evilsocket/bettercap-ng/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WindowsFirewall struct {
|
type WindowsFirewall struct {
|
||||||
|
iface *net.Enpoint
|
||||||
forwarding bool
|
forwarding bool
|
||||||
redirections map[string]*Redirection
|
redirections map[string]*Redirection
|
||||||
}
|
}
|
||||||
|
|
||||||
func Make() FirewallManager {
|
func Make(iface *net.Endpoint) FirewallManager {
|
||||||
firewall := &WindowsFirewall{
|
firewall := &WindowsFirewall{
|
||||||
|
iface: iface,
|
||||||
forwarding: false,
|
forwarding: false,
|
||||||
redirections: make(map[string]*Redirection, 0),
|
redirections: make(map[string]*Redirection, 0),
|
||||||
}
|
}
|
||||||
|
@ -34,7 +36,7 @@ func (f WindowsFirewall) IsForwardingEnabled() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f WindowsFirewall) EnableForwarding(enabled bool) error {
|
func (f WindowsFirewall) EnableForwarding(enabled bool) error {
|
||||||
fmt.Printf("iface idx=%d\n", session.I.Interface.Index)
|
fmt.Printf("iface idx=%d\n", f.iface.Index)
|
||||||
return fmt.Errorf("Not implemented")
|
return fmt.Errorf("Not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ func (s *Session) Start() error {
|
||||||
s.Env.Set("gateway.mac", s.Gateway.HwAddress)
|
s.Env.Set("gateway.mac", s.Gateway.HwAddress)
|
||||||
|
|
||||||
s.Targets = NewTargets(s, s.Interface, s.Gateway)
|
s.Targets = NewTargets(s, s.Interface, s.Gateway)
|
||||||
s.Firewall = firewall.Make()
|
s.Firewall = firewall.Make(s.Interface)
|
||||||
|
|
||||||
if err := s.setupInput(); err != nil {
|
if err := s.setupInput(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue