mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-09-22 14:54:56 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f83dbee1b1 | ||
|
|
d44873b37b | ||
|
|
bbe12c5358 | ||
|
|
9f49f910ea | ||
|
|
9403a338bb | ||
|
|
6b19685108 | ||
|
|
9d03ea57aa | ||
|
|
0672f0c6e1 | ||
|
|
080f4327bf | ||
|
|
521797b7b1 |
@@ -16,10 +16,10 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
|
||||||
<PackageReference Include="SabreTools.Serialization" Version="[3.0.1]" />
|
<PackageReference Include="SabreTools.Serialization" Version="3.2.0" />
|
||||||
<PackageReference Include="xunit" Version="2.9.3" />
|
<PackageReference Include="xunit" Version="2.9.3" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<Version>3.7.1</Version>
|
<Version>3.9.0</Version>
|
||||||
<WarningsNotAsErrors>NU5104</WarningsNotAsErrors>
|
<WarningsNotAsErrors>NU5104</WarningsNotAsErrors>
|
||||||
|
|
||||||
<!-- Package Properties -->
|
<!-- Package Properties -->
|
||||||
<Authors>Matt Nadareski</Authors>
|
<Authors>Matt Nadareski</Authors>
|
||||||
<Description>Protection scanning library</Description>
|
<Description>Protection scanning library</Description>
|
||||||
<Copyright>Copyright (c)2018-2025 Matt Nadareski</Copyright>
|
<Copyright>Copyright (c)2018-2026 Matt Nadareski</Copyright>
|
||||||
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/SabreTools/BinaryObjectScanner</RepositoryUrl>
|
<RepositoryUrl>https://github.com/SabreTools/BinaryObjectScanner</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
@@ -46,12 +46,16 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GrindCore.SharpCompress" Version="0.48.0" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
|
<None Include="README.md" Pack="true" PackagePath="" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="GrindCore.SharpCompress" Version="0.50.5" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
|
||||||
<PackageReference Include="MinThreadingBridge" Version="0.11.4" Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))" />
|
<PackageReference Include="MinThreadingBridge" Version="0.11.4" Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))" />
|
||||||
<PackageReference Include="SabreTools.Hashing" Version="[2.0.0]" />
|
<PackageReference Include="SabreTools.Hashing" Version="2.1.0" />
|
||||||
<PackageReference Include="SabreTools.IO" Version="[2.1.0]" />
|
<PackageReference Include="SabreTools.IO" Version="2.3.0" />
|
||||||
<PackageReference Include="SabreTools.Serialization" Version="[3.0.1]" />
|
<PackageReference Include="SabreTools.Serialization" Version="3.2.0" />
|
||||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="10.0.9" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="10.0.11" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -46,6 +46,22 @@ namespace BinaryObjectScanner
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Static Variables
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Path to the temporary directory
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Value has trailing directory separators trimmed</remarks>
|
||||||
|
private static readonly string TempFilePath = Path.GetTempPath().TrimEnd('\\', '/');
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Template for determining if a file is a temporary extracted path
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Value has trailing directory separators trimmed and the GUID value itself does not matter</remarks>
|
||||||
|
private static readonly string TempFilePathWithGuid = Path.Combine(TempFilePath, Guid.NewGuid().ToString()).TrimEnd('\\', '/');
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -123,10 +139,6 @@ namespace BinaryObjectScanner
|
|||||||
// Checkpoint
|
// Checkpoint
|
||||||
_fileProgress?.Report(new ProtectionProgress(null, depth, 0, null));
|
_fileProgress?.Report(new ProtectionProgress(null, depth, 0, null));
|
||||||
|
|
||||||
// Temp variables for reporting
|
|
||||||
string tempFilePath = Path.GetTempPath();
|
|
||||||
string tempFilePathWithGuid = Path.Combine(tempFilePath, Guid.NewGuid().ToString());
|
|
||||||
|
|
||||||
// Loop through each path and get the returned values
|
// Loop through each path and get the returned values
|
||||||
var protections = new ProtectionDictionary();
|
var protections = new ProtectionDictionary();
|
||||||
foreach (string path in paths)
|
foreach (string path in paths)
|
||||||
@@ -152,13 +164,7 @@ namespace BinaryObjectScanner
|
|||||||
string file = files[i];
|
string file = files[i];
|
||||||
|
|
||||||
// Get the reportable file name
|
// Get the reportable file name
|
||||||
string reportableFileName = file;
|
string reportableFileName = GetReportableFileName(file);
|
||||||
if (reportableFileName.StartsWith(tempFilePath))
|
|
||||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
|
||||||
reportableFileName = reportableFileName[tempFilePathWithGuid.Length..];
|
|
||||||
#else
|
|
||||||
reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Checkpoint
|
// Checkpoint
|
||||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, i / (float)files.Count, "Checking file" + (file != reportableFileName ? " from archive" : string.Empty)));
|
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, i / (float)files.Count, "Checking file" + (file != reportableFileName ? " from archive" : string.Empty)));
|
||||||
@@ -193,13 +199,7 @@ namespace BinaryObjectScanner
|
|||||||
else if (File.Exists(path))
|
else if (File.Exists(path))
|
||||||
{
|
{
|
||||||
// Get the reportable file name
|
// Get the reportable file name
|
||||||
string reportableFileName = path;
|
string reportableFileName = GetReportableFileName(path);
|
||||||
if (reportableFileName.StartsWith(tempFilePath))
|
|
||||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
|
||||||
reportableFileName = reportableFileName[tempFilePathWithGuid.Length..];
|
|
||||||
#else
|
|
||||||
reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Checkpoint
|
// Checkpoint
|
||||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, 0, "Checking file" + (path != reportableFileName ? " from archive" : string.Empty)));
|
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, 0, "Checking file" + (path != reportableFileName ? " from archive" : string.Empty)));
|
||||||
@@ -517,6 +517,44 @@ namespace BinaryObjectScanner
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the reportable file name by determining if the file was
|
||||||
|
/// likely extracted as a part of the scanning run.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">File path to check</param>
|
||||||
|
/// <returns>Trimmed file path if it should be an extracted file, the full path as passed in otherwise</returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// This will be a false positive if intentionally scanning a path that
|
||||||
|
/// fits the pattern of '%TEMP%/{GUID}/{file}'.
|
||||||
|
private static string GetReportableFileName(string path)
|
||||||
|
{
|
||||||
|
// If the file is not in the temp directory
|
||||||
|
if (!path.StartsWith(TempFilePath))
|
||||||
|
return path;
|
||||||
|
|
||||||
|
// If the filename isn't longer than the template path
|
||||||
|
if (path.Length < TempFilePathWithGuid.Length)
|
||||||
|
return path;
|
||||||
|
|
||||||
|
// Check if we're in a GUID subdirectory
|
||||||
|
string possibleGuid = path.Substring(TempFilePath.Length + 1, 36);
|
||||||
|
#if NET20 || NET35
|
||||||
|
if (System.Text.RegularExpressions.Regex.IsMatch(possibleGuid, @"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"))
|
||||||
|
#else
|
||||||
|
if (Guid.TryParse(possibleGuid, out _))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||||
|
return path[TempFilePathWithGuid.Length..];
|
||||||
|
#else
|
||||||
|
return path.Substring(TempFilePathWithGuid.Length);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, return the path as given
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2018-2025 Matt Nadareski
|
Copyright (c) 2018-2026 Matt Nadareski
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<Version>3.7.1</Version>
|
<Version>3.9.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Support All Frameworks -->
|
<!-- Support All Frameworks -->
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SabreTools.CommandLine" Version="[1.4.0]" />
|
<PackageReference Include="SabreTools.CommandLine" Version="1.5.0" />
|
||||||
<PackageReference Include="SabreTools.Serialization" Version="[3.0.1]" />
|
<PackageReference Include="SabreTools.Serialization" Version="3.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -13,7 +13,9 @@ USE_ALL=false
|
|||||||
INCLUDE_DEBUG=false
|
INCLUDE_DEBUG=false
|
||||||
NO_BUILD=false
|
NO_BUILD=false
|
||||||
NO_ARCHIVE=false
|
NO_ARCHIVE=false
|
||||||
while getopts "udba" OPTION; do
|
HAS_VERSION=false
|
||||||
|
VERSION="NONE"
|
||||||
|
while getopts "udbav:" OPTION; do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
u)
|
u)
|
||||||
USE_ALL=true
|
USE_ALL=true
|
||||||
@@ -27,6 +29,10 @@ while getopts "udba" OPTION; do
|
|||||||
a)
|
a)
|
||||||
NO_ARCHIVE=true
|
NO_ARCHIVE=true
|
||||||
;;
|
;;
|
||||||
|
v)
|
||||||
|
HAS_VERSION=true
|
||||||
|
VERSION=${OPTARG}
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid option provided"
|
echo "Invalid option provided"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -46,6 +52,7 @@ echo " Use all frameworks (-u) $USE_ALL"
|
|||||||
echo " Include debug builds (-d) $INCLUDE_DEBUG"
|
echo " Include debug builds (-d) $INCLUDE_DEBUG"
|
||||||
echo " No build (-b) $NO_BUILD"
|
echo " No build (-b) $NO_BUILD"
|
||||||
echo " No archive (-a) $NO_ARCHIVE"
|
echo " No archive (-a) $NO_ARCHIVE"
|
||||||
|
echo " Version (-v) $HAS_VERSION ($VERSION)"
|
||||||
echo " "
|
echo " "
|
||||||
|
|
||||||
# Create the build matrix arrays
|
# Create the build matrix arrays
|
||||||
@@ -139,10 +146,18 @@ if [ $NO_ARCHIVE = false ]; then
|
|||||||
# Only include Debug if set
|
# Only include Debug if set
|
||||||
if [ $INCLUDE_DEBUG = true ]; then
|
if [ $INCLUDE_DEBUG = true ]; then
|
||||||
cd $BUILD_FOLDER/ProtectionScan/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/
|
cd $BUILD_FOLDER/ProtectionScan/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/
|
||||||
zip -r $BUILD_FOLDER/ProtectionScan_${FRAMEWORK}_${RUNTIME}_debug.zip .
|
if [ $HAS_VERSION = true ]; then
|
||||||
|
zip -r $BUILD_FOLDER/ProtectionScan_${VERSION}_${FRAMEWORK}_${RUNTIME}_debug.zip .
|
||||||
|
else
|
||||||
|
zip -r $BUILD_FOLDER/ProtectionScan_${FRAMEWORK}_${RUNTIME}_debug.zip .
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
cd $BUILD_FOLDER/ProtectionScan/bin/Release/${FRAMEWORK}/${RUNTIME}/publish/
|
cd $BUILD_FOLDER/ProtectionScan/bin/Release/${FRAMEWORK}/${RUNTIME}/publish/
|
||||||
zip -r $BUILD_FOLDER/ProtectionScan_${FRAMEWORK}_${RUNTIME}_release.zip .
|
if [ $HAS_VERSION = true ]; then
|
||||||
|
zip -r $BUILD_FOLDER/ProtectionScan_${VERSION}_${FRAMEWORK}_${RUNTIME}_release.zip .
|
||||||
|
else
|
||||||
|
zip -r $BUILD_FOLDER/ProtectionScan_${FRAMEWORK}_${RUNTIME}_release.zip .
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,11 @@ param(
|
|||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[Alias("NoArchive")]
|
[Alias("NoArchive")]
|
||||||
[switch]$NO_ARCHIVE
|
[switch]$NO_ARCHIVE,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
|
||||||
|
[Alias("BuildVersion")]
|
||||||
|
[string]$BUILD_VERSION
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set the current directory as a variable
|
# Set the current directory as a variable
|
||||||
@@ -37,6 +41,7 @@ Write-Host " Use all frameworks (-UseAll) $USE_ALL"
|
|||||||
Write-Host " Include debug builds (-IncludeDebug) $INCLUDE_DEBUG"
|
Write-Host " Include debug builds (-IncludeDebug) $INCLUDE_DEBUG"
|
||||||
Write-Host " No build (-NoBuild) $NO_BUILD"
|
Write-Host " No build (-NoBuild) $NO_BUILD"
|
||||||
Write-Host " No archive (-NoArchive) $NO_ARCHIVE"
|
Write-Host " No archive (-NoArchive) $NO_ARCHIVE"
|
||||||
|
Write-Host " Version (-BuildVersion) $BUILD_VERSION"
|
||||||
Write-Host " "
|
Write-Host " "
|
||||||
|
|
||||||
# Create the build matrix arrays
|
# Create the build matrix arrays
|
||||||
@@ -123,11 +128,21 @@ if (!$NO_ARCHIVE.IsPresent) {
|
|||||||
# Only include Debug if set
|
# Only include Debug if set
|
||||||
if ($INCLUDE_DEBUG.IsPresent) {
|
if ($INCLUDE_DEBUG.IsPresent) {
|
||||||
Set-Location -Path $BUILD_FOLDER\ProtectionScan\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\
|
Set-Location -Path $BUILD_FOLDER\ProtectionScan\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\
|
||||||
7z a -tzip $BUILD_FOLDER\ProtectionScan_${FRAMEWORK}_${RUNTIME}_debug.zip *
|
if ($BUILD_VERSION -ne $null) {
|
||||||
|
7z a -tzip $BUILD_FOLDER\ProtectionScan_${BUILD_VERSION}_${FRAMEWORK}_${RUNTIME}_debug.zip *
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
7z a -tzip $BUILD_FOLDER\ProtectionScan_${FRAMEWORK}_${RUNTIME}_debug.zip *
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set-Location -Path $BUILD_FOLDER\ProtectionScan\bin\Release\${FRAMEWORK}\${RUNTIME}\publish\
|
Set-Location -Path $BUILD_FOLDER\ProtectionScan\bin\Release\${FRAMEWORK}\${RUNTIME}\publish\
|
||||||
7z a -tzip $BUILD_FOLDER\ProtectionScan_${FRAMEWORK}_${RUNTIME}_release.zip *
|
if ($BUILD_VERSION -ne $null) {
|
||||||
|
7z a -tzip $BUILD_FOLDER\ProtectionScan_${BUILD_VERSION}_${FRAMEWORK}_${RUNTIME}_release.zip *
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
7z a -tzip $BUILD_FOLDER\ProtectionScan_${FRAMEWORK}_${RUNTIME}_release.zip *
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user