home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LINUX / HOWTO / mini / trmfwall.txt < prev    next >
Text File  |  1997-07-07  |  11KB  |  287 lines

  1. ** HOWTO: Using Term to Pierce an Internet Firewall
  2. Copyright (C) 1996 Barak Pearlmutter <barak.pearlmutter@alumni.cs.cmu.edu>.
  3. Disclaimer: Below & Important!
  4. Revised: 22-May-1996
  5.  
  6.  
  7.  
  8. * Abstract:
  9.  
  10. Directions for using "term" to do network stuff through a TCP firewall
  11. that you're not supposed to be able to.
  12.  
  13.  
  14.  
  15. * Table of contents:
  16.  
  17.  Disclaimer
  18.  Introduction
  19.  The basic procedure
  20.  Detailed directions
  21.  Multiple term sockets
  22.  The ~/.term/termrc.telnet init file
  23.  Direction
  24.  Security
  25.  Telnet mode
  26.  Bugs and term wish list
  27.  Tricks that don't seem to work
  28.  
  29.  
  30.  
  31. * Disclaimer * <------- !!! READ THIS IMPORTANT SECTION !!!
  32.  
  33. I hereby disclaim all responsibility for this hack.  If it backfires
  34. on you in any way whatsoever, that's the breaks.  Not my fault.  If
  35. you don't understand the risks inherent in doing this, don't do it.
  36. If you use this hack and it allows vicious hackers to break into your
  37. company's computers and costs you your job and your company millions
  38. of dollars, well that's just tough nuggies.  Don't come crying to me.
  39.  
  40.  
  41.  
  42. * Copyright
  43.  
  44. Unless otherwise stated, Linux HOWTO documents are copyrighted by their
  45. respective authors. Linux HOWTO documents may be reproduced and distributed 
  46. in whole or in part, in any medium physical or electronic, as long as
  47. this copyright notice is retained on all copies. Commercial redistribution 
  48. is allowed and encouraged; however, the author would like to be notified of 
  49. any such distributions. 
  50.  
  51. All translations, derivative works, or aggregate works incorporating 
  52. any Linux HOWTO documents must be covered under this copyright notice. 
  53. That is, you may not produce a derivative work from a HOWTO and impose
  54. additional restrictions on its distribution. Exceptions to these rules
  55. may be granted under certain conditions; please contact the Linux HOWTO
  56. coordinator at the address given below.
  57.  
  58. In short, we wish to promote dissemination of this information through as
  59. many channels as possible. However, we do wish to retain copyright on the
  60. HOWTO documents, and would like to be notified of any plans to redistribute
  61. the HOWTOs. 
  62.  
  63. If you have questions, please contact Greg Hankins, the Linux HOWTO 
  64. coordinator, at gregh@sunsite.unc.edu via email, or at +1 404 853 9989.
  65.  
  66.  
  67.  
  68. * Introduction
  69.  
  70. The "term" program is normally used over a modem or serial line, to
  71. allow various host-to-host services to flow along this simple serial
  72. connection.  However, sometimes it is useful to establish a term
  73. connection between two machines that communicate via telnet.  The most
  74. interesting instance of this is for connecting two hosts which are
  75. separated by ethernet firewalls or SOCKS servers.  Such firewalls
  76. provides facilities for establishing a telnet connection through the
  77. firewall, typically by using the SOCKS protocol to allow inside
  78. machines to get connections out, and requiring outside users to telnet
  79. first to a gateway machine which requires a one-time password.  These
  80. firewalls make it impossible to, for instance, have X clients on an
  81. inside machine communicate with an X server on an outside machine.
  82. But, by setting up a term connection, these restrictions can all be
  83. bypassed quite conveniently, at the user level.
  84.  
  85.  
  86.  
  87. * The basic procedure
  88.  
  89. Setting up a term connection over a telnet substrate is a two-phase
  90. process.  First your usual telnet client is used to set up a telnet
  91. connection and log in.  Next, the telnet client is paused and control
  92. of the established telnet connection is given to term.
  93.  
  94.  
  95.  
  96. * Detailed directions
  97.  
  98. In detail, the process goes like this.
  99.  
  100. First, from a machine inside the firewall, telnet to a target machine
  101. outside the firewall and log in.
  102.  
  103. Unless you are under linux and will be using the proc filesystem (see
  104. below) make sure your shell is an sh style shell.  Ie if your default
  105. shell is a csh variant, invoke telnet by
  106.  
  107. (setenv SHELL /bin/sh; telnet machine.outside)
  108.  
  109. After logging in, on the remote (outside) machine invoke the command
  110.  
  111.     term -r -n off telnet
  112.  
  113. Now break back to the telnet prompt on the local (inside) machine,
  114. using ^] or whatever, and use the telnet shell escape command ! to
  115. invoke term,
  116.  
  117.     telnet> ! term -n on telnet <&3 >&3
  118.  
  119. Et voila!!!
  120.  
  121. (If you have a variant telnet, you might have to use some other file
  122. descriptor than 3; easy to check using trace.  But three seems to work
  123. on all bsd descendent telnet clients I've tried, under both sunon 4.x
  124. and the usual linux distributions.)
  125.  
  126. Some telnet clients do not have the ! shell escape command.  Eg the
  127. telnet client distributed with Slackware 3.0 is one such client.  The
  128. sources that the Slackware telnet client is supposedly built from,
  129. ftp://ftp.cdrom.com:/pub/linux/slackware-3.0/source/n/tcpip/NetKit-B-0.05.tar.gz
  130. have the shell escape command.  A simple solution is therefore to
  131. obtain these sources and recompile them.  This unfortunately is a task
  132. I have had no luck with.  Plus, if you are running from inside a SOCKS
  133. firewall, you will need a SOCKSified telnet client anyway.  To that
  134. end, I was able to compile a SOCKSified telnet client from
  135. ftp://ftp.nec.com/pub/security/socks.cstc/socks.cstc.4.2.tar.gz
  136. or if you're outside the USA,
  137. ftp://ftp.nec.com/pub/security/socks.cstc/export.socks.cstc.4.2.tar.gz
  138.  
  139. Alternatively, under linux kernels up to 1.2.13, you can pause the
  140. telnet with ^]^z, figure out its pid, and invoke
  141.  
  142.     term -n on -v /proc/<telnetpid>/fd/3 telnet
  143.  
  144. This doesn't work with newer 1.3.x kernels, which closed some
  145. mysterious security hole by preventing access to these fd's by
  146. processes other than the owner process and its children.
  147.  
  148.  
  149.  
  150. * Multiple term sockets
  151.  
  152. It is a good idea to give the term socket an explicit name.  This is
  153. the "telnet" argument in the invocations of term above.  Unless you
  154. have the TERMSERVER environment variable set to telnet as appropriate,
  155. you invoke term clients with the -t switch, eg "trsh -t telnet".
  156.  
  157.  
  158.  
  159. * The ~/.term/termrc.telnet init file
  160.  
  161. I have checked line clarity using linecheck over this medium.  I
  162. expected it to be completely transparent, but it is not.  However, the
  163. only bad character seems to be 255.  The ~/.term/termrc.telnet I use
  164. (the .telnet is the name of the term connection, see above) contains:
  165.  
  166.     baudrate off
  167.     escape 255
  168.     ignore 255
  169.     timeout 600
  170.  
  171. Perhaps it could be improved by diddling, I am getting a throughput of
  172. only about 30k cps over a long-haul connection through a slow
  173. firewall.  Ftp can move about 100k cps over the same route.  A
  174. realistic baudrate might avoid some timeouts.
  175.  
  176.  
  177.  
  178. * Direction
  179.  
  180. Obviously, if you are starting from outside the firewall and zitching
  181. in using a SecureID card or something, you will want to reverse the
  182. roles of the remote vs local servers given above.  (If you don't
  183. understand what this means, perhaps you are not familiar enough with
  184. term to use the trick described in this file responsibly.)
  185.  
  186.  
  187.  
  188. * Security
  189.  
  190. This is not much more of a vulnerability than the current possibility
  191. of having a telnet connection hijacked on an unsecured outside
  192. machine.  The primary additional risk comes from people being able to
  193. use the term socket you set up without you even being aware of it.  So
  194. be careful out there.  (Personally, I do this with an outside machine
  195. I know to be pretty secure, namely a linux laptop I maintain myself
  196. that does not accept any incoming connections.)
  197.  
  198. Another possibility is to add "socket off" to the remote
  199. ~/.term/termrc.telnet, or add "-u off" to invocation of term.  This
  200. prevents the socket from being hijacked from the remote end, with only
  201. a minor loss of functionality.
  202.  
  203.  
  204.  
  205. * Telnet mode
  206.  
  207. Be sure the remote telnetd is not in some nasty seven-bit mode.  Or if
  208. it is, you have to tell term about it when you invoke term, by adding
  209. the -a switch at both ends.  (I sometimes use "^] telnet> set outbin"
  210. or "set bin" or invoke telnet with a -8 switch to put the connection
  211. into eight-bit mode.)
  212.  
  213.  
  214.  
  215. * Bugs and term wish list
  216.  
  217. The linecheck program has some problems checking telnet connections
  218. sometimes.  This is sometimes because it doesn't check the return code
  219. of the read() call it makes.  For network connections, this call to
  220. read() can return -1 with an EINTR (interrupted) or EAGAIN (try again)
  221. error code.  Obviously this should be checked for.
  222.  
  223. There are a number of