---
title: Including the necessary libraries
course: code_malware
section: "Getting started"
layout: lesson
---

In C there are some types of files which can be included in others, these are
called "headers", they contain information and let you use functions, variables
and keywords that were defined in another place. These are libraries.

In order to properly develop each one of the things that are in our ToDo for the
malware, we'll need to include some libraries, these are the things our malware
will be able to perform:

1. Establish a connection between client and server (the client is the machine
   that awaits for a connection, in other words, the victim. And the server, is
   the one that connects to an address and sends information, that's us. The
   attacker)
2. Emulate a Shell, which will let us to execute commands in the client machine
   remotely
3. Add persistence to our malware, that means, each the infected operating
   system boots, it'll execute our malware as well.
4. Execute other files
5. A Change directory (cd-like) function to navigate through the victim's
   machine
6. A Keylogger (this will let us to capture and store all of the keys the victim
   presses)

To perform all of those tasks, we'll need to include some libraries which will
make the work easier. First, create a new "C" file (with the ".c" extension) and
call it as you want, in my case, I'll call it "Backdoor.c".

> Tip: To include libraries in C, write "#include \<library_name.h>"

We'll need to include the following libraries:

_stdio.h_: Will allow us to use Input/Output functions

_stdlib.h_: Will import some useful functions we'll need later

_unistd.h_: As "_stdlib.h_", this library will import some constants we'll use
later

_winsock2.h_: This library will import the sockets. We'll use them later for
creating a server/client connection

_windows.h_: As we are creating our malware for windows, we'll need this library
as it will let us use some platform-specific functions, constants and keywords

_winuser.h_: This library will let us use effects. We'll use it for hiding our
window, so when the malware is executed, none window will pop up.

_wininet.h_: Some windows-specific internet functions


_windowsx.h_: Some windows-specific useful functions

_string.h_: Will let us to create and manipulate strings

_sys/stat.h_: Will let us to read files metadata (size, name, creation date,
modification date, etcetera)

_sys/types.h_: Datatypes

These are all of the libraries we'll need. If you want a deeper explanation
about them, it's as easy as fire up a web browser and searching for the library
name, for example: "_windows.h_", uou can do this with functions, variables and
every thing you don't understand in the code.

This is our code so far:

```c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <winsock2.h>
#include <windows.h>
#include <winuser.h>
#include <wininet.h>
#include <windowsx.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
```
