try fix long path error
This commit is contained in:
parent
940b4bc791
commit
f86e301a1b
@ -35,6 +35,8 @@ namespace winPEAS.Checks
|
|||||||
public static string PaintActiveUsersNoAdministrator = "";
|
public static string PaintActiveUsersNoAdministrator = "";
|
||||||
public static string PaintDisabledUsers = "";
|
public static string PaintDisabledUsers = "";
|
||||||
public static string PaintDisabledUsersNoAdministrator = "";
|
public static string PaintDisabledUsersNoAdministrator = "";
|
||||||
|
public static bool is_long_path = false;
|
||||||
|
public static bool warning_is_long_path = false;
|
||||||
//static string paint_lockoutUsers = "";
|
//static string paint_lockoutUsers = "";
|
||||||
public static string PaintAdminUsers = "";
|
public static string PaintAdminUsers = "";
|
||||||
public static YamlConfig YamlConfig;
|
public static YamlConfig YamlConfig;
|
||||||
@ -206,6 +208,8 @@ namespace winPEAS.Checks
|
|||||||
CheckRegANSI();
|
CheckRegANSI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckLongPath();
|
||||||
|
|
||||||
Beaprint.PrintInit();
|
Beaprint.PrintInit();
|
||||||
|
|
||||||
CheckRunner.Run(CreateDynamicLists, IsDebug);
|
CheckRunner.Run(CreateDynamicLists, IsDebug);
|
||||||
@ -404,6 +408,24 @@ namespace winPEAS.Checks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CheckLongPath()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (RegistryHelper.GetRegValue("HKLM", @"SYSTEM\CurrentControlSet\Control\FileSystem", "LongPathsEnabled") != "1")
|
||||||
|
{
|
||||||
|
System.Console.WriteLine(@"Long paths are disabled, so the maximum length of a path supported is 260chars(this may cause false negatives when looking for files). If you are admin, you can enable it with 'REG ADD HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v VirtualTerminalLevel /t REG_DWORD /d 1' and then start a new CMD");
|
||||||
|
is_long_path = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
is_long_path = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Beaprint.GrayPrint("Error while checking LongPathsEnabled registry: " + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void WaitInput()
|
private static void WaitInput()
|
||||||
{
|
{
|
||||||
Console.Write("\n -- Press a key to continue... ");
|
Console.Write("\n -- Press a key to continue... ");
|
||||||
|
@ -213,6 +213,15 @@ namespace winPEAS.Helpers
|
|||||||
Console.WriteLine(DGRAY + to_print + NOCOLOR);
|
Console.WriteLine(DGRAY + to_print + NOCOLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LongPathWarning(string path)
|
||||||
|
{
|
||||||
|
if (!Checks.Checks.warning_is_long_path)
|
||||||
|
{
|
||||||
|
GrayPrint($"The path {path} is too large, try to enable LongPathsin th registry (no more warning about this will be shown)");
|
||||||
|
Checks.Checks.warning_is_long_path = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static void PrintDebugLine(string log)
|
internal static void PrintDebugLine(string log)
|
||||||
{
|
{
|
||||||
Console.WriteLine(YELLOW + " [Debug] " + log + NOCOLOR);
|
Console.WriteLine(YELLOW + " [Debug] " + log + NOCOLOR);
|
||||||
|
@ -76,7 +76,7 @@ namespace winPEAS.Helpers.Search
|
|||||||
if (!StaticExtensions.Contains(f.Extension.ToLower()))
|
if (!StaticExtensions.Contains(f.Extension.ToLower()))
|
||||||
{
|
{
|
||||||
// It should always be lesss than 260, but some times it isn't so this will bypass that file
|
// It should always be lesss than 260, but some times it isn't so this will bypass that file
|
||||||
if (f.FullName.Length <= 260)
|
if (Checks.Checks.is_long_path || f.FullName.Length <= 260)
|
||||||
{
|
{
|
||||||
CustomFileInfo file_info = new CustomFileInfo(f.Name, f.Extension, f.FullName, f.Length, false);
|
CustomFileInfo file_info = new CustomFileInfo(f.Name, f.Extension, f.FullName, f.Length, false);
|
||||||
files.Add(file_info);
|
files.Add(file_info);
|
||||||
@ -88,6 +88,8 @@ namespace winPEAS.Helpers.Search
|
|||||||
files.Add(file_dir);
|
files.Add(file_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (f.FullName.Length > 260)
|
||||||
|
Beaprint.LongPathWarning(f.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) ;
|
) ;
|
||||||
@ -169,14 +171,24 @@ namespace winPEAS.Helpers.Search
|
|||||||
{
|
{
|
||||||
foreach (var directory in directories)
|
foreach (var directory in directories)
|
||||||
{
|
{
|
||||||
|
if (Checks.Checks.is_long_path || directory.FullName.Length <= 260)
|
||||||
files.Add(new CustomFileInfo(directory.Name, null, directory.FullName, 0, true));
|
files.Add(new CustomFileInfo(directory.Name, null, directory.FullName, 0, true));
|
||||||
|
|
||||||
|
else if (directory.FullName.Length > 260)
|
||||||
|
Beaprint.LongPathWarning(directory.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var f in dirInfo.GetFiles(pattern))
|
foreach (var f in dirInfo.GetFiles(pattern))
|
||||||
{
|
{
|
||||||
if (!StaticExtensions.Contains(f.Extension.ToLower()))
|
if (!StaticExtensions.Contains(f.Extension.ToLower()))
|
||||||
|
{
|
||||||
|
if (Checks.Checks.is_long_path || f.FullName.Length <= 260)
|
||||||
files.Add(new CustomFileInfo(f.Name, f.Extension, f.FullName, f.Length, false));
|
files.Add(new CustomFileInfo(f.Name, f.Extension, f.FullName, f.Length, false));
|
||||||
|
|
||||||
|
else if (f.FullName.Length > 260)
|
||||||
|
Beaprint.LongPathWarning(f.FullName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (directories.Length > 1) return new List<DirectoryInfo>(directories);
|
if (directories.Length > 1) return new List<DirectoryInfo>(directories);
|
||||||
|
Loading…
Reference in New Issue
Block a user