I need a way to make a program work on only the first computer it is run on, it doesn't need to be very secure but it needs to work. The idea that I came up with is to have the program save the MAC Address (of the first computer it is run on) inside of its own EXE. And then from then on check to see if the MAC Address corresponds to the computer its on..
So I have a couple questions
1. How can I have a program edit its own file during execution. Is this possible? Are there workaround ways to do it?
2. How can I have the compiler tell me where, in the file, a certain piece of data was saved. I'm using GCC, though I could use Visual C++.
Self modifying executables are quite dangerous: most systems do not allow it. The main problem is that there are checksums embedded in the executable. If you don't patch them correctly, it stops working. Also, moving from one compiler to another or from one OS to another could cause the program to stop working.
How about alternative techniques like
1) writing it to the registry.
2) creating a file in allusers\documents
3) encrypted file containing the MAC
These are somewhere other than the directory from which the executable is run so, in theory, an unknowing pirate will only copy the exe and not the registry entry or the file in allusers\documents.
MAC addresses aren't totally safe (neither is any technique to a really determined cracker). If you are running MS loopback adapter, that is the first MAC address picked so anyone could just install the MS loopback adapter and they've got the Software. Also, network cards can change. Do you have an option to reset this and take a new address.
Thanks, but the problem with storing the MAC address in some hidden file is exactly that, the person would simply copy the EXE, which would be the first thing most users would try.. This protection is aimed against novice users, crackers will find a way around nearly any protection if they are given reason to try, so I'm not worried about making it extremely secure since even big companies like Microsoft and Apple can't seem to keep their programs extremely secure.
So if there's no way for an EXE to edit itsself I was thinking that I could store another EXE in a resource in the file, and then EXE #1 would export EXE #2, EXE #1 would close and #2 would edit the now available file. Then the only problem remaining is I wouldn't know where to edit the file.. I'd need to know where the constant I set aside in the code was saved. I could do a search for 00-00-00.... but that seems too unreliable to me.
Suggestions? Or a way to have the EXE edit itself if you know of one..
I need a way to make a program work on only the first computer it is run on
I don't understand the use case, I presume. Say Joe Schmoe downloads your app from somewhere, stores it on his flash drive, plugs in the flash drive to PC A , copies the exe and runs it. Now, what would prevent Joe Schmoe from copying the exe from his flash drive onto PC B and run it like a virgin copy ?
One of the most effective ways is to modify part of the download so that each one is unique. Then require registration via a webservice. Do not allow multiple registrations of the same "Serial Number"....
The KEY part is requiring an interaction with the server to achieve activation. Of course it is necessary to provide an alternate if you have people legitimately installing on machines without WebAccess, but there are service providers who specialize in that.....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009 In theory, there is no difference between theory and paractice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
The suggestion is quite simple: never let your exe run with no registration information present in the system. Consequense: using an application installer (that gathers a registration information, puts it into a system but does nothing really valuable except installation) is a minimal requirement. The optional step is further activation.
And one more point to be clear: forget about self-modification. This trick is easily cracked by plain binary diffing.