-
Notifications
You must be signed in to change notification settings - Fork 1
/
OpenVASManager.cs
88 lines (69 loc) · 2.5 KB
/
OpenVASManager.cs
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
using System;
using System.Xml;
using System.Xml.Linq;
namespace openvassharp
{
public class OpenVASManager : IDisposable
{
private OpenVASSession _session;
public OpenVASManager (OpenVASSession session)
{
if (session != null)
_session = session;
}
public XDocument GetVersion ()
{
return _session.ExecuteCommand (XDocument.Parse ("<get_version />"));
}
public XDocument GetScanConfigurations ()
{
return _session.ExecuteCommand (XDocument.Parse ("<get_configs />"), true);
}
public XDocument CreateSimpleTarget (string cidrRange, string targetName)
{
XDocument createTargetXML = new XDocument (
new XElement ("create_target",
new XElement ("name", targetName),
new XElement ("hosts", cidrRange)));
return _session.ExecuteCommand (createTargetXML, true);
}
public XDocument CreateSimpleTask (string name, string comment, Guid configID, Guid targetID)
{
XDocument createTaskXML = new XDocument (
new XElement ("create_task",
new XElement ("name", name),
new XElement ("comment", comment),
new XElement ("config",
new XAttribute ("id", configID.ToString ())),
new XElement ("target",
new XAttribute ("id", targetID.ToString ()))));
return _session.ExecuteCommand (createTaskXML, true);
}
public XDocument StartTask (Guid taskID)
{
XDocument startTaskXML = new XDocument (
new XElement ("start_task",
new XAttribute ("task_id", taskID.ToString ())));
return _session.ExecuteCommand (startTaskXML, true);
}
public XDocument GetTasks (Guid? taskID = null)
{
if (taskID != null)
return _session.ExecuteCommand (new XDocument (
new XElement ("get_tasks",
new XAttribute ("task_id", taskID.ToString ()))), true);
return _session.ExecuteCommand (XDocument.Parse ("<get_tasks />"), true);
}
public XDocument GetTaskResults (Guid taskID)
{
XDocument getTaskResultsXML = new XDocument (
new XElement ("get_results",
new XAttribute ("task_id", taskID.ToString ())));
return _session.ExecuteCommand (getTaskResultsXML, true);
}
public void Dispose ()
{
_session.Dispose ();
}
}
}