Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!

TUCoPS :: Unix :: General :: unix1.txt

HALE's Unix Hacking 1 of 2

                           A HALE Production
        H ackers        A gainst           L aw        E nforcement
                     Call HALE Hq. (619)660-67xx
        Active HALE members are: Ripper, Trashman, Rush2112.
        The Underground Newsletter: Vol I.  Issue I, Part I
Note:	Feel free to distribute the file provided none of its contents or 
	credits are changed.
Topic:	A Guide to Unix Systems, Part I.
Date:	September 1, 1989.
Foreword:  This file is compiled from my experiences on both BSD and Sys V 
	   Unix on VAX 750/780 mainframes, AT&T 3B20 and Pyramid Technology's

	In today's world, as a hacker, you are nothing unless you learn some
of the more popular operating systems around used on minis, mainframes, super-
computers and the like.  In this file I will attempt (to the best of my 
ability) to introduce you to one of those operating systems - namely - the
world of Unix.  It is hoped that by reading this file you can pick up perhaps
enough of a working knowledge so that if by chance in your hacking exploits you
come across a Unix system (and you will) you'll know what to do.
	There is NO WAY to cover everything about Unix in a file so this will
be the first of many that I hope to release in the future.  If I find there are
stuff I have not mentioned I will write more files as needed.  In Part II, I
plan to give you a tutorial on what to do while you're on-line in regards to
hacking and using essential system utilities.  Have fun.
	Usually (unless modifified by the system administrator or one with such
privileges), you can tell if you've connected to a Unix system of some type by
the login prompt which looks like this:


Pretty simple huh?  Anyway, that is the standard login prompt, it may or may
not be preceded by a message telling you what type of Unix or system you have
connected to. 
	If you try to login with an illegal login name and/or an illegal
password the system will respond as such and as you to try again:

login incorrect
(Note the password is not echoed in any form)

	In Part I of this Unix tutorial I'd like to start with an overview of 
the Unix system before I get into some of the more interesting stuff (so bear 
with me all you Unix experts).  Then I will go through the login process and
the /etc/passwd file and how it is structured.  This will not be an in-depth
look at all, merely an overview.  Some day I will write an in-depth study to
accompany this file and the files that follow for the more advance user/hacker.

	There are basically 2 types of Unix systems that you will most likely 
come across.  They are:

I.  BSD Unix - from UC Berkeley's (B)erkeley (S)oftware (D)istributors
II. System V UNIX - from AT&T (how nice - I know all you phreakers are smiling!)
(Other spinoff's of the above 2 will not be discussed - such as Ultrix,
 Minix, Xenix, etc...)

	They are alike in many respects but both have their differences, hence
their are advantages and disadvantages to both of the systems, BSD and Sys V.
Perhaps the main difference between the two are the default shell that each
uses as the user interface to the system utilities.
	BSD Unix defaults to the csh (C-Shell) while AT&T's Sys V uses the sh
(Bourne shell).  But on both of these systems both shell types are available to
the user.  A third optional shell which is also pretty popular is the ksh 
(Korn shell).  The way to recognize the default shells when you see them is by
their default prompt.  The csh uses the % symbol as the prompt while the sh
uses the $ symbol as the prompt.
	Now let's talk about files, shall we?  The MOST important file of all
on ANY UNIX system is the password file.  This file holds information about 
all the accounts on the system, passwords, and other information.  Without 
this file no one can log in and use the system.  You can find this file on any
system in the /etc directory.  It is called simply 'passwd'.  The full 
pathname is /etc/passwd (of course).

	The /etc/passwd file is stuctured as such:
Each user has an entry in the passwd file that holds his account information.
Among the information included on each user entry line is his login name,
his password (encrypted), his user id, his group id, his home directory, his
name, and his startup program if any.   Basically it looks something like this:

------------------------ Sample /etc/passwd file  -------------------------- 
		       General format of each entry:
login:password:user-ID:group-ID:info:home directory:startup program

root:Arllz76Dnq:0:0:The & of All Evil:/:/bin/csh
jsmith:Yi83amq9:102:100:John Smith:/usr/jsmith:/bin/sh
who::99:500:Who's on:/usr/ucb:/bin/who
daemon:r6Eeu:1:1:The DEVIL himself:/etc:/bin/csh
bin:mb033yt:3:3:The Keeper of the Flame:/etc:/bin/csh
info::508:501:Library user group:/usr2/info:/usr2/bin/rsh
..... [ and so on ]
	Now we'll examine each entry.  Remember that each field is separated 
by the colon.  So in the first entry in /etc/passwd given above, we can tell 
the following about the  entry.

login name is:		root
Password (encrypted):	Arllz76Dnq
User ID:		0
Group ID:		1
Info (usually owner):	root
Home Directory:		/
Startup Program:	/bin/sh

The second entry in /etc/passwd looks like this:
login name is:		jsmith
Password (encrypted):	Yi83amq9
User ID:		102
Group ID:		100
Info (usually owner):	John Smith
Home Directory:		/usr/jsmith
Startup Program:	/bin/sh

	But now you get the general let's discuss some things
about the field.

I.	The login field
   This is the login name that you use to login at the prompt of the Unix 
system.  During the login process, after you enter the login and the password
the system will then call routines to search the 1st field of each entry
in /etc/passwd to see if any login names match up with the one you have given
it.  If none exists it will report the "login incorrect" message and start
prompting for a new login name and new password.

II.	The Password field
   If the login name is valid, Unix then takes your password entry and encrypts
it then compares it against the encrypted password in the 2nd field of the 
login name entry (see I.  The login field).  If the two passwords match up, the
login process will continue, otherwise the "login incorrect" message will be 
displayed.  I'll explain later what goes on when comparisons of the encrypted
passwords take place.  If the Password Field contains null :: then no password
is needed and the system logs you into the home directory and executes the 
startup program.  If the Password Field contains :,.: then upon login the
system will run the passwd utility and assign that account a password.  (This
is nice if you're a system administrator, you create an account for your 
friend then put the ",." in the password field and he'll set his own password
upon login.

III.	The UID (UserID) field
   If everything is correct (login name and password) then the system proceeds
to put your in your home directory.  You are then given a UID from your entry
in the /etc/passwd file.  All UID's fall in the range 0-65535 with 0 as the 
superuser UID (see /etc/passwd example).  The system reserves UID 0-99 for 
special accounts.  UID's are used by the system and its utilities to control 
both access levels and file ownership (as determined by the ls utility - more 
on that later).  

IV.  	The GID (GroupID) field
   The Group ID is used to associate the user with a certain group, used by
Unix primarily for access levels as determined by file protections.  (i.e.
a member who is not in a group can not get group privileges on files for that
group, even though file protections for the file say all privileges to group
users.)  GID's fall in the range 0-655535 with GID 1 being the default.  All
GID's between 0-99 are reserved.

V.  	The Information field
   This field usually holds the account owner's	name though it can be used
for anything actually.   I have seen it used to describe the account function
(see the sample /etc/passwd file on the entry for login name "who"), and also
to hold people's phone extension, etc..

VI.  	The Home Directory Field
   This field should have the full pathname to your home directory.  On many
UNIX systems it is usually in the format of /usr/{loginname} (See the
entry for login name "jsmith").  Not necessarily your PERMANENT home 
directory, one can change it by reassigning an alternate path to the system
variable $HOME (on Sys V). 

VII.  	The Program Field 
   Usually this field holds the startup program to execute once the login
procedure has been completed.   If left blank then the default startup program
will be the shell assigned to the Unix system.  In the our example /etc/passwd
file, the entry for login name who, will execute the who command in /bin/who
once you log in.  However, after the command finishes executing, it will exit
the system as there is no password on the account, there is no way to stay
logged in.  On the info account however, you will remain login until you type
exit or logout or CTRL-D as the program running there is a shell.  Though not
a full Bourne shell or C-shell, the restricted shell (rsh) does allow to you
play around a little.  

	Well, that about does it for what I want to cover in Part I.  Look for
Part II coming out real soon.  I will be going into details what to do once
online with an account and how to go about getting an account.  This file is
for informational purposes only.

Brought to you by: The Apple Bandit 10-89

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2014 AOH