How to Program in
C
_________________________________________________________
Guide to (mostly) Harmless Hacking
Vol. 5 Programmers' Series
No. 4: How to Program in C, part 1
_________________________________________________________
New hackers have been going by the droves to the top two places
to get
computer break-in programs: http://www.rootshell.com
and http://www.securityfocus.com.
Then they try to stick these things into the windows of their
Web browsers, throw them at their would-be victim computers via
telnet and ftp, print them out and burn them at altars. OK, I'm
exaggerating, but only a tiny bit. Their problem is that they
don't know how to use these exploit programs.
The reason for this cluelessness is that they don't know how
to program. To be specific, they don't know how to program in
C on a Unix type computer! The problem is that there are so many
super easy ways to break into computers, and so many hackers
who never learned to program, that lots of people assume it is
all easy. But if you are serious about breaking into well-defended
computers, and especially if you are serious about learning how
to defend Unix type computers, you must learn how to write, patch
and compile C code into working programs.
If you aspire to become an Uberhacker against Unix systems,
you absolutely
MUST become a C programmer. One heck of a good C programmer!
If you want to escape us playing practical jokes on you when
you play Hacker Wargames, you absolutely MUST become a C programmer.
**********************************************************
In this Chapter you will:
In order to do this lesson, you must have a shell account,
whether at an ISP or by running some kind of Unix (for example,
Linux) on your home computer. DO NOT email us asking how to get
a shell account! The answer is in the chapter "How to Get
a Good Shell Account."
Why is C the single most
important programming language for a hacker to learn?
C is the language in which the Unix class of operating systems
is for the most part written. It also is the language of almost
all applications that run on Unix.
As one of my hacker friends who insists on anonymity explains,
both Unix and C "were developed by the same team at Bell
labs, and compliment each other nicely. Unix was not originally
written in C, but was re-written in C to make it easier to understand/maintain/debug
and a lot of other reasons. This was not without controversy,
but it was Ritchie's decision (the inventor of C), and I believe
he was proven right."
Not surprisingly, then, most exploits are also written in
C. True, you don't even need to learn to compile a C program
to use these exploits -- if you can get someone else to give
you a version of that exploit compiled to run on the type of
operating system and shell you are planning to use for the break-in.
**********************************************************
Newbie note: Wonder why there are all those "Free Kevin
Mitnick" Web sites in the haxor scene? Many people think
it is ludicrous to keep that man behind bars because he was such
a lame hacker that he apparently didn't even know how to program.
In fact, there is evidence that he didn't even compile his own
C programs! There are transcripts of him on IRC begging his friends
to compile programs for him. Note: Mr. Mitnick disputes this
statement, threatens a lawsuit, and we dispute him right back.
Click here to read all about
it.
**********************************************************
C is especially important for White Hat hackers because you
don't have a prayer of a chance to patch security holes in your
computer unless you can compile and run C programs to fix the
problem parts of your operating system.
Meino Christian Cramer adds, "And: using precompiled
binaries/executables is always a risk. Think of the ... viruses
introduced to computers by simply executing 'I-believe-it-has-no-virus'-programs.
Using the source code instead... you can check the code for "back
doors" and 'traps' -- which means you have to learn 'the
one and only' C..."
C also is good for hacking because it is able to run "low
level" code as part of its language. In programming, "low
level" means that you can play with the most basic things
on your computer, for example opening and closing sockets or
linking to the information on what sockets are open at any given
instant.
**********************************************************
Newbie note: A socket is a round-trip or two-way network connection.
For example, when you telnet into another computer's login sequence,
you connect to port 23 on that computer. It completes a round-trip
connection by assigning some high number port, for example port
3587, to complete the socket. If you have a shell account on
a good ISP, you can see everyone's sockets by giving the "last"
or "netstat" commands.
**********************************************************
Another important thing about C being a high level language
that easily incorporates low level (assembly language) commands
is that you can write it to run super fast.
More C programming --->>