Skip to content

Commit

Permalink
fixes for case sensitive linux log names, fix for finding profile nam…
Browse files Browse the repository at this point in the history
…e in compressed output names
  • Loading branch information
EricZimmerman committed Sep 4, 2024
1 parent 5cdd091 commit ae20982
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions rla/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Exceptionless;
using Exceptionless.Extensions;
Expand Down Expand Up @@ -211,6 +212,7 @@ private static void DoWork(string f, string d, string @out, bool ca, bool cn, bo
okFileParts.Add("SYSCACHE");
okFileParts.Add("SECURITY");
okFileParts.Add("DRIVERS");
okFileParts.Add("DEFAULT");
okFileParts.Add("COMPONENTS");
var directoryEnumerationFilters = new DirectoryEnumerationFilters();
directoryEnumerationFilters.InclusionFilter = fsei =>
Expand Down Expand Up @@ -357,6 +359,7 @@ private static void DoWork(string f, string d, string @out, bool ca, bool cn, bo
"SYSCACHE.hve",
"SECURITY",
"DRIVERS",
"DEFAULT",
"COMPONENTS"
};
var ignoreExt = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
Expand Down Expand Up @@ -484,7 +487,25 @@ private static void DoWork(string f, string d, string @out, bool ca, bool cn, bo
dirname = ".";
}

var logFiles = Directory.GetFiles(dirname, $"{hiveBase}.LOG?");

#if NET462
var logFiles = Directory.GetFiles(dirname, $"{hiveBase}.LOG?");
#elif NET6_0
var en = new EnumerationOptions
{
// IgnoreInaccessible = true,
MatchCasing = MatchCasing.CaseInsensitive,
// RecurseSubdirectories = true,
AttributesToSkip = 0
};

var logFiles = Directory.GetFiles(dirname, $"{hiveBase}.LOG?",en);
#endif




// var logFiles = Directory.GetFiles(dirname, $"{hiveBase}.LOG?",en);

if (logFiles.Length == 0)
{
Expand Down Expand Up @@ -558,13 +579,23 @@ private static void DoWork(string f, string d, string @out, bool ca, bool cn, bo
{
Log.Verbose("In cn && ntuser|usrclass",outFileAll);

var dl = hiveToProcess[0].ToString();
var segs = hiveToProcess.Split(Path.PathSeparator);
var profileName = "Undetermined";
var dl = "Undetermined";
try {
profileName = Regex.Match(hiveToProcess, @"(.)\\\b(.sers|.indows)\b\\(.+?)\\", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace).Groups[3].Value;
dl = Regex.Match(hiveToProcess, @"(.)\\\b(.sers|.indows)\b\\(.+?)\\", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace).Groups[1].Value;
} catch (ArgumentException ) {
// Syntax error in the regular expression
}


// var dl = hiveToProcess[0].ToString();
// var segs = hiveToProcess.Split(Path.DirectorySeparatorChar);

var profile = segs[2];

var filename = Path.GetFileName(hiveToProcess);

var outFile2 = $"{dl}_{profile}_{filename}";
var outFile2 = $"{dl}_{profileName}_{filename}";

outFileAll = Path.Combine(@out, outFile2);
}
Expand Down

0 comments on commit ae20982

Please sign in to comment.