Skip to content

Commit e12c9cb

Browse files
authored
Switch to using ^ instead of , separated paths. (#473)
There seems to be a Windows 8 specific issue with CommandOptions that doesn't pass through comma separated values.
1 parent 62475fa commit e12c9cb

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Lib/Collectors/FileSystemCollector.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Security.Principal;
2121
using System.Threading.Tasks;
2222
using Microsoft.CST.OpenSource.MultiExtractor;
23+
using Newtonsoft.Json;
2324

2425
namespace AttackSurfaceAnalyzer.Collectors
2526
{
@@ -28,7 +29,7 @@ namespace AttackSurfaceAnalyzer.Collectors
2829
/// </summary>
2930
public class FileSystemCollector : BaseCollector
3031
{
31-
public HashSet<string> Roots { get; } = new HashSet<string>();
32+
public List<string> Roots { get; } = new List<string>();
3233

3334
private readonly Dictionary<string, long> sizesOnDisk = new Dictionary<string, long>();
3435

@@ -45,10 +46,7 @@ public override void ExecuteInternal()
4546
{
4647
if (!string.IsNullOrEmpty(opts.SelectedDirectories))
4748
{
48-
foreach (string path in opts.SelectedDirectories.Split(','))
49-
{
50-
Roots.Add(path);
51-
}
49+
Roots.AddRange(opts.SelectedDirectories.Split('^'));
5250
}
5351

5452
if (!Roots.Any())
@@ -151,18 +149,18 @@ void TryIterateOnDirectory(string Path)
151149
Log.Verbose("Finished parsing {0}", Path);
152150
}
153151

154-
foreach (var root in Roots)
152+
foreach (var Root in Roots)
155153
{
156-
Log.Information("{0} root {1}", Strings.Get("Scanning"), root);
157-
var directories = Directory.EnumerateDirectories(root, "*", new System.IO.EnumerationOptions()
154+
Log.Information("{0} root {1}", Strings.Get("Scanning"), Root);
155+
var directories = Directory.EnumerateDirectories(Root, "*", new System.IO.EnumerationOptions()
158156
{
159157
ReturnSpecialDirectories = false,
160158
IgnoreInaccessible = true,
161159
RecurseSubdirectories = true
162160
});
163161

164162
//First do root
165-
TryIterateOnDirectory(root);
163+
TryIterateOnDirectory(Root);
166164

167165
if (!opts.SingleThread == true)
168166
{

Lib/Collectors/RegistryCollector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public RegistryCollector(CollectCommandOptions? opts = null, Action<CollectObjec
3636
if (opts.SelectedHives is string hiveString)
3737
{
3838
Hives = new List<(RegistryHive, string)>();
39-
var splits = hiveString.Split(',');
39+
var splits = hiveString.Split('^');
4040
foreach (var split in splits)
4141
{
4242
var innerSplit = split.Split('\\');

Lib/Objects/CommandOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ public class CollectCommandOptions : CommandOptions
128128
[Option("crawl-archives", Required = false, HelpText = "Attempts to crawl every archive file encountered when using File Collector. May dramatically increase run time of the scan.")]
129129
public bool CrawlArchives { get; set; }
130130

131-
[Option("directories", Required = false, HelpText = "Comma separated list of paths to scan with FileSystemCollector")]
131+
[Option("directories", Required = false, HelpText = "^ separated list of paths to scan with FileSystemCollector")]
132132
public string? SelectedDirectories { get; set; }
133133

134-
[Option("hives", Required = false, HelpText = "Comma separated list of hives and subkeys to search.")]
134+
[Option("hives", Required = false, HelpText = "^ separated list of hives and subkeys to search.")]
135135
public string? SelectedHives { get; set; }
136136

137137
[Option(HelpText = "Download files from thin Cloud Folders (like OneDrive) to check them.")]

0 commit comments

Comments
 (0)