Saturday, August 30, 2008

Getting Serious with Win95

GUIDE TO (mostly) HARMLESS HACKING

Microsoft-only version Number 1


____________________________________________________________
by KeyDet89
************************************************************
In this Guide you will learn:
1.  Important files on your system.
2.  My first program.
3.  Getting help.
4.  Finding out about programs.
5.  What can I do with an Internet connection?
************************************************************

Well, you're in luck, the answer is a resounding YES!!
However, there is a very basic step that must first be taken, and that is to
define what is meant by "hacking."  We'll start with what hacking is
not...it's not denial of service (DoS) attacks, nuking, mail bombing, IRC,
or ICQ.  Anyone can run a program, but a hacker learns how things work, and
tries to push them to their limits.  Exposing vulnerabilities is only part
of what a hacker does, and when he finds them, the hacker has the maturity
and sense of responsibility to not use the vulnerability for his own gain.
The Hacker Manifesto clearly states "thou shalt do no harm."

**Historical Note:  If you want a role model for becoming a
hacker, try these names:  Dennis Ritchie, Bob Metcalfe, Steve Wozniak, and
yes, Bill Gates.

With that aside, on with the show.  Past editions of the Guides to (mostly)
Harmless Hacking have talked about how to make modifications to a Win95
system to WOW your friends.  The point of those articles was that you can
begin hacking by learning all there is to know about your system.  I know a
lot of text files out there talk about using Linux and FreeBSD, shell
accounts, Un*x tools, and telnet, but if you don't have any of these
available to you, not to worry.  You can still learn, which is the whole point.

**Note:  Linux and FreeBSD are freeware or commercial (depending upon where
you go) versions of Un*x that run on the Intel platform (a PC computer).
These systems have uses throughout academia and research facilities, but
maybe a bit difficult to get running on your own system unless you know
quite a bit about your system and the operating system. The word "Un*x" uses
the star to refer to the various flavors of
the Unix operating system.

1.  IMPORTANT FILES ON YOUR SYSTEM.

The first thing we'll look at are the important files of the Win95
operating system.  The autoexec.bat, config.sys, win.ini, and
system.ini files are holdovers from DOS, but are also still used.
The config.sys file is used to configure hardware on your system
and the autoexec.bat file is used to load parameters and environment
variables that are needed when your system first starts.

In the next section, we'll discuss how to load environment
variables for specific purposes using batch files.  We'll look
specifically at the autoexec.bat file, as it will lead into
batch file programming in the next section.

To take a look at this file, go to the DOS prompt and type:

c:\>edit autoexec.bat

Your screen will turn blue when the editor opens and the autoexec.bat file
will be loaded automatically, because it's located in the current directory.
If you had typed:

c:\>notepad autoexec.bat

the file would've been opened in NotePad.  Use whichever is easier.

**Note:  This leads us to the subject of paths.  Paths in DOS are
areas where DOS will look on your hard drive for programs that you
type in at the prompt.  You may have the program on your hard drive
but you won't be able to run it from the prompt unless it's in your
path or you are in the directory where the program resides.

One command that should be visible in the autoexec.bat file is the
PATH statement.  It may look something like this:

SET PATH=.;c:\;c:\Windows;c:\windows\command

You don't need much more than this in your path, and you don't want it to
get out of control, so it's best if you leave it like as it is.  The "."
(period) that is in the beginning of the line says to begin the search for
the command in the current working directory.

You can add other tasks in the autoexec.bat file that you want run
upon startup, and you can even include command line parameters, as
necessary.

Now let's change directories at the DOS prompt:

c:\>cd windows

Now open the win.ini file in Notepad, and take a look at it.  We're not
going to make any changes to it, or go into a long explanation
of it's contents.  You can see that it contains different sections
that pertain to different components and applications on your
system.

**************************************************************
Evil Genius\Elite Hacker Tip:  Go to the section of the win.ini
file called "[Extensions]".  One of the first lines should be:

txt=notepad.exe ^.txt

You can use this line to plant messages on your computer.  Simply
change the reference to a batch file that contains some commands
and the line:

notepad %1 %2 %3 %4

...at the end.
***************************************************************

Now, open the system.ini file.

**Note:  To avoid having to type the same commands over and over,
type in "doskey" at the prompt, or edit the autoexec.bat file
to include the command "doskey on".  Then when you are in a DOS
window, you can hit the up and down arrow keys to move amongst
commands you've already typed in.

You'll see that the system.ini file contains sections similar to
the win.ini file.

*****************************************************************
Evil Genius\Elite Hacker Tip:  Go to the "[boot]" section and locate the
line that reads:

shell=Explorer.exe

This is the line that tells Win95 which shell to use for your
system.  The commands that control what colors to use are located
in the win.ini file.  However, you can change shells.  Change the
line to read:

shell=progman.exe

The next time you reboot the computer, the old Win3.1 Program
Manager shell will be loaded.
******************************************************************

2.  MY FIRST PROGRAM.

Most program languages that I have used have all started out
with the ubiquitous "Hello, World" program, so we'll start there.

A batch file is really more of an interpreted file.  The system
reads the file, and executes the commands within the file one at a time.
You can run into problems if the command you put into the file requires
input from the user, but some useful tasks can be accomplished through the
use of batch files.

So, for our first program, type:

@echo off
echo Hello, World!

Save the file as "hello.bat", and at the prompt, type:

c:\>hello

You have now written your first program!

Now, open hello.bat again, and type change the second line to:

echo Hello, %1

Save this, and run the program again, but enter in an argument:

c:\>hello Dave

What the "%1" does is take the first argument ("Dave") and includes it in
the echo statement.

You can use batch file programming to load specific environment
variables, as well.  If you do Java programming, for instance, you can leave
the autoexec.bat file the way it is, but you will need to load specific
environment variables so that you can use your development environment,
specifically the JDK from Sun.  So type:

@echo off
SET PATH=%PATH%;c:\java\;c:\java\bin
SET CLASSPATH=c:\java\lib\classes.zip
SET JAVAHOME=c:\java

Save this file as "java.bat" and whenever you want to do some
development, run the file.  You can even include a reference to the batch
file in the autoexec.bat file.  Notice the "%PATH%" in the second
line...this is an environment variable that exists for the DOS environment.
It refers to the PATH variable, as it exists before you run the new batch
file.  To view the path, type:

c:\>path

3.  GETTING HELP.

It's actually pretty easy to find out about particular things on
your Win95 computer.  The first and easiest way to find anything is to use
the Start -> Help (click on the Start button, then choose Help) feature.
>From there select a topic.  Some of the entries are pretty detailed, with
examples.

A resource that is very often overlooked by folks who are new to
computing in general is your local public library.  DOS has been available
for quite a while, and you will likely find books about DOS and Windows at
the library.  Some books even cover the specifics of batch files or other
aspects of DOS, and will prove to be very useful.  Now, you won't be
interested in sections on EDLIN, but you find lots of valuable information.

After libraries are used bookstores.  Lots of folks would rather
sell their old books rather than donate them to a library.  You can find
many useful books on a wide range of subjects.

Finally, new bookstores, such as Barnes and Noble, Borders, and
especially Computer Literacy are excellent sources of information. If you
can't afford some of the new books, don't worry.  Just drop by the
bookstore, look something up, and put the book back. Many of these
bookstores also carry a wide variety of magazines, many of which are
specific to computer systems.  There are even magazines available for Atari
and Amiga systems!

4.  FINDING OUT ABOUT PROGRAMS.

While in DOS, if you want to get some quick information about a command on
your computer and don't want to go through the steps of opening the online
Help, just type the command, followed by "/?":

c:\>edit /?

This provides a quick explanation of the command and a list of
arguments that can be used with it.  Keep in mind that this
technique works with DOS commands...programs written by folks
outside of Microsoft don't have to provide this functionality.

5.  WHAT CAN I DO WITH AN INTERNET CONNECTION?

So you have an Internet connection, eh?  Well, you already have
a shell account, of sorts.  It's your DOS window.  Yes, you can run commands
from your DOS window, as well as from the GUI.  For example, once you have
connected, try this:

c:\>telnet rs.internic.net

This will open up a telnet window directly to InterNIC.  After the
host, you can even specify a port:

c:\>telnet [host] [port]

This is useful if you want to see if a host has a particular port
open.

Your system also has a command line FTP program.  Just type:

c:\>ftp [host]

and it will attempt to connect you to the host.  You can use
this FTP client to connect to your own ftp sites, or to anonymous
ftp sites such as ftp.microsoft.com.

There are also other commands that you can use in a networked
environment, but they will be covered in another article.

___________________________________________________________
To subscribe to Happy Hacker and receive the Guides to (mostly) Harmless
Hacking, please email hacker@techbroker.com with message "subscribe
happy-hacker" in the body of your message.
Copyright 1998 KeyDet89 <keydet89@yahoo.com>. You may forward or post this
GUIDE TO (mostly) HARMLESS HACKING on your Web site as long as you leave
this notice at the end.