-
Notifications
You must be signed in to change notification settings - Fork 36
/
Server.ps1
158 lines (137 loc) · 4.33 KB
/
Server.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#region Server
####################################################################
<#
.Synopsis
Get information on a Nessus Server for a given session.
.DESCRIPTION
Get information on a Nessus Server for a given session.
.EXAMPLE
Get-NessusServerInfo -SessionId 0 -Verbose
VERBOSE: GET https://192.168.1.205:8834/server/properties with 0-byte payload
VERBOSE: received 478-byte response of content type application/json
loaded_plugin_set : 201502021615
server_uuid : 9b7b6864-d654-345f-57f2-aeaa5438654421ba99bb9f34e2b5
update : @{href=; new_version=0; restart=0}
expiration : 1505793600
nessus_ui_version : 6.0.2
nessus_type : Nessus
notifications : {}
expiration_time : 959
capabilities : @{multi_scanner=True; report_email_config=False}
plugin_set : 201502021615
idle_timeout :
scanner_boottime : 1422920519
login_banner :
server_version : 6.0.2
feed : ProFeed
#>
function Get-NessusServerInfo
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
Position=0,
ValueFromPipelineByPropertyName=$true)]
[Alias('Index')]
[int32[]]$SessionId = @()
)
Begin
{
$origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0
}
Process
{
$ToProcess = @()
foreach($i in $SessionId)
{
$Connections = $Global:NessusConn
foreach($Connection in $Connections)
{
if ($Connection.SessionId -eq $i)
{
$ToProcess += $Connection
}
}
}
foreach($Connection in $ToProcess)
{
$ServerInfo = InvokeNessusRestRequest -SessionObject $Connection -Path '/server/properties' -Method 'Get'
if ($ServerInfo -is [psobject])
{
$SrvInfoProp = [ordered]@{}
$SrvInfoProp.Add('NessusType', $ServerInfo.nessus_type)
$SrvInfoProp.Add('ServerVersion', $ServerInfo.server_version)
$SrvInfoProp.Add('UIVersion', $ServerInfo.nessus_ui_version)
$SrvInfoProp.Add('PluginSet', $ServerInfo.loaded_plugin_set)
$SrvInfoProp.Add('Feed', $ServerInfo.feed)
$SrvInfoProp.Add('FeedExpiration', $origin.AddSeconds($ServerInfo.expiration).ToLocalTime())
$SrvInfoProp.Add('Capabilities', $ServerInfo.capabilities)
$SrvInfoProp.Add('UUID', $ServerInfo.server_uuid)
$SrvInfoProp.Add('Update', $ServerInfo.update)
$SrvInfoProp.Add('Enterprise', $ServerInfo.enterprise)
$SrvInfoProp.Add('License', $ServerInfo.license)
$SrvInfoObj = New-Object -TypeName psobject -Property $SrvInfoProp
$SrvInfoObj.pstypenames[0] = 'Nessus.ServerInfo'
$SrvInfoObj
}
}
}
End
{
}
}
<#
.Synopsis
Get the current status of the Nessus Server for a session.
.DESCRIPTION
Get the current status of the Nessus Server for a session.
.EXAMPLE
Get-NessusServerStatus -Id 0
Progress :
Status : ready
#>
function Get-NessusServerStatus
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
Position=0,
ValueFromPipelineByPropertyName=$true)]
[Alias('Index')]
[int32[]]
$SessionId = @()
)
Begin
{
}
Process
{
$ToProcess = @()
foreach($i in $SessionId)
{
$Connections = $Global:NessusConn
foreach($Connection in $Connections)
{
if ($Connection.SessionId -eq $i)
{
$ToProcess += $Connection
}
}
}
foreach($Connection in $ToProcess)
{
$ServerStatus = InvokeNessusRestRequest -SessionObject $Connection -Path '/server/status' -Method 'Get'
if ($ServerStatus -is [psobject])
{
$ServerStatus.pstypenames[0] = 'Nessus.ServerStatus'
$ServerStatus
}
}
}
End
{
}
}
#endregion