kyoketsu

package
v0.0.0-...-60c35df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

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

View Source
const IPV4_BITLEN = 32

Variables

View Source
var (
	ErrDuplicate    = errors.New("record already exists")
	ErrNotExists    = errors.New("row not exists")
	ErrUpdateFailed = errors.New("update failed")
	ErrDeleteFailed = errors.New("delete failed")
)

Functions

func NetSweep

func NetSweep(ips []net.IP, cidr int, ports []int, scanned chan Host)

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 NewDialer

func NewDialer() net.Dialer

Create a new TCP dialer to share in a goroutine

func NewTCPSock

func NewTCPSock(interfaceName string) *syscall.SockaddrLinklayer

Create a new low level networking interface socket :param intf: the name of the interface to bind the socket to

func PortWalk

func PortWalk(addr string, ports []int) []int

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)

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
}

func (*ExecutionHandler) ServeHTTP

func (e *ExecutionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

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
}

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 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 PromptEntry struct {
	HostAddress    string
	NetworkAddress string
	Cidr           string
	SubnetMask     string
	InterfaceName  string
	MacAddress     string
}

type SQLiteRepo

type SQLiteRepo struct {
	// contains filtered or unexported fields
}

func NewSQLiteRepo

func NewSQLiteRepo(db *sql.DB) *SQLiteRepo

Instantiate a new SQLiteRepo struct

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) Delete

func (r *SQLiteRepo) Delete(id int64) error

Delete a record by its ID

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

func (*SQLiteRepo) Update

func (r *SQLiteRepo) Update(id int64, updated Host) (*Host, error)

Update a record by its ID

type ScanRequest

type ScanRequest struct {
	IpAddress string `json:"ip_address"`
}

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)
	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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL