Documentation ¶
Overview ¶
package dhcp4_spoofer implements a dhcp server designed to operate as a secondary dhcp server on the same lan.
It allows the segmentation of the LAN into two distintict subnets, one used for hosts not captured, and a more confined subnet for hosts in capture state.
Captured hosts will have a specific subnet with the default router set to us so that all captured host traffic is directed to us.
It may also be set to attack the primary DHCP host to exhaust entries.
The original implementation used Richard Burton's dhcp4 package (see: https://github.com/krolaw/dhcp4) for processing of dhcp packets but current versions use our own packet package.
Index ¶
- Variables
- type Config
- type Handler
- func (h *Handler) Close() error
- func (h *Handler) MinuteTicker(now time.Time) error
- func (h *Handler) Mode() Mode
- func (h *Handler) PrintTable()
- func (h *Handler) ProcessPacket(frame packet.Frame) error
- func (h *Handler) SendDiscoverPacket(chAddr net.HardwareAddr, ciAddr netip.Addr, xid []byte, name string) (err error)
- func (h *Handler) SetMode(mode Mode)
- func (h *Handler) StartHunt(addr packet.Addr) error
- func (h *Handler) StopHunt(addr packet.Addr) error
- type Lease
- type Mode
- type State
- type SubnetConfig
Constants ¶
This section is empty.
Variables ¶
var LeaseFilename = "./dhcpleases.yaml"
var Logger = fastlog.New(module)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // ClientConn net.PacketConn Mode Mode NetfilterIP netip.Prefix DNSServer netip.Addr LeaseFilename string }
Config contains configuration overrides
type Handler ¶
Handler is the main dhcp4 handler
func (*Handler) MinuteTicker ¶
MinuteTicker perform checks and free leases as required.
func (*Handler) PrintTable ¶
func (h *Handler) PrintTable()
PrintTable is a helper function to print the table to stdout
func (*Handler) ProcessPacket ¶
ProcessPacket handles a DHCP4 packet performing DHCP4 spoofing and segmentation to keep captured hosts on a different subnet.
func (*Handler) SendDiscoverPacket ¶
func (h *Handler) SendDiscoverPacket(chAddr net.HardwareAddr, ciAddr netip.Addr, xid []byte, name string) (err error)
SendDiscoverPacket send a DHCP discover packet to target
type Lease ¶
type Lease struct { ClientID []byte `yaml:",omitempty"` State State Addr packet.Addr IPOffer netip.Addr `yaml:",omitempty"` OfferExpiry time.Time `yaml:",omitempty"` XID []byte `yaml:",omitempty"` Count int `yaml:"-"` // a counter to check for repeat packets Name string DHCPExpiry time.Time `yaml:",omitempty"` // contains filtered or unexported fields }
Lease stores a client lease
type Mode ¶
type Mode int32
const ( ModePrimaryServer Mode = iota + 1 // sets the server to operate as the single DHCP on the LAN ModeSecondaryServer // sets the server to operate as a secondary DHCP on the LAN; will attack the primary ModeSecondaryServerNice // sets the server to operate nice; i.e. will attack captured entries only )
Mode type for operational mode: Primary or Secondary server
type SubnetConfig ¶
type SubnetConfig struct { LAN netip.Prefix // lan address & netmask DefaultGW netip.Addr // Default Gateway for subnet DHCPServer netip.Addr // DHCP server ID DNSServer netip.Addr // DNS server IP FirstIP netip.Addr // First IP in range Duration time.Duration // lease duration Stage packet.HuntStage // Default stage for subnet ID string // Used for logging }
SubnetConfig hold configuration values for the subnet
DefaultGW must be accessible in the subnet example: lan 192.168.0.0/24, gw 192.168.0.1
lan 192.168.0.128/25, gw 192.168.0.129