2021-07-18 09:44:23 -07:00
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
2022-12-19 21:39:24 -08:00
|
|
|
|
using System.Linq;
|
2023-03-09 11:52:28 -05:00
|
|
|
|
using BinaryObjectScanner.Interfaces;
|
2023-03-07 16:59:14 -05:00
|
|
|
|
using BinaryObjectScanner.Matching;
|
|
|
|
|
|
using BinaryObjectScanner.Wrappers;
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2023-03-09 23:19:27 -05:00
|
|
|
|
namespace BinaryObjectScanner.Protection
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2022-12-19 21:39:24 -08:00
|
|
|
|
/// <see href="https://zhidao.baidu.com/question/211454017.html"/>
|
|
|
|
|
|
/// <see href="https://bbs.pediy.com/thread-62414-3.htm"/>
|
|
|
|
|
|
/// <see href="https://bbs.pediy.com/thread-141554.htm"/>
|
|
|
|
|
|
/// <see href="https://forum.arabhardware.net/showthread.php?t=45360"/>
|
|
|
|
|
|
/// <see href="https://forum.arabhardware.net/showthread.php?t=45360&p=304085"/>
|
|
|
|
|
|
public class SoftLock : IPortableExecutableCheck, IPathCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2022-12-19 21:39:24 -08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
string name = pex.InternalName;
|
|
|
|
|
|
if (name?.Equals("Softlock Protected Application") == true)
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
name = pex.Comments;
|
|
|
|
|
|
if (name?.Equals("Softlock Protected Application") == true)
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
var stMatch = pex.FindStringTableByEntry("Softlock CD");
|
|
|
|
|
|
if (stMatch.Any())
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
stMatch = pex.FindStringTableByEntry("Softlock USB Key");
|
|
|
|
|
|
if (stMatch.Any())
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
var dbMatch = pex.FindDialogByTitle("Softlock Protection Kit");
|
|
|
|
|
|
if (dbMatch.Any())
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
dbMatch = pex.FindDialogByTitle("About Softlock Protected Application");
|
|
|
|
|
|
if (dbMatch.Any())
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
dbMatch = pex.FindDialogBoxByItemTitle("www.softlock.net");
|
|
|
|
|
|
if (dbMatch.Any())
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: See if the version number is anywhere else
|
2022-12-19 23:49:34 -08:00
|
|
|
|
// TODO: Parse the version number out of the dialog box item
|
2022-12-19 21:39:24 -08:00
|
|
|
|
// Found in "IALib.DLL" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
dbMatch = pex.FindDialogBoxByItemTitle("Softlock Protected Application Version 1.0");
|
|
|
|
|
|
if (dbMatch.Any())
|
|
|
|
|
|
return "SoftLock";
|
|
|
|
|
|
|
|
|
|
|
|
// There are many mentions of USB dongle and CD protection in the various string tables
|
|
|
|
|
|
// and dialog boxes. See if any of those are unique to SoftLock.
|
|
|
|
|
|
|
|
|
|
|
|
// Get strings from .section, if possible
|
|
|
|
|
|
var strings = pex.GetFirstSectionStrings(".section");
|
|
|
|
|
|
if (strings != null && strings.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
// Found in "TafseerVer4.exe" in IA item "TAFSEERVER4SETUP"
|
|
|
|
|
|
if (strings.Any(s => s?.Contains("SOFTLOCKPROTECTION") == true))
|
|
|
|
|
|
return "SoftLock";
|
2022-12-19 23:49:34 -08:00
|
|
|
|
}
|
2022-12-19 21:39:24 -08:00
|
|
|
|
|
|
|
|
|
|
// Investigate if the ".section" section is an indicator of SoftLock
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-02-26 00:32:09 -08:00
|
|
|
|
/// <inheritdoc/>
|
2021-07-18 09:44:23 -07:00
|
|
|
|
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-03-23 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2022-12-19 20:49:10 -08:00
|
|
|
|
new PathMatchSet(new List<PathMatch>
|
|
|
|
|
|
{
|
|
|
|
|
|
new PathMatch(needle: "SOFTLOCKC.dat", useEndsWith: true),
|
|
|
|
|
|
new PathMatch("SOFTLOCKI.dat", useEndsWith: true),
|
|
|
|
|
|
}, "SoftLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2022-12-19 20:49:10 -08:00
|
|
|
|
return MatchUtil.GetAllMatches(files, matchers, any: false);
|
2021-03-19 15:41:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckFilePath(string path)
|
|
|
|
|
|
{
|
2021-03-23 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2022-12-19 20:49:10 -08:00
|
|
|
|
new PathMatchSet(new PathMatch("SOFTLOCKC.dat", useEndsWith: true), "SoftLock"),
|
|
|
|
|
|
new PathMatchSet(new PathMatch("SOFTLOCKI.dat", useEndsWith: true), "SoftLock"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-23 10:36:14 -07:00
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|