-
Notifications
You must be signed in to change notification settings - Fork 2
/
DomainTypes.fs
634 lines (538 loc) · 16 KB
/
DomainTypes.fs
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
//Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
module Fetters.DomainTypes
open FSharp.Data
open System
open System.Net
open System.Security
//////////////////
//Elementary Types
//////////////////
type RegistryValueType =
|String of string
|ExpandString of string
|Binary of byte array
|MultiString of string array
|DWord of int32
|QWord of int64
type RegistryResult = {
name : string
value : RegistryValueType
}
type ChromeBookmarkJ = JsonProvider<".\SampleBookmarks">
///////////////
//PInvoke Types
///////////////
type LsaProcessHandle = LsaProcessHandle of IntPtr
type LsaAuthPackage = LsaAuthPackage of int
type LUIDPtr = LUIDPtr of IntPtr
type VaultGuid = VaultGuid of IntPtr
type VaultPtr = VaultPtr of IntPtr
type VaultItemPtr = VaultItemPtr of IntPtr
type VaultHandle = VaultHandle of IntPtr
type ArpTableByInd = {
indexaddresses : (int32 * (IPAddress * string))
}
//type ArpTable = {
// localaddress : IPAddress
// addresses : (IPAddress * string) list
// }
[<Flags>]
type KERB_TICKET_FLAGS =
|reserved = 2147483648u
|forwardable = 0x40000000u
|forwarded = 0x20000000u
|proxiable = 0x10000000u
|proxy = 0x08000000u
|may_postdate = 0x04000000u
|postdated = 0x02000000u
|invalid = 0x01000000u
|renewable = 0x00800000u
|initial = 0x00400000u
|pre_authent = 0x00200000u
|hw_authent = 0x00100000u
|ok_as_delegate = 0x00040000u
|name_canonicalize = 0x00010000u
|enc_pa_rep = 0x00010000u
|reserved1 = 0x00000001u
type KerberosRetrieveTicket = {
serviceName : string
target : string
client : string
domain : string
targetDomain : string
altTargetDomain : string
sessionKeyType : string
base64SessionKey : string
keyExpiry : DateTime
flags : KERB_TICKET_FLAGS
startTime : DateTime
endTime : DateTime
renewTime : DateTime
skewTime : DateTime
encodedSize : int32
base64EncodedTicket : string
}
type KerberosQueryTicket = {
serverName : string
realm : string
startTime : DateTime
endTime : DateTime
renewTime : DateTime
encryptionType : string
ticketFlags: KERB_TICKET_FLAGS
}
type KerberosTicket =
|KerberosRetrieveTicket of KerberosRetrieveTicket
|KerberosQueryTicket of KerberosQueryTicket
type DomainSession = {
username : string
domain : string
logonID : uint32
userSID : Principal.SecurityIdentifier
authenticationPkg : string
logonType : string
loginTime : DateTime
logonServer : string
logonServerDnsDomain : string
userPrincipalName : string
kerberosCachedTickets : KerberosTicket list
kerberosTGTcontents : KerberosTicket list
}
type RdpSession = {
state : string
sessionID : int
sessionName : string
hostName : string
username : string
remoteAddress : Net.IPAddress
}
type TCPConnection = {
localAddress : IPAddress
remoteAddress : IPAddress
localport : uint16
remoteport : uint16
connectionState : string
pid : uint32
service : string option
}
type TokenPrivileges = {
privileges : string list
}
type UDPListener = {
localAddress : IPAddress
localport : uint16
pid : uint32
service : string option
}
type VaultRecord = {
name : string
resource : string option
identity : string option
packageSid : string option
credential : string option
lastModified : DateTime
}
type FettersPInvokeRecord =
|ArpTableByInd of ArpTableByInd
|DomainSession of DomainSession
|RdpSession of RdpSession
|TCPConnection of TCPConnection
|TokenPrivileges of TokenPrivileges
|UDPListener of UDPListener
|VaultRecord of VaultRecord
////////////////
//Registry Types
////////////////
type AuditSettings = {
processauditing : RegistryResult option
}
type AutoLogonSettings = {
defaultDomainName : RegistryResult option
defaultUserName : RegistryResult option
defaultPassword : RegistryResult option
altDefaultDomainName : RegistryResult option
altDefaultUserName : RegistryResult option
altDefaultPassword : RegistryResult option
}
type AutorunSetting = {
location : string
value : RegistryResult option
}
type HistoryIE = {
path : string
url : RegistryResult option
}
type InternetSettings = {
proxyServer : RegistryResult option
proxyOverride : RegistryResult option
proxyEnable : RegistryResult option
}
type LapsSettings = {
lapsAdminAccountName : RegistryResult option
lapsPasswordComplexity : RegistryResult option
lapsPasswordLength : RegistryResult option
lapsPasswdProtection : RegistryResult option
}
type LSASettings = {
lsaPid : RegistryResult option
notificationPkgs : RegistryResult option
authorizationPkgs : RegistryResult option
prodType : RegistryResult option
limitBlankPwd : RegistryResult option
secureboot : RegistryResult option
disdomcreds : RegistryResult option
everyoneAnon : RegistryResult option
forceGuest: RegistryResult option
restrictAnon : RegistryResult option
restrictSAM : RegistryResult option
samConnAccnt : RegistryResult option
}
type PuttySSHSession = {
hostname : RegistryResult option
username : RegistryResult option
publicKeyFile : RegistryResult option
portForwardings : RegistryResult option
connectionSharing : RegistryResult option
}
type PuttyHostPublicKeys = {
recentHostKeys : RegistryResult option
}
type PowerShellEnv = {
poshVersion2 : RegistryResult option
poshVersion5 : RegistryResult option
poshTLog : RegistryResult option list
poshMLog : RegistryResult option list
poshSLog : RegistryResult option list
}
type RDPSavedConnection = {
host : string
usernameHint : RegistryResult option
}
type RecentCommand = {
recentCommand : RegistryResult option
}
type SysmonConfig = {
hashingAlgorithm : RegistryResult option
options : RegistryResult option
rules : RegistryResult option
}
type UACPolicies = {
//Will need to do some logic with these values to print restiction
//information at export.
consentPromptBehavior : RegistryResult option
enableLUA : RegistryResult option
localAccountTokenFilterPolicy : RegistryResult option
filterAdministratorToken : RegistryResult option
}
type WEFSettings = {
//Potentially huge keyspace makes anything more specific untenable
policies : RegistryResult option list
}
type FettersRegistryRecord =
|AuditSettings of AuditSettings
|AutoLogonSettings of AutoLogonSettings
|AutorunSetting of AutorunSetting
|HistoryIE of HistoryIE
|InternetSettings of InternetSettings
|LapsSettings of LapsSettings
|LSASettings of LSASettings
|PuttyHostPublicKeys of PuttyHostPublicKeys
|PuttySSHSession of PuttySSHSession
|PowerShellEnv of PowerShellEnv
|RDPSavedConnection of RDPSavedConnection
|RecentCommand of RecentCommand
|SysmonConfig of SysmonConfig
|UACPolicies of UACPolicies
|WEFSettings of WEFSettings
//////////////////////////////
//Filesystem Enumeration Types
//////////////////////////////
type AWSCredential = {
path : string
encodedFile : string
}
type AzureCredential = {
path : string
encodedFile : string
}
type ChromeBookmark = {
name : string
url : string
}
type ChromeHistory = {
path : string
url : string list //comes from filesystem, not registry
}
type ChromeInfo = {
bookmarks : ChromeBookmark list
history : ChromeHistory
}
type DPAPIMasterKey = {
userSID : string
encodedBlob : string
}
type DPAPICredFile = {
path : string
description : string
encodedBlob : string
}
type FirefoxHistory = {
path : string
url : string list
}
type FirefoxInfo = {
history : FirefoxHistory list
}
type GoogleCredential = {
path : string
encodedFile : string
}
type Credential =
|AWSCredential of AWSCredential
|AzureCredential of AzureCredential
|DPAPIMasterKey of DPAPIMasterKey
|DPAPICredFile of DPAPICredFile
|GoogleCredential of GoogleCredential
type FettersFilesystemRecord =
|Credential of Credential
|FirefoxInfo of FirefoxInfo
|ChromeInfo of ChromeInfo
///////////////
//Special Types
///////////////
type CurrentSession = {
username : string
cwd : string
isHighIntegrity : bool
isLocalAdmin : bool
}
type EnvironmentVar = {
environmentKey : string
environmentVal : string
}
type Event4624 = {
eventId : uint16
timeStamp : string
subjectSID : string
subjectUsername : string
subjectDomainname : string
subjectLogonId : string
targetUserSID : string
targetUsername : string
targetDomainname : string
logonType : string
workstationName : string
processName : string
ipAddress : string
}
type Event4648 = {
eventId : uint16
timeStamp : string
subjectSID : string
subjectUsername : string
subjectDomainname : string
subjectLogonId: string
targetUsername : string
targetDomainname : string
targetServername : string
processName : string
ipAddress : string
}
type FirewallRule = {
name : string
description: string
protocol : string
applicationName: string
localAddresses : string
localPorts : string
remoteAddresses : string
remotePorts : string
direction : string
profiles : string
}
type Firewall = {
profile : string
rules : FirewallRule list
}
type Interface = {
adapterIndex : uint16
adapterAddr : IPAddress
adapterMAC : string
gatewayAddr : IPAddress
dnsServers : IPAddress list
dhcpServers : IPAddress list
//arpTable : ArpTable Later
}
type Network = {
interfaces : Interface list
}
type PC = {
hostname : string
processorCount : int
}
type ServiceBinaryPath =
|Unquoted_Path
|Quoted_Path
type WindowsDetails = {
productName: RegistryResult option
releaseId : RegistryResult option
currentBuild: RegistryResult option
arch : string
buildBranch : RegistryResult option
currentSession : CurrentSession
}
type FettersSpecialRecord =
|EnvironmentVar of EnvironmentVar
|Event4624 of Event4624
|Event4648 of Event4648
|Firewall of Firewall
|Network of Network
|PC of PC
|WindowsDetails of WindowsDetails
///////////
//WMI Types
///////////
type AntiVirus = {
engine : string
productExe : string
reportingExe : string
}
type Disk = {
name : string
size: string
filesystem : string
}
type InterestingProcess = {
reason : string
description : string}
type LocalGroup = {
name : string
sid : string
members : string list
}
type MappedDrive = {
connectionState : string
localName : string
persistent : string
remoteName : string
remotePath : string
userName : string
}
type Patch = {
description : string
hotfixId : string
installedOn : string}
type Process = {
processName : string
pid : string
processBinpath : string
processInvocation : string
processOwner : string
//InterestingProcess : InterestingProcess option
}
type Service = {
serviceName : string
serviceDisplayname : string
serviceCompany : string
serviceDescription : string
serviceRunning : string
serviceStarttype : string
serviceIsdotnet : bool
serviceBinpath : string
}
type Share = {
shareName : string
shareDesc : string
sharePath : string
}
type User = {
name : string
domain : string
sid: string
}
//type LogonSession = {
// name : string
// logonId : string
// logonType : string
// authPkg : string
// }
type WmiQueryType = {
wmiSqlQuery: string
wmiFilterList: string list
}
type WmiRawResult = {
rawListofList : string list list
}
type WmiSemaphore =
|SAV
|SDisk
|SGroup
|SMappedDrive
|SNetworkShare
|SPatches
|SProcess
|SService
|SUser
//|SLogonSession
type WmiRecord =
|AV of AntiVirus
|Disk of Disk
|Group of LocalGroup
|MappedDrive of MappedDrive
|Service of Service
|NetworkShare of Share
|Patch of Patch
|Process of Process
|User of User
//|LogonSession of LogonSession
///////////////
//Program Types
///////////////
type RegHive =
|HKEY_LOCAL_MACHINE
|HKEY_CURRENT_USER
|HKEY_USER
type CColor =
|Red
|Yellow
|Green
|Blue
type Glyph =
|Asterisk
|Plus
|Minus
|At
|Bang
|Octothorpe
type initRecord = {
sysRoot : string
luserFolders : string array
localAdmin : bool
highIntegrity : bool
now : DateTime
windowWeek : DateTime
}
type ProgramArguments = {
terseHelp : bool
fullHelp : bool
functionGroup : string list
}
type FettersRecords =
|FettersFilesystemRecord of FettersFilesystemRecord
|FettersPInvokeRecord of FettersPInvokeRecord
|FettersRegistryRecord of FettersRegistryRecord
|FettersSpecialRecord of FettersSpecialRecord
|WmiRecord of WmiRecord