restuss

package module
v0.0.0-...-cfe4e09 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 7 Imported by: 0

README

Restuss

This is a Go package that support part of the Nessus rest(kind of) api.

go get github.com/stefanoj3/restuss

The amount of method supported is extremely small, I actually needed it for a personal project and decided to make a library out of it, so others can reuse it.

Example usage of the library:

auth := restuss.NewKeyAuthProvider(
    "fa74fcdd10db53bf54cd1467c11547efd70af0b526eb0d2b347b1050e1cab639",
    "71ebdf108b4d2fa9fef8c895096ff1a2a7732c215c64edc8d6495053488004d6",
)

c, err := restuss.NewClient(auth, "https://127.0.0.1:8834", true)

if err != nil {
    log.Fatal(err.Error())
}

var lastModificationDate int64 = 0

res, err := c.GetScans(lastModificationDate)

if err != nil {
    log.Fatal(err.Error())
}

Support for basic auth is also planned but not a priority.

For now the available calls are: create scan, launch scan, stop scan, list scans, list scan's templates.

This package has zero dependencies and I plan to keep it like that.

Tested with Nessus 6.10.1

Important note

Since it's in early development the next versions could contain breaking changes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider interface {
	AddAuthHeaders(*http.Request)
	Prepare(url string, client *http.Client) error
}

AuthProvider expose the methods necessary to perform authenticated calls

type BasicAuthProvider

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

BasicAuthProvider represent the basic auth method

func NewBasicAuthProvider

func NewBasicAuthProvider(username string, password string) *BasicAuthProvider

NewBasicAuthProvider returns a new BasicAuthProvider

func (*BasicAuthProvider) AddAuthHeaders

func (b *BasicAuthProvider) AddAuthHeaders(r *http.Request)

AddAuthHeaders add auth headers

func (*BasicAuthProvider) Prepare

func (b *BasicAuthProvider) Prepare(url string, c *http.Client) error

Prepare performs tasks required pre-auth, it should be called before AddAuthHeaders can be used

type Client

type Client interface {
	GetScanTemplates() ([]*ScanTemplate, error)
	LaunchScan(scanId int64) error
	StopScan(scanId int64) error
	CreateScan(scan *Scan) (*PersistedScan, error)
	GetScans(lastModificationDate int64) ([]*PersistedScan, error)
	GetScanByID(id int64) (*ScanDetail, error)
	GetPluginByID(id int64) (*Plugin, error)
}

Client expose the methods callable on Nessus Api

type KeyAuthProvider

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

KeyAuthProvider represent the key based auth method

func NewKeyAuthProvider

func NewKeyAuthProvider(accessKey string, secretKey string) *KeyAuthProvider

NewKeyAuthProvider returns a new KeyAuthProvider

func (*KeyAuthProvider) AddAuthHeaders

func (k *KeyAuthProvider) AddAuthHeaders(r *http.Request)

AddAuthHeaders add auth headers

func (*KeyAuthProvider) Prepare

func (k *KeyAuthProvider) Prepare(_ string, _ *http.Client) error

Prepare performs tasks required pre-auth, it should be called before AddAuthHeaders can be used

type NessusClient

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

func NewClient

func NewClient(auth AuthProvider, url string, allowInsecureConnection bool) (*NessusClient, error)

NewClient returns a new NessusClient

func (*NessusClient) CreateScan

func (c *NessusClient) CreateScan(scan *Scan) (*PersistedScan, error)

CreateScan creates a scan

func (*NessusClient) GetPluginByID

func (c *NessusClient) GetPluginByID(ID int64) (*Plugin, error)

GetPluginByID retrieves a plugin by ID

func (*NessusClient) GetScanByID

func (c *NessusClient) GetScanByID(ID int64) (*ScanDetail, error)

GetScanByID retrieve a scan by ID

func (*NessusClient) GetScanTemplates

func (c *NessusClient) GetScanTemplates() ([]*ScanTemplate, error)

GetScanTemplates retrieves Scan Templates

func (*NessusClient) GetScans

func (c *NessusClient) GetScans(lastModificationDate int64) ([]*PersistedScan, error)

GetScans get a list of scan matching the provided lastModificationDate (check Nessus documentation)

func (*NessusClient) LaunchScan

func (c *NessusClient) LaunchScan(scanID int64) error

LaunchScan launch spe scan with the specified scanID

func (*NessusClient) StopScan

func (c *NessusClient) StopScan(scanID int64) error

StopScan stops the scan with the given scanID

type PersistedScan

type PersistedScan struct {
	ID                   int64  `json:"id"`
	UUID                 string `json:"uuid"`
	Name                 string `json:"name"`
	Enabled              bool   `json:"enabled"`
	Status               string `json:"status"`
	CreationDate         int64  `json:"creation_date"`
	LastModificationDate int64  `json:"last_modification_date"`
	Owner                string `json:"owner"`
}

type Plugin

type Plugin struct {
	ID         int64             `json:"id"`
	Name       string            `json:"name"`
	FamilyName string            `json:"family_name"`
	Attributes []PluginAttribute `json:"attributes"`
}

type PluginAttribute

type PluginAttribute struct {
	Name  string `json:"attribute_name"`
	Value string `json:"attribute_value"`
}

type Scan

type Scan struct {
	TemplateUUID string       `json:"uuid"`
	Settings     ScanSettings `json:"settings"`
}

type ScanDetail

type ScanDetail struct {
	ID              int64
	Info            *ScanInfo       `json:"info"`
	Vulnerabilities []Vulnerability `json:"vulnerabilities"`
}

type ScanInfo

type ScanInfo struct {
	Targets     string `json:"targets"`
	Status      string `json:"status"`
	ScannerName string `json:"scanner_name"`
	ScanType    string `json:"scan_type"`
}

type ScanSettings

type ScanSettings struct {
	Name    string `json:"name"`
	Enabled bool   `json:"enabled"`
	Targets string `json:"text_targets"`
}

type ScanTemplate

type ScanTemplate struct {
	UUID             string `json:"uuid"`
	Name             string `json:"name"`
	Title            string `json:"title"`
	Description      string `json:"description"`
	CloudOnly        bool   `json:"cloud_only"`
	SubscriptionOnly bool   `json:"subscription_only"`
	IsAgent          bool   `json:"is_agent"`
	Info             string `json:"more_info"`
}

type Vulnerability

type Vulnerability struct {
	VulnerabilityIndex int64  `json:"vuln_index"`
	Severity           int64  `json:"severity"`
	PluginName         string `json:"plugin_name"`
	Count              int64  `json:"count"`
	PluginId           int64  `json:"plugin_id"`
	PluginFamily       string `json:"plugin_family"`
}

Jump to

Keyboard shortcuts

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