home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / phrack1 / phrack23.008 < prev    next >
Encoding:
Text File  |  2003-06-11  |  13.2 KB  |  250 lines

  1.                                 ==Phrack Inc.==
  2.  
  3.                       Volume Two, Issue 23, File 8 of 12
  4.  
  5.                      ____________________________________
  6.                     |                                    |
  7.                     |  Getting Serious About VMS Hacking |
  8.                     |                                    |
  9.                     |     by VAXbusters International    |
  10.                     |                                    |
  11.                     |            January 1989            |
  12.                     |____________________________________|
  13.  
  14. The VAX/VMS operating system is said to be one of the most secure systems
  15. currently available.  It has been massively extended in the past to provide
  16. features which can help system managers getting their machines locked up to
  17. abusers and to trace back any attempts to indiscriminate system security.  As
  18. such, it is not easy getting into VMS machines now without having insider
  19. information, and it's even harder to stay in.
  20.  
  21. The following article describes some of the internals which make up the VMS
  22. security features, and tries to give hints what to do to remain undiscovered.
  23. The reader should be familiar with the VMS system from the programmer's point
  24. of view.
  25.  
  26. Some of the things mentioned are closely related to the internal workings of
  27. the VAX/VMS operating system.  All descriptions are held as general as
  28. possible.  It is tried to point out where weak points in the system are
  29. located, not to give step-by-step instructions on how to hack VMS machines.
  30. The main reason for this is, that it is very hard to remain undiscovered in a
  31. VMS system without having good knowledge of the whole system.  This knowledge
  32. is only aquirable by experience.
  33.  
  34. To use some of the techniques described herein, some literature is recommended:
  35.  
  36.      "The VAX Architecture Handbook," published by DEC.  This book describes
  37.      the VAX processor, it's instruction set and it's hardware.  It is a good
  38.      book to have on your desk, since it costs nothing (just go to your local
  39.      DEC store and ask for it) and is only in paperback format.
  40.  
  41.      "MACRO and Instruction Set," part of the VMS documentation kit.  This is
  42.      needed only if you want to program bigger things in MACRO.  It's
  43.      recommended reading, but you don't need to have it on your own normally.
  44.  
  45.      "VAX/VMS Internals and Data Structures" by L.Kenah and S.Bate.  This is
  46.      the bible for VMS hackers.  It describes the inner workings of the system
  47.      as well as most of the data structures used within the kernel.  The
  48.      Version published always is one version number behind the current VMS
  49.      release, but as the VAX architecture doesn't change, it is the best source
  50.      on a description how the system works.  After you've read and understood
  51.      this book, the VAX won't look more mysterious than your C64.  You can
  52.      order this book from DEC, the order number for the V3.0 version of the
  53.      book is EY-00014-DP.  The major drawback is the price, which is around
  54.      $70-$100.
  55.  
  56. A good source of information naturally is the source code of the VMS system.
  57. The easiest way to snoop around in it is to get the microfiche set, which is
  58. delivered by DEC to all bigger customers of the system. The major disadvantage
  59. is that you need a fiche reader to use it.  The fiche is needed if
  60. modifications to the system code are intended, unless you plan to disassemble
  61. everything you need.  The VMS system is written in BLISS-32 and FORTRAN.  BLISS
  62. is quite readable, but it might be worthwhile having a FORTRAN hacker around if
  63. you intend to do patch any of the programs implemented in FORTRAN.  The source
  64. fiche always contains the current release, so it's useful to check if the
  65. information in "Internals and Data Structures" is still valid.
  66.  
  67.  
  68. Hacker's Tools
  69. ~~~~~~~~~~~~~~
  70. There are several programs which are useful when snooping around on a VMS
  71. system.
  72.  
  73. The most important utility might be the System Dump Analyzer (SDA), which is
  74. started with the command ANALYZE/SYSTEM.  Originally, SDA was developed to
  75. analyze system crash dumps, which are created every time the machine crashes in
  76. a 'controlled' manner (bugcheck or opcrash).  SDA can also be used to analyze
  77. the running system, which is the more useful function.  A process which wants
  78. to run SDA needs the CMKRNL privilege.  With SDA, you can examine any process
  79. and find out about accessed files and devices, contents of virtual memory (like
  80. typeahead and recall buffers), process status and more.  SDA is a watching
  81. tool, so you normally can't destroy anything with it.
  82.  
  83. Another helpful tool is the PATCH utility, called up by the command PATCH.  As
  84. VMS is distributed in a binary-only fashion, system updates are normally
  85. distributed as patches to binaries.  PATCHES can be entered as assembler
  86. statements directly.  Combined with the source fiche, PATCH is a powerful tool
  87. for your modifications and improvements to the VMS operating system.
  88.  
  89.  
  90. Privileges
  91. ~~~~~~~~~~
  92. To do interesting things on the VMS system, you normally need privileges.  The
  93. following lists describes some of the privileges which are useful in the
  94. onliner's daily life.
  95.  
  96. CMKRNL
  97. CMEXEC  These two privileges enable a user to execute arbitrary routines with
  98.         KERNEL and EXECUTIVE access mode.  These privileges are needed when one
  99.         plans to access kernel data structures directly.  CMKRNL is the most
  100.         powerful privilege available, everything which is protected can be
  101.         accessed utilizing it.
  102.  
  103. SYSPRV  A process which holds this privilege can access objects via the system
  104.         protection.  A process holding the this privilege has the same access
  105.         rights as a process running under a system UIC.
  106.  
  107. SHARE   This allows a process to assign channels to nonshareable devices which
  108.         already have channels assigned to them.  This can be used to prevent
  109.         terminal hangups and to assign channels to system mailboxes.
  110.  
  111.  
  112. Process States And The Process Control Block
  113. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  114. When you get into kernel hacking, you should pay special attention to the field
  115. PCB$L_STS.  This field tells about the process status.  Interesting bits are
  116. PCB$V_DELPEN, PCB$V_NOACNT and PCB$V_BATCH.  There can be achieved astonishing
  117. effects by setting these bits.
  118.  
  119.  
  120. Hideout
  121. ~~~~~~~
  122. A nice possibility to have is to be unseen by a system manager.  There are many
  123. ways to get invisible to SHOW USERS, but hiding from SHOW SYSTEM is another
  124. story, as it doesn't even use standard system calls to get a list of the
  125. currently running processes.  And in fact, hiding from SDA is even harder,
  126. since it directly peeks kernel data structures.  Anyway, being invisible to
  127. SHOW USERS is useful on small systems, where one user more could ring the alarm
  128. bell of the system operator.
  129.  
  130. One possibility to do this is to become a subprocess of some non-interactive
  131. job (like a BATCH or NETWORK process).  The other way is to patch the PCB to
  132. become a BATCH process or to delete the terminal name (which makes SHOW USERS
  133. think you are non-interactive as well).  Patching the PCB has a disadvantage:
  134. The system global variable SYS$GW_IJOBCNT which contains the number of
  135. interactive users must be directly decremented before you hide, and MUST be
  136. incremented before you log out.
  137.  
  138. If you forget this, the interactive job count will be wrong.  If it becomes
  139. negative, strange effects will show up, which will confuse every system
  140. manager.
  141.  
  142.  
  143. Accounting And Audits
  144. ~~~~~~~~~~~~~~~~~~~~~
  145. The most nasty thing about VMS since release 4.2 is the security auditing
  146. feature.  It enables the system manager to log almost every security relevant
  147. event he desires.  For example, access to files, login failures and
  148. modification user authorization data base can all be monitored, logged and
  149. written to the system printer.  The first thing to find out in a new, unknown
  150. system is the awareness of the system management.  The status of the accounting
  151. system is easily determinable by the command SHOW ACCOUNTING.  Normally,
  152. everything except IMAGE accounting is enabled.  When IMAGE accounting is also
  153. enabled, this is the first hint to be careful.  The second thing to check out
  154. is the status of the security auditing system.  You need the SECURITY privilege
  155. to execute the command SHOW AUDIT.
  156.  
  157. If no audits are enabled, and image accounting is not turned on, the system
  158. normally is not set up to be especially secure.  Such systems are the right
  159. playground for a system hacker, since one doesn't have to be as careful as one
  160. has to be on a correctly managed system.
  161.  
  162.  
  163. Accounting
  164. ~~~~~~~~~~
  165. The main intention for running accounting on a system is the need to charge
  166. users for resources (cpu time, printer usage etc.) they use on the machine.  On
  167. the other hand, accounting can be very useful to track down invaders.  Luckily,
  168. accounting information is being logged in the normal file system, and as such
  169. one can edit out information which isn't supposed to be seen by sneaky eyes.
  170. The most important utility to handle accounting files is, naturally, the
  171. ACCOUNTING utility.  It has options to collect information which is stored in
  172. accounting files, print it in a human readable manner, and, most importantly,
  173. edit accounting files.  That is, you can edit all information out of an
  174. accounting file which you don't want to appear in reports anymore.  The
  175. important qualifier to the ACCOUNTING command is /BINARY.
  176.  
  177.  
  178. File Access Dates
  179. ~~~~~~~~~~~~~~~~~
  180. One way for system managers to discover unwanted guests is to look out for
  181. modified system files.  Fortunately, there are ways to modify the modification
  182. dates in a file's header.  This can be done with RMS system calls, but there is
  183. no easy way to do that with pure DCL.  There are several utilities to do this
  184. kind of things in the public domain, so look out in the DECUS catalog.
  185.  
  186.  
  187. OPCOM
  188. ~~~~~
  189. OPCOM is a process which logs system and security relevant events (like tape
  190. and disk mount transactions, security auditing messages etc.).  OPCOM receives
  191. messages via a mailbox device, formats them, logs the event in the operator
  192. logfile (SYS$MANAGER:OPERATOR.LOG) and notifies all operators.  Additionally,
  193. it sends all messages to it's standard output, which normally is the system
  194. console device _OPA0:.  When OPCOM is started, one message is sent to the
  195. standard output announcing that the operator logfile has been initialized.
  196. Thus, it's not recommended to kill OPCOM to remain undiscovered, since the
  197. system manager most likely will get suspicious if the operator logfile has been
  198. initialized without an obvious reason.  The elegant solution to suspend OPCOM,
  199. for the time where no operator messages shall come through.  While OPCOM is
  200. suspended, all messages will be buffered in the mailbox device, where every
  201. process with sufficient privilege can read them out, thus avoiding that OPCOM
  202. reads those messages after it is restarted.
  203.  
  204. There is one problem with this solution though:  OPCOM always has a read
  205. pending on that mailbox, and this read will be there even if the OPCOM process
  206. is suspended.  Unless you're heavily into kernel hacking, there is no way to
  207. get rid of this read request.  As such, the easy solution is to generate an
  208. unsuspicious operator message as soon as OPCOM is suspended.  Afterwards, your
  209. own process (which can be a DCL procedure) reads all subsequent messages off
  210. the OPCOM mailbox until you feel save enough to have OPCOM resume it's work. By
  211. the way, the OPCOM message mailbox is temporary and has no logical name
  212. assigned to it.  You'll need SDA to get information about the device name.
  213.  
  214.  
  215. Command Procedures
  216. ~~~~~~~~~~~~~~~~~~
  217. Timely, you'll need DCL procedures to have some routine work done
  218. automatically.  It is important not to have strange command procedures lying
  219. around on a foreign system, since they can be easily read by system managers.
  220. Fortunately, a command file may be deleted while someone is executing it.  It
  221. is good practice to do so, utilizing the lexical function F$ENVIRONMENT.  If
  222. you need access to the command file itself from the running procedure, just
  223. assign a channel to it with OPEN.
  224.  
  225.  
  226. Piggy-Backing
  227. ~~~~~~~~~~~~~
  228. It's not normally a good idea to add new, possibly privileged accounts to a
  229. foreign system.  The better approach is to to use accounts which have been
  230. unused for some months and to hide privileged programs or piggybacks which gain
  231. privilege to the caller by some mechanism.  A piggyback is a piece of code
  232. which is added to a privileged system program, and which gives privileges
  233. and/or special capabilities to callers which have some kind of speciality (like
  234. a special process name, for example).  Be careful not to change file sizes and
  235. dates, since this makes people suspicious.
  236.  
  237.  
  238. Conclusion
  239. ~~~~~~~~~~
  240. This file just tries to give an impression how interesting VMS kernel hacking
  241. can be, and what possibilities there are.  It of course is not complete, and
  242. many details have been left out.  Hopefully, it has been useful and/or
  243. interesting lecture.
  244.  
  245.  
  246.  
  247.                (C)opyright 1989 by the VAXBusters International.
  248.    You may give around this work as long as you don't pretend you wrote it.
  249. _______________________________________________________________________________
  250.