nessusRPC

package module
v0.0.0-...-4f59161 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2014 License: MIT Imports: 8 Imported by: 0

README

nessus-rpc

Interact with Nessus REST

Example Usage

package main

import (
        "fmt"
        "github.com/b00stfr3ak/nessus-rpc"
        "io/ioutil"
        "log"
        "time"
)

func main() {
        // Login to Nessus
        nessus, err := nessusRPC.Login("user", "password", "localhost", "8834")
        if err != nil {
                log.Fatal(err)
        }
        /*   List policy name and id's Avail
             fmt.Println("Listing Policy Name")
             pn := nessus.ListPolicyName()
             fmt.Println(pn)
             fmt.Println("List Policy ID")
             pi := nessus.ListPolicyID()
             fmt.Println(pi)
        */
        // Start Scan
        uid := nessus.StartScan("-5", "testing", "localhost")
        fmt.Println("Scan Status")
        checkStatus(uid, nessus)
        //Pause Scan
        nessus.PauseScan(uid)
        checkStatus(uid, nessus)
        //Resume Scan
        nessus.ResumeScan(uid)
        status := checkStatus(uid, nessus)
        //Stop Scan
        //nessus.StopScan(uid)
        //status := checkStatus(uid, nessus)
        //Check status loop
        scanStatus(uid, status, nessus)
        // Download file
        fmt.Println("Downloading File")
        content := nessus.DownloadFile(uid)
        //fmt.Println(content)
        errs := ioutil.WriteFile("/tmp/dat1", content, 0644)
        if errs != nil {
                log.Fatal(errs)
        }

}

func checkStatus(uid string, nessus *nessusRPC.Contents) string {
        s := nessus.ScanStatus(uid)
        fmt.Println(s)
        return s
}

func scanStatus(uid, status string, nessus *nessusRPC.Contents) string {
        if status != "completed" {
                time.Sleep(time.Second * 5)
        } else {
                return "completed"
        }
        s := checkStatus(uid, nessus)
        return scanStatus(uid, s, nessus)
}
Package provides
  1. ListPolicyName
  • Returns a slice of policy names
  1. ListPolicyID
  • Returns a slice of policy id's
  1. ReportsList
  • Returns XML file of reports
  1. ReportListAll
  • Returns a struct of data that contains all the id's, scan names, scan status and the time stamp of when it was completed
  1. StartScan
  • Starts a new scan and returns teh scans uuid
  1. ScanStatus
  • Returns the status of a scan based on the given uuid number
  1. DownloadFile
  • Retruns a nessusv2 xml report from the given uid

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contents

type Contents struct {
	Token string `xml:"contents>token"`
	Name  string `xml:"contents>user>name"`
	Admin bool   `xml:"contents>user>admin"`
	// contains filtered or unexported fields
}

func Login

func Login(user, pass, host, port string) (c *Contents, err error)

Trys to log into nessus

func (Contents) DownloadFile

func (content Contents) DownloadFile(uid string) (b []byte)

Returns a nessus v2 xml report from the given uid

func (Contents) ListPolicyID

func (content Contents) ListPolicyID() (r []string)

Returns a slice of policy id's

func (Contents) ListPolicyName

func (content Contents) ListPolicyName() (r []string)

Returns a slice of policy names

func (Contents) PauseScan

func (content Contents) PauseScan(uuid string)

Pause a scan with the given uuid

func (Contents) ReportsList

func (content Contents) ReportsList() (b []byte)

Returns XML file of reports

func (Contents) ReportsListAll

func (content Contents) ReportsListAll() (r *reportList)

Returns a struct of data that contains all the id's, scan names scan status and the time stamp of when it was completed

func (Contents) ResumeScan

func (content Contents) ResumeScan(uuid string)

Resume a scan with the given uuid

func (Contents) ScanStatus

func (content Contents) ScanStatus(uuid string) (status string)

Returns the status of a scan based on the given uuid number.

func (Contents) StartScan

func (content Contents) StartScan(policyID, scanName, target string) (r string)

Starts a new scan and returns the scans uuid

func (Contents) StopScan

func (content Contents) StopScan(uuid string)

Stop a scan with the given uuid

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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