TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on January 14, 2017, 01:53:10 AM

Title: Is this good way to protect the lisp from running out of the owner's computer?
Post by: HasanCAD on January 14, 2017, 01:53:10 AM
I am trying to protect the lisp from running out of the owner's computer.

I'll add these lines then compile to VLX

Code - Auto/Visual Lisp: [Select]
  1. (defun c:xxx (/)
  2.       (if (findfile "C:/TestFolder/TestFile.dwg")
  3.         (progn
  4.           (princ
  5.             (strcat "Welcome " (getvar "loginname") " to | HasanCAD |")
  6.           )
  7.                                         ;...the code
  8.         )
  9.         (alert (strcat "Welcome "
  10.                        (getvar "loginname")
  11.                        "\n You are out of | HasanCAD | PLease call | xxxxxxxx | for getting permisiom to run the code"
  12.                )
  13.         )
  14.       )
  15.     )
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: Lee Mac on January 14, 2017, 07:07:37 AM
Alternatively, you could hardcode the MAC address - this is hardware-specific and will not change.
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: HasanCAD on January 14, 2017, 08:01:01 AM
Alternatively, you could hardcode the MAC address - this is hardware-specific and will not change.

How is this?
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: mailmaverick on January 14, 2017, 08:17:49 AM
Your computer has a specific MAC address which you can get from following function :-

Code: [Select]
(defun get_macaddress (/ query retval)
;;Source : http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/seial-number-etc/td-p/2674574
  (vl-catch-all-apply
    '(lambda ()
       (vlax-for item (setq query (vlax-invoke
                                    (vlax-invoke (vlax-create-object "WbemScripting.SWbemLocator") 'ConnectServer "." "root\\cimv2")
                                    'ExecQuery
                                    (strcat "select * " "from Win32_NetworkAdapterConfiguration " "where IPEnabled = True")
                                  )
                      )
         (setq retval (vlax-get item 'MACAddress))
       )
     )
  )
  (if query
    (vlax-release-object query)
  )
  retval
)

(if (eq 'your_hardcoded_MAC_address' (get_macaddress))
(progn Its your computer )
(progn Your code has been stolen !)
)

Please see following link to see MAC address in Windows :-
https://helpdesk.latech.edu/index.php?option=com_content&task=view&id=207&Itemid=79

Also note that if you have multiple Network Connections such as 'Local Area Connection' , 'Wireless Network Connection1' , 'Wireless Network Connection2' etc the MAC address would be different for each connection.

Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: Grrr1337 on January 14, 2017, 10:24:46 AM
In addition to Lee Mac and mailmaverick, might be better to use this structure (as I've seen before, being used/suggested before by MP and LM) :
Code - Auto/Visual Lisp: [Select]
  1. (defun C:test ( / MyCode )
  2.   (defun MyCode ( / )
  3.     ; <full code here>
  4.   )
  5.   (cond
  6.     ( (not get_macaddress) (princ "\nFunction get_macaddress is not loaded.") )
  7.     ( (not (eq MyMacAddress (get_macaddress))) (princ "\nYou have no permission to run this routine.") )
  8.     ( (not MyCode) (princ "\nThe code is not defined properly.") )
  9.     (T (MyCode) )
  10.   ); cond
  11.   (princ)
  12. ); defun C:test
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: HasanCAD on January 14, 2017, 11:16:04 AM
I belive the owner has a network
So it is better to use my option.

Thanks all
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: roy_043 on January 14, 2017, 12:47:57 PM
@HasanCAD:
If you are talking about custom software for one particular client this solution may work. But for software licensing in general I would choose a different option.
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: HasanCAD on January 14, 2017, 01:53:20 PM
@HasanCAD:
If you are talking about custom software for one particular client this solution may work. But for software licensing in general I would choose a different option.
This is a lisp protection only. in most of engineering offices the user want to get a copy of a good lisp. So we trying to be againest that illigal copy.
So wha tis another options you prefere?
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: roy_043 on January 14, 2017, 06:34:42 PM
For the protection of company Lisp files I would:
1. Compile the code (obviously).
2. Hide some 'unlock' data somewhere in the registry (harder to detect than a file).
3. Add a time limit to the code.
4. Perhaps also check (getvar 'loginname) against a (hardcoded/registry) list.
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: Lee Mac on January 14, 2017, 06:47:54 PM
...And hash any value stored in the registry to make it harder to find.
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: HasanCAD on January 15, 2017, 04:24:19 AM
Thanks all for your value help.
Title: Re: Is this good way to protect the lisp from running out of the owner's computer?
Post by: roy_043 on January 15, 2017, 05:43:17 AM
Your computer has a specific MAC address which you can get from following function :-
As an aside:
I find it strange that the parent 'external' object is not released in the function. I often have doubts about what to release (only the parent or all 'external' objects), but I would always release the parent object.