Sentinel LDK Demo Test
Hi everyone,
I've been testing Sentinel Envelope using the free demo provided on the website for the last couple of days and I have a couple of questions.
1. Using the following code:
- static void Main(string[] args)
- {
- bool inputLoop = true;
- while (inputLoop)
- {
- Console.Write(">");
- string[] input = Console.ReadLine()?.Split(' ');
- if (input != null)
- {
- switch (input[0].ToLower())
- {
- case "add":
- Console.WriteLine(Calculator.Add(int.Parse(input[1]), int.Parse(input[2])));
- break;
- case "sub":
- Console.WriteLine(Calculator.Subtract(int.Parse(input[1]), int.Parse(input[2])));
- break;
- case "mult":
- Console.WriteLine(Calculator.Multiple(int.Parse(input[1]), int.Parse(input[2])));
- break;
- case "exit":
- inputLoop = false;
- break;
- default:
- Console.WriteLine("Invalid action.");
- break;
- }
- }
- }
- }
I tried to check the string encryption option inside the Envelope tool, looking at the result using dotPeek I saw the following code:
- private static void Main(string[] args)
- {
- \u003445698164.\u003405710557((object) null, MethodBase.GetCurrentMethod(), true);
- try
- {
- bool flag = true;
- while (flag)
- {
- Console.Write(">");
- string str = Console.ReadLine();
- string[] strArray1;
- if (str == null)
- {
- strArray1 = (string[]) null;
- }
- else
- {
- char[] chArray = new char[1]{ ' ' };
- strArray1 = str.Split(chArray);
- }
- string[] strArray2 = strArray1;
- if (strArray2 != null)
- {
- string lower = strArray2[0].ToLower();
- if (!(lower == "add"))
- {
- if (!(lower == "sub"))
- {
- if (!(lower == "mult"))
- {
- if (lower == "exit")
- flag = false;
- else
- Console.WriteLine(\u003445698180.\u003445698215.\u003405710642("懶᧭棴\x1C39엶蘍뿫摪䤠㟺熋\xEAEE貖괮駏뜱"));
- }
- else
- Console.WriteLine(Calculator.Multiple(int.Parse(strArray2[1]), int.Parse(strArray2[2])));
- }
- else
- Console.WriteLine(Calculator.Subtract(int.Parse(strArray2[1]), int.Parse(strArray2[2])));
- }
- else
- Console.WriteLine(Calculator.Add(int.Parse(strArray2[1]), int.Parse(strArray2[2])));
- }
- }
- }
- finally
- {
- \u003445698164.\u003405710557((object) null, MethodBase.GetCurrentMethod(), false);
- }
- }
As you can probably see, the string inside the Console.WriteLine is encrypted, but the strings inside the switch-case remained the same.
Is it not supported or is it just a bug? Did I put wrong configuration somehow?
2. On another class I wrote the following code:
- public class Calculator
- {
- [EnvelopeMethodProtectionAttributes(Protect = true, CodeObfuscation = true, Encrypt = true, MinCodeSizeForProtection = 1)]
- public static int Add(int num1, int num2)
- {
- return num1 + num2;
- }
- [EnvelopeMethodProtectionAttributes(Protect = true, CodeObfuscation = false, Encrypt = true, MinCodeSizeForProtection = 1)]
- public static int Multiple(int num1, int num2)
- {
- return num1 * num2;
- }
- [EnvelopeMethodProtectionAttributes(Protect = true, CodeObfuscation = true, Encrypt = false, MinCodeSizeForProtection = 1)]
- public static int Subtract(int num1, int num2)
- {
- return num1 - num2;
- }
- }
(Please note the CodeObfuscation and Encrypt attributes).
Again, using dotPeek I expected to see somehow at least 2 different outcome from those 3 methods.
The code did change but it seems that all of it look kind of the same. For example:
- public static int Subtract(int num1, int num2)
- {
- try
- {
- DynamicMethod dynamicMethod = \u003445698164.\u003405710557((object) null, MethodBase.GetCurrentMethod(), true);
- object obj;
- if (dynamicMethod == null)
- {
- obj = (object) null;
- }
- else
- {
- object[] parameters = new object[2]
- {
- (object) num1,
- (object) num2
- };
- obj = dynamicMethod.Invoke((object) null, parameters);
- }
- \u003445698164.\u003405710557((object) null, MethodBase.GetCurrentMethod(), false);
- return (int) obj;
- }
- catch (Exception ex)
- {
- Exception innerException = ex.InnerException;
- // ISSUE: variable of the null type
- __Null local = null;
- if (innerException != local)
- throw innerException;
- throw;
- }
- }
Any way to know if the code is encrypted, obfuscated or both?