2022-03-02 08:56:26 -08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2022-03-14 10:40:44 -07:00
|
|
|
|
using BurnOutSharp.ExecutableType.Microsoft.PE;
|
2022-05-01 17:41:50 -07:00
|
|
|
|
using BurnOutSharp.Interfaces;
|
2022-03-02 08:56:26 -08:00
|
|
|
|
using BurnOutSharp.Matching;
|
2021-03-21 14:30:37 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-09-14 22:57:17 -07:00
|
|
|
|
// CodeLock / CodeLok / CopyLok
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public class CodeLock : IContentCheck, IPortableExecutableCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-08-25 19:37:32 -07:00
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckContents(string file, byte[] fileContent, bool includeDebug)
|
2021-08-29 22:26:58 -07:00
|
|
|
|
{
|
2022-03-02 08:56:26 -08:00
|
|
|
|
// TODO: Obtain a sample to find where this string is in a typical executable
|
|
|
|
|
|
if (includeDebug)
|
|
|
|
|
|
{
|
|
|
|
|
|
var contentMatchSets = new List<ContentMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
// CODE-LOCK.OCX
|
|
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x43, 0x4F, 0x44, 0x45, 0x2D, 0x4C, 0x4F, 0x43,
|
|
|
|
|
|
0x4B, 0x2E, 0x4F, 0x43, 0x58
|
|
|
|
|
|
}, "CodeLock / CodeLok / CopyLok"),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return MatchUtil.GetFirstMatch(file, fileContent, contentMatchSets, includeDebug);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-14 22:57:17 -07:00
|
|
|
|
return null;
|
2021-08-29 22:26:58 -07:00
|
|
|
|
}
|
2022-03-14 11:20:11 -07:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2022-03-14 11:20:11 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
// If there are more than 2 icd-prefixed sections, then we have a match
|
|
|
|
|
|
int icdSectionCount = pex.GetSectionNames().Count(s => s.StartsWith("icd"));
|
|
|
|
|
|
if (icdSectionCount >= 2)
|
|
|
|
|
|
return "CodeLock / CodeLok / CopyLok";
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|