Skip to content

Commit d061d8c

Browse files
authored
Gfs/#15 (#148)
* More filters. Some minor fixes to registry filter load behavior. * Remove extraneous log statement.
1 parent 7d8b5be commit d061d8c

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-16
lines changed

Cli/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@
364364
<value>Collectors</value>
365365
</data>
366366
<data name="Err_AccessControl" xml:space="preserve">
367-
<value>Could not get file permissions</value>
367+
<value>Could not get file permissions for: {0}</value>
368368
</data>
369369
<data name="Err_FiltersFile" xml:space="preserve">
370370
<value>Json error parsing your filters.json file.</value>

Lib/Collectors/Certificates/CertificateCollector.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class CertificateCollector : BaseCollector
3131

3232
public CertificateCollector(string runId)
3333
{
34-
Log.Debug("Initializing a new {0} object.", this.GetType().Name);
3534
this.runId = runId;
3635
}
3736

Lib/Collectors/FileSystem/FileSystemCollector.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public void Write(FileSystemObject obj)
130130

131131
public FileSystemCollector(string runId, bool enableHashing = false, string directories = "")
132132
{
133-
Log.Debug("Initializing a new {0} object.", this.GetType().Name);
134133
this.runId = runId;
135134
this.roots = new HashSet<string>();
136135
INCLUDE_CONTENT_HASH = enableHashing;

Lib/Collectors/FileSystem/WindowsFileSystemUtils.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ protected internal static string GetFilePermissions(FileSystemInfo fileInfo)
2525
{
2626
fileSecurity = new FileSecurity(filename, AccessControlSections.All);
2727
}
28-
catch (Exception ex)
28+
catch (UnauthorizedAccessException)
2929
{
30-
Log.Debug("{0} {1}: {2}", Strings.Get("Err_AccessControl"),fileInfo.FullName, ex.Message);
30+
Log.Verbose(Strings.Get("Err_AccessControl"), fileInfo.FullName);
3131
//Log.Debug(ex.StackTrace);
3232
}
3333
}
@@ -37,9 +37,9 @@ protected internal static string GetFilePermissions(FileSystemInfo fileInfo)
3737
{
3838
fileSecurity = new DirectorySecurity(filename, AccessControlSections.All);
3939
}
40-
catch (Exception ex)
40+
catch (UnauthorizedAccessException)
4141
{
42-
Log.Debug("{0} {1}: {2}", Strings.Get("Err_AccessControl"), fileInfo.FullName, ex.Message);
42+
Log.Verbose(Strings.Get("Err_AccessControl"), fileInfo.FullName);
4343
//Log.Debug(ex.StackTrace);
4444

4545
}
@@ -51,7 +51,7 @@ protected internal static string GetFilePermissions(FileSystemInfo fileInfo)
5151
if (fileSecurity != null)
5252
return fileSecurity.GetSecurityDescriptorSddlForm(AccessControlSections.All);
5353
else
54-
return null;
54+
return "";
5555
}
5656
}
5757
}

Lib/Collectors/Registry/RegistryCollector.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ public override void Execute()
111111
{
112112
Start();
113113

114-
Log.Information(JsonConvert.SerializeObject(DefaultHives));
115-
116114
if (!this.CanRunOnPlatform())
117115
{
118116
return;
@@ -133,6 +131,7 @@ public override void Execute()
133131
return;
134132
}
135133

134+
Filter.IsFiltered(Helpers.RuntimeString(), "Scan", "Registry", "Key", "Exclude", hive.ToString());
136135
var registryInfoEnumerable = RegistryWalker.WalkHive(hive);
137136
try
138137
{

Lib/Utils/DirectoryWalker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static IEnumerable<FileSystemInfo> WalkDirectory(string root)
122122
// Future improvement: log it as a symlink in the data
123123
if (fileInfo.Attributes.HasFlag(FileAttributes.ReparsePoint))
124124
{
125-
Log.Debug("Skipping symlink {0}", str);
125+
Log.Verbose("Skipping symlink {0}", str);
126126
continue;
127127
}
128128
}

Lib/Utils/Filter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ public static bool IsFiltered(string Platform, string ScanType, string ItemType,
5151
try
5252
{
5353
JArray jFilters = (JArray)config[Platform][ScanType][ItemType][Property][FilterType];
54-
Log.Debug(jFilters.ToString());
5554
foreach (var filter in jFilters)
5655
{
57-
Log.Debug(filter.ToString());
5856
try
5957
{
6058
filters.Add(new Regex(filter.ToString()));
@@ -120,7 +118,7 @@ public static bool IsFiltered(string Platform, string ScanType, string ItemType,
120118
if (filter.IsMatch(Target))
121119
{
122120
regex = filter;
123-
Log.Debug("{0} caught {1}", filter, Target);
121+
Log.Verbose("{0} caught {1}", filter, Target);
124122
return true;
125123
}
126124
}

filters.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@
2828
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\ControlSet001\\\\Services\\\\mpssvc\\\\Parameterss",
2929
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\ControlSet001\\\\Services\\\\PolicyAgent\\\\Parameters",
3030
"^HKEY_CURRENT_USER\\\\System\\\\CurrentControlSet\\\\Control\\\\DeviceContainers\\\\",
31-
"^HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\WOW6432Node\\\\Microsoft\\\\EAPSIMMethods"
31+
"^HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\WOW6432Node\\\\Microsoft\\\\EAPSIMMethods",
32+
"^HKEY_LOCAL_MACHINE\\\\SECURITY",
33+
"^HKEY_LOCAL_MACHINE\\\\SAM",
34+
"^HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\EAPSIMMethods",
35+
"^HKEY_USERS\\\\S-[0-9-]*\\\\System\\\\CurrentControlSet\\\\Control\\\\DeviceContainers",
36+
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\ControlSet001\\\\Services\\\\ADOVMPPackage",
37+
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\ControlSet001\\\\Services\\\\BTHPORT\\\\Parameters",
38+
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\ControlSet001\\\\Services\\\\mpssvc\\\\Parameters",
39+
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\ADOVMPPackage",
40+
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\BTHPORT\\\\Parameters",
41+
"^HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\PolicyAgent\\\\Parameters"
3242
]
3343
},
3444
"Hive": {
@@ -67,7 +77,9 @@
6777
"^[A-Z]:\\\\Windows\\\\Temp\\\\MpCmdRun.log$",
6878
"^[A-Z]:\\\\Windows\\\\Temp\\\\MpSigStub.log$",
6979
"^[A-Z]:\\\\Windows\\\\System32\\\\LogFiles\\\\WMI\\\\LwtNetLog.etl$",
70-
"^[A-Z]:\\\\ProgramData\\\\Microsoft\\\\Windows Defender\\\\Support\\\\MpWppTracing$"
80+
"^[A-Z]:\\\\ProgramData\\\\Microsoft\\\\Windows Defender\\\\Support\\\\MpWppTracing$",
81+
"^[A-Z]:\\\\Windows\\\\CCM\\\\ScriptStore",
82+
"^[A-Z]:\\\\ProgramData\\\\Microsoft\\\\Windows\\\\Containers\\\\BaseImages\\\\.*?\\\\Files\\\\System Volume Information"
7183
]
7284
}
7385
}

0 commit comments

Comments
 (0)