Jump to content

Recommended Posts

Posted

hi all
is there a way that lisp can edit itself?!!
maybe it's a strange question, bcz im a beginner 🤐

Posted

Yes, a Lisp program can edit its own source code. But here we are talking about AutoLisp and that is missing this feature

.

Posted

You could append a modified routine to the end of an existing file, the file will have multiple routines in it. Later routines will supersede the ones earlier in the file.

 

Save this to a file as an example,

 

(defun c:test ( / )
  (princ "First test")
)

(defun c:test ( / )
  (princ "second test")
)

 

 

Since the LISP file is just really a text file you can edit it as if it was. 

Posted
22 hours ago, Steven P said:

You could append a modified routine to the end of an existing file, the file will have multiple routines in it. Later routines will supersede the ones earlier in the file.

 

Save this to a file as an example,

 

(defun c:test ( / )
  (princ "First test")
)

(defun c:test ( / )
  (princ "second test")
)

 

 

Since the LISP file is just really a text file you can edit it as if it was. 

?
i mean for example i have a code like below, i want this program ask user pass code until he enter correct number but after enter the true , dont ask again next times (for next run)!
 

(defun c:gaz ()
  (setq pass (getint "enter password"))
  (if (= pass 140)
    (princ "all ok")
    (progn
      (alert
	"Incorrect serial number please contact \" ****** \" for correct number"
      )
      (EXIT)
    )

  )
  (princ)
)

 

Posted

Yes, you could do that, append a small LISP to the end of the file to return "Pass OK" or something like that, however if the user then sends the LISP file to someone else then it has all ready got that "Pass OK" routine in it.

 

A different method would be to write to the computers registry the password has been recorded in the registry and not the LISP file - which is a slightly better way to do things. You'll need to compile your code above, gaz, otherwise it is very simple to read the password or even modify the code to take out the password requirement all together. Not sure if that will work with Mac computers though.

 

What are you trying to password protect and who are you protecting it from? that might define what method you use to protect the routine. There are a lot of posts about on the various merits of different protection methods. For my routines, it is another thing to consider and usually not worth it - the routines are for myself of within the company - developed on company time and so open to all other empoyees.

Posted (edited)

actually my way is give some one a lisp  code that can show HD Serial number and then he give me back that serial , so i change my code according to the his computer HD Serial and give him main lisp as (fas type).
in this way i protect my lisp and its a unique.😅
but i looking for a briefly way ! that customer be independent!.
could i explain clearly???
 

Edited by mohammadreza
Posted
3 hours ago, Steven P said:

Yes, you could do that, append a small LISP to the end of the file to return "Pass OK" or something like that, however if the user then sends the LISP file to someone else then it has all ready got that "Pass OK" routine in it.

 

A different method would be to write to the computers registry the password has been recorded in the registry and not the LISP file - which is a slightly better way to do things. You'll need to compile your code above, gaz, otherwise it is very simple to read the password or even modify the code to take out the password requirement all together. Not sure if that will work with Mac computers though.

 

What are you trying to password protect and who are you protecting it from? that might define what method you use to protect the routine. There are a lot of posts about on the various merits of different protection methods. For my routines, it is another thing to consider and usually not worth it - the routines are for myself of within the company - developed on company time and so open to all other empoyees.

actually my way is give some one a lisp  code that can show HD Serial number and then he give me back that serial , so i change my code according to the his computer HD Serial and give him main lisp as (fas type).
in this way i protect my lisp and its a unique.
but i looking for a briefly way ! that customer be independent!.
could i explain clearly???
 

Posted

I would struggle with de-compiling the code you send out, without sending out any password protection details, I might be wrong, there are others out there who are better at that than me.

 

The way I'd see this having to work is:

They receive the code and run it.

The code checks if there is a LISP, lets call it check-pass, if there is no LISP called this then create at and ask for the serial numbers

Decompile the compiled code

Edit the LISP text file and append to the end of it a new function "check-pass"

Compile the file again.

 

 

Problems might be where the user saves the files, you have no control over that - for example, mine are in files on the one-drive, away from trusted locations (I can log onto any company computer and get my LISPs that way), and also decompile a compiled file without any password being available to view.

 

Might be easier to generate a new text file after a successful check of serial numbers , saved in the AutoCAD directory, or trusted locations so that you know the file paths to save to and edit. You can then compile that a lot easier, and the source code for your main LISP is still protected.

 

 

Tricky but I don't think LISP was designed with any password protection thoughts

Posted (edited)

Been adding a security check to code for years since "Protect" existed like 30 years ago, like others can use "_PKSER" returns Cad serial number, also yes I know it does work stopped an install by some one not wanting to pay.

 

For us oldies using a DOS command ie CMD in windows you can copy a security lisp to every lisp program that you want then run another lisp that makes all of them into FAS, just done for like 30 lisps for a client. Protecting his investment not mine.

 

The DOS command is as next you need a bat file to do it for all the files

COPY D:\mylisps\securty.lsp+D:\mylisps\mylisp1.lsp D:\newfolder\mylisp1.lsp

repeat for all lisps

 

Compile 2 examples

(defun comp ( )
(if (null vlisp-compile) (c:vlide T)) 
(setq fname (getfiled "Pick lisp to be compiled" "D:\\alan\\lisp" "lsp" 8))
(setq len (strlen fname))
(setq diff (- len (+ 15 3)))
(setq fnameout (substr fname 15 diff))
(vlisp-compile 'st  fname  (strcat "d:\\alan\\compiled\\" fnameout ".fas"))
)
(comp)

; part 2

; must have vlide open to work
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "Vlide ")
(setq loads (list 
; make a list of all lsp files.
"mylisp1"
"mylisp2"


))
(setq loc1 "C:\\CAD-TOOLS") ;;change dirs to where ever you want them found
(setq loc2 "C:\\CAD-TOOLS\\") ;;change dirs to where ever you want them saved
(foreach lisp loads
(vlisp-compile 'st (strcat loc1 lisp ".lsp") (strcat loc2 lisp ".fas"))
)

 

For BRICSCAD users just change to BLADE and DES.

 

So as mentioned some security checks 

Hard disk id

Cad serial number

Set & Getenv registry check

Network card IP address

Ping remote server and check in a file

User name 

Edited by BIGAL
  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...