Documentation
¶
Overview ¶
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
kyoketsu, a Client-To-Client Network Enumeration System Copyright (C) 2024 Russell Hrubesky, ChiralWorks Software LLC
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func BuildAndSend(intf string, fd int, srcMac net.HardwareAddr, dstMac net.HardwareAddr, ...)
- func BuildPacket(c *PacketConfig) ([]byte, error)
- func NetSweep(ips []net.IP, cidr int, ports []int, scanned chan Host)
- func NewSocket() int
- func PortWalk(addr string, ports []int) []int
- func RetrieveScanDirectives() []int
- func RunHttpServer(port int, dbhook TopologyDatabaseIO, portmap []int, logStream io.Writer)
- func TuiTemplate() *promptui.SelectTemplates
- type AssetHandler
- type ExecutionHandler
- type Host
- type HtmlHandler
- type IpSubnetMapper
- type NetworkInterfaceNotFound
- type PacketConfig
- type PacketOption
- type PortScanResult
- type PromptEntry
- type SQLiteRepo
- func (r *SQLiteRepo) All() ([]Host, error)
- func (r *SQLiteRepo) Create(host Host) (*Host, error)
- func (r *SQLiteRepo) Delete(id int64) error
- func (r *SQLiteRepo) FilterDnsPattern(network string, patterns []string) ([]Host, error)
- func (r *SQLiteRepo) GetByIP(ip string) (*Host, error)
- func (r *SQLiteRepo) GetByNetwork(network string) ([]Host, error)
- func (r *SQLiteRepo) Migrate() error
- func (r *SQLiteRepo) Update(id int64, updated Host) (*Host, error)
- type ScanRequest
- type TopologyDatabaseIO
- type TuiSelectionFeed
Constants ¶
const IPV4_BITLEN = 32
const NoFqdn = "Not found with default resolver"
Variables ¶
Functions ¶
func BuildAndSend ¶
func BuildPacket ¶
func BuildPacket(c *PacketConfig) ([]byte, error)
BuildPacket constructs the packet based on the PacketConfig. It automatically includes the Ethernet layer if both SrcMAC and DstMAC are provided.
func NetSweep ¶
Perform a port scan sweep across an entire subnet
:param ip: the IPv4 address WITH CIDR notation :param portmap: the mapping of ports to scan with (port number mapped to protocol name)
func PortWalk ¶
Perform a concurrent TCP port dial on a host, either by domain name or IP.
:param addr: the address of fqdn to scan :param ports a list of port numbers to dial the host with
func RetrieveScanDirectives ¶
func RetrieveScanDirectives() []int
Wrapper function to dependency inject the resource for a port -> service name mapping. May move to a database, or something.
func RunHttpServer ¶
func RunHttpServer(port int, dbhook TopologyDatabaseIO, portmap []int, logStream io.Writer)
Run a new webserver
:param port: port number to run the webserver on
func TuiTemplate ¶
func TuiTemplate() *promptui.SelectTemplates
This is a helper function to return the TUI template for interactive mode
Types ¶
type AssetHandler ¶
type AssetHandler struct {
Root embed.FS // Should be able to use anything that implements the fs.FS interface for serving asset files
EmbedRoot string // This is the root of the embeded file system
RelPath string // The path that will be used for the handler, relative to the root of the webserver (/static, /assets, etc)
}
func (*AssetHandler) ServeHTTP ¶
func (a *AssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Handler function to serve out asset files (HTMX, bootstrap, pngs etc)
:param w: http.ResponseWriter interface for sending data back to the caller :param r: pointer to an http.Request
type ExecutionHandler ¶
type ExecutionHandler struct {
DbHook TopologyDatabaseIO
TableEntry *template.Template
PortMap []int
// contains filtered or unexported fields
}
func (*ExecutionHandler) Log ¶
func (e *ExecutionHandler) Log(vals ...string)
func (*ExecutionHandler) ServeHTTP ¶
func (e *ExecutionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Top level function to be routed to, this will spawn a suite of goroutines that will perform a concurrent scan on hosts and write back HTML data
:param w: an http.ResponseWriter that we will write data back to :param r: a pointer to the request coming in from the client
type Host ¶
type Host struct {
Fqdn string // The FQDN of the address targeted as per the systems default resolver
IpAddress string // the IPv4 address (no ipv6 support yet)
PingResponse bool // boolean value representing if the host responded to ICMP
ListeningPorts []int // list of maps depicting a port number -> service name
Network string
PortString string
Id int64
}
type HtmlHandler ¶
type HtmlHandler struct {
Home *template.Template // pointer to the HTML homepage
TableEntry *template.Template // pointer to the table entry html template
DbHook TopologyDatabaseIO
// contains filtered or unexported fields
}
func (*HtmlHandler) Log ¶
func (h *HtmlHandler) Log(vals ...string)
func (*HtmlHandler) ServeHTTP ¶
func (h *HtmlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Handler function for HTML serving
:param w: http.ResponseWriter interface for sending data back :param r: pointer to the http.Request coming in
type IpSubnetMapper ¶
type IpSubnetMapper struct {
Ipv4s []net.IP `json:"addresses"`
NetworkAddr net.IP
Current net.IP
Mask int
}
func GetNetworkAddresses ¶
func GetNetworkAddresses(addr string) (IpSubnetMapper, error)
Get all of the IPv4 addresses in the network that 'addr' belongs to. YOU MUST PASS THE ADDRESS WITH CIDR NOTATION i.e. '192.168.50.1/24'
:param addr: the ipv4 address to use for subnet discovery
type NetworkInterfaceNotFound ¶
type NetworkInterfaceNotFound struct{ Passed string }
func (*NetworkInterfaceNotFound) Error ¶
func (n *NetworkInterfaceNotFound) Error() string
Implementing error interface
type PacketConfig ¶
type PacketConfig struct {
SrcIP, DstIP net.IP
SrcPort, DstPort layers.TCPPort
SrcMAC, DstMAC net.HardwareAddr
PayloadSize int
}
PacketConfig stores configuration for building a packet.
func NewPacketConfig ¶
func NewPacketConfig(opts ...PacketOption) (*PacketConfig, error)
NewPacketConfig creates a new PacketConfig with specified options.
type PacketOption ¶
type PacketOption func(*PacketConfig) error
PacketOption is a function that applies a configuration to a PacketConfig.
func WithEthernetLayer ¶
func WithEthernetLayer(srcMAC, dstMAC net.HardwareAddr) PacketOption
WithEthernetLayer enables the Ethernet layer in the packet.
func WithIpLayer ¶
func WithIpLayer(srcIp, dstIp net.IP) PacketOption
WithIpLayer enables the IP layer in the packet.
func WithPayloadSize ¶
func WithPayloadSize(size int) PacketOption
WithPayloadSize sets the payload size for the packet.
type PortScanResult ¶
type PortScanResult struct {
// This is used to represent the results of a port scan against one host
PortNumber int `json:"port_number"` // The port number that was scanned
Service string `json:"service"` // the name of the service that the port was identified/mapped to
Protocol string `json:"protocol"` // The IP protocol (TCP/UDP)
Listening bool `json:"listening"` // A boolean value that depicts if the service is listening or not
}
type PromptEntry ¶
type SQLiteRepo ¶
type SQLiteRepo struct {
// contains filtered or unexported fields
}
func (*SQLiteRepo) All ¶
func (r *SQLiteRepo) All() ([]Host, error)
Get all Hosts from the host table
func (*SQLiteRepo) Create ¶
func (r *SQLiteRepo) Create(host Host) (*Host, error)
Create an entry in the hosts table
:param host: a Host entry from a port scan
func (*SQLiteRepo) FilterDnsPattern ¶
func (r *SQLiteRepo) FilterDnsPattern(network string, patterns []string) ([]Host, error)
func (*SQLiteRepo) GetByIP ¶
func (r *SQLiteRepo) GetByIP(ip string) (*Host, error)
Get a record by its FQDN
func (*SQLiteRepo) GetByNetwork ¶
func (r *SQLiteRepo) GetByNetwork(network string) ([]Host, error)
func (*SQLiteRepo) Migrate ¶
func (r *SQLiteRepo) Migrate() error
Creates a new SQL table with necessary data
type ScanRequest ¶
type TopologyDatabaseIO ¶
type TopologyDatabaseIO interface {
/*
This interface defines the Input and output methods that will be necessary
for an appropriate implementation of the data storage that the distributed system will use.
When I get around to implementing the client-to-client format of this, it could be anything.
*/
Migrate() error
Create(host Host) (*Host, error)
All() ([]Host, error)
GetByNetwork(network string) ([]Host, error)
FilterDnsPattern(network string, patterns []string) ([]Host, error)
GetByIP(ip string) (*Host, error)
Update(id int64, updated Host) (*Host, error)
Delete(id int64) error
}
type TuiSelectionFeed ¶
type TuiSelectionFeed struct {
Choice []PromptEntry
}
func RetrieveLocalAddresses ¶
func RetrieveLocalAddresses() (TuiSelectionFeed, error)
Needs cleanup, but this function populatest a data structure that will be used during TUI program startup