TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on February 14, 2017, 09:46:44 AM

Title: Programmation inside a drawing..
Post by: Andrea on February 14, 2017, 09:46:44 AM
is that possible ?

Hi all,..
I've receive a DWG that contain reactor in it !
how this is possible !!? I think this is soooo dangerous..

to be sure,..I've reinstalled AutoCAD from scratch..without any custom settings or prog..
remove all bundle folder from appsexchange....no VBA ObjectEnabler installed..
tested on 5 machine. with diffrent CAD version...

after purging Audit and anything based...
the reactor still active.

so if I use (vlr-remove-all) then the issue is fixed.
however,..This is weird,..so I've made a test and delete all entities in the drawing and purge...
and I've discover that the program is running if a simple specific MTEXT is present in the drawings...

so I check XDATA and remove all...but the program still there...

If I delete the text.....the reactor gone..
If I copy the text and delete the original....the reactor gone.
if I edit text, the reactor still there.
If I edit text and out only a simple space " "...the reactor still there..

so by doing this,...I've an empty drawing containing program in it....this is not only weird...but very dangerous..
so I would like to share the DWG,...but I'm afraid about viruses...because that kind of running function cannot be detected by antivirus I guess..

I open AutoDESK ticket for that,...but they do not seem to be able to help me..
or if you want anyways the DWG for test....please write me PM and i'll send you..
but I'm not responsable of that thing..

any help will be appreciated...
Thank you very much.
Title: Re: Programmation inside a drawing..
Post by: dgorsman on February 14, 2017, 10:10:48 AM
Isn't the old RTEXT and a few other things handled through persistent reactors?

I haven't played around with persistent reactors much, so I don't know how much of the code stays resident in the drawing.
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 14, 2017, 10:34:21 AM
Isn't the old RTEXT and a few other things handled through persistent reactors?

I haven't played around with persistent reactors much, so I don't know how much of the code stays resident in the drawing.

no,...simple MTEXT without any field...no Xdata...
Title: Re: Programmation inside a drawing..
Post by: MP on February 14, 2017, 10:54:53 AM
Hint: It's hiding in ldata.
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 14, 2017, 11:02:00 AM
Hint: It's hiding in ldata.

nope,..no Ldata stored..
Title: Re: Programmation inside a drawing..
Post by: MP on February 14, 2017, 11:17:28 AM
post the dwg
Title: Re: Programmation inside a drawing..
Post by: MP on February 14, 2017, 11:20:29 AM
Does this help?

Code: [Select]
(defun _CleanReactors   ( )
    ;;  MP (distilled from code authored by Luis Esquivel)
    ;;  See post: http://www.theswamp.org/index.php?topic=6870.msg112068#msg112068
    (mapcar
        (function
            (lambda (reactor)
                (cond
                    (   (and
                            (equal (vlr-type reactor) :vlr-object-reactor)
                            (or
                                (vl-some 'vlax-erased-p (vlr-owners reactor))
                                (null (vlr-owners reactor))
                            )
                        )
                        (foreach owner (vlr-owners reactor)
                            (vlr-owner-remove reactor owner)
                        )
                        (vlr-data-set reactor nil)
                        (vlr-pers-release reactor)
                    )
                    (   (and   
                            (vlr-added-p reactor)
                            (not (equal (vlr-type reactor) :vlr-object-reactor))
                            (or
                                (vl-some 'vlax-erased-p (vlr-data reactor))
                                (not (vlr-data reactor))
                            )
                        )                   
                        (vlr-data-set reactor nil)
                        (vlr-pers-release reactor)
                    )
                )
            )
        )               
        (vlr-pers-list)
    )
)
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 14, 2017, 11:28:26 AM
Does this help?

Code: [Select]
(defun _CleanReactors   ( )
    ;;  MP (distilled from code authored by Luis Esquivel)
    ;;  See post: http://www.theswamp.org/index.php?topic=6870.msg112068#msg112068
    (mapcar
        (function
            (lambda (reactor)
                (cond
                    (   (and
                            (equal (vlr-type reactor) :vlr-object-reactor)
                            (or
                                (vl-some 'vlax-erased-p (vlr-owners reactor))
                                (null (vlr-owners reactor))
                            )
                        )
                        (foreach owner (vlr-owners reactor)
                            (vlr-owner-remove reactor owner)
                        )
                        (vlr-data-set reactor nil)
                        (vlr-pers-release reactor)
                    )
                    (   (and   
                            (vlr-added-p reactor)
                            (not (equal (vlr-type reactor) :vlr-object-reactor))
                            (or
                                (vl-some 'vlax-erased-p (vlr-data reactor))
                                (not (vlr-data reactor))
                            )
                        )                   
                        (vlr-data-set reactor nil)
                        (vlr-pers-release reactor)
                    )
                )
            )
        )               
        (vlr-pers-list)
    )
)

no.... :|

Title: Re: Programmation inside a drawing..
Post by: MP on February 14, 2017, 11:36:55 AM
See reply #6.
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 14, 2017, 11:47:37 AM
See reply #6.

See answer #7  :)
Title: Re: Programmation inside a drawing..
Post by: ronjonp on February 14, 2017, 11:50:08 AM
If you really want help post the drawing.
Title: Re: Programmation inside a drawing..
Post by: Stefan on February 14, 2017, 11:54:07 AM
This is weird,..so I've made a test and delete all entities in the drawing and purge...
and I've discover that the program is running if a simple specific MTEXT is present in the drawings...

So, what exactly is running? A lisp, a code, something else?
And when? At the opening? When you try to modify this Mtext?
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 14, 2017, 11:56:28 AM
post the dwg

Ok,,..there is more info...
each time the text is modified, or the drawing SAVED ...the reactor run.
and look at a function require 3 arguments..

fonction looking at:
TESTDEMODIFICATIONRECTANGLE

so I'Ve created this function
(defun TESTDEMODIFICATIONRECTANGLE (a b c)(alert "test"))

and then, test the drawing manipulation.
please be careful because I don'T know if there is any other reactor or function running.
I've discovered that because of error message when saving the DWG.

Thanks for the help.

Title: Re: Programmation inside a drawing..
Post by: roy_043 on February 14, 2017, 12:25:21 PM
(namedobjdict) > "VL-REACTORS" > "$DOC$" (is a "VLO-VL" entity... so MP's first hint seem to be correct)
Title: Re: Programmation inside a drawing..
Post by: ronjonp on February 14, 2017, 12:37:09 PM
Some more info:
Code - Auto/Visual Lisp: [Select]
  1. _$
  2. ((-1 . <Entity name: 1a98f370dc0>)
  3.   (0 . "VLO-VL")
  4.   (5 . "281E4")
  5.   (102 . "{ACAD_REACTORS")
  6.   (330 . <Entity name: 1a98f362e90>)
  7.   (102 . "}")
  8.   (330 . <Entity name: 1a98f362e90>)
  9.   (100 . "vlo_VL")
  10.   (90 . -64512)
  11.   (91 . 142)
  12.   (92 . 1)
  13.   (340 . <Entity name: 1a98f365bc0>)
  14.   (300
  15.     .
  16.     "((&VLO-C Object-Reactor ((:VLR-modified . \"TESTDEMODIFICATIONRECTANGLE\") (:VLR-erased . \"ENLEVEREACT\")) ((&VLO-A . 0)) (\"17F09\" \"17F0A\") 0 T))"
  17.   )
  18. )
  19. _$
Title: Re: Programmation inside a drawing..
Post by: Lee Mac on February 14, 2017, 12:38:12 PM
Haven't we been down this road already? (http://bit.ly/2ldbOlk)
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 14, 2017, 02:13:07 PM
The fact is,... I thing that reactor type still dangerous..beacause it can interfere on some programming tool ..

I mean,...in this case,....the function name is unusual,....but what that can be if the function name will be something else ?  or same as function name used by some personal tools ?

Actually,...I got some error beacause the function do not exist....but,...what append if the function exist  and we never know ?
Also,...the reactor react on SAVE...so first,...never know if the save is correctly done...and second,...maybe interfere with one of my checking Save Tool..:\
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 15, 2017, 01:28:29 PM
well..

I'm trying to reproduce this thing with reactor...but it seem that it doesn't work..
maybe isn't the way ?..

Code: [Select]
(defun c:ld ()
(defun AO (alert-object reactor-object parameter-list)
(alert "Reactor RUN")

(setq actdoc (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace actdoc))
(setq vlaobj (vlax-ename->vla-object (car (entsel)))) 
(setq lineReactor (vlr-object-reactor (list vlaobj)
"TEST" '((:vlr-modified . AO))))
(princ)
)
Title: Re: Programmation inside a drawing..
Post by: Andrea on February 16, 2017, 09:54:20 AM
ok I thing I understand now,..
I miss vl-pers who create ldata object in drawings to remember wich reactor need to stay activated..
(vlr-pers-dictname)

however,...it still dangerous I think... :sick:




Title: Re: Programmation inside a drawing..
Post by: Andrea on February 16, 2017, 10:17:10 AM
Example...

Code: [Select]
(defun c:test (/ actdoc mspace vlaobj Objectreactor)
(vl-load-com)
(setq actdoc (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace actdoc))
(setq vlaobj (vlax-ename->vla-object (car (entsel))))

(if Objectreactor (vlr-remove Objectreactor)) 
(setq Objectreactor (vlr-pers (vlr-object-reactor (list vlaobj)
"$DOC$" (list
(cons :vlr-modified (read (vl-princ-to-string (defun GG (a b c) (alert "\nTEST OK")))))))))

(if (not (vlax-object-released-p actdoc))(vlax-release-object actdoc))
(if (not (vlax-object-released-p mspace))(vlax-release-object mspace))
 
(princ)
)
)
Title: Re: Programmation inside a drawing..
Post by: ronjonp on February 16, 2017, 11:12:32 AM
Might as well have some fun with it  ;D
Code - Auto/Visual Lisp: [Select]
  1. ...
  2.  
  3.                      (defun gg (a b c)
  4.                        (vlax-invoke (vlax-create-object "Shell.Application") 'tilevertically)
  5.                      )
  6. ...