2022-05-01 21:02:59 -07:00
|
|
|
using System.Collections.Concurrent;
|
2021-03-21 22:45:06 -07:00
|
|
|
using System.Collections.Generic;
|
2022-05-01 21:02:59 -07:00
|
|
|
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-03-21 22:45:06 -07:00
|
|
|
using BurnOutSharp.Matching;
|
2021-03-21 23:36:01 -06:00
|
|
|
|
|
|
|
|
namespace BurnOutSharp.PackerType
|
|
|
|
|
{
|
2022-05-01 21:02:59 -07:00
|
|
|
// TODO: Add extraction
|
|
|
|
|
// TODO: Verify that all versions are detected
|
|
|
|
|
public class AdvancedInstaller : IPortableExecutableCheck, IScannable
|
2021-03-21 23:36:01 -06:00
|
|
|
{
|
2022-05-01 21:02:59 -07:00
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public bool ShouldScan(byte[] magic) => true;
|
|
|
|
|
|
2021-08-26 21:57:56 -07:00
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2021-03-23 09:52:09 -07:00
|
|
|
{
|
2021-08-26 21:57:56 -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 21:57:56 -07:00
|
|
|
if (sections == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
// Get the .rdata section, if it exists
|
2021-09-11 16:47:25 -07:00
|
|
|
if (pex.ResourceDataSectionRaw != null)
|
2021-07-17 23:40:16 -07:00
|
|
|
{
|
2021-08-26 21:57:56 -07:00
|
|
|
var matchers = new List<ContentMatchSet>
|
2021-07-17 23:40:16 -07:00
|
|
|
{
|
2021-08-26 21:57:56 -07:00
|
|
|
// Software\Caphyon\Advanced Installer
|
2021-09-11 16:47:25 -07:00
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
{
|
|
|
|
|
0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
|
|
|
|
|
0x5C, 0x43, 0x61, 0x70, 0x68, 0x79, 0x6F, 0x6E,
|
|
|
|
|
0x5C, 0x41, 0x64, 0x76, 0x61, 0x6E, 0x63, 0x65,
|
|
|
|
|
0x64, 0x20, 0x49, 0x6E, 0x73, 0x74, 0x61, 0x6C,
|
|
|
|
|
0x6C, 0x65, 0x72
|
|
|
|
|
}, "Caphyon Advanced Installer"),
|
2021-08-26 21:57:56 -07:00
|
|
|
};
|
2021-07-17 23:40:16 -07:00
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
return MatchUtil.GetFirstMatch(file, pex.ResourceDataSectionRaw, matchers, includeDebug);
|
2021-08-26 21:57:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-05-01 21:02:59 -07:00
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, string file)
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(file))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
using (var fs = File.OpenRead(file))
|
|
|
|
|
{
|
|
|
|
|
return Scan(scanner, fs, file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, Stream stream, string file)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-03-21 23:36:01 -06:00
|
|
|
}
|
|
|
|
|
}
|