Hello Tenderfoot hackers, welcome you to the world of hacking. You came here because you don’t want to be a script kiddie in this generation of hacking. you need to know how to write your own hacking tools and also you have to know how to write your own malware(ie:-virus, trojan, spyware, ransomware,….) and many more.

Before deep-diving into a programming session at first, we have to know some basics of computation and many more beyond hacking.

Computer:

It is an electronic device that takes input, Process it, and gives Output.

The electronic → Amount of Current is very low(Computer, Calculator…).The electrical → Amount of current is very high(Fan, AC…).

Binary Concept:

01001000 01100101 01101100 01101100 01101111 00100001(Hello!)

There is nothing like 0 and 1 in the computer, it is only a concept to show the presence and absence of a charge. There is no physical significance to it.

It is a number system of base 2, which means only two elements present in it (ie:-0 and 1).

It represents text, computer processor instructions, or any other data using a two-symbol system. The two-symbol system used is often “0” and “1” from the binary number system. The binary code assigns a pattern of binary digits, also known as bits, to each character, instruction, etc.

Any information can be encoded as a sequence of 0 & 1.

RAM is made up of capacitors and capacitors are used to hold a charge, If capacitors have a charge then it is denoted by 1 and if capacitors have no charge then it is denoted by 0.

Hardware and Software:

The computer is a combination of hardware and software. Hardware is a physical part of the computer that causes the processing of data, we can touch it and it consists of interconnected electronic devices that we can use to control the computer’s operation, input and output. Examples of hardware are CPU, keyboard, mouse, hard disk, etc.

Software is a set of instructions that tells a computer exactly what to do. It is a set of instructions that drive the computer to do stipulated tasks called a program. Software instructions are programmed in a computer language, translated into machine language, and executed by a computer. The software can be categorized into two types −

System software:

System software operates directly on hardware devices of computers. It provides a platform to run an application. It provides and supports user functionality. Examples of system software include operating systems such as Windows, Linux, Unix, etc.

Application software:

Application Software is the type of software that runs as per user request. It runs on the platform which is provided by system software. High-level languages are used to write the application software. It is a specific purpose software.

Note: Without system software, the system can not run on the other hand without application software, the system always runs and application software runs on system software.

Input & Output devices:

A device that takes input from the user is known as an input device and a device that shows the result of any operation is called an output device.

There are many input devices such as a keyboard, mouse, webcam, microphone, and more, which send information to a computer system for processing. An output device, like Monitor, printer, and more, displays the result of processing generated by input devices. Input devices only work for giving input of data to the system, and output devices accept the output after processing data from other devices.

In C language we consider the keyboard as an Input device and the monitor as an Output device.

Operating System:

It is system software that provides an interface between user and machine. It acts as a manager of the computer system. It does process management, memory management, and file management.

example: Kali, Linux, Windows, macOS, Ubuntu ….etc.

Device Drivers:

In computing, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer or automaton. A driver provides a software interface to hardware devices, enabling operating systems and other computer programs to access hardware functions without needing to know precise details about the hardware being used.

C Language is extensively used for developing device drivers.

Basic Terminology:

Program: a set of instructions is called a program.Process: active state of a program is called a process.file: file is a data bundle.data: data is information that has been translated into a form that is efficient for movement or processing.folder or directory: It is a collection of files.

Introduction to C language:

C programming is considered as the base for other programming languages, that is why it is known as the mother language of all programming languages.

It is developed by Dennis Ritchie in 1972, At AT&T Bell Labs,USA. It is developed for creating system applications that directly interact with the hardware devices such as drivers, kernels, etc. He was the Co-developer of the UNIX Operating System.

From my point of view if someone starts their programming journey with the ‘C’ language their basic concepts got strong with compare to others. They feel fewer difficulties to learn any other programming language in their life.

For that, if you directly learn Java or C++ without learning or knowing the concept of the C language you feel too many difficulties in learning it. You don’t have that level of the base to learn it so at first, I recommend learning the C language in your life.

C is called middle-level language because it actually binds the gap between a machine-level language and a high-level language. A user can use c language to do System Programming (for writing operating systems) as well as Application Programming (for generating menu-driven customer billing systems)

In Hacking World, you can write a backdoor in it or any malware which is not easily detected by antiviruses because it supports system programming also.

In Reverse Engineering it is very helpful to understand the meaning of a compiled binary in ghidra.

If you want to contribute or understand the process of the Linux kernel it can help you a lot because Linux kernel is written in C language.

Why Coding exists:

We already know that computers only understand binary language. So if we assign a task to a computer to perform it we have to give that task in binary language.

Binary language is a combination of lots of 0 and 1. If we want to make a set of tasks to be done by computer it is very difficult to do it and also we can’t debug it if it shows any error

For Solving this type of Problem Humans made a programming language in their understandable language. Then after they design software as per an operating system that converts their language to binary language and easily runs on that operating system.

For that, we write a code in the English language. then process it through a software that is called a compiler or interpreter that converts the English language to binary language. and now if we run that binary language then the task will be performed whatever we wrote in that programming language.

Compilation of a C program:

Here, we are going to know about how a c program has complied.

At first, we wrote a C program in any code editor and saves it with the .c extension.

2. Then a software called the Preprocessor runs and it replaces header files with their contents. what line is to be performed by a preprocessor is specified with the ‘#’ symbol. and it generates a file with .i extension.

3. Then after the file which is obtained by the preprocessor is going to be proceeded by the compiler which is a software that converts all the programming language into binary language. to make it executable by an operating system. It generates a file with the .obj extension.

note: For every Operating System different compilers exist in the market. Which compile that program to run on that OS. ie: if we want to make a software to be run on windows then we have to use windows based compiler.

4. At last software is to be run on a file obtained by the compiler that is called a linker that links all the library files with compiled code.

Now, after all of these processes, a file with a .exe extension is generated and it is called a final product you can run it or share it with anyone.

Execution of a program in C language:

At first, we have a binary file that is going to be executed which is of .exe extension. It stores in our hard disk when we double click on it, OS generates its copy in RAM.

Then after all the instructions are going to the processor by line.

Every Instructions saves on MU(Memory Unit), Which contains some registers in it to store those instructions.

Then, In the processor CU(Control Unit) is a circuit that reads instructions and decodes them. and also tells ALU to perform what type of operation with given data.

ALU (Arithmetic Logic Unit): responsible for all arithmetical and logical calculations.

Then after the Input/Output Device is called by the preprocessor as per their task.

Thanks, for Reading I will meet with you in next article.

C Language for Hackers & Beyond! 0x01 was originally published in InfoSec Write-ups on Medium, where people are continuing the conversation by highlighting and responding to this story.