2023-03-09 16:02:51 -05:00
|
|
|
|
using System.IO;
|
2023-03-09 11:52:28 -05:00
|
|
|
|
using BinaryObjectScanner.Interfaces;
|
2023-03-07 16:59:14 -05:00
|
|
|
|
using BinaryObjectScanner.Wrappers;
|
2021-09-23 13:43:57 -07:00
|
|
|
|
|
2023-03-09 23:52:58 -05:00
|
|
|
|
namespace BinaryObjectScanner.Packer
|
2020-10-29 10:05:56 -07:00
|
|
|
|
{
|
2022-05-01 21:02:59 -07:00
|
|
|
|
// TODO: Add extraction
|
2022-07-13 12:52:41 -07:00
|
|
|
|
// https://raw.githubusercontent.com/wolfram77web/app-peid/master/userdb.txt
|
2023-03-09 16:02:51 -05:00
|
|
|
|
public class PEtite : IExtractable, IPortableExecutableCheck
|
2020-10-29 10:05:56 -07:00
|
|
|
|
{
|
2021-09-23 13:43:57 -07:00
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2021-09-23 13:43:57 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
// Get the .petite section, if it exists -- TODO: Is there a version number that can be found?
|
2022-12-05 10:47:17 -08:00
|
|
|
|
bool petiteSection = pex.ContainsSection(".petite", exact: true);
|
|
|
|
|
|
if (petiteSection)
|
2021-09-23 13:43:57 -07:00
|
|
|
|
return "PEtite";
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2022-05-01 21:02:59 -07:00
|
|
|
|
|
2023-03-09 15:33:21 -05:00
|
|
|
|
/// <inheritdoc/>
|
2023-03-09 17:16:39 -05:00
|
|
|
|
public string Extract(string file, bool includeDebug)
|
2023-03-09 15:33:21 -05:00
|
|
|
|
{
|
|
|
|
|
|
if (!File.Exists(file))
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
|
|
|
|
|
{
|
2023-03-09 17:16:39 -05:00
|
|
|
|
return Extract(fs, file, includeDebug);
|
2023-03-09 15:33:21 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2023-03-09 17:16:39 -05:00
|
|
|
|
public string Extract(Stream stream, string file, bool includeDebug)
|
2023-03-09 15:33:21 -05:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2020-10-29 10:05:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|