Files
BinaryObjectScanner/BurnOutSharp/PackerType/NSIS.cs

54 lines
1.8 KiB
C#
Raw Normal View History

2022-05-01 21:02:59 -07:00
using System.Collections.Concurrent;
2021-03-21 15:24:23 -07:00
using System.Collections.Generic;
2022-05-01 21:02:59 -07:00
using System.IO;
2022-12-09 15:18:17 -08:00
using System.Linq;
2022-05-01 17:41:50 -07:00
using BurnOutSharp.Interfaces;
using BurnOutSharp.Wrappers;
2020-10-30 09:56:34 -06:00
2020-10-30 09:09:16 -07:00
namespace BurnOutSharp.PackerType
2020-10-30 09:56:34 -06:00
{
2022-05-01 21:02:59 -07:00
// TODO: Add extraction
public class NSIS : IPortableExecutableCheck, IScannable
2020-10-30 09:56:34 -06:00
{
/// <inheritdoc/>
2022-05-01 17:17:15 -07:00
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
2021-08-27 13:30:24 -07:00
{
2021-08-30 11:40:14 -07:00
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
if (sections == null)
return null;
string description = pex.AssemblyDescription;
2021-09-10 21:45:14 -07:00
if (!string.IsNullOrWhiteSpace(description) && description.StartsWith("Nullsoft Install System"))
return $"NSIS {description.Substring("Nullsoft Install System".Length).Trim()}";
2021-08-30 11:40:14 -07:00
2022-12-09 15:18:17 -08:00
// Get the .data/DATA section strings, if they exist
List<string> strs = pex.GetFirstSectionStrings(".data") ?? pex.GetFirstSectionStrings("DATA");
if (strs != null)
2021-08-30 11:40:14 -07:00
{
2022-12-09 15:18:17 -08:00
if (strs.Any(s => s.Contains("NullsoftInst")))
return "NSIS";
2021-08-30 11:40:14 -07:00
}
2021-08-27 13:30:24 -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;
2022-12-22 22:03:32 -08:00
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
2022-05-01 21:02:59 -07:00
{
return Scan(scanner, fs, file);
}
}
/// <inheritdoc/>
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, Stream stream, string file)
{
return null;
}
2020-10-30 09:56:34 -06:00
}
}