Cracking the Lab! – 1

Being in the seventh semester has had its pros and cons. However, the labs in this semester haven’t been a good experience, in terms of all the trouble we had to go through just to get the software work at our home PCs for practice. I have tried hard and come close to what you might say, “a working” situation, where everything seems to work for me. Here are the steps I had to take to arrive at this very metastable state, you could try and follow the steps below to make things work for you; however, I do not guarantee that it will always work.

Also, here is the code for the programs I have written. Download it here. (Note: For database related programs, you will have to properly create databases/tables for it to work)

1. Fedora + Apache (for Perl, CGI, PHP, MySQL)

Get the latest fedora from http://fedoraproject.org and install it using all the packages selected (this is the safest way to do it; but if you know exactly what you are doing, you are free to select the right packages)

Once you are booted into Fedora, login using the root account (always do this – since you are on localhost, security should not be a problem for you.) and run apache and mysql.

  • Select “System” from the main menu, then click on “Services” in “Administration”.
  • Browse through the list and start (and enable) the “httpd” and “mysqld” services.
  • Now run the browser and point it to “http://localhost” to see if the apache service has started successfully. If it has, you will be able to see a Fedora Start Page in your browser.

You are now finished configuring. For working with apache you’ll have to know the following:

  • All “*.html, *.php, *. htm, *.shtml, *.xhtml” files go in “/var/www/html” directory.
  • All “*.pl, *.cgi” files go in “/var/www/cgi-bin” directory.
  • You’ll have to make the *.cgi, *.pl files executable by right-clicking on them and setting the permissions in their properties or by simply using the command in a terminal: “chmod 777 /var/www/cgi-bin/filename.cgi
  • If you find yourself looking at the “500 – Server Error” page, you might want to look into the logs to debug your errors. The logs are found at “/etc/httpd/logs/”

2. Tomcat + Java (for Java Servlet programming)

Get the JDK from the Java website here. And Apache Tomcat from here. Log into an account with administrative privileges and install them. Once you have installed both of them, you will need to set a few environment variables before you can start writing/compiling the code. I’m assuming that you have installed Java at “D:\j2sdk” and Tomcat at “D:\Tomcat”. (Make necessary changes in the below values as per your installation directories)

Variable Name

Value

CATALINA_HOME D:\Tomcat
PATH D:\j2sdk\bin
CLASSPATH D:\Tomcat\common\lib\servlet-api.jar

You can set these variables by, right-clicking on “My Computer”. Then, choose “Properties”, and in the “Advanced” tab, click on “Environment Variables”. If a variable by that name already exists, you can append the above value to it by using the delimiter semi-colon “;”.

Spot check! Write a sample Java code and try compiling it by opening Command Prompt (Start -> Run: “cmd.exe”) and using the following command: > javac filename.java

If you get any error stating that “javac” is a bad command or filename, then there is something wrong with your installation. Recheck the above steps again.

Start the Tomcat server: Start -> All Programs -> Apache Tomcat -> Configure Tomcat. Once the Tomcat tool is running, click “Start”.

Open your browser and point it to: “http://localhost:8080/”. If Tomcat has been properly installed, you will see default Apache Tomcat page. If not, recheck the above steps.

That’s (sadly) not all of the configurations that you have to change in order for things to work. Right now, you will be able to code in Java and also compile it. However, you will not be able to code servlets unless you change the default “web.xml” file or add a custom web.xml file for your servlet. I’m going to tell you how to modify the default web.xml file so that you can get things to work.

Open the web.xml file (Located at: D:\Tomcat\conf\web.xml) in a text editor, and look for the following codes and uncomment them. (Remove the ‘<!–‘ and ‘–>’ around the code)

<servlet>
        <servlet-name>invoker</servlet-name>
        <servlet-class>
          org.apache.catalina.servlets.InvokerServlet
        </servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
</servlet>

And this:

<servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
</servlet-mapping>

!!! One piece of warning !!! Uncommenting these lines will prove to be a security threat if you are doing it on a commercial web server. You shouldn’t really worry about it if you are using it at your home computer.

Once you are done with the above steps, you can be glad to know that nothing stands between you and coding the servlets now. (Phew!) Anyhow, you must know these for the things to actually work: (I’m assuming that you will be using the “ROOT” directory for your servlets, if not, make changes in the following paths accordingly)

  • All the “*.class” files go into “D:\Tomcat\webapps\ROOT\WEB-INF\classes” directory.
  • All “*.html, *.jsp, *.htm, *.shtml, *.xhtml” files go into “D:\Tomcat\webapps\ROOT” directory.
  • Use the “javac.exe” application (in “D:\j2sdk\bin”) to compile your code, which will create a classname.class file for you.
  • Now copy the .class to the classes directory and you can access the servlet using “http://localhost:8080/servlet/classname

Well, that’s it for now. Its sad that we have to go through all this just to practice five programs for our labs. Anyway, I hope all the settings work for you. If not, let me know; I hope I can help you.

P.S: Configuration for Networks Lab (Fedora + NCTUns) will be out tomorrow. 🙂

Advertisements

Secure your browsing with Firefox

If you haven’t read the previous post of this series, I suggest you do. If you have done that, or you are already a Firefox fan, then read on to know more on securing your browsing on firefox.

One of the major aspects of firefox is its extensibility, which is possible by the use of addons. Addons are either themes, plugins, or extensions. While themes enhance the appearance of the browser, plugins enable viewing of certain types of content from within the browser, such as flash and videos. However, extensions improve the functionality of the browser. Choosing the right extensions can effectively improve your online browsing experience.

The top five must have firefox extensions:

1. NoScript

NoScript is the best security extension that firefox has got till date. It works by blocking all scripts from ‘unknown’ websites. Once the page is loaded, you can allow or permanently block scripts on that website. You can also allow scripts to run temporarily for the current firefox session. This extension also blocks Java applets, flash and silverlight objects on the page. With a wide range of options to configure from, this is a must-have extension for all firefox users.

2. Adblock Plus

As the name suggests, this versatile extension blocks all the annoying ads on the webpages. All kinds of ads such as textlinks, banners, rotating images and video ads are blocked. You can also add a subscription list which is updated with all new ad loaders. Thus, once installed, Adbock Plus saves you the distractions arising from the adverts.

*This extension must be taken with a pinch of salt. Though it sounds all pretty and nice, you may lose out on good deals, and links to better websites. I suggest using it selectively for different websites.

3. DownThemAll!

The ultimate download helper extension for firefox. It is the best because, it does all the work of a commercial download manager program and the best part is that it works from within firefox. It splits the files upto 10 chunks and downloads them simultaneously thereby increasing download speeds.

*Did I mention that it works for rapidshare.com links as well? 😉

4. Foxmarks Bookmark Synchronizer

Are you one among those who browse the internet at several places? Home, Office, Laptop, etc? Imagine having to maintain a separate list of bookmarks at each browser! Foxmarks helps to overcome this problem by synchronizing the bookmarks between the ones on your system with the ones on the server. All you need is sign-up for an account (or you could also use your own FTP server) and foxmarks maintains a global bookmarks list on the server which is updated every time you add a new bookmark. Hence wherever you log on to the internet from, your bookmark list will be intact.

*This extension has saved my bookmarks several times when there were browser crashes, and I have no need to make backups while I’m reinstalling my OS. 🙂

5. StumbleUpon

StumbleUpon is an amazing extension that helps you ‘stumble upon’ webpages based upon your interests. This is one of the long standing extensions in the history of firefox and is awesome fun and very useful when you are searching for something specific.

*I have elaborated upon how to acquire StumbleUpon in one of my previous posts, take a look for complete instructions.

The next part of the series, will contain information on more utility addons which are particulary useful and help you browse the internet with ease.

Why Firefox?

Its been a while since the most-awaited Firefox 3 was released. Too much hype surrounded its release and also the world record ‘Download Day’. Was it all worth the hype? Is the record really worth some applause? Let’s see.

After building up huge hype, Mozilla Foundation must have prepared for it. The release itself was deferred by 45 minutes (approximately) and when it took place, the Firefox website choked with the amount of traffic it received. Unfortunately, there were no load balancing techniques employed to share the load between different servers, and surprisingly, there were no mirrors for download. Every Firefox package was downloaded from the same server. Of course, the download speed plunged downwards! Thankfully, the server did not breakdown. When the changes to the website were going on, the changes were made in real-time. I mean, I could see the logo of Firefox 3, but the version number at the download button was still 2.x. It was fixed quickly though, and the website was finally put together. It was almost one hour after the release that I managed to download a copy for myself.

Coming to the browser, the installation was simple (as always) and the loading time had decreased drastically, almost as much as Mozilla claimed. It takes far lesser memory now, and handles AJAX applications well – noticed how quickly GMail loads? Bookmarking was redefined, and organizing the bookmarks became easier and simple. The address bar, searches through your bookmark list as you type and lets you choose the site if you have bookmarked it earlier. A lighter side to this feature is that it promises keyboards with a better lifetime. I wont be going through the features anymore, if you are reading this, you are probably doing it on Firefox 3 and have experienced the features (or bugs perhaps) – you can even go to the site to check them out again if you feel like.

At first, I could not find a downside to the browser, but the crash occurred a couple of weeks later. All my addons started acting weird and the themes wont work! It was nightmarish. I had to create a new profile (using the profile manager) to fix it, and re-download all my addons and configure them again.

Now for the real deal: Firefox still is the best browser out there. And if you are using any other browser, its only a matter of time until you’ll change. Why?

1. Faster – This is the most controversial feature of firefox. Internet Explorer claims to load faster than Firefox. Of course it does; its running on Windows ain’t it? If you could, why not install IE on Linux and see the difference?

2. Addons – The biggest and celebrated feature of Firefox is its extensibility. There are numerous addons for a multitude of user proficiency – novices to experts.

3. Safer – Firefox is undoubtedly the safest browser. Install a few more addons (which I discuss later) and you’ll make it much safer!

Give a little more importance to the box you view the web through. 🙂

I’ll follow up with another post on how to make your firefox installation safer and how to troubleshoot problems and recover from crashes.

Eliminating Piracy – A long shot?

Updated: Revisiting Piracy (24/01/2012)

Piracy

Piracy basically is theft. Stealing can be broadly split into two kinds:

  • Stealing to fill one’s stomach.
  • Stealing for any other reason.

We are not talking of the sea-faring pirates, whose sins might just be pardonable when compared to the modern day pirates who follow a form of piracy more significantly put as copyright infringement.

Piracy: Why? (– Why not?)

Hunger here, signifies the inability to access content due to monetary or other situational constraints. This form of piracy is acceptable to a certain degree; more like compassion shown upon a man who steals to save himself from dying of hunger.

This form of piracy is practiced by ‘youth’. (Youth is a heavy word. Pardon me) The younger lot, of which I’m pretty much a part of, have a lot of things to spend on: weekend parties, fueling their vehicles, girlfriends, and a lot more! Wouldn’t it be obnoxiously painful to us when expected to pay for software too? And a few software like the Adobe Photoshop being so heavily priced, is unreachable by us; and isn’t it like curbing our creativity if good software like that are not available to us for free (or a reasonable price: $100? For the record, Adobe Photoshop CS3 Extended costs $999! About 10 times the price I quoted for it!)

I’d say, the worst type of piracy is music. Most of the times, though the albums are reasonably priced, people tend to download them for free either from websites like ‘yourmp3.net’, ‘mp3raid.com’, ‘mp3pk.com’, or thousands of other such websites. The P2P in itself may seem like an ‘innocent’ advancement in technology (–like the nuclear power plants, which also gave us the atomic bomb!) but it is surely helping the phenomenal rise in music Piracy.

Sometimes, movie piracy is justifiable. For instance, living in India, I have access to only a few hollywood movies that are released here, compared to a lot that gets released around the world. I’m not complaining about new movies which can be easily bought (and shipped) at some online store like Amazon; I’m actually thinking about good old movies, which are out of cinemas a long time ago and you cannot possibly find it on any online store (and even if you could, the search is never easy).

The most unfortunate form of piracy is the piracy of books. Writers put their heart and soul into their works and go through a lot of trouble which they truly deserve merit for.

Eliminating Piracy

Thinking of eliminating global piracy is like trying to be heard in a crowd of a million people. No matter how many initiatives you take to curb piracy, there will always be a ‘small’ group of people who would resort to piracy in any case. Reducing piracy is a more realistic goal that the ‘concerned people’ must take up, rather than aiming to eliminate it completely.

Here are a few suggestions I’d make:

  • Ban websites primarily targeting to provide downloads of pirated content. Trying to get the country (in which the server is located) to take action is a foolish way of trying to stop the culprits. Instead, all countries must come up with an agreement that a universal list of domains (and IP addresses) will be maintained by a non-government and non-profit organization, all of which must be banned from being accessible to public by all ISPs.
  • Governments must initiate the funding of good open source software especially the alternatives to the expensive ones in the market. This encourages people to create good open source software, and also urges many to use more open source applications.
  • 90% of all movies make their share of money within 15-24 months of their release. The film makers must come to an agreement that the movies must be made available for download (for free or for a reasonable price) after 24 months of its release. This not only ensures that the movies reach out to a bigger group of people, also guarantees that the movie isn’t forgotten very soon.
  • Urge software companies to create a ‘student’ version of all software that they make and it must be available for students for free, if used for non-commercial purposes.

All good things in life comes free; for everything else, there’s piracy!

Disclaimer: The links provided to certain websites are for knowledgeable purposes only and are not intended to promote piracy of any sort or any method.

Tips to take care of your PC against aliens (Viruses, Worms and Trojans)

What an alien does to your system can be pretty irritating. Disabling system functions, high memory usage, internet bandwidth stealing to name a few. Other times, it can be dangerous as well; stealing passwords or bank and credit card information.

The best way to avoid infecting your PC with these aliens is to block their source of entry into your PC. Usually, these aliens propagate through Pen Drives, EMail, Illegal downloads, Torrents, and other means of data transfer such as CDs and DVDs.

Basic security settings:

  • Use a good anti-virus software, update it regularly and scan your system frequently. This does 25% of the work. A good anti-virus software with a real time scanning ability will detect most of the infection before it occurs, thereby saving you the trouble even before it erupts.
  • Update your Windows OS with all the security releases from Microsoft. This is pretty essential, but I haven’t seen many high-priority updates since SP2. So, if you have SP2, I guess that’s update enough; but always update if you can.
  • Always watch the task manager. Be aware of the number of processes that your system usually runs. This could help you detect any unwanted processes running in the background.
  • Always scan any file that you download from the internet or your email inbox before executing it.

Safeguarding from infection through Pen Drives:

Aliens in pen drives rely upon autorun to affect your system. As soon as you insert an affected pen drive and double click on its icon in My Computer, be assured that your system is now infected. The best way (probably the only good way) to stop this is by disabling autorun. You can do this by manually editing the registry which is not always the best option. Instead, you could download TweakUI, released by Microsoft for tweaking the performance and related issues of Windows XP.

Using TweakUI (TweakUI is a PowerToy for Windows XP released by Microsoft):

  • Download it from Microsoft Download Center and install it. Pretty straight forward installation and shouldn’t be any problem. Run it.
  • Disable autoplay on all drives. (You may keep it on for your CD or DVD drives if you wish)

tweakui1.jpg
  • This will disable autoplay for all drives and hence, when you insert the device, your PC will not be infected. But it is not over yet.
  • As soon as you connect a device, always right click on its icon in My Computer and click on Open. Better yet, use Windows Explorer to view the contents. Enable option to view hidden files and folders.
  • Delete the ‘autorun.inf’ file if present and any suspicious ‘.exe’ files if found.
  • Your pen drive is now clean.

Follow these steps every time you use the pen drive. These steps are usually required if your anti-virus software fails to detect/resolve the threat.