bacnet

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0, ISC Imports: 6 Imported by: 0

Documentation

Overview

Package bacnet provides a zgrab2 module that scans for bacnet. Default Port: 47808 / 0xBAC0 (UDP)

Behavior and output copied identically from original zgrab.

Index

Constants

View Source
const (
	VLC_TYPE_IP               byte = 0x81
	VLC_FUNCTION_UNICAST_NPDU byte = 0x0a
)

VLC Header constants

View Source
const (
	NPDU_VERSION_ASHRAE_135_1995 byte = 0x01
	NPDU_FLAG_EXPECTING_RESPONSE byte = 0x04
)

NPDU header constant

View Source
const (
	MAX_BACNET_FRAME_LEN = 1476
)
View Source
const (
	SERVER_CHOICE_READ_PROPERTY byte = 0x0c
)

APDU Server Choice constants

Variables

This section is empty.

Functions

func ReadVLC

func ReadVLC(c net.Conn) (vlc *VLC, npdu *NPDU, apdu *APDU, leftovers []byte, err error, isBACNet bool)

func RegisterModule

func RegisterModule()

RegisterModule registers the zgrab2 module.

func SendVLC

func SendVLC(c net.Conn, payload []byte) error

Types

type APDU

type APDU struct {
	TypeAndFlags byte              `json:"type_and_flags"`
	SegmentSizes SegmentParameters `json:"segment_sizes"`
	InvokeID     byte              `json:"invoke_id"`
	ServerChoice byte              `json:"server_choice"`
}

func (*APDU) Marshal

func (apdu *APDU) Marshal() ([]byte, error)

Marshal encodes a full APDU to binary

func (*APDU) Unmarshal

func (apdu *APDU) Unmarshal(b []byte) (out []byte, err error)

Unmarshal decodes a full APDU from binary

type Flags

type Flags struct {
	zgrab2.BaseFlags
	zgrab2.UDPFlags

	Verbose bool `long:"verbose" description:"More verbose logging, include debug fields in the scan results"`
}

Flags holds the command-line configuration for the bacnet scan module. Populated by the framework.

func (*Flags) Help

func (flags *Flags) Help() string

Help returns the module's help string.

func (*Flags) Validate

func (flags *Flags) Validate(args []string) error

Validate checks that the flags are valid. On success, returns nil. On failure, returns an error instance describing the error.

type Frame

type Frame struct {
	VLC     *VLC        `json:"vlc,omitempty"`
	NPDU    *NPDU       `json:"npdu,omitempty"`
	APDU    *APDU       `json:"apdu,omitempty"`
	Payload interface{} `json:"payload,omitempty"`
}

type Log

type Log struct {
	IsBACNet                    bool   `json:"is_bacnet"`
	InstanceNumber              uint32 `json:"instance_number"`
	VendorID                    uint16 `json:"vendor_id"`
	VendorName                  string `json:"vendor_name,omitempty"`
	FirmwareRevision            string `json:"firmware_revision,omitempty"`
	ApplicationSoftwareRevision string `json:"application_software_revision,omitempty"`
	ObjectName                  string `json:"object_name,omitempty"`
	ModelName                   string `json:"model_name,omitempty"`
	Description                 string `json:"description,omitempty"`
	Location                    string `json:"location,omitempty"`
}

func (*Log) QueryApplicationSoftwareRevision

func (log *Log) QueryApplicationSoftwareRevision(c net.Conn) (err error)

func (*Log) QueryDescription

func (log *Log) QueryDescription(c net.Conn) (err error)

func (*Log) QueryDeviceID

func (log *Log) QueryDeviceID(c net.Conn) (err error)

func (*Log) QueryFirmwareRevision

func (log *Log) QueryFirmwareRevision(c net.Conn) (err error)

func (*Log) QueryLocation

func (log *Log) QueryLocation(c net.Conn) (err error)

func (*Log) QueryModelName

func (log *Log) QueryModelName(c net.Conn) (err error)

func (*Log) QueryObjectName

func (log *Log) QueryObjectName(c net.Conn) (err error)

func (*Log) QueryVendorName

func (log *Log) QueryVendorName(c net.Conn) (err error)

func (*Log) QueryVendorNumber

func (log *Log) QueryVendorNumber(c net.Conn) (err error)

type Module

type Module struct {
}

Module implements the zgrab2.Module interface.

func (*Module) Description

func (module *Module) Description() string

Description returns text uses in the help for this module.

func (*Module) NewFlags

func (module *Module) NewFlags() interface{}

NewFlags returns a default Flags object.

func (*Module) NewScanner

func (module *Module) NewScanner() zgrab2.Scanner

NewScanner returns a new Scanner instance.

type NPDU

type NPDU struct {
	Version byte
	Control byte
}

func (*NPDU) Marshal

func (npdu *NPDU) Marshal() ([]byte, error)

Marshal encodes an NPDU header to binary

func (*NPDU) Unmarshal

func (npdu *NPDU) Unmarshal(b []byte) ([]byte, error)

Unmarshal decodes an NPDU header from binary

type ObjectID

type ObjectID uint32
const (
	OID_ANY ObjectID = 0x023fffff
)

type PropertyID

type PropertyID byte
const (
	PID_OID                           PropertyID = 75
	PID_VENDOR_NUMBER                 PropertyID = 0x78
	PID_VENDOR_NAME                   PropertyID = 0x79
	PID_FIRMWARE_REVISION             PropertyID = 0x2c
	PID_APPLICATION_SOFTWARE_REVISION PropertyID = 0x0c
	PID_OBJECT_NAME                   PropertyID = 0x4d
	PID_MODEL_NAME                    PropertyID = 0x46
	PID_DESCRIPTION                   PropertyID = 0x1c
	PID_LOCATION                      PropertyID = 0x3a
)

type ReadProperty

type ReadProperty struct {
	Object   ObjectID   `json:"object"`
	Property PropertyID `json:"property"`
}

func (*ReadProperty) Marshal

func (rp *ReadProperty) Marshal() ([]byte, error)

func (*ReadProperty) Unmarshal

func (rp *ReadProperty) Unmarshal(b []byte) (leftovers []byte, err error)

type ReadPropertyRequest

type ReadPropertyRequest struct {
	NPDU      NPDU         `json:"npdu"`
	APDU      APDU         `json:"apdu"`
	Selection ReadProperty `json:"read_property"`
}

func NewReadPropertyRequest

func NewReadPropertyRequest(oid ObjectID, pid PropertyID) *ReadPropertyRequest

func (*ReadPropertyRequest) Marshal

func (rp *ReadPropertyRequest) Marshal() (out []byte, err error)

type Scanner

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

Scanner implements the zgrab2.Scanner interface.

func (*Scanner) GetName

func (scanner *Scanner) GetName() string

GetName returns the Scanner name defined in the Flags.

func (*Scanner) GetTrigger

func (scanner *Scanner) GetTrigger() string

GetTrigger returns the Trigger defined in the Flags.

func (*Scanner) Init

func (scanner *Scanner) Init(flags zgrab2.ScanFlags) error

Init initializes the Scanner.

func (*Scanner) InitPerSender

func (scanner *Scanner) InitPerSender(senderID int) error

InitPerSender initializes the scanner for a given sender.

func (*Scanner) Protocol

func (scanner *Scanner) Protocol() string

Protocol returns the protocol identifier of the scan.

func (*Scanner) Scan

func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error)

Scan probes for a BACNet service. Behavior taken from original zgrab. Connects to the configured port over UDP (default 47808/0xBAC0). Attempts to query the following in sequence; if any fails, returning anything that has been detected so far. (Unless QueryDeviceID fails, the service is considered to be detected) 1. Device ID 2. Vendor Number 3. Vendor Name 4. Firmware Revision 5. App software revision 6. Object name 7. Model name 8. Description 9. Location The result is a bacnet.Log, and contains any of the above.

type SegmentParameters

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

type VLC

type VLC struct {
	Type     byte
	Function byte
	Length   uint16
}

func (*VLC) Marshal

func (vlc *VLC) Marshal() ([]byte, error)

Marshal encodes a VLC header to binary

func (*VLC) Unmarshal

func (vlc *VLC) Unmarshal(b []byte) ([]byte, error)

Unmarshal decodes a VLC header from binary

Jump to

Keyboard shortcuts

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