-
Notifications
You must be signed in to change notification settings - Fork 14
Add PACE Anti-Piracy InterLok detection #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0273cfe
Add detection class and test class for PACE Anti-Piracy Interlok
HeroponRikiBestest 2803b3f
Remove unnecessary empty lines after end of class.
HeroponRikiBestest 1fa015e
Added missing null check for pex section strings.
HeroponRikiBestest efb94a1
Add newline above getversion
HeroponRikiBestest 5f961d6
GetFirstSectionStrings assigned to variable.
HeroponRikiBestest 3318c7e
Change getversion in InterLok to use regex.
HeroponRikiBestest a3b5053
Final? getversion regex cleanup
HeroponRikiBestest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| using System.IO; | ||
| using BinaryObjectScanner.Protection; | ||
| using Xunit; | ||
|
|
||
| namespace BinaryObjectScanner.Test.Protection | ||
| { | ||
| public class InterLokTests | ||
| { | ||
| [Fact] | ||
| public void CheckPortableExecutableTest() | ||
| { | ||
| string file = "filename"; | ||
| SabreTools.Models.PortableExecutable.Executable model = new(); | ||
| Stream source = new MemoryStream(); | ||
| SabreTools.Serialization.Wrappers.PortableExecutable pex = new(model, source); | ||
|
|
||
| var checker = new InterLok(); | ||
| string? actual = checker.CheckExecutable(file, pex, includeDebug: false); | ||
| Assert.Null(actual); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using System.Text.RegularExpressions; | ||
| using BinaryObjectScanner.Interfaces; | ||
| using SabreTools.Serialization.Wrappers; | ||
|
|
||
| namespace BinaryObjectScanner.Protection | ||
| { | ||
| public class InterLok : IExecutableCheck<PortableExecutable> | ||
| { | ||
| /// <inheritdoc/> | ||
| public string? CheckExecutable(string file, PortableExecutable pex, bool includeDebug) | ||
| { | ||
| // Get the .rsrc section strings, if they exist | ||
| var strs = pex.GetFirstSectionStrings(".rsrc"); | ||
| if (strs != null) | ||
| { | ||
| // Found in "nfsc_link.exe" in IA item "nfscorigin". | ||
| // Full string: | ||
| // (: ) InterLok PC v2.0, PACE Anti-Piracy, Copyright (C) 1998, ALL RIGHTS RESERVED | ||
| var match = strs.Find(s => s.Contains("InterLok") && s.Contains("PACE Anti-Piracy")); | ||
| if (match != null) | ||
| return $"PACE Anti-Piracy InterLok {GetVersion(match)}"; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| private static string GetVersion(string match) | ||
mnadareski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| var versionMatch = Regex.Match(match, @"(?<=InterLok )(.*?)(?=,)"); | ||
| if (versionMatch.Success) | ||
| return versionMatch.Value; | ||
|
|
||
| return "(Unknown Version - Please report to us on GitHub)"; | ||
mnadareski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.