Friday, October 28, 2011

Setup transparent net access over insti proxies

If you are a student at an institute that forces you to cross a damn proxy server for accessing internet, you must be fed up of entering your username and password time and again in browsers, as well as configuring each new application you install, to use the proxy. And if an application doesn't have any proxy configuration option, then you can't use that application! For example you can't install the Android Development plugin for eclipse. This is very irritating. And, some campuses add to this torture further by using crappy NTLM authentication.
Here in IIT Madras exactly this condition prevails. But here I present a step by step walk through to get rid of this situation. Welcome to transparent proxying!

What is transparent proxy?
A transparent proxy(correctly called intercepting proxy) intercepts your requests and forwards to the destination without letting your applications know that there is a proxy between you and internet. This is done with some intervention from iptables in Linux. So what are the advantages? You need not configure each and every application with the proxy address, port, username and passwords. You can keep the setting "Direct connection to internet" in every application and every darn-so-ever app will work flawlessly!!!! Cool?? Eh?? Lets start.

Configure a transparent proxy on your notebook
I assume you are using a recent version of Ubuntu. Even older ones will do :) The steps should work for any Linux distro provided you use appropriate distro specific commands.

Before installing software you should have a working internet connection. You may setup proxy in /etc/apt/apt.conf for the time being to install required software for now. You need to put the proxy details in apt.conf as follows for https, https and ftp:

Acquire::http::Proxy "http://<username>:<password>@<proxy-address>:<port>


An example:

Acquire::http::Proxy "http://cs11m039:bleeeep@proxy.iitm.ac.in:3128";
Acquire::https::Proxy "https://cs11m039:bleeeep@proxy.iitm.ac.in:3128";
Acquire::ftp::Proxy "ftp://cs11m039:bleeeep@proxy.iitm.ac.in:3128";


If you are not from computer science background then I should tell you that, to edit /etc/apt/apt.conf you should open terminal then type sudo gedit /etc/apt/apt.conf

Step 1: 
If your campus doesn't require NTLM authentication then you can simply install and configure squid to setup transparent proxying. The details for that are beyond the scope of this post and I may cover that sometime later or you may search the net for other writers who might have posted the same.
IIT Madras campus network has NTLM. So I need to install cntlm. It works as a proxy and performs NTLM authentication on your behalf so you don't need to enter username and password everytime ypu lauch the browser. Type the following command and press enter:
sudo apt-get install cntlm 
Now edit /etc/cntlm.conf file and edit these lines to reflect your settings:

Username cs11m039
Domain iitm
Password password
If you have different proxies in institute and hostels then you can specify them all in these lines



Proxy 10.93.0.38:3128
Proxy 10.93.0.34:3128
Edit socks proxy details too

SOCKS5Proxy 3128
SOCKS5User cs11m039:password

Leave all other settings as default. Instead of cs11m039, put your username and instead of password put your password. Instead of domain as iitm put your institutes NTLM domain. For SOCKS5Proxy put the port number of proxy.

Now restart cntlm by typing:

sudo service cntlm restart

Now open any browser and set the http proxy as 127.0.0.1 and port 3128. Try opening google.com. If it works, means you got cntlm installed perfectly. Proceed to next step. Else, double check your configuration. Make sure cntlm got installed. Also make sure if your computer is even turned on!!!!! If all else fails, write a comment here and I may reply if I feel like.(:P)

Step 2:
Install tinyproxy.
sudo apt-get install tinyproxy

Open its configuration file

sudo gedit /etc/tinyproxy.conf 

Edit these lines:
Port 8888
Upstream 127.0.0.1:3128
Comment the line that says Allow 127.0.0.1 by adding a leading # symbol before Allow.
Don't touch any other line.

Step 3:
Open /etc/default/tinyproxy and put this inside and close the file:


case "$1" in
  start)
    iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to 8888
    ;;
  stop)
    iptables -t nat -F OUTPUT
    ;;
  restart)
    start-stop-daemon --stop --quiet -t --exec $DAEMON > /dev/null || exit 0

    iptables -t nat -F OUTPUT
    iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to 8888
    ;;
esac


Now restart tinyproxy by typing sudo service tinyproxy restart 
Disable proxy settings in the browser and try opening a website. If you followed all the above steps correctly then the website should open. Also, you may now safely truncate the /etc/apt/apt.conf file and it will work. All your apps like installing software in Eclipse will work too without any problems.

This is how your internet is working now:

Your application requests for internet access which is received by Linux kernel and due to the iptables rule setup above the request is redirected to port 8888 where tinyproxy is running. Tinyproxy intercepts the non-proxyified request and makes it http-proxy request compliant then forwards it to upstream proxy which is cntlm running on port 3128. Cntlm then performs NTLM authentication and contacts the insti proxy server to serve your request.

User application<==>Kernel(iptables)<==>tinyproxy intercepting proxy<==>cntlm authentication proxy<==>insti squid proxy<==>The internet

Happy browsing!

Update
On 3rd November, IIT Madras ditched the NTLM authentication and implemented rather insecure HTTP Basic authentication with OpenLDAP. Now you don't require cntlm if you want to setup transparent proxy.

In step 1 above don't install cntlm. Just install polipo by:
sudo apt-get install polipo

Then open its configuration file by:
sudo gedit /etc/polipo/config

And set these values:
parentProxy = "hproxy.iitm.ac.in:3128"
parentAuthCredentials = "username:password"

where username and password should be your username and your password for OpenLDAP.Also make sure to comment the lines that stand for SOCKS proxy.
Also set its listening port to 3128, so that tinyproxy doesn't need to be reconfigured. And don't forget to uninstall or disable cntlm(if it is installed) from startup because both polipo and cntlm will try to capture port 3128 for listening and you may face issues.




Thursday, September 29, 2011

My experience with CentOS 6

And finally I decided to switch to 64 bit computing! Motivated by my Parallel Computer Architecture course (in which I'm underperforming) I decided to install CentOS 6 X86_64 version. IIT gives enough internet speed in the campus (if only you know how to tap into :P) that I ended up downloading the two bin-DVD ISOs as well as LiveCD and LiveDVD ISOs totalling around 8GB in less than 2 hours from http://ftp.jaist.ac.jp/pub/Linux/CentOS/6.0/isos/x86_64/. Then I used the cool dd command to replicate the LiveDVD ISO onto my pen drive.

dd if=CentOS-6.0-x86_64-LiveDVD.iso of=/dev/sdb bs=1K

Don't forget to
umount /dev/sdb1
before issuing the above command.

So, after getting the bootable pen drive I restarted my notebook and pressed F12 to alter the boot order to select the pen drive instead of hard disk. The LiveDVD environment booted and I clicked on autologin letting it boot to GNOME by default. The interface was pretty fast. In fact much faster than Ubuntu because there is not much of eye candy at your disposal in CentOS by default. One irritation I had, was that I couldn't click by tapping the touchpad. I had to press the touchpad's left button to make the clicks. After some fiddling I found out in System>Preferences>Mouse in the Touchpad tab the option to Enable mouse clicks with touchpad. Then I enabled Desktop Effects and tested the Desktop on a cube of Compiz that pumps in zeal in linux fanboys and jeal in Windoze fans! Everything seemed to work perfectly, and I decided to go ahead and replace my Backtrack 5 installation with CentOS6. I launched the Install to hard drive installer and chose create a cutom layout in disk partitioning to specify my own partition to install and selected the Backtrack 5 partition and formatted it. After clicking the final install button, to my utter dismay the installer blurted something very nasty! The installation media is corrupt and installer can't proceed! Damn!!!!!!!!!!
I rebooted to find that my Backtrack 5 partition was wiped out. I booted into Ubuntu and used dd to replicate the bin-DVD1.iso image into my USB pen drive. After a wait of around 15 minutes my bin-DVD1 installer was ready. I rebooted and chose USB boot after F12 but this time it said: Operating system not found!!! Damn again!
After booting back to Ubuntu I replicated the LiveCD.iso into USB disk and re-booted into the LiveCD environment without any issues. I checked my system information and was proud to see 4GB of installed RAM! Both my 32-bit OSes viz. Windoze and Ubuntu 11.04 let me use only 3GB(approx.) RAM because of that damn memory mapping for I/O devices. Anyways I launched the installer and started following the wizard. During the bootloader setup screen I saw only Windoze was detected and named as Other. I added an entry for Ubuntu as well and edited the Other to read Windoze. I proceeded with the installer and after setting up all configs pressed the final install button. To my surprise, the install took less than 3 minutes!!!! Yes!! Thats right!
Then I rebooted and after a couple of formalities booted straight into lean and thin and clean upto the brim desktop environment of GNOME with very basic set of apps like GIMP, OpenOffice etc. Next thing I did was to install the multimedia codecs. I issued the following command
yum install gstreamer-plugins-base gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly gstreamer-ffmpeg
For a user switching from Ubuntu it was nice to see that the package names are consistent across distros. Anyways I noticed that the gstreamer plugins from the base set and good set were already installed and yum started downloding the rest of them.
Then I installed vlc media player by
yum install vlc
When I tried typing gcc and g++ on the terminal I got command not found. Same happened for java but python was installed and worked. They don't provide everything in the CD due to space constraint. So I went ahead to install these myself. yum install g++ didn't work.
After some fiddling I noticed that I could hear sound when I plugged in the earphones but after plugging them out I couldn't hear any sound through speakers. Exactly same problem I faced in last october with Ubuntu and had posted at http://www.techbite.in/2010/10/realtek-alc888-sound-issues-in-ubuntu.html but I couldn't use the same solution for CentOS because there was no /etc/modprobe.d/alsa-base.conf in CentOS. I tried the locate command but in vain. If you know how to solve this issue please comment here.
Next I updated /etc/fstab and entered the entries for auto mounting of my Windoze partitions and Ubuntu partition. But before that I had to installl ntfs-3g because that would let my CentOS access NTFS partitions.
Anyways I went ahead with my installation streak and downloaded flash plugin 11 rc from Adobe's site for 64 bit architecture and extracted it and copied the libflahplayer.so to ~/.mozilla/plugins directory and my firefox started to show YouTube videos after a restart. My installation streak is still going on and the apps waiting in the queue for installation are:
compiz
w3m
aria2c
chrome
opera
nmap
g++
lftp
openssh
ettercap
apache
php
mysql
audacious
skype
gnuplot
vidalia

After the installation of these I'll have a relaxed sleep because I have a 4 day holiday!! That will be enough for me to spend nice time with CentOS6.

Update(Sep29 9:30AM IST):
I added these two lines to /etc/modprobe.d/dist-alsa.conf to got the sound from speakers working after a restart.
alias snd-card-0 snd-hda-intel
options snd-hda-intel model=auto
Other issues I faced so far are
1. Upon trying to install byobu-3.21-1.el6.noarch.rpm it says it needs python 2.6. But I already have python 2.6.5 installed
2. To run the ADT plugin for eclipse I require 32 bit libs support. Can't figure out how to do that. In Ubuntu 64 bit, one just have to install ia32-libs using apt-get.
3. Can't install audacious through yum. It says audacious-plugins package not found.
4. Installed compiz but can't find ccsm
5. Can't find aria2 through yum. I guess I've to hunt for a manual download of rpm instead.

Update(Oct 1 07:30PM IST)
I downloaded JDK 7 from here http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html and installed it. It worked perfectly. But after that I used yum to install Eclipse IDE which in turn installed OpenJDK and made it the default java. I hate OpenJDK and want only Sun JAVA. I tried:
update-alternatives --config java
But Sun Java wasn't listed there. There were two javas listed there. One was Open JDK 1.6 and other was gcj 1.5. I played some hide n seek and found out that Sun Java was installed in /usr/java/ and there were three directories there named jdk1.7.0, latest and default. Then after some fiddling with the man page of update-alternatives command I issued these three commands:

update-alternatives --install "/usr/bin/java" "java" "/usr/java/default/bin/java" 3
update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/default/bin/javac" 3
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/java/default/bin/javaws" 3

And then running this:
update-alternatives --config java
showed me Sun Java as the third option. Then I set it as the default java and my problem was solved.

To get started with server administration in CentOS if you have some basic Linux background, you should read the CentOS Server Administration Cookbook.

Thursday, August 11, 2011

M.Tech CS - Admissions through GATE - Analysis 2011

Intro
This blog post has content specific to those:

  • who belong to CS
  • who are under 460 rank in GATE
  • who are in General category
If you don't belong to the category described above, you may still read on because you may find some interesting information in this post.

If you are just preparing for GATE, you should solve more and more questions. And for that I would recommend GKP Publisher's Question Bank. Although there are some mistakes in the book for solutions to some problems, but I recommend this book solely for the huge collection of problems it has.

GATE CS has become very competitive and the competition is increasing every year at an alarming rate. In GATE 2009 only 41000 candidates appeared in CS. The number increased to 107086 in 2010, mostly contributed by recession and lack of job opportunities in IT sector. In 2011 amazingly the number of candidates rose to 136291(last rank was 136027 but exact number of candidates who appeared in the exam was 136291) although recession had retreated and jobs were available in plenty. This shows the increasing interest of Indian youth towards masters degree.

GATE - Who takes it? Why?

Now lets know who are the people who opt to pursue M.Tech and why?

Broadly, there are three kinds of people who want to pursue M.Tech from IITs. The first kind is like me, who want better placement opportunities in reputed companies like Microsoft, Google, Cisco, Directi, Intel, Facebook, Yahoo! , Adobe etc. which are unavailable to most students who haven't done B.Tech from NITs or some other better colleges other than IITs. It is considered that these companies not only give you a well paid and reputed job that doesn't insult your talent but also give a great life and corporate culture. After doing B.Tech from private engineering colleges most of the students are absorbed by TCS, Wipro, Infosys and a couple of other mass recruiters. Once you land in these companies and get under some nasty manager you will realize that a labour working hard carrying bricks in the sun has a better life than you. Sometimes in these companies, you'll feel that the people above you are no match for your talent and still they are making more money(being there for more time than you) than you and also load you with stuff to do in a day that would require at least a week! This high profile bureaucracy prevailing in these companies and the plight of newly entered Software Engineers can't be felt by those who have never been victims of this, and can't be expressed by those who are already facing this thanks to their lack of time. Also you are trained like dogs and put to any job profile according to their wish. The field you are put into may be the one you hated most during your B.Tech, for example Testing. So, for these students M.Tech from IITs apparently, is the only saviour.
The second category of students is the one who want to pursue M.Tech then after making pretty sum of money and enjoying vibrant lifestyle, want to pursue Ph.D and then enter the academic field with cravings for being professors in top institutions.
The third category consists of the people who are dedicated to research only. They want to do researches through out their life, put forward some remarkable new findings, get them popular enough to find place in some textbooks. So our next generations when don't understand their algorithms/formula/theorems abuse them saying who on earth on what unlucky day gave this freaking theorem I can't mug up to vomit in my exam!!!!
There is another narrow overlapping category consisting of people who missed IIT-JEE by a few marks, and now want to fulfill their dream of being an IITian, through the GATE way!

The top institutes analyzed

I would focus on the eight best institutes according to the candidate's choices. All the IITs are the best and saying that one is better than other would be like writing an algorithm to sort an array of equal elements!!!! All of them are the best. But here I would like to rank them according to the students' tastes. The taste of students is driven by the specializations they want to pursue and the no. of professors in that specialization in particular IIT, lifestyle at the institute, placements and a couple of other aspects like regional inclination for example most north Indian people prefer IIT Delhi over Madras and south Indians do the other way round.


 IISc
Indian Institute of Science, Bangalore is the undisputed champion when it comes to research. It ranks first in India in terms of research output. Getting into it is equally tough. There are two flagship programs for Computer Science graduates. The ME in Computer Science program is open only for direct admission. If you have an All India Rank of under 45 in GATE then you may expect a direct admission call in this program. Another program called ME in Systems Science and Automation requires you to pass their own written test and interview. The candidates are shortlisted based on GATE scores and called for written test and interview. I am not sure upto how much rank they call for this program.
The third program for CS graduates is M.Sc Eng. For this program too you should have a good GATE score. But generally upto around 1000 rank people are called for written test and interview. IISc is highly mathematics inclined. If maths is not your cup of tea then it is almost impossible to get into SSA or M.Sc Eng. even though you have a very very high GATE score. The interviews and written are generally maths oriented.
Research wise IISc is the best. But placements in IISc are not considered to be as great as compared to top IITs like Bombay, Madras and Delhi. Although no one remains unplaced after going through IISc for 2 years rigorously but not all companies that visit IITs are aware of IISc. Moreover in IITs the placements are managed professionally and each IIT has a separate placement cell whose sole purpose is to get companies. But in IISc, professors do it in their spare time.
If you want to apply for IISc then do it early because last date for application submission is generally 2 or 3 days after declaration of GATE result(15 March) i.e. 17 or 18th March.

IIT Bombay
IIT Bombay's flagship program for CS graduates is M.Tech in Computer Science(TA). This program accepts only direct admits. In 2011 last GATE rank offered admission in 4th list in general category is 104. In 2010 it was above 125. GATE score cutoff is 868 for general category in 4th list in 2011. IIT Bombay is the most popular choice for toppers who get under 100 rank. Backed by highly paid placement offers, the vibrant lifestyle of Mumbai and a very large Computer Science faculty group, IIT-B houses top performers of GATE.
Here is the admission summary of 2011.
So, if you are under hundred rank in GATE you can be sure to get admitted there.
There is also an RA program which is of 3 years where you are assigned on some project and you have to serve for 20 hours a week instead of 8 hours in TA. In return you get Rs.1000 extra as stipend.
The admission offer lists of IIT Bombay are declared first, among all IITs.
In IIT-B there are other interdisciplinary programs like Geoinformatics where you can get in even if you are not in top 100. There you may take CS branch electives and get placed in software development field. But I wont get into details for these workarounds to get inside IIT Bombay. I'll talk only about programs of excellence in top institutes.
IIT Bombay is best choice if you are just course and placement oriented and not much of research oriented.

IIT Kanpur
IIT Kanpur is 2nd best choice for research oriented people. It is considered that, after IISc the name of IIT-K is taken for research.
IIT-K has 38 seats for general(as of 2011). They first declare a direct admit list. You can make into this list if you are under 70 rank in GATE. But generally around 5-6 highly motivated students take direct admission here. Rest join IIT-B. To fill the rest seats IIT-K conducts a written test and interview. They called upto 460 rank(in 2011) for written. The written comprised of aptitude questions which has very high percentage of application of probability distributions. If you are not good at probability distributions you may not get through the written test. 93 people( from all categories) were selected in written test. I was also one of them(luckily). Then you have to get through an interview. If you have high marks in written test then interview is pretty formal. But if you have lower marks then it is tougher and even if you answer their 50% questions and show good approach in trying to solve the problem you will get through the interview. I couldn't get through the interview. I had a very low score in written(just above the cutoff) because I am very bad at probability distributions. They asked me just 2 questions and they were sure that I am not worth IIT-K :P
I am also not that research oriented and so I knew IIT-K M.Tech isn't my cup of tea.
I met a senior and he advised me to join IIT-D or M instead of IIT-K if placements is my only aim. He also threw some light on doing M.Tech from IIT-K. According to him, it is quite tough in academics and building good CGPA is a very difficult task here. Also, if the professors are not satisfied with your thesis work, then your M.Tech may get extended for 6 months at a time. It is like a mini Ph.D.
So, join IIT-K if you are highly motivated towards research and dare to take on.

IIT-D
IIT Delhi is a great institute for placement oriented students. Being in the national capital surrounded by IT hubs of north India i.e. Noida and Gurgaon results in great placements. IIT Delhi has 4 programmes for CS students. MCS is the flagship programme which is M.Tech in Computer Science. JCA is an interdisciplinary programme run by maths department along with CS department which is Computer Applications. Computer Technology(EET) programme is another interdisciplinary course run by EE and CS departments. Placements are great in all these programmes. VDTT i.e. VLSI Design: Tools and Technology is also a great programme for people with inclination towards electronics. It has very high paying placement offers. Apart from this there is also MS but it has a very few seats.
The admission to all these courses is through an interview. There is no written test. You are shortlisted through GATE score and have to crack an interview to get into these. VDTT course also involves an interview with your sponsoring company which will pay all your fees and other expenses during your M.Tech and you may even get PPO(pre placement offer) if you perform well.
In 2011 cut off for MCS and MS have been GATE score 760. For other courses it was lesser. In JCA 750 was the cutoff for interview and 850 and 75% or 8.5 GPA would get you a direct admit in JCA. For VDTT the cut off for CS was 700. For EET too the criteria was similar to JCA. All courses have great placements but preference wise you should opt for MCS>JCA>EET. And if you want to do something in VLSI field then VDTT is a great option.
IIT Delhi has world class faculty for Algorithms. Prof. Naveen Garg is renowned in this field. Moreover Computer Networks, Computer Vision and Graphics are great here with very good professors. If you are interested in Databases then IIT Delhi is not for you because no good professors for databases are there.
Those who want to know about JCA may read this blog post written by an alumni of M.Tech CS at IIT Delhi who is currently working for Amazon:

http://mtech-admission-iits.blogspot.com/2011/01/jca-computer-applications-at-iit-delhi.html 

Or this blog post by a current student of JCA

http://gaurav89.wordpress.com/2012/03/18/jca-at-iit-delhi/


IIT Madras
IIT Madras offers only direct admissions based on GATE score. In first list upto 101 rank people were called. The cut off for 2nd list was rank 155 and in 3rd list it went above 175. IIT Madras has great placements being near Bangalore and Hyderabad. It is considered very good for Computer Architecture and High Performance Computing. Also Computer Networks, Cryptography, Network Security are considered good here. I got admission in IIT Madras. I'll post more about IIT Madras when I get there and get to know the institute more. There is also a second phase of registrations in IIT Madras if the seats are vacant after fourth offer. People upto rank 500 are advised to register for it and who haven't got any other IITs yet, may get spot admission offers.
IIT Madras has one of the finest campuses in India and it is run in collaboration with German government. Some students also get opportunities for DAAD fellowships. Many north Indian students don't opt for it because of confrontation with newer culture, language and food style. But, I don't think these things are problems. After all, we should experience different kinds of lifestyles during our life and adapt the good traits from wherever possible :-) Moreover, as far as I know IIT Madras has north Indian mess for people who are scared of food changes.

IIT Kharagpur
Most students with top ranks don't like to opt for IIT Kharagpur citing that the quality of faculty is not as great as the top 4 IITs for M.Tech in CS. IIT-KGP is one of the best institutes in the country for B.Tech in various engineering streams. I don't have much details about it. The admission process is through interview. 70% weightage is given to GATE score and 30% to interview performance. Many people don't want to go to Kharagpur because it is a very small city and doesn't extend much after the IIT. So you can't enjoy the lifestyle of Delhi, Bombay, Chennai and Bangalore.

IIT Roorkee & Guwahati
These two institutes are the new institutes. IIT-G was setup in 1995 and IIT Roorkee got the IIT status in 2001. Most of the top rankers don't want to join these. In Roorkee, Computer Networks is good. Admission is purely based on GATE score(as of 2011). In Guwahati the cut off for written test and interviews was 55 marks in GATE. The placements are good in both these institutes too but not at par with other IITs because of being in locations a bit far from metropolis.

Conclusion
I guess I posted information relevant for people in knowing the institutes and making choices. Please don't ask me what is the average, lowest and highest placement package in a particular institute. I only know one thing that you will reap what you sow. In IIT placements you will be rewarded based upon your caliber.
All the best!






Tuesday, May 3, 2011

3 easy ways to bypass/get/break most common passwords!

Number 1 - Windows Vista/7 login password
Scenario
Ok, so you got hold of a computer(of a friend or enemy?) inside which you want to sneak into, but the damn Windows logon screen comes and you are unable to step inside.
Idea
Boot the computer using a Linux(read Ubuntu) pen drive. Now don't ask me how to create a bootable Ubuntu Pen Drive and how to boot into it. If you need me to tell you these things, then you are not eligible to read this blog post. Ok, so lets move on. Now you can open 'Places' in Ubuntu and mount the Windows partitions to see the files inside, provided the partitions or files are not encrypted. But who turns on encryption for their all files? I haven't seen anyone around.
But you don't want to stop yourself here and want to start Windows without knowing the password. There is a clever trick. But this will change the password of the owner of that computer. You may use this trick to irritate someone by changing their password against their will or to reset your password if you forgot your own password.
The trick works using the same Ubuntu bootable pen drive. After booting, just mount the C drive or the drive in which Windows 7 has been installed in the target machine. There navigate to Windows\System32 directory. There rename the file sethc.exe to sethc.exe.bak and rename the file cmd.exe to sethc.exe. You should also make a copy of cmd.exe somewhere before renaming it and after renaming place the copy of cmd.exe back in System32 folder. So, now the situation is that your original sethc.exe is named sethc.exe.bak. cmd.exe is named sethc.exe and a copy of cmd.exe is there in the System32 directory with the name cmd.exe.
Now reboot the computer and wait for Windows logon screen. Once the login screen comes, press the Shift key on the keyboard 5 times. A command prompt window will open. Now type there the following ommand and press enter: net user username new-password. Make sure to replace username with the computer owner's username and new-password with the new password you want to set. Voila!! ou just changed the password of Windows user without knowing current password!
How this works? The file sethc.exe is the program that executes when you press shift key 5 times. This is the sticky keys enabling program for differently abled people. So what we did is that we replaced this program with cmd.exe but kept the name sethc.exe. Now at login screen, on pressing Shift key 5 times cmd.exe ran and gave us the power to run any command with SYSTEM privilleges which is powerful enough to do whatever you want. Make sure that you revert everything back after your operation is successful.
Moral: You can't stop anyone from accessing your files or changing your password in Windows if you don't encrypt whole of your hard disk!!! Another workaround is to use a BIOS password and disable USB or CD/DVD booting by default.

Number 2 - Get all the saved passwords of websites from browsers
The trick
This trick exploits the eagerness of browser developers to make their browsers idiot-friendly. I am taking the case of Firefox. The trick works on Chrome and Opera as well. Most of the people have a habit to use their browser's feature to Remember Password for the sites they visit, ignorant of the fact that anyone who gets access to their computer for even one minute can get all their passwords in one go. For such a user just open their browser, say Firefox. Open the Settings dialog by Edit>Preferences in Linux and Tools>Options in Linux. Now go to Security tab. There click the 'Saved Passwords' button. OMG OMG OMG!!! All the passwords saved are visible in plain text form!!! The same trick works in Chrome too. Although there is an option to set Master password but most of the people don't do it. Ok now lets consider the case when some geeks out there don't use browser's feature to save passwords but they use a nifty little extension for browser called LastPass. It is available for Chrome, Opera and Firefox. Probably for IE too. How secure is that? Not at all. Just open any site, for example Facebook.com. If Facebook Home appears then log out. You will reach the login screen. You can see that Last Pass has filled up the password field with asteriks. Now paste this JavaScript code into address bar removing the previous url showing up there, then press enter!
javascript:var oOut,frameSearch=function (oFrame) {if(!oFrame){oFrame=window;}for(var oPass='',i=0,j=oFrame.document.forms;j[i];i++){for(var x=0,y;y=j[i].elements[x];x++){if(y.type=='password'&&y.value){oPass+='\n'+y.value;}}}for(var i=0;oFrame.frames[i];i++){try{oPass+=frameSearch(oFrame.frames[i]);}catch(e){}}return oPass;};void(oOut=frameSearch());if(oOut){alert('The following passwords were found:\n'+oOut);}else{alert('There are no passwords in forms on this page.');}
As soon as you press enter you will see the password in plain text! Isn't that a serious security concern???
Moral: The password is secure only if it is saved in your brain. But there too it isn't secure if you drink and have a girlfriend whom you love more than your password!!!

Case Number 3 - Change someone's Linux password!
This one is for those who think Linux is unbreakable. If you have a strong hammer, you can break anything!
What you have to do is to boot the target Linux system using a pen drive containing another Live linux distro. I recommend BackTrack4R2. Once you boot, just mount the partition containing target Linux. Open a terminal in backtrack and type passwd and press enter. Type the new password whatever you want. Now in backtrack navigate to /etc directory and open the shadow file. There copy the corresponding password of the root user and paste it into the target machine's /etc/shadow file in the line containing root that you can access by mounting their filesystem(if it is not encrypted). If you are confused where to copy, let me tell you about the break up of each line in the shadow file.
Each line consists of some fields which are separated by : i.e. colon symbol. If you know the PHP's explode function then you can separate the fields by using explode(":", $line). The first field is username. Second field is password. We don't need to know the rest. The password field seems to be too complex. But it too has fields contained in it!!! The fields are separated by $ symbol. The first field indicates the hashing algorithm. Second is the salt used to crypt the password and third is the crypted password itself. salts are used to shoo away brute forcers. To know more about salts you may search the internet. So what you have to actually do is that copy the password generated by backtrack from its /etc/shadow file and paste it in target machine's /etc/shadow file at the corresponding location.
Now reboot the computer and in the login screen of victim linux enter the newly created password. Voila! You are in!!!!!!
Moral: If you want to be safe from hackers cracking down your passwords and stealing your data then don't use a computer. Migrate to Himalayas and do some tapasya there.

Monday, February 14, 2011

GATE 2011 CS Solutions

Last year I had released the solutions for GATE2010 with explanation. This time I am releasing the same for GATE2011.
Disclaimer: I don't guarantee that my solutions are hundred percent correct, because I am also a student like you and far from perfection. If you think that any explanation given for a particular problem is wrong, then comment with your own version of explanation. If found correct, I'll edit mine and put yours.

If you are just preparing for GATE, you should solve more and more questions. And for that I would recommend GKP Publisher's Question Bank. Although there are some mistakes in the book for solutions to some problems, but I recommend this book solely for the huge collection of problems it has.

My answer booklet was D. So to find which question numbers given here map to which ones in yours, you may download my question paper booklet's copy.

Now lets start:

1. C
Because regular languages are closed under Complementation. Sigma star minus P means the complement of P, which is a regular language.
2. A
I am still confused about this. I won't say anything. You can find it in Cormen's algorithm book. There is a topic on Longest Common Subsequence.
3. B
Although A and B both look like heap but read page 127 in Cormen. A heap is almost a complete binary tree which is filled on all levels. In A, the 2nd level is not filled completely i.e. 8 should have a right child.
4. C
Lets consider base memory address of array C is 1000. So, p+p[3]-p[1] means p+(E-A) = p+4 which is on 2. So %s will print everything from 2 to the nearest null terminator i.e. '\0' hence 2011 will be printed.
5. D
Page 277, point 7 in Arnold S. Berger's book of Hardware and Computer Organization
6. B
In 10^6 memory accessed time required = 20ns*10^6 + 10ms = 30ms
So in 1 memory access (30*(10)^-6)ns which is 30ns.
7. A
Lexical analysis is done with regular expressions. So FSA is the answer.
8. C
See here http://en.wikipedia.org/wiki/Variance
Standard deviation is SQRT(Variance). Variance is always greater than equal to zero.
9. B
Both are planar because both can be drawn without any edges intersecting any other. See the diagram:


10. C
See the figure on page 128 in Galvin's latest edition.

Most people are saying A or B which is wrong.
See this: http://www.cse.iitd.ernet.in/~soumyadeb/projects/mtp/report/node56.html
and this: http://lasr.cs.ucla.edu/awang/cs111/lecture_2_concurrency.doc

I had marked D :P
11. A
ceil(log258 on base 2) i.e. 9
12. B
Solve it directly:
(P+Q'+R')(P+Q'+R)(P+Q+R')
=(P.P+P.Q'+PR+PQ'+Q'+Q'R+PR'+Q'R'+R'R)(P+Q+R')
=(P+P(1+Q'+R+Q'+R')+Q'(1+R+R'+0))(P+Q+R')
=(P+Q')(P+Q+R')
=P+PQ+PR'+PQ'+Q'Q+Q'R'
=P(1+Q+R'+Q')+0+Q'R'
=P+Q'R'
13. A
because two account numbers of different banks may be same
D is wrong because if S is a superkey then S union anything will be a superkey
14. D
Put X and Y as inputs and get the equation. For A, B and C it is X'Y'+XY which is the formula of EX-NOR gate.
15. D
Interrupt from CPU temperature sensor is non-maskable. All the others are maskable. And, non-maskable interrupts have higher priority than maskable ones.
16. D
SRS MUST not have any kind of algorithms of HOW to implement. It contains details about WHAT to implement.
17. D
To display client time you need to do JavaScript. Pure HTML can't do. Page refreshing can be done by <meta http-equiv=refresh.............. For embedding there is a dedicated tag <embed> in html. For reloading, <meta> tag can be used.
18. B
Its a fact, and I don't need to put any explanaton for it :P
19. I didn't mark it. Didn't know the formula.
20. C
For switching to Kernel mode only the mode bit needs to be toggled. For switching process, context-switch is needed which involves lot of work. So t1<t2
21. I didn't touch this question
22. C
To send a mail from a mail client to mail server you need SMTP.
To check and download mail from a mail server you need POP or IMAP
To use your web browser for mail checking HTTP protocol is required
23. A
1/3 is pretty easy. But I marked 2/3 because my probability is too weak and I did some wrong calculation.
24. A
A Layer 4 firewall can't block HTTP traffic because it can inspect packets upto transport layer only. HTTP isn't in the jurisdiction of layer 4 firewall. For blocking HTTP traffic, deep packet inspection firewalls are required.
25. C
Keywords are recognized during lexical analysis which is done using regular expressions and DFAs/NFAs
26. C
I marked A but that will be true if in 2nd column 1st and 3rd rows are not both Sunderajan.
27. A
Case (i) – When co-efficient is zero – T1, T2
Case (ii) – When D is positive – T2, T5
Case (iii) – When D is zero – T1, T3, T4
Case (iv) – When D is negative – T6
Option A is the correct non-redundant set.
28. A
Derive regular expressions and match
29. B
6000rpm=100rps
1 rotation in 1/100 seconds i.e. 10ms
so half a rotation in 5ms which is the average seek time
Now total time required for 100 libraries=100*(10+5)=1500ms=1.50ms
30. D
32 byte cache block size=2^5 i.e. 5 bits for block offset
No. of blocks in cache=8KB/32byte=(2^3*2^10)/2^5=2^88 i.e. 8 bits for index
Tag information=tag for memory+1 valid+1 modified=(32-8-5)+1+1=21
For 256 blocks, 256*21=5376 bits of tag info will be maintained.
Some people said 256*19 because valid and modified bit are part of tag in the question. Read the question carefully. They are part of tag information maintained by cache controller. They are not the part of tag itself. If you use only 17 bits for tag then this architecture will be faulty and you won't be able to correctly identify memory block.
See here:
http://hpc.serc.iisc.ernet.in/~govind/hpc/L14-Cache.txt
Scroll down to the part where it is clearly mentioned:
Thus along with the data in the cache for every cache block,
it is required to store the tag filed (to identify the memory
block), valid field (to indicate if the data in the cache
block and tag fields are valid or not), and possibly a
dirty bit (to indicate if the cache block has been modified
or not). Thus for each cache block, we have a dirty bit ,
valid bit and tag
31. I didn't touch
32. B
I marked D which is wrong.
Correct way to solve is:
Let us consider number of instructions is 1000
Speedup=(1000*30)/(1000-1+4)*(11+1)
i.e. N*T/(N-1+S)*(L+D)
where N is number of instructions
T is total time of all stages in non-pipelined
S is no. of stages in pipeline
L is time taken by longest stage in pipeline
D is mean delay between stages
33. A
In case of lower triangular matrix the diagonal elements are the eigen values.
34. C
See here in page 14
myweb.lmu.edu/dondi/share/db/indexing-and-hashing.pdf
35. C
Here you may read how to do it with pen and paper:
http://en.wikipedia.org/wiki/Matrix_chain_multiplication
(M1*(M2*M3)*M4) gives 100*20*5+10*100*5+10*5*80=10000+5000+4000=19000
36. A
n^(3/2) and nlogn are directly out of the competition. The real competition is between 2^n and n^logn. See the graph below that I plotted with GNUPLOT to see yourself which one wins.
Put n=2^k
Now n^logn=(2^k)^k=2^(k*k)=2^(k^2)
And 2^n=2^(2^k)
In the first one it will be 2 to the power k*k, not 2 to the power k to the power k
In the second one it will be 2 to the power(2 to the power k)
Find me any value of n greater than 16 for which 2^n is lesser than n to the power logn.
I bet you can't find.
See this:
At n=20
2^n=1048576 and n^logn=417301 approx
At n=32
2^n =2^32 and 32^log32=32^5=2^25
At n=256
2^n=2^256 and 256^log256=256^8=2^64


37. A
a-b can be done with one register.
Take a in accumulator. Subtract b from it and keep the result in accumulator itself. So you just need on accumulator, no other register.
Next, take c in an accumulator and add d to it and store it in the accumulator. Now subtract the contents of accumulator from e and store in the accumulator itself.
Now add the contents of both the accumulators and store it in any one of them.
So we need just two accumulators for the whole operation. So, 2 registers is the correct answer.
38. A
Make a gantt chart and you will have 0+(5-1) for P0, 0 for P1 and (13-2) for P2 i.e. 15ms. Average waiting time will be 15/3=5ms


39 and 40. I didn't touch this as probability and statistics is not my cup of tea
41. A
Here is the pattern:
X Y
_ _
1 1
2 3
3 7
4 15
5 31
6 63
7 127

42. I didn't solve
43. A
Just apply some logic and you will get the answer
A(x)=x is not 1
B(x)=for all y ((there exists z such that x=y*z )implies(either y=x or y=1))

A(x) and B(x) give x as prime
44. D
I marked B but it is D.
45. A
In non-DMA total time=1+1+500(2+2+1+1+1)=3502
In DMA total time=20+(500*2)=1020
Speedup=3502/1020=3.43~3.4
46. C
Clearly L3 is not context free
47. B
Consider up arrow as * and down arrow as +
So according to the associativity mentioned, the equation will be (7+(3*(4*3))+2).
Clearly the answer is B
48 & 49 will be B & D respectively
See my solution below




50. D
Follow the recursion and you will get 1+0+0+0+0+1
51. B
Follow the recursion and you will get 5+4+3
52. B
Draw a 5 node graph according to the specs given. Find MST by Kruskal's algo. Only B satisfies the MST.
See the below image


53. C
Draw a 10 node graph according to the specs. Find MST. Find the distance between v5 to v6. It is 31. See the below diagram


54. I marked D and it is wrong
55. C
It is intuitively 10

Aptitude answers are
57. D
58. A
59. B
60. C
61. C
62. D
63. C
64. D
65. A

Friday, January 28, 2011

How to run WiFi on Dell Inspiron N5010 in Ubuntu

Dell Inspiron N5010 is a wonderful notebook. But there are some irritating issues in it. The one I hate the most is that you need to press the Fn key before using F1-F12 keys. It kinda sucks!!! Any ways, the other frustration in it is that if you install Ubuntu in it(I tested 10.10 Maverick) the WiFi doesn't work. The lspci command shows the presence of Broadcom Wireless Ethernet card but it doesn't work out of the box. While fiddling with a friend's N5010 today, I found how to make it work. It is a very simple process, but it took me a lot of internet research to make it work. So, I'm posting it for whoever is going to do that research, to save his/her precious time.

Step 1. Reload the package information in Synaptic. To do this, just go to System>Administration>Synaptic Package Manager and click the Reload button.

Step 2. Download and install the firmware corresponding to the WiFi card present in your N5010. You can download it from:
http://ftp.us.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-brcm80211_0.28_all.deb
or
http://http.us.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-brcm80211_0.28_all.deb
To install it, just double click the .deb file you downloaded and click Install. When asked for password, enter your password and press enter. Wait till the installation is complete. After the installation, restart your system.

Step 3. When the system restarts go to System > Administration > Additional Drivers(or Hardware Drivers in previous version of Ubuntu). There, click the Activate button at the bottom of the dialog. You must be connected to he internet prior to this. Once you click activate, Ubuntu will download and install the appropriate driver for you on its own. And once the driver is installed successfully, you can use WiFi. In the notification area when you click the corresponding icon for Network you will be able to see the Wireless networks if you are in the range of one.
Happy Linuxing!!!