Sign in to follow this  
Followers 0
flyCODES93

Hardlocking a Program using AutoIt?

7 posts in this topic

So...I have a program that I created a while back and it's written in Python. It's a .exe that loads up a config.txt file when the program is loaded up.

Is there any way that I can create a script with AutoIt that will allow the program to only open one computer? i.e. hardlocking?

Share this post


Link to post
Share on other sites



Assuming the program is a standalone executable that is able to run on any computer, then I think you are looking for FileInstall. You can read something from the registry that would be unique to that computer, such as a hardware ID or a special registry entry you put on that computer. Or you could simply password protect the AutoIt exe that contains the program. After extracting the Python program, you will have to delete it. And of course, you will have the small risk that someone who knows what they are doing can find the extracted file and make a copy of it. Nothing is foolproof, but depending on what level of security you are looking for, you can make it very complicated and hard to figure out.

If you gave us more details about exactly what you are trying to accomplish, that may help us make better suggestions.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

Assuming the program is a standalone executable that is able to run on any computer, then I think you are looking for FileInstall. You can read something from the registry that would be unique to that computer, such as a hardware ID or a special registry entry you put on that computer. Or you could simply password protect the AutoIt exe that contains the program. After extracting the Python program, you will have to delete it. And of course, you will have the small risk that someone who knows what they are doing can find the extracted file and make a copy of it. Nothing is foolproof, but depending on what level of security you are looking for, you can make it very complicated and hard to figure out.

If you gave us more details about exactly what you are trying to accomplish, that may help us make better suggestions.

Would it be possible to use AutoIt to wrap around my program and password protect it? And could the password have to match perhaps an ecrypted hash key of the machine id?

Share this post


Link to post
Share on other sites

Would it be possible to use AutoIt to wrap around my program and password protect it? And could the password have to match perhaps an ecrypted hash key of the machine id?

Yes, that can be done. You can use RegRead to get the machine id (HKEY_LOCAL_MACHINESOFTWAREMicrosoftCryptographyMachineGuiid). Then use _StringEncrypt to encrypt it (with a predefined decoding password).

Now use that info to make your wrapping program. Prompt the user for a password and use _StringEncrypt to decrpyt it and check against the registry entry on the host computer (again using RegRead). If the decrypted machine id matches the one read from the computer, you use the FileInstall to extract the program to a temporary directory. When the program is closed (use ProcessExists to detect it closing), delete it from the temp directory.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Would it be possible to use AutoIt to wrap around my program and password protect it? And could the password have to match perhaps an ecrypted hash key of the machine id?

Look at Crypt.au3. You can use _Crypt_HashData() to build a md5 hash out of any string. Then read the reg key that contains the information, transform it into the md5 hash and compare it to the one you've created. Here's a sample one I used as a passworded login:

Func _Login() ; Tested[COMPLETE]
    $sIni = "xxxxxxxxPDF_MergePDF_MERGE.ini"
    $sMasterPassword = IniRead($sIni, "Passwords", "Master Password", "") ; read the master password from ini file
    $sUserPassword = IniRead($sIni, "Passwords", "User Password", "") ; read the user password from ini file
    If Not $sMasterPassword Or Not $sUserPassword Then ; if it can't find either password in the ini file, error out of app
        SetError(2, 1, 0)
        _Error(@error, @extended)
    EndIf
    If Not _UserInput($sMasterPassword, $sUserPassword) Then _Cleanup() ; if user cancels input, perform cleanup
EndFunc

    Func _UserInput($sMasterPassword, $sUserPassword) ; Tested[COMPLETE]
        While 1
            $sInput = InputBox(@ScriptName, "Please enter your password...", "", "*", 250, 150)  ; pops up a box for user to enter password
            If Not $sInput And @error = 1 Then Return False ; If they cancel input, return to previous function
            _Crypt_Startup() ; start the crypt engine
            $sEncryptedInput = _Crypt_HashData($sInput, $CALG_MD5) ; take the user input and transform into MD5 hash
            _Crypt_Shutdown() ; stop the crypt engine
            If $sEncryptedInput = Binary($sUserPassword) Then ; compare user encrypted password to stored user password
                    Global $sLoginType = "User"
                    Return True
            ElseIf $sEncryptedInput = Binary($sMasterPassword) Then; compare user encrypted password to stored master password
                    Global $sLoginType = "Admin"
                    Return True
            Else
                msgbox(16 + 262144, @ScriptName, "Incorrect Password. Please try again.") ; if neither password matches, pop up a message box
            EndIf
        WEnd
    EndFunc

EDIT: Added comments to code

Edited by mechaflash213

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Look at Crypt.au3. You can use _Crypt_HashData() to build a md5 hash out of any string. Then read the reg key that contains the information, transform it into the md5 hash and compare it to the one you've created. Here's a sample one I used as a passworded login:

Func _Login() ; Tested[COMPLETE]
    $sIni = "xxxxxxxxPDF_MergePDF_MERGE.ini"
    $sMasterPassword = IniRead($sIni, "Passwords", "Master Password", "")
    $sUserPassword = IniRead($sIni, "Passwords", "User Password", "")
    If Not $sMasterPassword Or Not $sUserPassword Then
        SetError(2, 1, 0)
        _Error(@error, @extended)
    EndIf
    If Not _UserInput($sMasterPassword, $sUserPassword) Then _Cleanup()
EndFunc

    Func _UserInput($sMasterPassword, $sUserPassword) ; Tested[COMPLETE]
        While 1
            $sInput = InputBox(@ScriptName, "Please enter your password...", "", "*", 250, 150)
            If Not $sInput And @error = 1 Then Return False
            _Crypt_Startup()
            $sEncryptedInput = _Crypt_HashData($sInput, $CALG_MD5)
            _Crypt_Shutdown()
            If $sEncryptedInput = Binary($sUserPassword) Then
                    Global $sLoginType = "User"
                    Return True
            ElseIf $sEncryptedInput = Binary($sMasterPassword) Then
                    Global $sLoginType = "Admin"
                    Return True
            Else
                msgbox(16 + 262144, @ScriptName, "Incorrect Password. Please try again.")
            EndIf
        WEnd
    EndFunc

How would this wrap around my existing program and it's config file? Keep in mind all I've ever done is create a GUI interface with Koda. ;) Edited by flyCODES93

Share this post


Link to post
Share on other sites

I'll throw you some bones, go create some code and come back w/what you've got.

You can package your program into your AutoIt executable with FileInstall(). You can run your app with either Run() or ShellExecute(). Look in the help file for those functions. Prior to running the app, create a login prompt. Take a look at _UserInput() function from the code I provided above. Based on whether or not the passwords match, run it or don't run it. I'll edit my original code-post with some comments so you can better understand what I'm doing.

Notice I read an ini file and set my password variables ($sMasterPassword and $sUserPassword), I'm reading them from an Ini file I created. These passwords I previously transformed them to an MD5 hash, and stored them in the ini in their hash form. Then when the user enters in the plain-text password, you hash it, and compare its output with the hash stored in your ini file.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0