PHP for Hackers: Part 1, Introduction and Setting Up

Mar 5, 2016 06:36 PM
Mar 6, 2016 07:54 PM
635927698170762981.jpg

In this series you will learn how to use PHP to perform attacks, gather information, and setup backdoors. Along with performing attacks you will learn how to protect yourself from them. In this part you will learn about PHP as well as install Apache and PHP.

635927698170762981.jpg

What you'll need for this series

  1. Text editor(Any will work)
  2. Browser(Any will work)
  3. Apache web server with PHP(We set that up in this part)

What Is PHP?

PHP is a server-side scripting language. All code written in PHP is executed exclusively on the server. The client never sees the code which is why most attacks in this series will be on a server.

Finding Your IP Address

Throughout this series I will use "yourip" in place of your IP address. If you are using a browser on the same system you are hosting the Apache server on, just replace "yourip" with "localhost" or "127.0.0.1". Otherwise you will need to know your local IP address. To find your local IP address, run the following command.

ifconfig | grep 'inet addr:'

Your local IP addres is the IP address next to "inet addr:" on the line that doesn't contain "127.0.0.1".

635927707431700569.jpg

Step 1: Setting Up Apache

To Install Apache run the following command.

sudo apt-get install apache2

After running the command you will be asked if you want to continue.

Select "Yes"

635927689886388883.jpg

Let Apache finish installing.

Step 2: Making Sure Apache Works

Open a browser and navigate to "http://yourip". You should see a page similar to the one in the image bellow.

635923583715181197.jpg

Now that we know Apache works we can install PHP!

Step 3: Setting Up PHP

To Install PHP run the following command.

sudo apt-get install php5 libapache2-mod-php5

After running the command you will be asked if you want to continue.

Select "Yes"

635927690120450296.jpg

Let PHP finish installing.

In order for PHP to work you need to restart Apache. To restart Apache run the following command.

sudo service apache2 restart

635927766755679434.jpg

Step 4: Making Sure PHP Works

Create a file called "test.php" and place it in your public html folder (usually located at "/var/www/" or /var/www/html"). We need to run some PHP code to make sure that PHP was installed properly. I will be using the code bellow which returns a page with the PHP version we installed and "Hello,World!".

//+-----------------------------------------------------------------------------------+


$version=phpversion();//sets $version to curent php version

echo 'version: '.$version;//prints "version: x.x.x" to the page

echo '
';//prints a new line to the page

echo 'Hello, World!';//prints "Hello, World!" to the page

?>


//+-----------------------------------------------------------------------------------+

Open a browser and navigate to "http://yourip/test.php". You should see a page similar to the one in the image bellow.

635924890279103346.jpg

Congratulations you have a working Apache2 web server with PHP!

Conclusion

You now have a fully functional Apache web server with PHP! You have everything you need to follow along with this series. If you have any comments, trouble, or questions please leave a comment bellow.

Comments

No Comments Exist

Be the first, drop a comment!