Does the application have / on / off arguments ? How can I protect the application from running them? For example, knowing where the application is located, you can execute a command and disable its functions.

Is there a way to create a certain file with a bunch of characters, without which the application does not work? And how can this file be modified using the application form?

Or, something like binding an application to a hardware or activating by keys, in order to protect it from itself.

Closed due to the fact that the essence of the issue is not clear to the participants of Kromster , ermak0ff , user194374, Denis Bubnov , Pavel Mayorov 16 Feb '17 at 14:13 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 7
    try to rephrase the question. I could not understand him. - Mikhail Vaysman
  • there is a console.exe file with the / off parameter, it can be used for bad purposes, for example, to disable all the functions of the application, so you need protection against this, i.e. enter console.exe /off in the command line and the application is disabled, you need to enter such a command to check for a password or another method - Vitokhv
  • 3
    Update your question according to the guidelines for keeping discussions on Stack Overflow , instead of posting comments. - Mikhail Vaysman
  • one
    Well, great. What does not roll if (args.Contains("/off")) { if (!AskAndVerifyPassword()) return; } if (args.Contains("/off")) { if (!AskAndVerifyPassword()) return; } ? - VladD
  • You can carry your application with you on a flash drive. Then nobody will execute it. - vp_arth

1 answer 1

Does the application have / on / off arguments? How can I protect the application from running them?

No Or do you allow the use of arguments or not.

Is there a way to create a certain file with a bunch of characters, without which the application does not work?

There is. You write the code inside the program to check the validity of a file (not necessarily text, it can be a bit file) and if it does not match or the file is missing, close the program with the corresponding error / message.

And how can this file be modified using the application form?

And what is it for?

Or, something like binding an application to a hardware or activating by keys, in order to protect it from itself.

The simplest binding to the gland is realized through the generation of an activation key from the mac address. Mac address is always unique on every computer. Accordingly, you take the first of poppies, somehow you process it and keep the key by which you can activate your application. This is done quite simply: here on the console screen will give you a generated key tied to the hardware:

 class Program { static void Main(string[] args) { var mac = GetMacAdress(); Console.WriteLine(GetNumbersFromMac(mac) + GetMirroredCharsFromMac(mac)); } private static string GetMacAdress() { return NetworkInterface.GetAllNetworkInterfaces().Where(nic => nic.OperationalStatus == OperationalStatus.Up) .Select(nic => nic.GetPhysicalAddress().ToString()).FirstOrDefault(); } private static string GetNumbersFromMac(string mac) { string tmpDigit = Regex.Replace(mac, @"[^0-9]+", String.Empty); string getPositionNumber = string.Empty; foreach (char number in tmpDigit) { getPositionNumber += number * 129 / 258; } return getPositionNumber; } private static string GetMirroredCharsFromMac(string mac) { string tmpLetter = Regex.Replace(mac, @"[^AZ]+", String.Empty); string getMirrored = string.Empty; for (int i = tmpLetter.Length; i > 0; i--) { getMirrored += (tmpLetter[i - 1]); } return getMirrored; } } 

Accordingly, if the key is entered correctly, you need to make an entry in the registry or create the same registry file based on the key in the program folder ... And the next time you start it, check for the presence of a key in the registry / registry file. If there are none, simply make a request to enter an activation key or close the program.