• Tidak ada hasil yang ditemukan

CREATING AN HTTP WEB SERVER WITH THE APACHE WEB SERVER

Dalam dokumen LINUX BASICS FOR HACKERS (Halaman 157-160)

The Apache Web Server is probably the most commonly used service on Linux systems.

Apache is found on over 60 percent of the world’s web servers, so any self­respecting Linux admin should be familiar with it. As a hacker aspiring to hack websites, it’s critical to understand the inner workings of Apache, websites, and the backend

databases of these sites. You can also use Apache to set up your own web server, from which you could serve up malware via cross­site scripting (XSS) to anyone who visits your site, or you could clone a website and redirect traffic to your site via abuse of the Domain Name System (DNS). In either of these cases, a basic knowledge of Apache is required.

Starting with Apache

If you have Kali running on your system, Apache is already installed. Many other Linux distros have it installed by default as well. If you don’t have Apache installed, you can download and install it from the repositories by entering the following:

WOW! eBook

kali >apt-getinstall apache2

The Apache Web Server is often associated with the MySQL database (which we will look at in the next section) and these two services are very often paired with a scripting language such as Perl or PHP to develop web applications. This combination of Linux, Apache, MySQL, and PHP or Perl forms a powerful and robust platform for the

development and deployment of web­based applications, known collectively as LAMP.

These are the most widely used tools for developing websites in the Linux world—and they’re very popular in the Microsoft world too, where they’re generally referred to as WAMP, with the W standing for Windows.

The first step, of course, is to start our Apache daemon. In Kali, go to Applications ▸ Services ▸ HTTPD and click Apache start. You can accomplish the same from the command line by entering the following:

kali >servicesapache2start

Now that Apache is running, it should be able to serve up its default web page. Enter http://localhost/ in your favorite web browser to bring up the web page, which should look something like Figure 12­1.

Figure 12­1: The Apache2 Web Server default page

As you can see, Apache displays “It works” as its default web page. Now that you know your Apache Web Server is working, let’s customize it!

Editing the index.html File

Apache’s default web page is at /var/www/html/index.html. You can edit the

index.html file to serve up whatever information you want, so let’s create our own. For

WOW! eBook

this, you can use any text editor you please; I’ll be using Leafpad. Open up /var/www/html/index.html and you should see something like Listing 12­1.

   <!DOCTYPE html PUBLIC "­//W3C//DTD XHTML 1.0 Transitional//EN" 

   "http://www.w3.org/TR/xhtm11/DTD/xhtm11­transiti    <html xmlns="http://www.w3.org/1999/xhtml>

   <head>

   <meta http­equiv="Content­Type" content="text/html; charset=UTF­8" I>

➊ <title>Apache2 Debian Default Page: It works</title>

   <style type="text/css" media="screen">

   * {

   margin: Opx Opx Opx Opx;

   padding: Opx Opx Opx Opx;

   }

   body, html {

   padding: 3px 3px 3px 3px;

   background­color: #D8DBE2;

   font­family: Verdana, sans­serif;

   font­size: 11pt;

   text­align: center;

   }

   div.main_page {    position: relative;

   display: table;

Listing 12­1: The Apache Web Server index.html file

Note here that the default web page has exactly the text that was displayed when we opened our browser to localhost, but in HTML format ➊. All we need to do is edit or replace this file to have our web server display the information we want.

Adding Some HTML

Now that we have the web server up and running and the index.html file open, we can add whatever text we’d like the web server to serve up. We will create some simple HTML blocks.

Let’s create this page. In a new file in your text editor, enter the code shown in Listing 12­2.

WOW! eBook

<html>

<body>

<h1>Hackers­Arise Is the Best! </h1>

<p> If you want to learn hacking, Hackers­Arise.com </p>

<p> is the best place to learn hacking!</p>

</body>

</html>

Listing 12­2: Some simple HTML to add to the index.html file

Once you have entered the text exactly as it appears in Listing 12­2, save this file as /var/www/html/index.html and close your text editor. Your text editor will then prompt you that the file already exists. That’s okay. Just overwrite the existing /var/www/html/index.html file.

Seeing What Happens

Having saved our /var/www/html/index.html file, we can check to see what Apache will serve up. Navigate your browser once again to http://localhost, and you should see something like Figure 12­2.

Figure 12­2: New Hackers­Arise website

Apache has served up our web page just as we created it!

Dalam dokumen LINUX BASICS FOR HACKERS (Halaman 157-160)