-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodel.go
194 lines (171 loc) · 6.43 KB
/
model.go
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package nmapxml
import "encoding/xml"
// Run contains the main data of an nmap scan
type Run struct {
XMLName xml.Name `xml:"nmaprun" json:"-"`
Scanner string `xml:"scanner,attr" json:"scanner"`
Args string `xml:"args,attr" json:"args"`
Start string `xml:"start,attr" json:"start"`
StartStr string `xml:"startstr,attr" json:"startstr"`
Version string `xml:"version,attr" json:"version"`
XMLOutputVersion string `xml:"xmloutputversion,attr" json:"xmloutputversion"`
ScanInfo ScanInfo
Verbose Verbose
Debugging Debugging
Host []Host `xml:"host" json:"host"`
}
// ScanInfo contains metadata of an nmap scan
type ScanInfo struct {
XMLName xml.Name `xml:"scaninfo" json:"-"`
Type string `xml:"type,attr" json:"type"`
Protocol string `xml:"protocol,attr" json:"protocol"`
Numservices string `xml:"numservices,attr" json:"numservices"`
Services string `xml:"services,attr" json:"services"`
}
// Verbose contains verbosity level of an nmap scan
type Verbose struct {
XMLName xml.Name `xml:"verbose" json:"-"`
Level string `xml:"level,attr" json:"level"`
}
// Debugging contains debugging level of an nmap scan
type Debugging struct {
XMLName xml.Name `xml:"debugging" json:"-"`
Level string `xml:"level,attr" json:"level"`
}
// Host contains a scanned host
type Host struct {
XMLName xml.Name `xml:"host" json:"-"`
StartTime string `xml:"starttime,attr" json:"starttime"`
EndTime string `xml:"endtime,attr" json:"endtime"`
Status Status
Address Address
Hostnames Hostnames
Ports Ports
Times Times
}
// Status contains status of a scanned host
type Status struct {
XMLName xml.Name `xml:"status" json:"-"`
State string `xml:"state,attr" json:"state"`
Reason string `xml:"reason,attr" json:"reason"`
ReasonTTL string `xml:"reason_ttl,attr" json:"reason_ttl"`
}
// Address contains IP address of a scanned host
type Address struct {
XMLName xml.Name `xml:"address" json:"-"`
Addr string `xml:"addr,attr" json:"addr"`
AddrType string `xml:"addrtype,attr" json:"addrtype"`
}
// Hostnames wraps an array of Hostname nodes
type Hostnames struct {
XMLName xml.Name `xml:"hostnames" json:"-"`
Hostname Hostname
}
// Hostname contains hostname of a scanned host
type Hostname struct {
XMLName xml.Name `xml:"hostname" json:"-"`
Name *string `xml:"name,attr" json:"name,omitempty"`
Type *string `xml:"type,attr" json:"type,omitempty"`
}
// Ports contains all ports scanned of a scanned host
type Ports struct {
XMLName xml.Name `xml:"ports" json:"-"`
ExtraPorts ExtraPorts `xml:"extraports" json:"extraports"`
Port *[]Port `xml:"port" json:"port,omitempty"`
}
// ExtraPorts contains any non-open ports of a scanned host
type ExtraPorts struct {
XMLName xml.Name `xml:"extraports" json:"-"`
State string `xml:"state,attr" json:"state"`
Count string `xml:"count,attr" json:"count"`
ExtraReasons []ExtraReason `xml:"extrareasons" json:"extrareasons"`
}
// ExtraReason contains metadata of extra ports
type ExtraReason struct {
XMLName xml.Name `xml:"extrareasons" json:"-"`
Reason string `xml:"reason,attr" json:"reasons"`
Count string `xml:"count,attr" json:"count"`
}
// Port contains an open port of a scanned host
type Port struct {
XMLName xml.Name `xml:"port" json:"-"`
Protocol string `xml:"protocol,attr" json:"protocol"`
PortID string `xml:"portid,attr" json:"portid"`
State State `xml:"state" json:"state"`
Service Service `xml:"service" json:"service"`
Script *Script `xml:"script" json:"script,omitempty"`
}
// State contains state information of a port
type State struct {
XMLName xml.Name `xml:"state" json:"-"`
State string `xml:"state,attr" json:"state"`
Reason string `xml:"reason,attr" json:"reason"`
ReasonTTL string `xml:"reason_ttl,attr" json:"reason_ttl"`
}
// Service contains service information of a port
type Service struct {
XMLName xml.Name `xml:"service" json:"-"`
Name string `xml:"name,attr" json:"name"`
Product *string `xml:"product,attr" json:"product,omitempty"`
DeviceType *string `xml:"devicetype,attr" json:"devicetype,omitempty"`
ServiceFP *string `xml:"servicefp,attr" json:"servicefp,omitempty"`
Tunnel *string `xml:"tunnel,attr" json:"tunnel,omitempty"`
Method string `xml:"method,attr" json:"method"`
Conf string `xml:"conf,attr" json:"conf"`
CPE *string `xml:"cpe" json:"cpe,omitempty"`
}
// Script contains metadata of script ran on a port
type Script struct {
XMLName xml.Name `xml:"script" json:"-"`
ID string `xml:"id,attr" json:"id"`
Output string `xml:"output,attr" json:"output"`
Table *[]Table `xml:"table" json:"table,omitempty"`
ScriptData *[]Elem `xml:"elem"`
}
// Elem contains output of a script
type Elem struct {
Key string `xml:"key,attr" json:"key,omitempty"`
Value string `xml:",innerxml" json:"value,omitempty"`
}
// Table contains a table of elems
type Table struct {
XMLName xml.Name `xml:"table" json:"-"`
Key *string `xml:"key,attr" json:"key,omitempty"`
Table *Table `json:",omitempty"`
TableData *[]Elem `xml:"elem" json:",omitempty"`
}
// Times contains latency information of a scanned host
//
// Srtt == Smoothed Averaged Round Trip Time
//
// RTT == Round Trip Time
//
// To == ?
type Times struct {
XMLName xml.Name `xml:"times" json:"-"`
Srtt string `xml:"srtt,attr" json:"srtt"`
RttVar string `xml:"rttvar,attr" json:"rttvar"`
To string `xml:"to,attr" json:"to"`
}
// Runstats contains final information of a scan
type Runstats struct {
XMLName xml.Name `xml:"runstats" json:"-"`
Finished Finished `xml:"finished" json:"finished"`
Hosts Hosts `xml:"hosts" json:"hosts"`
}
// Finished contains total time a scan took
type Finished struct {
XMLName xml.Name `xml:"finished" json:"-"`
Time string `xml:"time,attr" json:"time"`
Timestr string `xml:"timestr,attr" json:"timestr"`
Elapsed string `xml:"elapsed,attr" json:"elapsed"`
Summary string `xml:"summary,attr" json:"summary"`
Exit string `xml:"exit,attr" json:"exit"`
}
// Hosts contains counts of hosts up vs down and a count of total hosts of a scan
type Hosts struct {
XMLName xml.Name `xml:"hosts" json:"-"`
Up string `xml:"up,attr" json:"up"`
Down string `xml:"down,attr" json:"down"`
Total string `xml:"total,attr" json:"total"`
}