简体   繁体   中英

Close wpf application using dll

I have a dll with an "authentication" method in it that checks if a password is valid, like this:

public static void AuthenticationExample(string password)
{
    if (PasswordIsValid(password))
        this.locked = false;
}

To prevent the password from being "cracked" by a loop, I want the method to crash the entire application if authentication fails, like this:

public static void AuthenticationExample(string password)
{
    if (PasswordIsValid(password))
        this.locked = false;
    else
        Crash();
}

Is there a way of doing this?

Alternatively, what is a better way of protecting a dll?

CLOSING WPF:

You can just call the main window and close it or throw a custom exception.

PASSWORD PROTECTION:

I had same issue. Finally, understood that whatever you do, it can be cracked. Nothing is fail proof. If your license verification is done on the cloud, like sending some info to a server and receiving back response, it can be managed to an extent.

Just because everything can be hacked, doesn't mean that you have to leave your product wide open for cracking. You can add some barriers so that it is little hard for the crackers. If the product is worth the effort, eventually someone will hack it.

For my applications, I have 2 or 3 licensing steps (which can slow down a hacker but not stop him/her)

  1. A dll (say, DLL-A) with cryptography methods for verifying a license. DLL-A will be placed in working directory. Along with that, a copy of this dll (say, DLL-B) will also be placed as an embedded resource.

  2. During runtime, when the DLL-A is about to be loaded, the DLL-B will be extracted and hash for both will be compared. This is to ensure that DLL-A is not tampered with. In case, DLL-A is tampered, the DLL-B will replaced DLL-A.

  3. Along with that dll method, a XML-Signed file will also be used. This will be verified somewhere in the code.

  4. A C++ native library, with different cryptography methods. This will also be used similar to DLL-A /DLL-B procedure (steps 1,2).

Thus, in my application, i generally use 3 to 4 different license verification scheme. All are independent. Even though everything can be hacked and broken, the hacker will have to be fed up trying to hack all the 4. And with every year, I change my licensing methods and update the new app. So, this means that for every year, hacker has to spend hard time to hack it. (Which should eventually make them feel frustrated).

Above all, I also have cloud based verification for my apps (the ones which store credentials in cloud DB). But, there are still some clients who expect their app to run without connection to internet (due to some security reasons).

Note: Eventually everything is hackable. Point is you just make it hard for hackers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM