-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathscan.py
More file actions
345 lines (306 loc) · 9.89 KB
/
scan.py
File metadata and controls
345 lines (306 loc) · 9.89 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
"""Schemas to support Scan endpoints."""
# Standard Python Libraries
from datetime import datetime
from typing import Any, Dict, List, Optional
from uuid import UUID
# Third-Party Libraries
from pydantic import BaseModel
from .organization_schema import Organization
from .organization_tag import OrganizationalTags
class Scan(BaseModel):
"""Scan schema reflecting model."""
id: UUID
createdAt: datetime
updatedAt: datetime
name: str
arguments: Any
frequency: int
lastRun: Optional[datetime]
isGranular: bool
isUserModifiable: Optional[bool]
isSingleScan: bool
manualRunPending: bool
tags: Optional[List[OrganizationalTags]] = []
organizations: Optional[List[Organization]] = []
class ScanSchema(BaseModel):
"""Scan type schema."""
type: str = "fargate" # Only 'fargate' is supported
description: str
# Whether scan is passive (not allowed to hit the domain).
isPassive: bool
# Whether scan is global. Global scans run once for all organizations, as opposed
# to non-global scans, which are run for each organization.
global_scan: bool
# CPU and memory for the scan. See this page for more information:
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html
cpu: Optional[str] = None
memory: Optional[str] = None
# A scan is "chunked" if its work is divided and run in parallel by multiple workers.
# To make a scan chunked, make sure it is a global scan and specify the "numChunks" variable,
# which corresponds to the number of workers that will be created to run the task.
# Chunked scans can only be run on scans whose implementation takes into account the
# chunkNumber and numChunks parameters specified in commandOptions.
numChunks: Optional[int] = None
class GranularScan(BaseModel):
"""Granular scan model."""
id: UUID
name: str
isUserModifiable: Optional[bool]
class GetScansResponseModel(BaseModel):
"""Get Scans response model."""
scans: List[Scan]
schema: Dict[str, Any]
organizations: List[Dict[str, Any]]
class GetGranularScansResponseModel(BaseModel):
"""Get Scans response model."""
scans: List[GranularScan]
schema: Dict[str, Any]
class IdSchema(BaseModel):
"""Schema for ID objects."""
id: UUID
class NewScan(BaseModel):
"""Create Scan Schema."""
name: str
arguments: Any
organizations: Optional[List[UUID]] = []
tags: Optional[List[IdSchema]] = []
frequency: Optional[int] = None
isGranular: Optional[bool] = None
isUserModifiable: Optional[bool] = None
isSingleScan: Optional[bool] = None
class CreateScanResponseModel(BaseModel):
"""Create Scan Schema."""
id: UUID
name: str
arguments: Any
frequency: int
isGranular: bool
isUserModifiable: Optional[bool]
isSingleScan: bool
createdBy: Optional[Any]
tags: Optional[List[IdSchema]]
organizations: Optional[List[IdSchema]]
class GetScanResponseModel(BaseModel):
"""Get Scans response model."""
scan: Scan
schema: Dict[str, Any]
organizations: List[Dict[str, Any]]
class GenericMessageResponseModel(BaseModel):
"""Generic response model."""
status: str
message: str
SCAN_SCHEMA = {
"amass": ScanSchema(
type="fargate",
isPassive=False,
global_scan=False,
description="Open source tool that integrates passive APIs and active subdomain enumeration in order to discover target subdomains",
),
"censys": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
description="Passive discovery of subdomains from public certificates",
),
"censysCertificates": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="2048",
memory="6144",
numChunks=20,
description="Fetch TLS certificate data from censys certificates dataset",
),
"censysIpv4": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="2048",
memory="6144",
numChunks=20,
description="Fetch passive port and banner data from censys ipv4 dataset",
),
"cve": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Matches detected software versions to CVEs from NIST NVD and CISA's Known Exploited Vulnerabilities Catalog.",
),
"credential_sync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Pull in Credential breach and exposure data from commercial mdl",
),
"vulnScanningSync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Pull in vulnerability data from VSs Vulnerability database",
),
"cveSync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Matches detected software versions to CVEs from NIST NVD and CISA's Known Exploited Vulnerabilities Catalog.",
),
"dnstwist": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
cpu="2048",
memory="16384",
description="Domain name permutation engine for detecting similar registered domains.",
),
"dotgov": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
description='Create organizations based on root domains from the dotgov registrar dataset. All organizations are created with the "dotgov" tag and have a " (dotgov)" suffix added to their name.',
),
"findomain": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
description="Open source tool that integrates passive APIs in order to discover target subdomains",
),
"hibp": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
cpu="2048",
memory="16384",
description="Finds emails that have appeared in breaches related to a given domain",
),
"intrigueIdent": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
cpu="1024",
memory="4096",
description="Open source tool that fingerprints web technologies based on HTTP responses",
),
"lookingGlass": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
description="Finds vulnerabilities and malware from the LookingGlass API",
),
"portscanner": ScanSchema(
type="fargate",
isPassive=False,
global_scan=False,
description="Active port scan of common ports",
),
"rootDomainSync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
description="Creates domains from root domains by doing a single DNS lookup for each root domain.",
),
"savedSearch": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
description="Performs saved searches to update their search results",
),
"searchSync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="4096",
description="Syncs records with Elasticsearch so that they appear in search results.",
),
"shodan": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
cpu="1024",
memory="8192",
description="Fetch passive port, banner, and vulnerability data from shodan",
),
"shodan_sync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Pull in Shodan asset and vulnerability data from commercial mdl",
),
"sslyze": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
description="SSL certificate inspection",
),
"test": ScanSchema(
type="fargate",
isPassive=False,
global_scan=True,
description="Not a real scan, used to test",
),
"trustymail": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
description="Evaluates SPF/DMARC records and checks MX records for STARTTLS support",
),
"vulnSync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Pull in vulnerability data from PEs Vulnerability database",
),
"wappalyzer": ScanSchema(
type="fargate",
isPassive=True,
global_scan=False,
cpu="1024",
memory="4096",
description="Open source tool that fingerprints web technologies based on HTTP responses",
),
"flagFloatingIps": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="2048",
memory="16384",
description="Loops through all domains and determines if their associated IP can be found in a report Cidr block.",
),
"updateBlocklist": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
numChunks=0,
cpu="1024",
memory="8192",
description="Updates blocked ip records against blocklist.de global IP blocklist",
),
"was_sync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Pull in WAS finding data from commercial mdl",
),
"xpanse_sync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
cpu="1024",
memory="8192",
description="Pull in Xpanse alert data from commercial mdl",
),
}