2021-07-18 09:44:23 -07:00
|
|
|
using System.Collections.Concurrent;
|
2021-06-05 16:08:10 -06:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2022-03-14 10:40:44 -07:00
|
|
|
using BurnOutSharp.ExecutableType.Microsoft.PE;
|
2022-05-01 17:41:50 -07:00
|
|
|
using BurnOutSharp.Interfaces;
|
2021-06-05 16:08:10 -06:00
|
|
|
using BurnOutSharp.Matching;
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.PackerType
|
|
|
|
|
{
|
2022-05-01 21:02:59 -07:00
|
|
|
// TODO: Add extraction - https://github.com/Bioruebe/UniExtract2
|
2022-05-01 17:17:15 -07:00
|
|
|
public class InstallerVISE : IPortableExecutableCheck, IScannable
|
2021-06-05 16:08:10 -06:00
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public bool ShouldScan(byte[] magic) => true;
|
|
|
|
|
|
2021-08-25 20:26:43 -07:00
|
|
|
//TODO: Add exact version detection for Windows builds, make sure versions before 3.X are detected as well, and detect the Mac builds.
|
2021-08-25 19:37:32 -07:00
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2021-08-26 23:18:55 -07:00
|
|
|
{
|
|
|
|
|
// Get the sections from the executable, if possible
|
2021-08-27 09:42:05 -07:00
|
|
|
var sections = pex?.SectionTable;
|
2021-08-26 23:18:55 -07:00
|
|
|
if (sections == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
// Get the DATA/.data section, if it exists
|
2021-09-11 16:47:25 -07:00
|
|
|
if (pex.DataSectionRaw != null)
|
2021-08-26 23:18:55 -07:00
|
|
|
{
|
|
|
|
|
var matchers = new List<ContentMatchSet>
|
|
|
|
|
{
|
|
|
|
|
// ViseMain
|
2021-09-11 16:47:25 -07:00
|
|
|
new ContentMatchSet(new byte?[] { 0x56, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E }, "Installer VISE"),
|
2021-08-26 23:18:55 -07:00
|
|
|
};
|
|
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
return MatchUtil.GetFirstMatch(file, pex.DataSectionRaw, matchers, includeDebug);
|
2021-08-26 23:18:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-06-05 16:08:10 -06:00
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2021-07-18 09:44:23 -07:00
|
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, string file)
|
2021-06-05 16:08:10 -06:00
|
|
|
{
|
|
|
|
|
if (!File.Exists(file))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
using (var fs = File.OpenRead(file))
|
|
|
|
|
{
|
|
|
|
|
return Scan(scanner, fs, file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2021-07-18 09:44:23 -07:00
|
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, Stream stream, string file)
|
2021-06-05 16:08:10 -06:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|