C/C++ Programming for Hackers: Part 2 (The History of C and Coding Our First Program).

Part 2 (The History of C and Coding Our First Program).

Welcome back everyone! in this tutorial, i will talk a little bit about the history of the C programming language aswell as some famous programs that are programmed in this language (it is not really necessary to be able to code in C, but it's still nice to know!). after that, we will go ahead and write our very first program! i will also go in detail on every line and explain exactly what it does.

if you haven't read my previous article yet, you can do it here.

The History of the C Programming Language

C was developed between 1969 and 1973 by Dennis Ritchie at AT&T Bell Labs, and was used to create the Unix operating system (which in turn forms the base of our trust worthy Linux kernel). since then, C has dominated the world of computer programming. it has influenced other programming languages like C++, C#, Java, Python, and many more.

now a little bit about some famous pieces of software written in C. here is a list of them:

  • Tor
  • Windows (the applications that come with it such as the calculator are C++, but at it's core, Windows is still written in C)
  • Unix (the operating system that keeps Google, Facebook and almost every other big website up and running. it wouldn't even surprise me if wonderhowto runs on some kind of Unix)
  • Linux (since Linux is a re-engineered version of Unix.)
  • Android (uses the Linux kernel.)
  • Embedded Systems (C is a lightweight language, therefor it is favored to program embedded systems.)
  • IOS and MacOSX (also uses some kind of Unix kernel.)

as you can see, C is an important language, especially for operating systems. but it is also interesting to us since quite a lot of hacking tools are written in C, like Bully, for example.

ok, enough lecture, let's code!

Step 1: Fire Up Ubuntu and Open a Text Editor of Your Choice

As i said earlier, i will use Ubuntu for this tutorial, but you can use any linux distro you want. once you have fired up Ubuntu, you can go ahead and open a text editor and paste this code in it.

once pasted, it should look like this:

Step 2: Save the File

simply save the file to any directory you want. But remember this directory, as we will need to point the compiler to it. save the file as main.c

MAKE SURE YOU NAME IT main.c the "main" file is always the start file of your program and the .c extension tells our compiler that it is a program written in C. i simply saved the main.c file in my home directory.

Step 3: Compiling

if you have the main.c file in your home directory, you can immediatly go ahead and enter this command:

gcc main.c

if you saved the file somewhere else, you first need to move your terminal to that location using the cd command.

if everything goes alright, you should get no errors and there should be a new file in your directory named a.out.

Step 4: Running Your Freshly Compiled Program

to run the program, first check if you have execution permissions on your a.out file. to do this, open your file explorer > right click a.out > click on Properties > go to Permissions tab > check if "Allow executing file as program" is enabled.

now, just go into a terminal, go to the directory where a.out is saved, and enter the following command:

./a.out

if the program outputs "Hello Null Byte!", congratulations! you've coded your first program!

that is it for now folks! in the next how-to, i will be explaining the code we just wrote, step-by step.

if you have any problems or questions regarding this tutorial, feel free to ask me in the comments bellow!

-Phoenix750

19 Comments

thanks, keep it up.

WonderHowTo runs on Windows Server 2012, not Unix.

Great series, and good work. Keep it up. Bacon, rainbows, and unicorns.

:3

i said that it wouldn't surprise me if it were Unix, to point out that a lot of websites run on Unix based systems (i'm not the kind of guy who nmap's every website i come accross :p).

-Phoenix750

WTF is that xD

I love it ..
(omg I cant get that song out of my head now! PLease make it stop! >
<)
PINK FLUFFY UNICORN DANCING ON RAINBOW whuhu
PINK FLUFFY UNICORN DANCING ON RAINBOW

Great Job, thank you!

Looking forward for part 3

Waiting for the next chapter!

Wappalyzer extension for FF reveals Wonderhowto run on MS server and other MS technologies .
Anyway, It doesn't matter much.
Good Writeup .

Back when I wrote this article I didn't know yet that WHT runs on MS based technologies. It's not like I start doing reconassiance on any website I visit ;)

-Phoenix750

Hi. I am learning C++ and want to know... Is std::cout the same as printf? and if so what is the difference.

std::cout is the equivelant of printf(), but it's not the exact same thing.

-Phoenix750

I can appreciate that this was written for the complete novice. But if you want to get in to the topic of "hacking" serious code and network skills are needed, and installing a simple thing of *nix is a given. Of course ya gotta start somewhere and that is to read the docs. .. installing linux and downloading a sploit from rootshell isnt really what we are about. Reading the docs is a great step. Times have changed from a simple buffer overflow exploit to the modern systems of today

I'm oldschool but I thought i'd throw my pennies out there. DW.

An excellent post. It's very important to read about and understand the systems we work with.

Hey Phoenix I would like to talk to you privately on twitter my name is Sly Sparta or Andrew Freeman

Hey every one i am new here and I liked your post
Made it in my first attempt

Share Your Thoughts

  • Hot
  • Latest