From 8aa90dbc49ce59d0c88f0878265efb9fac33d64d Mon Sep 17 00:00:00 2001
From: TheRogueArchivist <24215969+TheRogueArchivist@users.noreply.github.com>
Date: Sun, 24 Mar 2024 20:08:09 -0600
Subject: [PATCH] Add FlexLM detection (#289)
---
.../Protection/Macrovision.FLEXnet.cs | 95 ++++++++++++++++++-
.../Protection/RainbowSentinel.cs | 1 +
2 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs b/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs
index da60ef81..dbab4d9a 100644
--- a/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs
+++ b/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs
@@ -1,4 +1,11 @@
using System;
+#if NET40_OR_GREATER || NETCOREAPP
+using System.Collections.Concurrent;
+#endif
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Principal;
+using SabreTools.Matching;
using SabreTools.Serialization.Wrappers;
namespace BinaryObjectScanner.Protection
@@ -16,12 +23,96 @@ namespace BinaryObjectScanner.Protection
if (sections == null)
return null;
- // Found in "IsSvcInstDanceEJay7.dll" in IA item "computer200709dvd" (Dance eJay 7).
var name = pex.ProductName;
+
+ // Found in "IsSvcInstDanceEJay7.dll" in IA item "computer200709dvd" (Dance eJay 7).
if (name?.Equals("FLEXnet Activation Toolkit", StringComparison.OrdinalIgnoreCase) == true)
- return $"FLEXnet";
+ return "FLEXnet";
+
+ // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403".
+ if (name?.Equals("Globetrotter Software Inc lmgr326b Flexlm", StringComparison.OrdinalIgnoreCase) == true)
+ return $"FlexLM {pex.ProductVersion}";
+
+ // Generic case to catch unknown versions.
+ if (name?.Contains("Flexlm") == true)
+ return "FlexLM (Unknown Version - Please report to us on GitHub)";
+
+ name = pex.FileDescription;
+
+ // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403".
+ if (name?.Equals("lmgr326b", StringComparison.OrdinalIgnoreCase) == true)
+ return $"FlexLM {pex.ProductVersion}";
+
+ name = pex.LegalTrademarks;
+
+ // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403".
+ if (name?.Equals("Flexible License Manager,FLEXlm,Globetrotter,FLEXID", StringComparison.OrdinalIgnoreCase) == true)
+ return $"FlexLM {pex.ProductVersion}";
+
+ if (name?.Contains("FLEXlm") == true)
+ return $"FlexLM {pex.ProductVersion}";
+
+ name = pex.OriginalFilename;
+
+ // Found in "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403".
+ // It isn't known why these various executables have the same original filename.
+ if (name?.Equals("lmgr326b.dll", StringComparison.OrdinalIgnoreCase) == true)
+ return $"FlexLM {pex.ProductVersion}";
+
+ // Get the .data/DATA section strings, if they exist
+ var strs = pex.GetFirstSectionStrings(".data") ?? pex.GetFirstSectionStrings("DATA");
+ if (strs != null)
+ {
+ // Found in "FLEXLM.CPL", "INSTALLS.EXE", "LMGR326B.DLL", "LMGRD.EXE", and "TAKEFIVE.EXE" in IA item "prog-17_202403".
+ if (strs.Any(s => s.Contains("FLEXlm License Manager")))
+ return "FlexLM";
+ }
return null;
}
+
+ ///
+#if NET20 || NET35
+ internal Queue FLEXNetCheckDirectoryPath(string path, IEnumerable? files)
+#else
+ internal ConcurrentQueue FLEXNetDirectoryPath(string path, IEnumerable? files)
+#endif
+ {
+ var matchers = new List
+ {
+ // Found in IA item "prog-17_202403".
+ new(new PathMatch("FlexLM-6.1F", useEndsWith: true), "FlexLM 6.1f"),
+ new(new PathMatch("FlexLM", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("FLexLM_Licensing.wri", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMGR326B.DLL", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("FLEXLM.CPL", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMGRD.EXE", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMGRD95.EXE", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMUTIL.EXE", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("READFLEX.WRI", useEndsWith: true), "FlexLM"),
+ };
+
+ return MatchUtil.GetAllMatches(files, matchers, any: false);
+ }
+
+ ///
+ internal string? FLEXNetCheckFilePath(string path)
+ {
+ var matchers = new List
+ {
+ // Found in IA item "prog-17_202403".
+ new(new PathMatch("FlexLM-6.1F", useEndsWith: true), "FlexLM 6.1f"),
+ new(new PathMatch("FlexLM", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("FLexLM_Licensing.wri", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMGR326B.DLL", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("FLEXLM.CPL", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMGRD.EXE", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMGRD95.EXE", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("LMUTIL.EXE", useEndsWith: true), "FlexLM"),
+ new(new PathMatch("READFLEX.WRI", useEndsWith: true), "FlexLM"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
+ }
}
}
diff --git a/BinaryObjectScanner/Protection/RainbowSentinel.cs b/BinaryObjectScanner/Protection/RainbowSentinel.cs
index b9ba0338..daa7a558 100644
--- a/BinaryObjectScanner/Protection/RainbowSentinel.cs
+++ b/BinaryObjectScanner/Protection/RainbowSentinel.cs
@@ -15,6 +15,7 @@ namespace BinaryObjectScanner.Protection
/// Rainbow Sentinel SuperPro: https://www.rainbow.com.my/superpro.php
/// TODO: Investigate other versions/products.
/// TODO: See if this is at all related to https://cpl.thalesgroup.com/software-monetization/all-products/sentinel-hl.
+ /// TODO: Investigate the possible integration between FlexLM and Rainbow Sentinel in IA item "prog-17_202403".
///
/// Versions:
/// Rainbow Sentinel PD-15: IA items "ASMEsMechanicalEngineeringToolkit1997December" and "aplicaciones-windows".