AETH-erial пре 1 година
родитељ
комит
1633b64487
8 измењених фајлова са 25 додато и 51 уклоњено
  1. 1 7
      cmd/kyoketsu/kyoketsu.go
  2. 6 8
      pkg/local.go
  3. 1 0
      pkg/packer.go
  4. 0 1
      pkg/packer/packer.go
  5. 12 18
      pkg/scanner.go
  6. 3 16
      pkg/storage.go
  7. 2 0
      pkg/torrent.go
  8. 0 1
      pkg/torrent/torrent.go

+ 1 - 7
cmd/kyoketsu/kyoketsu.go

@@ -4,22 +4,16 @@ import (
 	"fmt"
 	"log"
 	"os"
-
-	"git.aetherial.dev/aeth/kyoketsu/pkg/scan"
 )
 
-
-
 func main() {
 	if len(os.Args) == 1 {
 		log.Fatal("Please pass in the name of an interface that belongs to the network to scan.")
 	}
-	addr, err := scan.GetAllAddresses(os.Args[1])
+	addr, err := kyoketsu.GetAllAddresses(os.Args[1])
 	if err != nil {
 		log.Fatal(err)
 	}
 	fmt.Printf("%+v\n", addr)
 
-
 }
-

+ 6 - 8
pkg/scan/local.go → pkg/local.go

@@ -1,4 +1,4 @@
-package scan
+package kyoketsu
 
 import (
 	"fmt"
@@ -6,15 +6,13 @@ import (
 	"net"
 	"net/netip"
 	"strings"
-
 )
 
-
 type AllAddress struct {
-	Addr	[]net.IP `json:"addresses"`
+	Addr []net.IP `json:"addresses"`
 }
 
-type NetworkInterfaceNotFound struct {Passed string}
+type NetworkInterfaceNotFound struct{ Passed string }
 
 // Implementing error interface
 func (n *NetworkInterfaceNotFound) Error() string {
@@ -23,6 +21,7 @@ func (n *NetworkInterfaceNotFound) Error() string {
 
 /*
 Recursive function to get all of the IPv4 addresses for each IPv4 network that the host is on
+
 	:param addr: the address to recursively find the next address for
 	:param out: a pointer to a struct containing a list of addresses
 */
@@ -43,6 +42,7 @@ func addressRecurse(addr netip.Addr, out *AllAddress) {
 
 /*
 Retrieve the address of a specific interface
+
 	:param name: the name of the interface to get the address of
 */
 func getAddressByInterface(name string) ([]net.Addr, error) {
@@ -58,12 +58,11 @@ func getAddressByInterface(name string) ([]net.Addr, error) {
 	return nil, &NetworkInterfaceNotFound{Passed: name}
 }
 
-
 /*
 Utilized a recursive function to find all addresses in the address space that the host belongs.
 Returns a pointer to an AllAddresses struct who has a list of net.IP structs inside
 */
-func GetAllAddresses(name string) (*AllAddress, error){
+func GetAllAddresses(name string) (*AllAddress, error) {
 	addresses, err := getAddressByInterface(name)
 	if err != nil {
 		return nil, err
@@ -82,4 +81,3 @@ func GetAllAddresses(name string) (*AllAddress, error){
 	}
 	return out, nil
 }
-

+ 1 - 0
pkg/packer.go

@@ -0,0 +1 @@
+package kyoketsu

+ 0 - 1
pkg/packer/packer.go

@@ -1 +0,0 @@
-package packer

+ 12 - 18
pkg/scan/scanner.go → pkg/scanner.go

@@ -1,4 +1,4 @@
-package scan
+package kyoketsu
 
 import (
 	"fmt"
@@ -6,8 +6,6 @@ import (
 	"net/netip"
 	"sync"
 	"time"
-
-
 )
 
 var PORT_MAP = map[int]string{
@@ -16,29 +14,29 @@ var PORT_MAP = map[int]string{
 }
 
 type TcpScanHost struct {
-	Host			string				`json:"host"`
-	Ipv4Address		netip.Addr			`json:"ipv4_address"`
-	PortsScanned	[]PortScanResult 	`json:"ports_scanned"`
+	Host         string           `json:"host"`
+	Ipv4Address  netip.Addr       `json:"ipv4_address"`
+	PortsScanned []PortScanResult `json:"ports_scanned"`
 }
 
 type PortScanResult struct {
-	PortNumber	int		`json:"port_number"`
-	Service		string	`json:"service"`
-	Protocol	string	`json:"protocol"`
-	Listening	bool	`json:"listening"`
+	PortNumber int    `json:"port_number"`
+	Service    string `json:"service"`
+	Protocol   string `json:"protocol"`
+	Listening  bool   `json:"listening"`
 }
 
 type PortScanDirective struct {
-	Pairs	map[int]string
+	Pairs map[int]string
 }
 
 func RetrieveScanDirectives() PortScanDirective {
 	return PortScanDirective{Pairs: PORT_MAP}
 }
 
-
 /*
 Scans a single host on a single port
+
 	:param addr: the address to dial
 	:param port: the port number to dial
 */
@@ -55,13 +53,14 @@ func singlePortScan(addr string, port int, svcs string) *PortScanResult {
 
 /*
 Perform a TCP scan on the pointers host
+
 	:param posts: a list of ports to scan against a host
 */
 func (t *TcpScanHost) ScanPortRange(ports []int) []*PortScanResult {
 	wg := &sync.WaitGroup{}
 	out := make(chan *PortScanResult)
 	var res []*PortScanResult
-    wgOuter := &sync.WaitGroup{}
+	wgOuter := &sync.WaitGroup{}
 	wgOuter.Add(1)
 	go func() {
 		defer wgOuter.Done()
@@ -90,14 +89,9 @@ func (t *TcpScanHost) ScanPortRange(ports []int) []*PortScanResult {
 
 }
 
-
 /*
 Evaluate whether the host has an entry in the ARP table
 */
 func (h *TcpScanHost) IsOnline() bool {
 	return false
 }
-
-
-
-

+ 3 - 16
pkg/storage/storage.go → pkg/storage.go

@@ -1,4 +1,4 @@
-package storage
+package kyoketsu
 
 import (
 	"context"
@@ -11,14 +11,13 @@ import (
 )
 
 type TopologyDatabaseIO interface {
-	AddHostToDb(*scan.TcpScanHost) error	// Add a host to the hosts table
+	AddHostToDb(*scan.TcpScanHost) error             // Add a host to the hosts table
 	UpdateHostEntry(string, *scan.TcpScanHost) error //Update a host entry, indexing by its ip address
 	RemoveHostEntry(string) error
 }
 
-
 type MongoClient struct {
-	conn	*mongo.Client
+	conn *mongo.Client
 }
 
 func NewMongoClient(host string, port int) *MongoClient {
@@ -38,7 +37,6 @@ func (m *MongoClient) addDocument(id string, data interface{}) error {
 	return nil
 }
 
-
 func (m *MongoClient) AddHostToDb(host *scan.TcpScanHost) error {
 	return nil
 }
@@ -50,14 +48,3 @@ func (m *MongoClient) UpdateHostEntry(id string, host *scan.TcpScanHost) error {
 func (m *MongoClient) RemoveHostEntry(id string) error {
 	return nil
 }
-
-
-
-
-
-
-
-
-
-
-

+ 2 - 0
pkg/torrent.go

@@ -0,0 +1,2 @@
+package kyoketsu
+

+ 0 - 1
pkg/torrent/torrent.go

@@ -1 +0,0 @@
-package torrent