We've been going back-and-forth from Assembly to Networking, but here's the first time where a lot of this is gong to come together in a nice, satisfying way.
Here's a problem: a lot of the stuff we'd like to practice (breaking SQL, looking at the security of certain websites, etc.) requires us to have our own website and SQL server to practice on (lest we get into some sticky legal areas), but buying a domain name and getting a host costs money. Alas. Why can't we just be our own server? In fact, we can. Enter: LAMP.
LAMP is a web development framework (we'll talk about what that means in a little while) which stands for Linux-Apache-MySQL-PHP. Luckily, we've already done half of this: we have Linux (in the form of Ubuntu) and we have worked with MySQL. We just need to check out Apache and PHP. We'll do Apache first since it's relatively easy to set it up.
Apache.Apache is a web server software; we will be using it to host practice web pages and databases. One could (and many do) use this software along with a server (which could be a computer, for example) to allow others to access their web pages through the internet. For now, we'll restrict ourselves to just making and hosting pages that we'll practice with.
Installing Apache is easy: go here and follow the instructions in the Install Apache 2 section. Then, install PHP (we'll need it later) by using the commands (with sudo):
apt-get install libapache2-mod-php5 php5 php-pear php5-xcache
apt-get install php5-suhosin
apt-get install php5-mysql
Good job, pal. Now,
Start from Step One and skip the optional step. This will set up a sample website from your server. Neato.
First, they use the command "sudo nano index.html" to use the nano word processor. If you'd like, you can use "sudo gedit index.html" to run the gedit word processor, which is a bit easier to use. If you use nano, save is "ctrl + O" and quit is "ctrl + X".
Second, you can simply type localhost in the browser at the end instead of your IP address.
Third, right before Step Six the instructions tell you to do the commandsudo a2ensite example.com
but not much more is said about this command. Note that a2ensite means "apache2 enable site" and it means that the server will host that site. If you want to make another site (for now) you will have to disable your first site; it will be good practice for you to remember: after you're done practicing, disable the site by using the commandsudo a2dissite example.com
This will save you from a ton of headaches if you're thinking about making up more than one site (though you can just edit example.com in all the following exercises instead of creating new websites each time).
Create a new example site (like in the steps before) called, "pentest" (you don't need to put a ".com" or anything, but you can if you'd like) where the index.html file is given by:
<html><body> hi everybody! </body></html>
Make sure it runs by going to your favorite web browser in Ubuntu and typing the address "localhost" in.
There's a ton of ways to have websites put together for you now-a-days, but is there anything more satisfying than building up something from scratch? Read from the introduction to the chapter "HTML FORMS" and do the little examples to see how some of this stuff works. Don't worry so much about the CSS, TABLES, or BLOCKS chapters right now.
For this exercise, use the "index.html" file for either the "pentest" website you made in the last exercise, or in the "example.com" website you made when you set up apache. Clear everything so that index.html is a blank page. Remember, you may use the gedit program or the nano program to edit these texts (or whatever text editor you want, for that matter).
Create a website with the index.html file using HTML code with the following properties:
It has "What a nice day!" as a title.
It contains a paragraph that says, "Hello, this is my website. I hope you like it!"
Make the word "website" in the previous sentence bold, and the word "Hello" italic.
Make a new paragraph that says, "Is sunshine better than moonshine?"
Make an unordered list which has three items: "Yes", "No", "Maybe".
Make a new paragraph which says, "I love grapes." and have the word "grapes" contain a link to this page.
Make sure you check it in the browser (with "localhost") to make sure your html works!
Tables are a bit confusing in HTML, so I wanted to dedicate a section to building just them. Go through this tutorial (which is from the above tutorial) and try to mess around with things. Then do the following exercise:
HTML Tables Exercise!
For this exercise, use the same "index.html" file as in the previous exercise.
Create a fake table that displays five students names and five grades (so it will have two headers, like in the last example on the tutorial page: Name and Grade).
Add another COLUMN for "Age" and fill in ages for each of the students.
What happens if you change the table border="1" code to make it ="0"? Try messing around with this.
|⇐ Back to 4.1||Home||Onwards to 4.3 ⇒|