NanGlase Posted June 23 Posted June 23 Hello, I'm here again. I have already created a few independent Lisp programs. I want to add a registration feature using a combination of the computer name, volume serial number, and a secret code. I'm thinking of creating a main Lisp file that all the other Lisp files will depend on. The idea is that if the main file detects that the computer's details don't match the registration code, the entire program won't run. Is it possible to implement this?" Please, can anyone help me? Quote
GLAVCVS Posted June 23 Posted June 23 Hi I suppose you should compile the code. Do you have functions to obtain hardware serial numbers? If so, one implementation of the code could be to group the payment functions under a main function that only runs if a key you created exists in the Windows registry. Your code should create that key when the user enters a valid registration code. Another option is to save the registration code in a file. Or in both. If, when your application loads, it finds the key and it's correct, then it would load the defun with all the protected code. 1 Quote
GLAVCVS Posted June 23 Posted June 23 But if the registration code is invalid, all symbols created during application loading must be set to 'nil'. 1 Quote
Steven P Posted June 23 Posted June 23 So you'll need to compile the code otherwise the test can just be overwritten and the LISP used without it. (getenv "COMPUTERNAME") will give you the computer name and this might give you the drive number - based on a drive (setq ser (vla-get-Serialnumber (vlax-invoke (vlax-create-object "Scripting.FileSystemObject") 'getdrive "c:"))) ;;https://www.cadtutor.net/forum/topic/70821-usb-drive-serial-number/ 1 Quote
GLAVCVS Posted June 23 Posted June 23 (edited) This returns the serial number of the motherboard. It is more unique than the hard drive's serial number and also more unique than the variant of this same function that uses "Select * from Win32_BaseBoard". (defun obt_UUID (/ LObj SObj OSObj UUID) (setq LObj (vlax-create-object "WbemScripting.SWbemLocator") SObj (vlax-invoke LObj 'ConnectServer nil nil nil nil nil nil nil nil) OSObj (vlax-invoke SObj 'ExecQuery "SELECT UUID FROM Win32_ComputerSystemProduct") ) (vlax-for Obj OSObj (setq UUID (vlax-get Obj 'UUID)) ) (foreach Obj (list LObj SObj OSObj) (and Obj (vlax-release-object Obj)) ) UUID ) This might be a good option if you want your program to continue working when the user changes their hard drive but not their motherboard. Edited June 23 by GLAVCVS 3 Quote
NanGlase Posted June 23 Author Posted June 23 (edited) @GLAVCVS How do I update the compiled main lisp file to work with other UUID? Edited June 23 by NanGlase Quote
GLAVCVS Posted June 23 Posted June 23 21 minutes ago, NanGlase said: @GLAVCVS How do I update the compiled main lisp file to work with other UUID? I don't think I understand exactly what you mean. Can you explain that a little more? 1 Quote
BIGAL Posted June 24 Posted June 24 Ok one of the things you can do is using old fashioned DOS, yes us oldy's know what that is, but you can write one checkuser.lsp program that has the hidden code in it. Ok from windows cmd you can run a bat file, yeah old DOS. Repeat for every lisp. Copy checkuser.lsp+mylispprogram1.lsp c:/compile/mylispprogram.lsp You do this in a bat file for every lisp program so it appends your check code to your lisp programs. Saving as a copy is a good idea. You can then use this to make FAS files of the new lisp. ; must have vlide open to work (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "Vlide") (setq loads (list ""xxx3d pts on face 4" "xxxblock atts invisible" "xxxChange client logos-3" "xxxClose plines" "xxxCogo Label_C" ) ) (setq loc1 "C:\\XXX-CAD-TOOLS\\") ;;change dirs to where ever you want them found (setq loc2 "D:\\XXX\\compile\\") ;;change dirs to where ever you want them saved (foreach lisp loads (vlisp-compile 'st (strcat loc1 lisp ".lsp") (strcat loc2 lisp ".fas")) ) 1 Quote
GLAVCVS Posted June 24 Posted June 24 1 hour ago, NanGlase said: @GLAVCVS How do I update the compiled main lisp file to work with other UUID? Maybe I finally understood your question: If what you mean is that you were planning to write a unique registration code in your Lisp to register your application on any PC, I don't think it's a good idea. The right thing to do is design an algorithm to generate a key from the serial number of the hard drive or motherboard (whichever you prefer). From that algorithm, you'll need to write a function that converts the serial number into a key. And that key will be the one you'll need to register when you first install your application, and it will be checked every time it's loaded thereafter. Therefore, your algorithm will create a different key for each PC. 1 Quote
BIGAL Posted June 25 Posted June 25 @GLAVCVS has mad e a good suggestion, In your check code you can do a IF with a "OR" with the list of keys, or a cond so can have multiple keys but only one program required. In your lisps you just need a (load "mysecuritylisp.lsp) as 1st line it would be set up to auto run. You would give it a name similar to your other lisps so it does not appear to be the check lisp. You can pad it out with junk so long as it has a ";" as 1st character so the lisp file size is not obvious. You only need to run once by checking has it been loaded. (if (not mysecurtiycheck)(load "ASDFGH.lsp")) ; the defun name in the security lisp would be in this case mysecurtiycheck. NO C:. 1 Quote
NanGlase Posted Thursday at 12:57 PM Author Posted Thursday at 12:57 PM Thank you for all the suggestions — I really appreciate them. I tried using DOS, and it worked quite well. The only issue I'm facing now is when installing the program on another computer. The LISP files saved on the USB seem a bit risky since they haven't been compiled yet. Also, someone is observing the installation process, which adds a bit of pressure. The new suggestion looks good too. I just need some time to try it out and build it. I’ll keep you all updated. Quote
GLAVCVS Posted Thursday at 02:06 PM Posted Thursday at 02:06 PM (edited) A very simple function to convert any text string into a 'RegistryCode' could be this one. (defun genKey (serial / s) (foreach c (vl-string->list serial) (setq s (strcat (if s s "") (chr ((if (zerop (rem c 2)) + -) c 1)) (if s (itoa (rem (strlen s) 3)) ""))) ) ) You could create a similar function (or modify this one). The workflow would be to record the resulting key for each PC in a file or in the Windows registry. And, from then on, every time your application loads, you would run this algorithm to calculate the key and check if it's registered in the intended location on the PC. Of course: you should compile the code so that all this cannot be easily "cracked" Edited Thursday at 02:13 PM by GLAVCVS Quote
NanGlase Posted Thursday at 02:31 PM Author Posted Thursday at 02:31 PM (edited) 51 minutes ago, GLAVCVS said: A very simple function to convert any text string into a 'RegistryCode' could be this one. (defun genKey (serial / s) (foreach c (vl-string->list serial) (setq s (strcat (if s s "") (chr ((if (zerop (rem c 2)) + -) c 1)) (if s (itoa (rem (strlen s) 3)) ""))) ) ) You could create a similar function (or modify this one). The workflow would be to record the resulting key for each PC in a file or in the Windows registry. And, from then on, every time your application loads, you would run this algorithm to calculate the key and check if it's registered in the intended location on the PC. Of course: you should compile the code so that all this cannot be easily "cracked" Is this possible or something hard to do? During the first installation, a dialog box appears. It generates a unique key based on the motherboard ID. Then, from that unique key, a registration code is created using HTML. I paste that code into the same dialog box, and the program saves it and checks it every time it runs. Does this need a registration code? Edited Thursday at 03:00 PM by NanGlase Quote
GLAVCVS Posted Thursday at 03:48 PM Posted Thursday at 03:48 PM Are you talking about turning your AutoCAD installation into a server that handles URL requests? That's not possible with VLisp. With Python, it might be. @DanielM103 might have some interesting suggestions for you. In VLisp, the only possibility would be for your PC — from which you're going to provide the registration code — to run a while loop checking for updates in a predefined file that logs the requests coming from your program on other PCs. 1 Quote
GLAVCVS Posted Thursday at 03:53 PM Posted Thursday at 03:53 PM Are you talking about turning your AutoCAD installation into a server that handles URL requests? That's not possible with VLisp. With Python, it might be. @Danielm103 might have some interesting suggestions for you. In VLisp, the only possibility would be for your PC — from which you're going to provide the registration code — to run a while loop checking for updates in a predefined file that logs the requests coming from your program on other PCs. 1 Quote
NanGlase Posted Thursday at 03:53 PM Author Posted Thursday at 03:53 PM 1 hour ago, GLAVCVS said: A very simple function to convert any text string into a 'RegistryCode' could be this one. (defun genKey (serial / s) (foreach c (vl-string->list serial) (setq s (strcat (if s s "") (chr ((if (zerop (rem c 2)) + -) c 1)) (if s (itoa (rem (strlen s) 3)) ""))) ) ) You could create a similar function (or modify this one). The workflow would be to record the resulting key for each PC in a file or in the Windows registry. And, from then on, every time your application loads, you would run this algorithm to calculate the key and check if it's registered in the intended location on the PC. Of course: you should compile the code so that all this cannot be easily "cracked" If the license key is saved in a file and the user deletes it, what would happen? Can the user bypass the registration? Quote
GLAVCVS Posted Thursday at 03:57 PM Posted Thursday at 03:57 PM 4 minutes ago, NanGlase said: If the license key is saved in a file and the user deletes it, what would happen? Can the user bypass the registration? All of this must be planned for in your Lisp code. It will only do what you tell it to. 1 Quote
GLAVCVS Posted Thursday at 04:25 PM Posted Thursday at 04:25 PM Thinking a bit about the idea of being able to handle URL requests, it occurs to me that this could be done by creating a command ("c:genKeys", for example) that asks for the number of requests to handle and starts a "while" loop. In this "while" loop, it will look for any changes in a predetermined file (which will be where your remote Lisp writes the hard drive or motherboard ID). For each change it detects, it will subtract 1 from the number of requests you indicated at the beginning, and when that subtraction reaches 0, the command will end. This is the only way I can think of to do this without using a language other than Lisp. 1 Quote
GLAVCVS Posted Thursday at 06:34 PM Posted Thursday at 06:34 PM And, after a moment of reflection, there's another, less invasive way. I'm just winging it here because I haven't done it before, but I think it should be possible to create an embedded HTTP server in PowerShell. You could write the necessary script to do this from Lisp and run it by calling PowerShell, giving it the necessary instructions to listen to a specific port and call AutoCAD via "sendCommand." But this is such an interesting topic that it might deserve its own thread. I'll leave it for the forum administrators to consider. 1 Quote
NanGlase Posted Thursday at 10:03 PM Author Posted Thursday at 10:03 PM Really appreciate you taking the time to think about this and help out. I’m totally clueless with this stuff, but your ideas sound cool especially that PowerShell thing. Thanks again! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.