Private Script ?

Get help with using AutoHotkey and its commands and hotkeys
xhoffzz
Posts: 36
Joined: 07 Dec 2019, 17:01

Private Script ?

15 Jan 2020, 12:38

Hello everyone, I'm new to AHK and developed a GUI.

My doubt is a way to make this GUI work only with the PC hardware ID number, knowing the number of hardware to put into the script.

Example: If my ID is 1234-1234
I would like a line that would only open the script or work if id 1234-1234 is the one of the pc used

how to execute this idea?Hello everyone, I'm new to AHK and developed a GUI.

My doubt is a way to make this GUI work only with the PC hardware ID number, knowing the number of hardware to put into the script.

Example: If my ID is 1234-1234
I would like a line that would only open the script or work if id 1234-1234 is the one of the pc used

how to execute this idea?
User avatar
flyingDman
Posts: 456
Joined: 29 Sep 2013, 19:01
Location: Burbank, California

Re: Private Script ?

15 Jan 2020, 13:44

I would not know how to get the PC Hardware number but maybe the Windows product key would work. The problem is that , if you use something like: if (productkey = "xxxxx-yyyyy-zzzzz-ttttt-uuuuu") anyone can hack it. It provides weak protection at best.

To get the Windows key. You can use:

Code: Select all

runwait, %comspec% /c wmic path softwareLicensingService get OA3xOriginalProductKey | clip,, hide        
msgbox % trim(strsplit(clipboard,"`n","`r").2)
Works on Windows 10, maybe not prior versions.
FanaticGuru
Posts: 1381
Joined: 30 Sep 2013, 22:25

Re: Private Script ?

15 Jan 2020, 13:49

xhoffzz wrote:
15 Jan 2020, 12:38
Hello everyone, I'm new to AHK and developed a GUI.

My doubt is a way to make this GUI work only with the PC hardware ID number, knowing the number of hardware to put into the script.

Example: If my ID is 1234-1234
I would like a line that would only open the script or work if id 1234-1234 is the one of the pc used

how to execute this idea?Hello everyone, I'm new to AHK and developed a GUI.

My doubt is a way to make this GUI work only with the PC hardware ID number, knowing the number of hardware to put into the script.

Example: If my ID is 1234-1234
I would like a line that would only open the script or work if id 1234-1234 is the one of the pc used

how to execute this idea?

This is the way I would do it.

I would get my computer's UUID using this function:

Code: Select all

; Function UUID
; 	returns UUID member of the System Information structure in the SMBIOS information
;	this should be unique to a particular computer
UUID()
{
	For obj in ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2").ExecQuery("Select * From Win32_ComputerSystemProduct")
		return obj.UUID	; http://msdn.microsoft.com/en-us/library/aa394105%28v=vs.85%29.aspx
}

Then I would use that UUID to encrypt my script code using Crypt.ahk:
https://github.com/jwhipple/Autohotkey-Scripts/blob/master/Crypt.ahk

Now I would take that encrypted script and put it in a file. Then I would write a script that got my computers UUID and used Crypt.ahk to decrypt the script. You can then save and execute that decrypted script or you could execute it dynamically without saving it using ExecScript https://github.com/cocobelgica/AutoHotkey-Util/blob/master/ExecScript.ahk.

The script can only be executed or viewed on the computer it was designed for or by someone that knows that computers UUID. The encryption is very secure. The script can be viewed and modified by the user so it is not really a way to hide the code from the intended user but it is a way so only a certain user can access the code.

Here is a link to something along the same lines being discussed on forum but with just passwords: https://www.autohotkey.com/boards/viewtopic.php?p=268667#p268667

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
xhoffzz
Posts: 36
Joined: 07 Dec 2019, 17:01

Re: Private Script ?

15 Jan 2020, 15:32

thanks for reply but i am new to ahk and code writing.
I did not understand what this process would be like.

with this code i think i can get serial number,
Spoiler
the idea would be to send this script to get the serial for the user, he will check and copy the number and send it to me.

With this number I would put something inside the gui, to check if the number matches the computer, if the GUI check opens, if it doesn't show a message



I apologize for understanding superficially about codes, but I'm trying to learn :)

again thanks for the reply
FanaticGuru
Posts: 1381
Joined: 30 Sep 2013, 22:25

Re: Private Script ?

15 Jan 2020, 18:12

xhoffzz wrote:
15 Jan 2020, 15:32
I did not understand what this process would be like.

with this code i think i can get serial number,
Spoiler
the idea would be to send this script to get the serial for the user, he will check and copy the number and send it to me.

With this number I would put something inside the gui, to check if the number matches the computer, if the GUI check opens, if it doesn't show a message

The hard drive serial numbers is ok but a computer's UUID (Universally Unique IDentifier) is better. It was created by Windows for exactly the purpose of getting a unique ID for a computer.

Also the method you are proposing is fairly easily circumvented. Anyone with basic knowledge of AHK would be able to open your script and remove the check for the ID number and run the script on any computer.

The method I proposed is not that hard but it is not easy either. Most of the complex stuff is done by other peoples functions but you do have to be able to download several other peoples functions and be able to use them properly.

If you just need a very simple solution for making sure a user does not run a script on the wrong computer by mistake that is one thing but if you are trying to create some type of copy protection that is totally different.

Good copy protection is far more complex than the code that most people are trying to protect with it.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
xhoffzz
Posts: 36
Joined: 07 Dec 2019, 17:01

Re: Private Script ?

15 Jan 2020, 19:25

yes you are absolutely right, "copy protection is far more complex than the code". In reality, I want to prevent passing the script to a user and he just spreads my executable with a simple ctrl c / v

The script will be used by 14- to 38-year-olds, who are usually unaware of ahk and others, I would like to make sharing difficult, I understand that I could hardly do anything with UUID with knowledge I have: / I'm just a curious user to learn

I found this code in searches on the forum, its idea is good, but many pcs get the same name, would there be any other data that I could replace?

Code: Select all

If !(A_UserName = "Fulano")
{
msgbox Este script está restrito a outro usuário.
Exitapp
}
same logic as the post above flyingDman but same problem, several computers here use some kind of tool to crack windows, some having similar keys and others nonexistent.

Which alternative would you suggest?

It doesn't really have to be a complicated thing to get around, just make it a little difficult not to make it so exposed
FanaticGuru
Posts: 1381
Joined: 30 Sep 2013, 22:25

Re: Private Script ?

16 Jan 2020, 13:15

xhoffzz wrote:
15 Jan 2020, 19:25
I understand that I could hardly do anything with UUID with knowledge I have: / I'm just a curious user to learn

Great thing about functions is that you don't have to understand them to use them.

Code: Select all

MsgBox % UUID()

; Function UUID
; 	returns UUID member of the System Information structure in the SMBIOS information
;	this should be unique to a particular computer
UUID()
{
	For obj in ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2").ExecQuery("Select * From Win32_ComputerSystemProduct")
		return obj.UUID	; http://msdn.microsoft.com/en-us/library/aa394105%28v=vs.85%29.aspx
}
The serial number that MsgBox displays is exactly as it is named, a universally unique identifier for that computer. Microsoft designed it specifically for this type purpose.

You can just compile the script with the UUID imbedded into the script like you proposed. It will stop the very lowest level 'hackers' from distributing the script. Compression on the compile will help hide it a little bit more but that level of protection can be broken by many many users on this forum within minutes. It will stop those that know very little about AHK though.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
xhoffzz
Posts: 36
Joined: 07 Dec 2019, 17:01

Re: Private Script ?

16 Jan 2020, 16:37

Thanks for reply.

sorry, but could you show me what the code would look like from UUID?

I'm getting embarrassed by my questions, but I don't understand and would like to finish the project with this key

thanks again for the answers and patience
FanaticGuru
Posts: 1381
Joined: 30 Sep 2013, 22:25

Re: Private Script ?

17 Jan 2020, 14:58

xhoffzz wrote:
16 Jan 2020, 16:37
sorry, but could you show me what the code would look like from UUID?

Have the User run this script and send you the information:

Code: Select all

MsgBox % UUID()
Clipboard := UUID() ; put UUID on clipboard for easy pasting

; Function UUID
; 	returns UUID member of the System Information structure in the SMBIOS information
;	this should be unique to a particular computer
UUID()
{
	For obj in ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2").ExecQuery("Select * From Win32_ComputerSystemProduct")
		return obj.UUID	; http://msdn.microsoft.com/en-us/library/aa394105%28v=vs.85%29.aspx
}

Then take the UUID they send you and put in your script:

Code: Select all

UUID_User := "3D4C4989-3486-8937-5322-F8A89C448931" ; Put the UUID the user sends you here, this is just a dummy serial number for demo to show the format of the UUID
If !(UUID_User = UUID())
{
	MsgBox WRONG COMPUTER
	ExitApp
}
MsgBox YEA, THIS IS THE RIGHT COMPUTER

; Function UUID
; 	returns UUID member of the System Information structure in the SMBIOS information
;	this should be unique to a particular computer
UUID()
{
	For obj in ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2").ExecQuery("Select * From Win32_ComputerSystemProduct")
		return obj.UUID	; http://msdn.microsoft.com/en-us/library/aa394105%28v=vs.85%29.aspx
}
This script will then only run completely on the computer with the correct UUID.

Now you would need to compile and possibly not make the check so obvious so that it is not as easy to remove.

This basic concept is used by some commercial software except it is all automated. There is an installer program that gets the computer's UUID, sends it over the internet to a server that takes the UUID and generates a custom copy of a piece of software that it is automatically downloaded and deployed by the installer. The server requires that the user enter some type of verification to the server proving they bought the software before it will give them the download. This also means the serve can keep track of every computer that a user installs the software on and control which computers the software will work on. Hackers then 'crack' the software by searching through the software and removing the code that checks the UUID match. Good protection makes that check hard to find and remove. This is just one of many protection schemes though.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
xhoffzz
Posts: 36
Joined: 07 Dec 2019, 17:01

Re: Private Script ?

17 Jan 2020, 18:19

thanks for help me :) solved my problema, thanks so much.

Return to “Ask For Help”

Who is online

Users browsing this forum: adrian_9832, anadir, Bing [Bot], daywalker, Odlanir, Xeo786 and 198 guests