old-www/LDP/LG/issue41/nielsen1.html

157 lines
7.8 KiB
HTML

<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.08 [en] (X11; I; Linux 2.0.36 i586) [Netscape]">
<TITLE> Breaking Into Your Own System LG #41</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!--endcut ============================================================-->
<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H1><font color="maroon">Breaking Into Your Own System</font></H1>
<H4>By <a href="mailto:mark@tcu-inc.com">Mark Nielsen</a></H4>
</center>
<P> <HR> <P>
Hello!
<BR>If there are any changes to this article, it will be located at <A HREF="http://www.tcu-inc.com/mark/articles/Breaking.html">http://www.tcu-inc.com/mark/articles/Breaking.html.</A>&nbsp;&nbsp;&nbsp;&nbsp;
This brief article is just my easy way to break into my own system if I
screw up the root password. There are much easier ways to do it, but this
can also be used if you cannot log into your system if a configuration
file is messed up.
<P>Okay, this isn't a Linux independent OS solution. I use a bootable cdrom
that I got from www.cheapbytes.com which is a cheapbytes version of the
RedHat 5.2 cd.
<P>For this documentation, I am going to assume the computer is partitioned
in the following manner:
<BR>&nbsp;&nbsp;&nbsp; /dev/hda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
swap partition
<BR>&nbsp;&nbsp;&nbsp; /dev/hda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
root partition for Linux or "/"
<BR>&nbsp;&nbsp;&nbsp; /dev/hda3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DOS partition (yes, I know, it is scary to put nasty software on the same
hard drive as Linux)
<P>/dev/hda2 means we are using the master hard drive on the primary IDE
controller and root is on the 2nd primary partition on the hard drive.
If your root is on the first primary partition, it would be /dev/hda1.
<P>Here are the steps I use to hack into my own computer.
<P>1. Make your system bootable off of the cdrom in your computers BIOS.
If your computer doesn't support booting off of the cdrom, then you will
have to figure out how to do it with bootable floppy disks. For me, I just
want to use what is the fastest and easiest method, and so, I boot of off
cdroms. I haven't booted off of a floppy drive in ages.
<P>2. Put in your cdrom into your cdrom drive and turn on your computer.
<P>3.&nbsp; Pretend to go through the installation of RedHat 5.2, and after
it asks you to put in the cdrom and it gets to next screen, you can now
goto the second console window.
<P>4. Press Alt-F2, Alt-F3, Alt-F4, Alt-F5, and then Alt-F1. You should
see various screens with different messages. The one we are concerned about
is Alt-F2.
<P>5. Okay, press Alt-F2.
<P>6. Type "cd /tmp" and press enter.&nbsp; This takes us to a directory
where we can make files, directories, etc.
<P>7. Now we need to make a temporary directory and a temporary device
for the partition on the hard drive that we want to look at or edit. Type
in the following commands
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mkdir /tmp/my_dir
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mknod /tmp/my_dev b 3 2
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mount /tmp/my_dev /tmp/my_dir
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
df
<P>8. "mkdir" makes a directory for us to mount the a partition to.
<BR>&nbsp;&nbsp;&nbsp; "mknod" makes a device for 2nd partition on the
master hard drive. This lets us "see" the partition.
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In particular, "b
3 2" means the following. "b" is for block device. "3" is the master hard
drive on the
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; primary IDE controller
on your computer. "2" means the second partition.
<BR>&nbsp;&nbsp;&nbsp; "mount" takes the device we can "see" and puts it
on top of the directory "/tmp/my_dir"
<BR>&nbsp;&nbsp;&nbsp; "df" just lets you see what file systems are mounted
and where they are mounted to.
<P>Now, for our example, we could either edit the password file or perhaps
do something simple like turning off xwindows from starting up if you have
your computer set to use xdm. Let's do the xwindows example.
<P>10. Do the following steps:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd /tmp/my_dir/etc
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vi inittab
<P>11. Now you need to know how to use vi which is a fantastic editor,
but it is a pain to learn. Here are some simple commands in vi.
<BR>&nbsp;&nbsp;&nbsp; "x" deletes a character.
<BR>&nbsp;&nbsp;&nbsp; "i" makes it so you can insert letters or characters.
<BR>&nbsp;&nbsp;&nbsp; "Esc" turns off inserting characters.
<BR>&nbsp;&nbsp;&nbsp; "wq!"&nbsp; writes, quits, and ignores any problems
with read only files.
<BR>&nbsp;&nbsp;&nbsp; "h" moves one character to the left
<BR>&nbsp;&nbsp;&nbsp;&nbsp; "l" moves one character to the right
<BR>&nbsp;&nbsp;&nbsp;&nbsp; "k" moves up one line
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "j" moves down one line
<P>12. Now, go down to the line which should have something that looks
like
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id:5:initdefault:
<P>&nbsp;&nbsp;&nbsp;&nbsp; Delete the "5" by positioning the cursor at
the "5".
<BR>&nbsp;&nbsp;&nbsp;&nbsp; Press "x".
<BR>&nbsp;&nbsp;&nbsp;&nbsp; Press "i" to insert a number. Press "3".
<BR>&nbsp;&nbsp;&nbsp;&nbsp; Press the "Esc" key.
<BR>&nbsp;&nbsp;&nbsp;&nbsp; Type "wq!" and press enter.
<P>13. Now you are done editing a file! What is the problem now? If you
reboot you will most likely loose all of your changes. You must unmount
the directory and then reboot.
<P>14. Do this
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd /tmp
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; umount /tmp/my_dir
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; df
<P>15. Now Press Crtl-Alt-Del to reboot. Also, take your cdrom out of
the cdrom
drive. When your computer restarts, I would recommend having your BIOS
boot off of the hard drive instead of a CDROM.
<P>That is it! You can also use this method to change the password file
and do other stuff.
<P>Naturally, having a password in your computers BIOS would be ideal.
If you haven't physically secured your computer, then anybody can do this
to the computer. Even if you put a password in the BIOS, someone could
always take out the hard drive by taking apart the computer.
<P>-------------------------------------------------------
<BR>Mark Nielsen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"Where 98 has no meaning."
<BR>www.tcu-inc.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
sales@tcu-inc.com
<BR>The Computer Underground, Inc.&nbsp; 614-485-0506
<BR>computers, programming, networking, Perl, PHP, SQL, HTMl, Linux, Unix
<!--===================================================================-->
<P> <hr> <P>
<center><H5>Copyright &copy; 1999, Mark Nielsen <BR>
Published in Issue 41 of <i>Linux Gazette</i>, May 1999</H5></center>
<!--===================================================================-->
<P> <hr> <P>
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./lg_tips41.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./sevenich.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->