Documentation
¶
Index ¶
- Constants
- Variables
- func GetBlacklistStats() map[string]int
- func IsBlacklisted(scriptName string) (bool, string)
- func SaveManifest(manifest *Manifest, path string) error
- type DefaultGitOps
- type GitOperations
- type Manifest
- type Metadata
- type RepoManager
- type Repository
- type RepositoryList
- type Script
- type ScriptContent
- type ScriptSelector
- type SyncManager
- func (sm *SyncManager) Sync(ctx context.Context) error
- func (sm *SyncManager) SyncScriptContent(id string, script Script) error
- func (sm *SyncManager) UpdateScriptFromUI(ctx context.Context, scriptID string, content *ScriptContent) error
- func (sm *SyncManager) UpdateValKeyManifest(ctx context.Context, manifest *Manifest) error
Constants ¶
const ( // DefaultNSERepoURL is the default Git repository URL for Sirius NSE scripts. // Override with the NSE_REPO_URL environment variable. DefaultNSERepoURL = "https://github.com/SiriusScan/sirius-nse.git" // DefaultNSEBasePath is the default base path where NSE scripts are stored. // Override with the NSE_BASE_PATH environment variable. DefaultNSEBasePath = "/opt/sirius-nse" // ManifestFile is the name of the manifest file ManifestFile = "manifest.json" // ValKeyManifestKey is the key used to store the manifest in ValKey ValKeyManifestKey = "nse:manifest" // ValKeyRepoManifestKey is the key used to store the repository manifest in ValKey ValKeyRepoManifestKey = "nse:repo-manifest" // ValKeyScriptPrefix is the prefix for script content keys in ValKey ValKeyScriptPrefix = "nse:script:" // ValKeyScriptMetaPrefix is the prefix for script metadata keys in ValKey ValKeyScriptMetaPrefix = "nse:meta:" )
Variables ¶
var NSEBasePath = envOrDefault("NSE_BASE_PATH", DefaultNSEBasePath)
NSEBasePath is the base path where NSE scripts are stored.
var NSERepoURL = envOrDefault("NSE_REPO_URL", DefaultNSERepoURL)
NSERepoURL returns the NSE repository URL from env or the default.
var ScriptBlacklist = map[string]string{
"afp-brute": "brute",
"ajp-brute": "brute",
"backorifice-brute": "brute",
"cassandra-brute": "brute",
"cics-user-brute": "brute",
"citrix-brute-xml": "brute",
"cvs-brute": "brute",
"cvs-brute-repository": "brute",
"deluge-rpc-brute": "brute",
"dicom-brute": "brute",
"dns-brute": "brute",
"domcon-brute": "brute",
"dpap-brute": "brute",
"drda-brute": "brute",
"ftp-brute": "brute",
"http-brute": "brute",
"http-form-brute": "brute",
"http-iis-short-name-brute": "brute",
"http-joomla-brute": "brute",
"http-proxy-brute": "brute",
"http-wordpress-brute": "brute",
"iax2-brute": "brute",
"imap-brute": "brute",
"informix-brute": "brute",
"ipmi-brute": "brute",
"irc-brute": "brute",
"irc-sasl-brute": "brute",
"iscsi-brute": "brute",
"ldap-brute": "brute",
"membase-brute": "brute",
"memcached-brute": "brute",
"metasploit-msgrpc-brute": "brute",
"mikrotik-routeros-brute": "brute",
"mmouse-brute": "brute",
"mongodb-brute": "brute",
"mqtt-subscribe": "brute",
"ms-sql-brute": "brute",
"mysql-brute": "brute",
"netbus-brute": "brute",
"nexpose-brute": "brute",
"nping-brute": "brute",
"omp2-brute": "brute",
"openvas-otp-brute": "brute",
"openlookup-brute": "brute",
"oracle-brute": "brute",
"oracle-brute-stealth": "brute",
"oracle-sid-brute": "brute",
"ovs-agent-version": "brute",
"pcanywhere-brute": "brute",
"pgsql-brute": "brute",
"pop3-brute": "brute",
"redis-brute": "brute",
"rexec-brute": "brute",
"rlogin-brute": "brute",
"rpcap-brute": "brute",
"rsync-brute": "brute",
"rtsp-url-brute": "brute",
"sip-brute": "brute",
"smb-brute": "brute",
"smb-psexec": "brute",
"smtp-brute": "brute",
"snmp-brute": "brute",
"socks-brute": "brute",
"ssh-brute": "brute",
"svn-brute": "brute",
"telnet-brute": "brute",
"vnc-brute": "brute",
"vmauthd-brute": "brute",
"xmpp-brute": "brute",
"mikrotik-routeros-username-brute": "brute",
"broadcast-avahi-dos": "dos",
"dns-fuzz": "dos",
"http-form-fuzzer": "dos",
"ipv6-ra-flood": "dos",
"smb-flood": "dos",
"smb-vuln-regsvc-dos": "dos",
"broadcast-listener": "info-gathering",
"targets-asn": "info-gathering",
"targets-ipv6-multicast-echo": "info-gathering",
"targets-ipv6-multicast-invalid": "info-gathering",
"targets-ipv6-multicast-mld": "info-gathering",
"targets-ipv6-multicast-slaac": "info-gathering",
"targets-ipv6-wordlist": "info-gathering",
"targets-sniffer": "info-gathering",
"targets-traceroute": "info-gathering",
"targets-xml": "info-gathering",
"traceroute-geolocation": "info-gathering",
"ssh-hostkey": "syntax-error",
}
Functions ¶
func GetBlacklistStats ¶
GetBlacklistStats returns statistics about the blacklist
func IsBlacklisted ¶
IsBlacklisted checks if a script should be excluded
func SaveManifest ¶
SaveManifest saves the manifest to the specified path
Types ¶
type DefaultGitOps ¶
type DefaultGitOps struct{}
DefaultGitOps implements GitOperations using real Git commands
func (*DefaultGitOps) Clone ¶
func (g *DefaultGitOps) Clone(repoURL, targetPath string) error
func (*DefaultGitOps) Fetch ¶
func (g *DefaultGitOps) Fetch(repoPath string) error
func (*DefaultGitOps) Reset ¶
func (g *DefaultGitOps) Reset(repoPath string) error
type GitOperations ¶
type GitOperations interface {
Clone(repoURL, targetPath string) error
Fetch(repoPath string) error
Reset(repoPath string) error
}
GitOperations defines the interface for Git operations
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Scripts map[string]Script `json:"scripts"`
}
Manifest represents the NSE scripts manifest
func LoadManifest ¶
LoadManifest loads the manifest from the specified path
type Metadata ¶
type Metadata struct {
Author string `json:"author"`
Tags []string `json:"tags"`
Description string `json:"description"`
}
Metadata represents additional information about a script
type RepoManager ¶
type RepoManager struct {
BasePath string
RepoURL string
// contains filtered or unexported fields
}
RepoManager handles NSE script repository operations
func NewRepoManager ¶
func NewRepoManager(basePath string, repoURL string) *RepoManager
NewRepoManager creates a new RepoManager instance
func (*RepoManager) EnsureRepo ¶
func (r *RepoManager) EnsureRepo() error
EnsureRepo ensures the repository exists and is up to date
func (*RepoManager) GetManifest ¶
func (rm *RepoManager) GetManifest() (*Manifest, error)
GetManifest returns the current manifest from the repository
func (*RepoManager) SetGitOps ¶
func (rm *RepoManager) SetGitOps(gitOps GitOperations)
SetGitOps sets the GitOperations implementation (useful for testing)
type Repository ¶
Repository represents a single NSE script repository
type RepositoryList ¶
type RepositoryList struct {
Repositories []Repository `json:"repositories"`
}
RepositoryList represents the manifest file structure
func LoadRepositoryList ¶
func LoadRepositoryList(path string) (*RepositoryList, error)
LoadRepositoryList loads the built-in repository list from manifest.json
type Script ¶
type Script struct {
Name string `json:"name"`
Path string `json:"path"`
Protocol string `json:"protocol"`
}
Script represents a single NSE script
type ScriptContent ¶
type ScriptContent struct {
Content string `json:"content"` // The actual script content
Metadata Metadata `json:"metadata"` // Script metadata
UpdatedAt int64 `json:"updatedAt"` // Unix timestamp of last update
}
ScriptContent represents a script's content and metadata in the KV store
type ScriptSelector ¶
type ScriptSelector struct {
// contains filtered or unexported fields
}
ScriptSelector handles the selection of NSE scripts based on protocols
func NewScriptSelector ¶
func NewScriptSelector(manifest *Manifest) *ScriptSelector
NewScriptSelector creates a new ScriptSelector instance
func (*ScriptSelector) BuildNmapScriptFlag ¶
func (s *ScriptSelector) BuildNmapScriptFlag(protocols ...string) (string, error)
BuildNmapScriptFlag constructs the --script flag value for Nmap command It returns both the flag and any error that occurred during construction
func (*ScriptSelector) GetScriptsByProtocol ¶
func (s *ScriptSelector) GetScriptsByProtocol() map[string][]Script
GetScriptsByProtocol returns a map of protocols to their associated scripts
func (*ScriptSelector) SelectScripts ¶
func (s *ScriptSelector) SelectScripts(protocols ...string) []string
SelectScripts returns a list of script paths that match the given protocols If no protocols are provided, returns scripts marked with "*" protocol
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager handles synchronization between local NSE scripts and ValKey store
func NewSyncManager ¶
func NewSyncManager(repoManager *RepoManager, kvStore store.KVStore) *SyncManager
NewSyncManager creates a new SyncManager instance
func (*SyncManager) Sync ¶
func (sm *SyncManager) Sync(ctx context.Context) error
Sync synchronizes the local NSE scripts with the ValKey store
func (*SyncManager) SyncScriptContent ¶
func (sm *SyncManager) SyncScriptContent(id string, script Script) error
SyncScriptContent synchronizes a single script's content
func (*SyncManager) UpdateScriptFromUI ¶
func (sm *SyncManager) UpdateScriptFromUI(ctx context.Context, scriptID string, content *ScriptContent) error
UpdateScriptFromUI updates a script's content and metadata from the UI
func (*SyncManager) UpdateValKeyManifest ¶
func (sm *SyncManager) UpdateValKeyManifest(ctx context.Context, manifest *Manifest) error
UpdateValKeyManifest updates the manifest in ValKey store