0% found this document useful (0 votes)
91 views

Network Monitoring System

Uploaded by

tellerstory701
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

Network Monitoring System

Uploaded by

tellerstory701
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

FACE RECOGNITION BASED ATTENDANCE SYSTEM

A Project report submitted in partial fulfillment of the requirements for the award of the

degree of

BACHELOR OF TECHNOLOGY
IN

COMPUTER SCIENCE AND ENGINEERING

Submitted by

DEVRAJ CHATURVEDI(20EELCS015) MAYANK TIWARI(20EELCS032)

Under the guidance of

Mr. SUMIT KUMAR,

Department of CSE

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

GOVT. ENGINEERING COLLEGE BHARATPUR

Village-Shyorana, N.H. 11, Bharatpur dist.(Rajasthan) Pin-321303


It gives me pleasure to present my project report on “Network Monitoring
System” as per requirement of the curriculum of the course Deploma of computer
engineering from the msbte Mumbai at the government polytechnic jintur.
First , I am hearty thankful to project guide SUMIT KUMAR for selecting this
project.
I would also like to thank Prof. PRASHANT BAHETI, H.O.D. of CSE. and
Principal RAVI GUPTA of our college.
Once more we will express deepest thanks to our project guide SUMIT KUMAR
sir for these guidance and Encouragement at every step in our way completing this project.
Lastly we are heartly thankful to our parents and friends for their valuable support
for our project.

1. DEVRAJ CHATURVEDI
2. MAYANK TIWARI
3. VANSH
ABSTRACT

Network monitoring system supervises all computers in network. It consists of two


programs client & server each run on different terminals which having different operating
system that is platform independence like windows or Linux. Server program have task
manager which shows process running on all clients. By using this task manager server
can stop any process running on client terminal forcefully.
It also capture remote desktop screen of client for observing whatever activity
perform at that instant.
It also provides chatting facility between client and server. If client having any
difficulty he can chat with server. Client can ask question to server and server can reply.
Table of Contents

SR. NO. TOPIC PAGE NO.


1 Introduction [1-2]
1.1 Project Preview 1
1.2 Scope of Project 1
2 Survey of Literature [3-12]

2.1 Specialty about Remote Task Manager 4

2.1.1 Uses of Remote Task Manager 5

2.1.2 Working of Remote Task Manager 6

2.2 Specialty about Screen Capturing 6

2.2.1 Working of Screen Capturing 7

2.3 Specialty about Chatting 9


2.4 Requirement Analysis 10
2.5 Software Requirement Specification 11
3 Design [13-23]

4 Implementation [24-30]
4.1 Login Window on Server 24
4.2 Server side Interface 25
4.2.1 Remote Task Manager 26
4.2.2 Send Message 27
4.2.3 Execute Command 27
4.2.4 Screen Capturing Module 28
4.2.5 Chatting Module 29
4.2.6 Lock/Unlock Module 30

5 Testing [31-34]
5.1 Test 1 31
5.2 Test 2 31
5.3 Test 3 32
5.4 Test 4 33
5.5 Test 5 33
5.6 Test 6 34
6 Result & Analysis 35

7 Application 36

8 Future enhancement 37

9 Conclusion 38

10 Bibliography 39
11 Project code 40

Chapter 1

INTRODUCTION

Here in this section we will familiarize you with the project with its overview,
introduction and our objective behind choosing this project.

1.1 Project Overview:


The network monitoring system refers to supervising all the computers in a
network, be that LAN, WAN, MAN or GAN. Security was not a priority for the original
designers of the local area network protocols. Networks were assumed to be private,
isolated and physically secure, or else completely public. This assumption is no longer true
because of the growing commercial use of the internet and computers connected in small
network for the purpose of sharing; a considerable amount of private information is now
being sent over public networks.

“NETWORK MONITORING SYSTEM” is the client-server based project. In


this project administrator can keep the track of user’s running processes, time of login and
time of logout. Administrator can capture snapshot of clients desktop and can also chat
with them.
As the numbers of workstations are more in the network, it is the difficult task for
the network administrator to off each and every workstation computer individually. To
simplify this in our project there is a provision for remote shutdown, reboot and logoff the
workstation from the server. In addition to all this finally the report of login and logoff
from particular workstation can be generated on server computer. This project also
provides file transfer.

1.2 Scope of Project:


There was no any computerized based system existing to provide all function which
we will provide in our proposed project. The scope of project extends to the network related
organization that is connected by LAN.
Thus this project can be used in wide application like Schools, Offices, Colleges,

Institutions and Cyber café’s. More improvement can be made in this system if necessary.
Chapter 2

SURVEY OF LITERATURE

Remote Task Manager from SmartLine, Inc is a systems control interface that can
be run from any remote Windows NT/2000/XP computer. It is the leading
enterprise remote control solution for corporate networks.[1]

Remote Task Manager significantly reduces the total cost of network management
in enterprise environments by enabling IT personnel to control tasks, processes,
services, devices, shared resources, events and computer performance over LAN,
WAN and the Internet.[1]

The periodic distribution of new programs, patches and updates represent a large
portion of an administrator’s duties. The challenge is to find the right tool to do
the distribution with a minimum of fuss and muss. It turns out that you can do a
pretty good job at simple software distribution with minimal effort by just doing
remote file copies combined with creating jobs in each remote system to install
the just copied file(s). [2]
Remote Task Manager® (RTM) is a systems control interface that can be run
from any remote Windows NT/2000/XP and Windows Server 2003 computer.
This enables a Systems Administrator to control most aspects of a remote
environment. RTM adds the ability to lock/shutdown/reboot and to create
processes on remote computers. [3]

BB FlashBack is a leading screen recording program for Windows, published by


Blueberry Software. When the record function is activated, screen activity is
stored in a real time video file. This recording can then be replayed, edited and
enhanced with graphics, text or sound effects. [4]

Screen capturing is designed to meet the complex requirements of technical and


other workstation applications. It is designed for easy integration into
applications. The original colors of individual windows are preserved with any
combination of windows. Even when a window appears in false colors on the
screen due to color table overrun, it is captured in its original colors and is saved
correctly.[5]

Chatting on LAN approach enables cooperative work by using the LAN as an


entry point for starting applications that can offer more specific functionality for
cooperative work.[6]

2.1 Specialty about Remote Task Manager

A clean and simple-to-use user interface offers easy setup wizards and multiple
graphical views of the information. Remote Task Manager is designed to run
under Windows NT/2000/XP. It provides automated support for Install and
Uninstall.
Remote Task Manager even supports remote installs, enabling a Systems
Administrator to set up a service on remote machines without ever having to
physically go to them.
Remote Task Manager supports systems with up to 64 active CPUs. On an SMP
(multiprocessor) system, you can control which CPUs a process will be allowed
to execute on.
The Process Function and the Task Manager allows remote termination and
adjusting of priority.
An Event Viewer lets the Administrator view all events as though they were being
run on the host computer. The Performance Monitor displays a dynamic overview
of the computer's performance (CPU and memory usage).
Remote Task Manager adds the ability to create processes on remote computers.

2.1.1 Uses of Remote Task Manager

The following are a few examples of Remote Task Manager uses:


Starting applications on remote computers – You can run any applications on
remote ever having to physically go to them.
Terminating selected processes. Remote Task Manager has a special function to
close a process correctly (closes all handles opened by that process, unloads all
DLLs loaded by the process, etc.).
Monitoring all running tasks, processes, services, devices and events on remote
computers.
You can stop, start, restart, pause and continue any selected service or device on
the remote computer. In addition, it is possible to adjust service's and device's
security (permissions, auditing and owner) and change service's repair parameters.
Monitoring a dynamic overview of the computer's performance (CPU and
memory usage).
Remote Task Manager can also be used to manage shared resources on remote
computers.
You can create new sharings and delete existing resources.
You can shutdown and reboot remote computers. Remote Task Manager also
allows you to lock a remote computer.

2.1.2 Working of Remote Task Manager

Remote Task Manager consists of three parts: RTM Service, RTM Manager and
RTM Console.
RTM Service is the core of Remote Task Manager. It is installed on each client
system that you want to manage remotely. RTM Service runs automatically and
provides network access to the client machine while remaining invisible to that
computer’s local users.
RTM Manager is the control interface Systems Administrators use to remotely
manage each network computer that has RTM Service.

RTM Console is similar to RTM Manager except it uses a command line interface
rather than a GUI. RTM Console’s simpler interface works even on Windows
95/98/Me so you can remotely manage Windows NT/2000/XP systems from a
Windows 9x computer.
2.2 Specialty about Screen capturing

Recording methodology

Whereas other screen recorders are limited to a single capture technique, BB


FlashBack offers a choice of three different recording methods. This includes the
Blueberry capture driver, signed by Microsoft for Windows 2000 and XP systems,
representing the most advanced and high performance recording available to date.
The choice of recording methodologies means that, unlike our competitors, BB
FlashBack can give you the best recording whatever your material, computer and
operating system.
The capture driver is signed by Microsoft for use on Windows XP and 2000
operating systems. This driver is not supported on Windows 98, Me and NT
platforms - but users of these operating systems will instead have a choice of the
two alternative technologies below.

DirectX recording mode

DirectX recording is an innovative recording technique that monitors different


sections of the screen for changes. When a change in the screen is found, only the
required section of the screen is analysed and stored to disk – meaning faster
recording for the user without quality loss. This recording method is preferable
when recording on a when capturing special content such as Flash, extremely
graphical material, or when using a lower speciation computer.

GDI recording mode

In GDI mode the whole screen is captured in a series of frames then compared for
differences. Changes are stored to disk and compressed in a movie file. GDI
recording is preferable on higher specification machines with older operating
systems, and offers reliable and quality recording.

2.2.1 Working of Screen capturing

Capture Modes:

· X Enhanced mode which exploits the full EasyCapture functionality. This is the
default mode.
· XWD mode which is based on the standard xwd program. For simple
requirements this mode offers a faster alternative.
· GL mode (IBM RS/6000 and Silicon Graphics) may be required to capture
windows created by GLbased or other non-X applications.

Capture Types
· A single window, with or without its frame,
· The full screen,
· Any rectangular area of the screen

Captured Image File


EasyCapture saves the captured screen image in a file in XWD format. This file
can be imported into other applications, or converted into other formats.

Capture Options -
beep { true | false }
Issue a beep before and after screen capture. The default value is set in the
initialization file).
-display hostname:server.screen
Specifies the display on which the screen capture is to be performed. If the
display is not specified, the DISPLAY variable is used. If the DISPLAY variable
is not set, the local screen (hostname:0.0) is the default display. -application
window-id
Specifies the window id of the main window of the calling application. The
window id is used if the application is to be hidden during screen capture. When
this option is specified an output file name must also be specified. -delay seconds

This enforces a time delay (in seconds) when capturing. The delay applies if the
graphical user interface of the application overlaps the screen area to be captured,
and it has been specified that this window is hidden during capture. Occasionally,
the system’s event handling may initiate the capture event before the menu has
been hidden, or the desired redraw events have completed; this conflict is
resolved by inducing a delay. The default is supplied in the initialization file). -
capturemode { xe | xwd }

2.3 Specialty about Chatting

Chatting is one of the attractive facilities available in the Internet. It provides live
(on line) communication between people at different places by typing in the
computer. Now chatting can even be performed by talking and seeing each other.
For this, web cameras and microphones should be connected in both the computers.
Also the software that facilitates chatting should be executed. You know that an e-
mail id and password are required to use email. Similarly, you need a chat id and
password for chatting. As your e-mail id has two parts in the form of user name
@domain, chat id has also the same.

Creating ChatId
The domain name should be known to create chat id. You can get it from your
teacher. Otherwise, you can use the IP address of the computer in the place of
domain name. Password can be decided by you. You can use your name itself at
the user name. Note that no two persons can have the same user name. For example,
If the domain name is myschool.edu, then your chat id will be in the form of
‘myname @myschool.edu’. Once the chat id and password are decided, we can
create the chat id.

2.4 Requirement Analysis

Since after the analysis of existing system, it is found that all three features
are not combinly available in existing system, there is a need to combine screen
capturing, chatting and remote task manager.
Also, features present in existing system are platform dependent. Due to the
above shortcomings, there is a need to develop platform independent features.

Existing System:

Features are not available combinly.

Features are platform dependent.


Proposed System:

RTM, Screen Capturing and chatting features will be combined into

one. Platform independency will be achieved.

2.5 Software Requirement Specification

Administrator should be able to keep the track of all processes running on


client. Clients may have different platform such as Windows, LINUX etc.
Client & Server should be able to chat with each other in LAN.
Administrator should be able to kill the illegal processes of client.
Administrator should be able to keep an updated log file regarding recent
activities of clients.

With RTM you can:

Monitor all running tasks, processes, services and events on remote computers.
Watch features of running tasks (the handle of the main window, process ID, etc.).
Watch features of running processes (process ID, CPU time, privileges
used, memory and priority).
See which process is associated with a selected task.
See which process is associated with a selected
service. End a selected task correctly.
Terminate a selected process at any time.
Change priority of a selected process.
Control which CPUs the process will be allowed to execute on.
Stop, start, restart, pause and continue any selected service or device.
Change startup parameters of a service or a device (name, account, startup
type, dependencies, etc.).
Change service's repair parameters on Windows
2000/XP. Watch dependent services.
Adjust service's and device's security (permissions, auditing and
owner). Manage shared resources on remote computers.
Clear event logs.
Archive event logs.
Monitor a dynamic overview of the computer's performance (CPU and memory
usage).
Shut down and reboot remote computers.
Create processes on remote computers.
Lock computers remotely.
Chapter 3
DESIGN
Fig3.1:Use Case Diagram

USE CASE DIAGRAM SPECIFICATION

1. CONNECT_TO_SERVER :- It is used to connect client to the server after proper


authentication of the client. Authentication is done by validating the user name and
IP address of the client.
2. MANAGE_REMOTE_TASK: Remote task manager manages processes running
on all clients. By using this task manager server can stop any process running on
client terminal forcefully.
3. CAPTURE_SCREENSHOT: It capture remote desktop screen of client for
observing whatever activity perform at that instant.
4. Do_chatting: It is used for administrator and clients for chatting with each other.
It also used for chatting between client and client.
5. GENERATE_REPORT: It is used for generate report which specifies time of the
remote login, logoff, restart and shutdown.
Fig3.2:Class Diagram
Fig3.3:Activity Diagram
Fig3.4:State Chart Diagram
Fig 3.5:Sequence Diagram For Remote Task Manager
Fig 3.6:Sequence Diagram For Chatting
Fig 3.7:Sequence Diagram For Screen Capturing
Fig 3.8:Collaboration diagram for remote task manager
Fig 3.9:Collaboration Diagram For Chatting
Fig 3.10:Collaboration Diagram For Screen Capturing

Chapter 4
IMPLEMENTATION

4.1 Login Window On server

The above window is the first to appear at the server side. The window is named
Admin_Login since it is used by administrator for login purpose.
After the administrator enters the valid username and password, he is granted access
to the next form. By clicking on the Exit button Administrator can close the application.
The above given window is basically used for authentication of administrator. Database of
username and password is stored in oracle on Server side.

4.2 Server Side Interface

The server side interface act as a combined interface for all three modules i.e
Remote Task Manager, Screen Capturing and Chatting. The right hand side of the
window displays the operating system running at each and every client.

The number of clients connected is displayed with the corresponding name and ip
address of the client. The administrator can see the details of the client by clicking on the
respective client’s name and ip address and then clicking on See Details button.

This operation leads to the next window called as Remote Task Manager.
4.2.1 Remote Task Manager Module:

The Remote Task Manager is used to access the task manager of the client. The
name of the task running on the client’s side is enlisted along with its process id.

Two buttons are provided on this window namely, Kill process and Send Message.
By selecting the name of the process of the client that the server wishes to kill and by
clicking on the send message button , the server first sends warning message to the client
to close the respective process. If the client fails to do so, the server can kill the process
by clicking on the Kill Process button. Hence, the client process is closed forcefully.

4.2.2 Send Message:

By clicking on send message button, the server can send any message to client.
By default Hello Message is sent. Server can also send any message to client.

4.2.3 Execute Command:

The execute command button is used to execute different commands at the client
side by the server. For example server can open notepad.exe, mspaint.exe or can even
shutdown the client terminal by sending the command Shutdown-s.
4.2.4 Screen Capturing Module:

Screen capturing module has two subparts. They are Get Screen and Dynamic
Capture.

By clicking on Get Screen button, only static image of the client’s terminal is shot.
Whereas using Dynamic Capture, images of client’s terminal is captured dynamically i.e
after a specified time interval the captured image gets updated automatically and is stored
in a folder named after the respective client at server side.

Moreover, for effective use of disk space, after 25 images are stored, the entire
collection is erased and the 26th image is stored at the first location.
4.2.5 Chatting Module:

In Chatting module, a login window is provided at both the client as well as the server
side for authentication purpose. After clicking on the login button the client gets connected
to the server and vice versa.

After successful entry the chatting interface is displayed. The left hand side of the
window displays the name of the logged user. This list gets updated as the number of user
logged on increases. By default Welcome message is sent. The window has three buttons
namely Send, Send2all and Logout.

By clicking on send button, message is sent only to selected client. By clicking on


send2all, messages can be sent simultaneously to all users who are currently logged on.
By clicking on logout button, the respective user disconnects himself / herself from
chatting application.
Using Chatting application, both client and server can chat between each other whenever
required.

4.2.6 Lock/Unlock Window:

The lock/unlock window is basically used by administrator while he/she leaves the
terminal. This window provides security by forcing the administrator to enter the username
and password again. Hence, impersonisation can be avoided.
Chapter 5

TESTING

• Test cases

Test cases are designed such that all modules get tested at least by one of
test cases. For successful testing all test cases should pass i.e. outcome should be
as expected.

5.1 Test 1

Test - To test administrator login with correct ID & Password.

Test Description – This testing is performed for the authentication


of user.

Phase – Administrator Login.

Setup – A unique ID and password are setup in the


database itself.

Testing – Here the administrator ID and Password are checked.


The ID is also tested for different passwords and vice versa. An
error message is displayed unless entered with correct specified ID
and password.
Result – Verified ID and Password.

5.2 Test 2

Test – To test connection establishment.

Test Description – This test checks whether client is connected to


server or not. Here the server should always be in listening mode.

Phase – Client-Server connection establishment.

Setup – After configuring Network adapter (Ethernet)


card with proper IP address settings, the connectivity
in computers in the LAN are tested using PING
command.

Testing – Execute the server first and then specify the IP


address/DNS name in the client side.

The states through which the module flows:

SERVER_LISTENING

--After checking the server is listening, sending request for


connection from client side.

CLIENT_CONNECTIONREQUEST

--If the server is not listening, there will be no connection.


--also if no IP address name is specified, there will be error
message from client.

CLIENT_ERRORMESSAGE

--If everything is OK, then connection will be successful

CLIENT_CONNECTED
Module Tested- Establishing connection between
client and server.

Result – Connection is established between client & server.

5.3 Test 3

Test - To test General Utility tools.

Test Description – This test is performed to check the general


utility tools like send message and execute command.

Phase – General Utilities testing.

Testing – Lets consider the execute command tool. After testing it


for shutdown for windows98 we came to a conclusion that the
code needs some modifications for successful execution on
windows XP and higher versions.

Result – Modified as per requirements.

5.4 Test 4

Test – Test for Chat application.

Test Description – This test is performed to check the chat


application between the client and server.

Testing – After initiating the chat application at client and server


side, it is checked that whether messages are passed correctly.

Result – Chat application was tested successfully.


5.5 Test 5

Test – Test for Screen Capturing.

Test Description – This test is performed to see if the server can


capture the remote desktop screen without delay.

Phase – Testing screen capturing.

Testing – The capturing and actually viewing the remote screen


depends on the performance of the network (LAN).

Result – Screen can be captured without any delay as well as it


can be viewed in real-time.

5.6 Test 6

Test – To test access of client’s task manager.

Test Description – This testing is performed so that any illegal


processes can be stopped from being executed by client.

Phase – Testing Remote Task Manager (RTM).

Testing – Here new process is made to execute at client’s side and


we see whether the task list at the server side is updated. After this
is verified, a warning message is sent to client to shutdown the
process. If the client doesn’t respond to the warning message, the
process is killed by server.

Result – Warning messages are sent as well as process was killed


successfully.
Chapter 6

RESULT AND ANALYSIS

Testing has been performed for verification of user name and password, connection
establishment, chatting application, remote task manager, screen capturing and general
utility.
In login form testing the administrator ID and Password are checked. The ID is also
tested for different passwords and vice versa. An error message is displayed unless entered
with correct specified ID and password. After Verifying ID and Password he can get access
to system.
After configuring Network adapter (Ethernet) card with proper IP address settings,
the connectivity in computers in the LAN are tested using PING command. Execute the
server first and then specify the IP address/DNS name in the client side. After checking the
server is listening, sending request for connection from client side and connection is
established between server and client.
After initiating the chat application at client and server side, it is checked that
whether messages are passed correctly. If yes then Chat application was tested
successfully.
In Remote task manager testing new process is made to execute at client’s side and
we see whether the task list at the server side is updated. After this is verified, a warning
message is sent to client to shutdown the process. If the client doesn’t respond to the
warning message, the process is killed by server. In this way we can get required result.
In screen capturing the capturing and actually viewing the remote screen depends
on the performance of the network (LAN). Screen can be captured without any delay as
well as it can be viewed in real-time. Here also we got the required result. Also in general
utility testing the system gives required result.
After testing it was found that the output for given set of input was as expected.
Hence gives the positive result.

Chapter 7

APPLICATION

• Is very effective as a monitoring tool in offices/commercial places. For instance, if


an employee is watching a movie on media player during office hours, it can be
brought to light immediately and can be forced to close it.

• Can be used in cyber cafes, hence can help to reduce Cyber Crimes.

• Can be used in practical laboratories of schools and colleges so that a single person
can keep a track of all the students of what he or she is doing without having to visit
each and every terminal.
Chapter 8

FUTURE ENHANCEMENTS

1) Keystroke monitoring :
In this the code can be further modified to capture the keystrokes of remote
console. This will help you in monitoring and preventing illegal user
operations.

2) Webcam monitoring :
Webcam monitoring is useful tool in case of monitoring the users on the
remote terminals or even for surveillance. It can also be successfully
implemented for video conferencing.

3) Controlling the Remote terminals using Short Messaging Service (SMS) :


Using mobile phone interaction with the computer, the application can be
further enhanced. One can Remotely control some of the function such as
SHUTDOWN, RESTARTING the computer, killing the unnecessary tasks and
even getting remote desktop screen on GPRS enabled phones. The only necessity
is that the remote computer should always be connected to the internet for SMS
reception.

4) Session Continuation:
To make provision such that user session can be continued when the power
failure problem occurs.
Chapter 9

CONCLUSION

Security is an important aspect in the world of network. Various business


organizations are providing special attention for confidentiality in VPN’s. Also monitoring
each and every computer individually is very tedious job for Administrator. Hence, a
monitoring system plays a crucial role for administrating such networks.

Our project, ‘NETWORK MONITORING SYSTEM’ is designed taking into


account these aspects. The application provides a very friendly interface for remote
administration. The application can be easily enhanced with some additional features like
controlling remote computers via SMS, getting the remote computer screens on GPRS
enabled mobile phones.
Chapter 10

BIBLIOGRAPHY

1) ©1998-2002 SmartLine, Inc.


2) Easy Remote Program Installations Using the Task Scheduler Service, Rev 4
- April 27, 2006, Lieberman Software Corporation http://www.liebsoft.com/
3) Copyright © DeviceLock, Inc. 1997-2008.
4) BB FlashBack White Paper, 1st Edition – BB FlashBack 1.4.1 – February 2005
5) Implementation of Screen Capture in a Design Environment using
EasyCapture, White Paper by Knud Thomsen, Marketing Director.
6) Chatting on the LAN by Martijn van Welie and Anton Eliëns Vrije Universiteit,
Department of Mathematics and Computer Science De Boelelaan 1081, 1081 HV
Amsterdam, The Netherlands email: {martijn, eliens}@cs.vu.nl, fax:
+31.20.4447653
//PROGRAMS AT SERVER SIDE……

//program for login for administrator for access whole system


• //LoginAdmin.java

import java.rmi.*; //declare required packages.


import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.JOptionPane;
public class LoginAdmin extends javax.swing.JFrame implements
java.awt.event.ActionListener
{//declare different required variables
Connection cn; //variable fr connection with oracle private
javax.swing.JButton jButton1; //define different buttons private
javax.swing.JButton jButton2; private javax.swing.JLabel
jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPasswordField jPasswordField1;//define textfield and
passfield private javax.swing.JTextField jTextField1;
Font f; //define font variable
AdminGUI1 a1; //declare an object of AdminGUI1
public LoginAdmin() //constructor
{
setTitle("Admin_Login"); //set different variables of frame
f=new Font("Arial",1,16); //declare font
initComponents(); //call initcomponets() function for design GUI
try
{ //connectivity with oracle database for accessing the data.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbc:odbc:logdsn","system","niraj");
}
catch(Exception e)
{
System.out.println(""+e); // catch & print exception
}
}
public int adminlogin(String user, String password)throws RemoteException //check for
Authentication
{
int k=0; //declare for checking availability
try
{
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("Select * from adminlog where uname='"+user+"' and
pwd='"+password+"'"); //fire aquery for checking authentication
if(rs.next()) //execute query
{k=1;
}
rs.close(); //close
st.close();
}
catch(SQLException e)
{
System.out.println(e);
}
return k; //return value of K for athentication
}
public void actionPerformed(java.awt.event.ActionEvent ae) //action performed after
click on buttons
{
try
{
if(ae.getSource()==jButton2) //after clicking on exit button.
{
JOptionPane.showMessageDialog(this,"Exiting");
dispose(); //close window return;
}
if(jTextField1.getText().trim().length()>0) //check length of textfield
{
if(jPasswordField1.getText().trim().length()>0)
{
int
res=adminlogin(jTextField1.getText(),jPasswordField1.getText());
if(res==1) // if username & password is valid {
a1=new AdminGUI1(); // display server interface
dispose();
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Invalid
UserName/Password");
jTextField1.setText(""); //clear both textfields and setfocus at particular
textfield
jPasswordField1.setText("");
jTextField1.requestFocus();
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Enter
Password"); jPasswordField1.requestFocus();
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Enter
Username"); jTextField1.requestFocus();
}
}
catch(Exception e)
{
javax.swing.JOptionPane.showMessageDialog(this,"error is "+e);
}
}//end of actionperformed
private void initComponents()
{ // design or declaration of variable for GUI jLabel1 =
new javax.swing.JLabel(); jTextField1 = new
javax.swing.JTextField(); jLabel2 = new
javax.swing.JLabel(); jPasswordField1 = new
javax.swing.JPasswordField(); jButton1 = new
javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton1.addActionListener(this);
jButton1.setBackground(Color.darkGray); //set dolor of button
jButton1.setForeground(Color.white);
jButton2.addActionListener(this);
jButton2.setBackground(Color.darkGray);
jButton2.setForeground(Color.white);
addWindowListener( //close all programs after disposing this window
new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
dispose();
}
}
);
getContentPane().setLayout(null); //define layout of content pane
getContentPane().setBackground(Color.orange); //set color to content pane
jLabel1.setText("Password"); //defines diff. labels
jLabel1.setFont(f);
getContentPane().add(jLabel1);
jLabel1.setBounds(50, 70, 100, 14);
getContentPane().add(jTextField1);
jTextField1.setBounds(160, 30, 120, 20);
jTextField1.setFont(f);
jLabel2.setText("UserName");
jLabel2.setFont(f);
getContentPane().add(jLabel2);
jLabel2.setBounds(50, 30, 100, 14);
getContentPane().add(jPasswordField1);
jPasswordField1.setBounds(160, 70, 120, 20); //set bound to pwd field
jPasswordField1.setFont(f);
jButton1.setText("Login");
jButton1.setFont(f);
getContentPane().add(jButton1);
jButton1.setBounds(80, 150, 80, 28); //set bound to login field
jButton2.setText("Exit");
jButton2.setFont(f);
getContentPane().add(jButton2);
jButton2.setBounds(180, 150, 90, 28); //set bound to button
setSize(350,250);
}
public static void main(String args[])
{ // beginning of program
LoginAdmin l1=new LoginAdmin(); //call constructor
l1.setVisible(true);
}
}

// public interface for Adminserver.


• AdminInt1.java
import java.rmi.*; //import required packages.
import java.net.InetAddress;
import java.util.*;
public interface AdminInt1 extends Remote //Extends remote class.
{
public void acceptClient(java.net.InetAddress ia)throws
RemoteException; public void acceptOsName(String osname)throws
RemoteException; public int login(String user, String password)throws
RemoteException; public void logout(String user)throws
RemoteException; public Vector getAllUser()throws RemoteException;
public void sendMessage(String to,String msg )throws RemoteException;
public String readMsg(String user)throws RemoteException;
public void sendToAll(String msg,String sender)throws RemoteException;
}

// Main Adminserver program which run on server machine.


• //AdminServer1.java
import java.net.*; //import required packages.
import java.sql.*;
import java.rmi.*;
import java.util.*;
import java.rmi.server.*;
import java.io.*;
import java.net.InetAddress;
public class AdminServer1 extends UnicastRemoteObject
implements AdminInt1,Runnable //extends remote object.. {

Vector clientVec=new Vector(); //used for storing name and ip address.


Vector clientOs=new Vector(); // used to store OS name.
Vector v1=new Vector(); //used to store Connected Client name for
chating
Connection cn; //define connection variable.
Hashtable ht=new Hashtable(); //hashtable used for storing client msg and name.
String name = null;
Thread th; //define threads.
int MIN_PRIORITY; //define priority.
public AdminServer1()throws RemoteException
{
th = new Thread(this,"one");
th.setPriority(Thread.MIN_PRIORITY); //set priority to thread.
th.start(); //start thread.
try
{ //connection with oracle.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Declaring ODBC
Driver
cn=DriverManager.getConnection("jdbc:odbc:oradsn","system","niraj");// Provide
Connection
}
catch(Exception e) //catch exception.
{
System.out.println(""+e);
}
}
public void acceptClient(java.net.InetAddress ia)throws RemoteException
{
clientVec.add(ia); //Add IP address of client in Vector
}

public Vector getUserList() // Return client list


{
return clientVec; //return vector containing list of clients.
}
public String getIP(int index) // take IP address from clientVec vector
{
InetAddress ia=(InetAddress)clientVec.get(index);
return ia.getHostAddress();
}
public void acceptOsName(String osname)throws RemoteException //accept OS
name
{
clientOs.add(osname); //add OS name in clientOS vector
}
public Vector getOsName() //take os name of client
{
return clientOs; // return client os vector
}
public int login(String user, String password)throws RemoteException //login
function for chatting.It accept parameter username and pwd from client.
{
int k=0; //use for checking authentication or
if(ht.containsKey(user)) availability. // check user already login
return 1; or not // if yes return 1
try
{
Statement st=cn.createStatement(); //define variable for create statement ResultSet
rs=st.executeQuery("Select * from login where uname='"+user+"' and
pwd='"+password+"'"); //check authontication for chating
if(rs.next()) // execute query
{
ht.put(user,"welcome"); //put user & message in hash table
v1.add(user); //add user in vector v1
k=2;
}
rs.close(); //close resourceset or statement.
st.close();
}
catch(SQLException e)
{
System.out.println(e);
}
return k; //return value of K for verification.
}
public void logout(String user)throws RemoteException // logout client from chatting

{
ht.remove(user); //remove user from hash table
v1.remove(user); //remove user from vector v1
}
public Vector getAllUser()throws RemoteException //return client list of chatting .

{
return v1; // return vector v1
}
public void sendMessage(String to,String msg )throws RemoteException //send msg to
selected client
{
String omsg=(String)ht.get(to);
if(omsg==null)
omsg="";
ht.put(to,omsg+msg); // add old message & new message
}
public String readMsg(String user)throws RemoteException // read msg
{
String msg=(String)ht.get(user); //ckeck availability of user in hashtable.
ht.put(user,"");
return msg; //return msg
}
public void sendToAll(String msg,String sender)throws RemoteException //send msg to
all client
{
for(int i=0;i<v1.size();i++) //send msg to all connected user.
{
String user=(String)v1.get(i); //select user.
if(!user.equals(sender)) // send msg to all clients except him
sendMessage(user,msg); //send msg to user.
}
}
public void run() //execute this function at runtime i.e. run threads.
{
while(true)
try
{
for(int i = 0; i < clientVec.size(); ++i) //check whether client is shutdown or not
{// check whether client is connected or not
InetAddress ia = (InetAddress)clientVec.elementAt(i);
try
{
String host = ia.getHostName(); //get host name of client
InetAddress ia1 = InetAddress.getByName(host);//get Inetaddress of
client using host name
}

catch(Exception e)
{
System.out.println("---------------------------------"+e);
clientVec.remove(ia); // remove client name after shutdown or
disconnected
clientOs.removeElementAt(i); //remove os name
}
}
th.sleep(5000); /thread sleep after particular time interval
}
catch(Exception e)
{
System.out.println(e);
}
}
}

// Main GUI design of server interface.


• //AdminGUI1.java
import java.awt.*; //import required packages.
import java.util.*;
import java.rmi.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JFrame;
import java.io.*;
import javax.swing.ImageIcon;
public class AdminGUI1 extends JFrame implements ActionListener,Runnable
{
AdminServer1 adminserver1; //create an object.
// Design Interface.
JButton b1,b2,b3,b4,b5,b6,b7; //define diff. variables for
private javax.swing.JLabel jLabel1; buttons //define diff. labels
boolean flag=true;
Font f1,f2,f3;
JScrollPane jsp,jsp1;
JList lst=new JList(); //initialize the list
JPanel p3=new JPanel();
Thread th,thos,tclr; //declare threads
String cmd;
JList lst1=new JList();
public AdminGUI1() //Constructor.
{
setVisible(true); //visbility of frame is set true
setTitle("Server Window"); //gives title to frame
setSize(1400,775); //set size of frame
setBackground(Color.cyan); //set background color.
f1=new Font("Arial",1,20); //declare different fonts
f2=new Font("Arial",1,16);
f3=new Font("Viner Hand ITC",1,20);
jLabel1 = new javax.swing.JLabel();
jLabel1.setForeground(Color.white); //set color of label
jLabel1.setText("** NETWORK MONITORING SYSTEM **");
jLabel1.setFont(f1);
jLabel1.setBounds(200, 100, 200,130);
setLayout(new BorderLayout());
b1=new JButton("See Details"); //define buttons...
b1.addActionListener(this);
b1.setBackground(Color.darkGray);
b1.setForeground(Color.white);
b2=new JButton("Send Msg");
b2.addActionListener(this);
b2.setBackground(Color.darkGray);
b2.setForeground(Color.white);
b3=new JButton("Execute Command");
b3.addActionListener(this);
b3.setBackground(Color.darkGray);
b3.setForeground(Color.white);
b4=new JButton("Get Screen");
b4.addActionListener(this);
b4.setBackground(Color.darkGray);
b4.setForeground(Color.white);
b5=new JButton("Dynamic Capture");
b5.addActionListener(this);
b5.setBackground(Color.darkGray);
b5.setForeground(Color.white);
b6=new JButton("Chat");
b6.addActionListener(this);
b6.setBackground(Color.darkGray);
b6.setForeground(Color.white);
b7=new JButton("Logoff");
b7.addActionListener(this);
b7.setBackground(Color.darkGray);
b7.setForeground(Color.white);
p3.add(jLabel1); //define panel
add(p3,BorderLayout.SOUTH);
JPanel p1=new JPanel();
p1.add(b1); //add all buttons in panel 1
p1.add(b2);
p1.add(b3);
p1.add(b4);
p1.add(b5);
p1.add(b6);
p1.add(b7);
p1.setBackground(Color.lightGray); //set panel color
add(p1,BorderLayout.NORTH); //set location of panel
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
//close all programs after closing..
jsp=newJScrollPane(lst,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//define scrollpane for hoizontal & vertical scolling...
add(jsp);
try
{
adminserver1=new AdminServer1(); //create an object of server. //
Naming.rebind("adminserver1",adminserver1); bind name to adminserver1
}
catch(Exception e) //catch and display different errors..
{
System.out.println(".................."+e);
}
JPanel p2=new JPanel();
p2.add(lst1);
p2.setBackground(Color.lightGray);
add(p2,BorderLayout.EAST);
lst1.setBackground(Color.lightGray);
th=new Thread(this,"ThToUpListOfClients");
th.start(); //START different threads..
thos = new Thread(this,"os"); //assign names to threads..
thos.start();
tclr = new Thread(this,"clr");
tclr.start();
}
public void run() //Start Threads.
{
Thread temp = Thread.currentThread();
while(true)
{
if(temp.getName().equals("ThToUpListOfClients")) //Refresh Client List.
{
try
{
lst.setBackground(Color.orange); //set list color
lst.setFont(f2); //set font of list
lst.setListData(adminserver1.getUserList()); //update the list of IP address of
client
th.sleep(15000); //sleep thread after perticular time interval
}
catch(Exception e) // Exception Errors.
{
System.out.println("error is "+e);
}
}
else
if(temp.getName().equals("os")) //Refresh O.S. Name.
{
try
{
lst1.setFont(f2);
lst1.setListData(adminserver1.getOsName()); //update OS list of client
thos.sleep(15000);
}
catch(Exception e)
{
System.out.println("error is "+e);
}
}
else
if(temp.getName().equals("clr"))
// Pannel Design. :-change color of pannel at perticular time interval
{
try
{
p3.setBackground(Color.cyan);
jLabel1.setForeground(Color.darkGray);
jLabel1.setFont(f1); tclr.sleep(1000);
p3.setBackground(Color.darkGray);
jLabel1.setForeground(Color.white);
jLabel1.setFont(f3); tclr.sleep(1000);
p3.setBackground(Color.magenta);
jLabel1.setForeground(Color.blue);
jLabel1.setFont(f1);
tclr.sleep(1000);
}
catch(Exception e)
{
System.out.println("error is "+e);
}
}
}
} //eof run()
public void actionPerformed(ActionEvent ae) //After Click On Buttons Particular
Action is taken.
{
try
{
int index=lst.getSelectedIndex(); //select client
if(ae.getSource()==b1) //Get Tasklist of Selected Client.
{
if(index>=0)
{
TabDemo1 tb=new TabDemo1(index,adminserver1); //display tasklist of client
}
return;
}
else
if(ae.getSource()==b2) // SEND MSG TO SELECTED CLIENT
{
String cmd;
if(index>=0)
{
cmd = JOptionPane.showInputDialog("msg","Hello"); //send "hello" msg
by default
if(cmd!=null)
{
if(cmd.trim().length()>0) //check length of msg which server
want to send to selected client.
{ // find obeject reference from rmiregistry
ClientInt
clientref=(ClientInt)Naming.lookup("rmi://"+adminserver1.getIP(index) +"/cs");
clientref.adminMsg(cmd); //call adminmsg function at client side..
}
}
}
}
else
if(ae.getSource()==b3) //EXECUTE PARTICULAR COMMAND ON
SPECIFIC CLIENT.
{
try
{
if(index >= 0)
{
cmd = JOptionPane.showInputDialog("enter the
command"); //show input dialog box for executing command.
if(cmd!=null)
{
if(cmd.trim().length()>0)
{ // find obeject reference from rmiregistry
ClientInt clientref =
(ClientInt)Naming.lookup("rmi://"+adminserver1.getIP(index)+"/cs");
clientref.aggCommand(cmd);
}
}
}
}
catch( java.awt.HeadlessException e)
{
e.printStackTrace(); //print list of errors or stack of errors.
}
}
else
if(ae.getSource()==b4) //Get static Image of selected client.
{
try
{
if(index >= 0)
{
byte b[];
ClientInt clientref =
(ClientInt)Naming.lookup("rmi://"+adminserver1.getIP(index)+"/cs");
b = clientref.getScreen(); //call getScreen() function at client side.
File file = new File("screencapture.jpg"); //create file
FileOutputStream fout = new FileOutputStream(file); fout.write(b);
//write in file
fout.close(); //close file
JFrame fr= new JFrame(); //create new frame
Icon ia= new ImageIcon(b);
JLabel l1 = new JLabel(ia);
fr.setLayout(new java.awt.BorderLayout());
fr.setSize(750,600);
fr.setTitle("Staic_Image");
fr.setVisible(true);
fr.add(l1);
addWindowListener(
new WindowAdapter() //close window...
{
public void windowClosing(WindowEvent we)
{
dispose();
}
}
);
}
}
catch(Exception e)
{ System.out.println("Error is "+e);
e.printStackTrace();
}
}
else
if(ae.getSource()==b5) //dynamic Capture Of particular Client.
{
String name = adminserver1.getIP(index); //get IP of selected client
new DynamicScreenCapture(name);

// call DynamicScreen() function for taking dynamic image of selected client.


}
else
if(ae.getSource()==b6) //Login window for chating.
{
LoginForm l1=new LoginForm(); //display login form for authonticate for
chatting
l1.setVisible(true);
}
else
if(ae.getSource()==b7) //Lock server interface.
{
setVisible(false);
LockWindow l2 = new LockWindow(this); //display
login window after administrator would be logoff.
l2.setVisible(true);
}
}
catch(Exception e)
{
System.out.println(e);
}
}

// Program for login/unlock window after logoff./lock.


• //LockWindow.java
import java.rmi.*; //declare required packages
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;

class LockWindow extends javax.swing.JFrame implements


java.awt.event.ActionListener
{
Connection cn;
private javax.swing.JButton jButton1;
// private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField1;
AdminGUI1 a1;
Font f;

public LockWindow(AdminGUI1 a1) //Constructor with arguments


{
setTitle("Unlock_Window"); //set title to frame
f=new Font("Arial",1,16);
initComponents(); // call function initcomponents()
try
{
this.a1=a1; //use globle object
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // initialize
Odbcdriver
cn=DriverManager.getConnection("jdbc:odbc:logdsn","system","niraj");
//assign oracle connection to cn
}
catch(Exception e)
{
System.out.println(""+e);
}
}

public int adminlogin(String user, String password)throws RemoteException


{
int k=0;
try
{
Statement st=cn.createStatement(); // assign create statement to st
ResultSet rs=st.executeQuery("Select * from adminlog where uname='"+user+"' and
pwd='"+password+"'");
if(rs.next()) // check user name & password in database
{
k=1;
}
rs.close(); //close
st.close();
}
catch(SQLException e)
{
System.out.println(e);
}
return k;
}
public void actionPerformed(java.awt.event.ActionEvent ae)
{
try
{
if(jTextField1.getText().trim().length()>0)
{
if(jPasswordField1.getText().trim().length()>0)
{
int res=adminlogin(jTextField1.getText(),jPasswordField1.getText());
if(res==1)
{
dispose();
a1.setVisible(true); // display server interface as it
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Invalid
UserName/Password");
jTextField1.setText("");
jPasswordField1.setText("");
jTextField1.requestFocus();
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Enter
Password"); jPasswordField1.requestFocus();
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Enter
Username"); jTextField1.requestFocus();
}
}
catch(Exception e)
{
javax.swing.JOptionPane.showMessageDialog(this,"error is "+e);
}
}//eof act

private void initComponents() {

jLabel1 = new javax.swing.JLabel();


jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jPasswordField1 = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();
jButton1.addActionListener(this);
jButton1.setBackground(Color.darkGray);
jButton1.setForeground(Color.white);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
getContentPane().setBackground(Color.orange);
jLabel1.setText("Password");
jLabel1.setFont(f);
getContentPane().add(jLabel1);
jLabel1.setBounds(50, 70, 100, 14);
getContentPane().add(jTextField1);
jTextField1.setBounds(160, 30, 120, 20);
jTextField1.setFont(f);
jLabel2.setText("UserName");
jLabel2.setFont(f);
getContentPane().add(jLabel2);
jLabel2.setBounds(50, 30, 100, 14);
getContentPane().add(jPasswordField1);
jPasswordField1.setBounds(160, 70, 120, 20);
jPasswordField1.setFont(f);
jButton1.setText("Login");
getContentPane().add(jButton1);
jButton1.setBounds(95, 150, 95, 28);
setSize(350,250);
}
}
//Program for displaying task list of selected clients
• //TabDemo1.java
import java.rmi.*; //declare required packages
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

class TabDemo1 extends JFrame implements ActionListener,Runnable


{
JTable tab; //declare table
ClientInt clientref; //create object of client
Vector heads=new Vector(); //define vector
Vector data=new Vector();
JButton b1=new JButton("KillProcess"); //define buttons
JButton b2=new JButton("Send Message"); Font f2;

AdminServer1 adminserver; //create an object of adminserver


Thread updateTableThread;

TabDemo1(int index, AdminServer1 adminserver) //constructor with variables selected


client & object
{
this.adminserver=adminserver; //access global object
f2=new Font("Arial",1,14); setVisible(true);

setTitle("Task_Manager"); //set title to frame


setSize(500,500);
try
{ // Add heads in frame for tasklist
heads.add("ProcessName");
heads.add("PID");
heads.add("SessioName");
heads.add("Session#");
heads.add("Memory_Usage");
clientref=(ClientInt)Naming.lookup("rmi://"+adminserver.getIP(index)+"/cs"); //get
client object from rmiregistry
}
catch(Exception e)
{
System.out.println("System Error :"+e);
}
try
{
tab=new JTable(data,heads); //create new table
setLayout(new BorderLayout()); //set layout to table
tab.setBackground(Color.pink); //set background color of table
tab.setFont(f2);
JScrollPane jsp=
NewScrollPane(tab,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,Scr
ollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(jsp);
b1.addActionListener(this);
b1.setBackground(Color.darkGray);
b1.setForeground(Color.white);
b2.addActionListener(this);
b2.setBackground(Color.darkGray);
b2.setForeground(Color.white);
JPanel p1=new JPanel();
p1.add(b1);
p1.add(b2);
p1.setBackground(Color.lightGray);
add(p1,BorderLayout.NORTH);
}
catch(Exception e)
{
System.out.println("Error is "+e);
}
tab.updateUI(); //update table
validate(); //validate table or frame
updateTableThread=new Thread(this);
updateTableThread.start(); //start thread
}
public void run()
{
while(true)
{
try
{
upDateDataInTable(); //update thread after perticulr period
updateTableThread.sleep(30*1000);
}
catch(Exception e)
{
System.out.println("Error in TabDemo1 run ");
}
}
}//end of run
void upDateDataInTable() throws IOException //use for refresh table ater perticula
period
{
if(data.size()>0)
data.clear(); //clear data vector
StringBuffer sbr=clientref.getTasklist(); // call tasklist command of clients
BufferedReader br=new BufferedReader(new StringReader(sbr.toString()));
//take list in buffer reader
String str="";
while((str=br.readLine())!=null)
{

Vector vrow=new Vector();


StringTokenizer stk=new StringTokenizer(str);
while(stk.hasMoreTokens()) // token add in in vrow
{
vrow.add(stk.nextToken()); //add fields token by token
}
data.add(vrow);
}
data.remove(0); //remove first row
data.remove(0);
tab.updateUI();
}

public void actionPerformed(ActionEvent ae) //action performed after clicking on button


{
try
{
if(ae.getSource() == b1) //kill selected process of particular client
{
if(tab.getSelectedRow()>0)
{
int rowind=tab.getSelectedRow();
String sel=(String)tab.getValueAt(rowind,1);
JOptionPane.showMessageDialog(this,sel);
clientref.killProcess(sel); // kill process of selected process id at client machine
data.remove(rowind); // remove process from list at server side
tab.updateUI(); // update table which having tasklist
JOptionPane.showMessageDialog(this,"Process killed");
}
}

if(ae.getSource()==b2)
{
if(tab.getSelectedRow()>0)
{
int rowind=tab.getSelectedRow();
String sel=(String)tab.getValueAt(rowind,0);
String cmd = sel + ": terminate the process";
clientref.adminMsg(cmd); //send msg to terminate the
process
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,"Error in TabDemo1 is "+e);
}
}
}

//Program at client side…


//Remote interface for clientserver
• //ClientInt.java

import java.rmi.*; //declare required packages


import java.io.*;
import java.awt.image.BufferedImage;

public interface ClientInt extends Remote //interface for client program {

public void killProcess(String pid)throws RemoteException ;


public void adminMsg(String msg)throws RemoteException ;
public void aggCommand(String cmd)throws RemoteException;
public StringBuffer getTasklist()throws RemoteException ;
public byte[] getScreen()throws RemoteException;
//,AWTException,IOException;
}

//Program on client side to communicate server


• //ClientSoft1.java
import javax.swing.*; // import required packages
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.net.*;
import java.util.*; // os name
//for Robot class
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Rectangle;
import java.io.*;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class ClientSoft1 extends UnicastRemoteObject implements ClientInt


{
public ClientSoft1()throws RemoteException
{
}
public void killProcess(String pid)throws RemoteException //Kill the Process
which server want.
{
try
{
Runtime r=Runtime.getRuntime(); //getruntime environment of client
r.exec("taskkill /pid "+pid); return; // execute command of taskkill

}
catch(Exception e)
{
System.out.println("error is "+e);
}
}
public void adminMsg(String msg)throws RemoteException //get msg which
is send by admin.
{
if(msg.equals(null)) //if msg is null never print
return;
else
new Message(msg); // call Message function pass msg as
parameter
}
;public StringBuffer getTasklist()throws RemoteException // get tasklist and
return to Server
{
StringBuffer sbr=new StringBuffer(); //declare ‘sbr’ as string buffer
try
{
Runtime r1=Runtime.getRuntime(); //getruntime environment of client
Process p1=r1.exec("Tasklist");// execute tasklist command
InputStream i1= p1.getInputStream(); //take inputstream of process
p1 in i1
BufferedReader br=new BufferedReader(new
InputStreamReader(i1)); String str="";
while((str=br.readLine())!=null) //read line of buffer reader br in
str {
sbr.append(str+"\n"); // append sbr
}
br.close(); // close
}
catch(Exception e)
{
System.out.println("System Error :"+e);
}
return sbr; //return Tasklist.
}
public void aggCommand(String cmd)throws RemoteException //execute
command which server want
{
try
{
if(cmd.equals(null))
return;
else
{
Runtime r2 = Runtime.getRuntime(); //getruntime environment of
client
Process p2 = r2.exec(cmd); // execute command
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public byte[] getScreen()throws RemoteException,AWTException,IOException
{ //return current static image to server
try
{

BufferedImage screencapture = new Robot().createScreenCapture(new


Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
// strore image in BufferedImage screencapture by Robot
function
File file = new File("screencapture.jpg"); //create new file
“screencapture.jpg”
ImageIO.write(screencapture,"jpg",file); //write image in
screencapture.jpg file
byte b[] = new byte[(int)file.length()]; // take file length in
byte b
FileInputStream fin = new FileInputStream(file); //take file
in FileInputStream fin
fin.read(b); //read byte b in FileInputStream fin
fin.close(); // close
return b;
}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}
public static void main (String args[])
{
try
{
ClientSoft1 cs=new ClientSoft1(); // add object in rmiregistry
Naming.rebind("cs",cs);
InetAddress ia=InetAddress.getLocalHost(); // get ip address of localhost
BufferedReader br = new BufferedReader(new FileReader("name.txt"));
// read hostname from name.txt
String name = br.readLine();
AdminInt1
adminint=(AdminInt1)Naming.lookup("rmi://"+name+"/adminserver1");
//lookup server object in rmiregistry
adminint.acceptClient(ia); // return ip address to to server
System.out.println("ok"); //after connecting to server print ok message
Properties p = System.getProperties(); //get OS name and return to server
String os = p.getProperty("os.name"); adminint.acceptOsName(os); //
return oS name to server
}
catch(Exception e)
{
System.out.println("error is "+e);
}
}
}

// Program for Dynamic capturing of Client Screen


• //DynamicScreenCapture.java
import java.util.*;
import java.io.*; import
java.rmi.*; import
java.awt.event.*; import
javax.swing.*;
import javax.swing.ImageIcon;
public class DynamicScreenCapture extends JFrame implements Runnable
{
Thread th = new Thread(this);
String hostname;
File file, file1;
int cnt = 0; // initialize cnt as 0
JLabel l1=new JLabel();
public DynamicScreenCapture(String hostname)
{
setLayout(new java.awt.BorderLayout()); // set borderLayout
setVisible(true);
setTitle("Captured Screen"); //set tiltle as “Captured Screen”
setSize(750,750);
addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{ // after closing window if thread is alive
if(th.isAlive())
{
try
{
th.stop(); // stop thread
}
catch(Exception e)
{
th.destroy(); // destroy thread
}
}
dispose(); //dispose window
}
}
);
this.hostname = hostname;
this.file = new File(hostname);
if(!file.exists())
file.mkdir(); // create new directory
else
{
File f2[]=file.listFiles();
for(int i=0;i < f2.length;i++)
{
f2[i].delete(); // if directory is already present then delete existing photos
}
}
th.start();
add(l1);
}
public void run()
{
try{
while(true)
{
if(cnt==25) //if cnt=25 then clear directory & store 26 image on 1
location
{
th.sleep(100);
cnt=0;
File f2[]=file.listFiles();
for(int i=0;i < f2.length;i++)
{
f2[i].delete();
}
}
cnt++;
byte b[];
ClientInt clientref = (ClientInt)Naming.lookup("rmi://"+hostname+"/cs"); //find
cs in rmiregistry
b = clientref.getScreen(); // call function getscreen
File file1 = new File(file.getPath(),String.valueOf(cnt)+".jpg"); // save file by
“value(cnt).jpg” name
FileOutputStream fout = new FileOutputStream(file1);
fout.write(b); //write
fout.close(); //close
ImageIcon icon=new ImageIcon(b); // screen is take as icon
l1.setIcon(icon);
th.sleep(10000); // sleep thread
}
}
catch(Exception e)
{
System.out.println("error in Dynamic Capture is "+e);
}
}
}

// program of login form for chatting


• LoginForm.java

import java.rmi.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
public class LoginForm extends javax.swing.JFrame implements
java.awt.event.ActionListener
{
AdminInt1 ref;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField1; Font f;

public LoginForm()
{
setTitle("Chatting_Login");
f=new Font("Arial",1,16);
initComponents();
try
{
BufferedReader br = new BufferedReader(new FileReader("name.txt"));
String name = br.readLine();
ref=(AdminInt1)Naming.lookup("rmi://"+name+"/adminserver1");
// read name of server from file store on client
}
catch(Exception e)
{
javax.swing.JOptionPane.showMessageDialog(this,"Error is "+e); //error display in
joptionpane
}
}
public void actionPerformed(java.awt.event.ActionEvent ae)
{ // Performed following action after pressing button
try
{
if(ae.getSource()==jButton2)
{
JOptionPane.showMessageDialog(this,"Exiting");
dispose();
return;
}
if(jTextField1.getText().trim().length()>0)
{
if(jPasswordField1.getText().trim().length()>0)
{
int res=ref.login(jTextField1.getText(),jPasswordField1.getText());
if(res==2)
{
new ChatWin(ref,jTextField1.getText()); // display
chatwindow dispose();
}
else
if(res==0)
{
javax.swing.JOptionPane.showMessageDialog(this,"Invalid
UserName/Password");
jTextField1.setText("");
jPasswordField1.setText("");
jTextField1.requestFocus();
}
else
if(res==1)
{
javax.swing.JOptionPane.showMessageDialog(this,"Already Logged
Inn");
jTextField1.setText("");
jPasswordField1.setText("");
jTextField1.requestFocus();
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Enter
Password"); jPasswordField1.requestFocus();
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(this,"Enter
Username"); jTextField1.requestFocus();
}
}
catch(Exception e)
{
javax.swing.JOptionPane.showMessageDialog(this,"error is "+e);
}
}//eof act

private void initComponents()


{
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jPasswordField1 = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton1.addActionListener(this);
jButton1.setBackground(Color.darkGray);
jButton1.setForeground(Color.white);
jButton2.addActionListener(this);
jButton2.setBackground(Color.darkGray);
jButton2.setForeground(Color.white);
addWindowListener(
new WindowAdapter() // close only window not all program after click on exit

{
public void windowClosing(WindowEvent we)
{
dispose();
}
}
);
getContentPane().setLayout(null);
getContentPane().setBackground(Color.orange);
jLabel1.setText("Password");
jLabel1.setFont(f);
getContentPane().add(jLabel1);
jLabel1.setBounds(50, 70, 100, 14);
getContentPane().add(jTextField1);
jTextField1.setBounds(160, 30, 120, 20);
jTextField1.setFont(f);
jLabel2.setText("UserName");
jLabel2.setFont(f);
getContentPane().add(jLabel2);
jLabel2.setBounds(50, 30, 100, 14);
getContentPane().add(jPasswordField1);
jPasswordField1.setBounds(160, 70, 120, 20);
jPasswordField1.setFont(f);
jButton1.setText("Login");
jButton1.setFont(f);
getContentPane().add(jButton1);
jButton1.setBounds(80, 150, 80, 28);
jButton2.setText("Exit");
jButton2.setFont(f);
getContentPane().add(jButton2);
jButton2.setBounds(180, 150, 90, 28);
setSize(350,250);
}
public static void main(String args[])
{
LoginForm l1=new LoginForm();
l1.setVisible(true);
}
}

// Program for displaying message

• Message.java

import javax.swing.*;
public class Message extends Thread
{
String msg = "no message"; // assign ‘no message’ string to msg
public Message(String msg) //assign msg
{
this.msg = msg;
start(); // start thread
}
public void run()
{
try
{
JOptionPane.showMessageDialog(null,msg); // display msg
}
catch(Exception e)
{
e.printStackTrace(); // display stack of errors
}
}
}

//program at both server and client side…


//Program for chatting
• ChatWin.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.rmi.*;
import java.util.*;
class ChatWin extends JFrame implements ActionListener,Runnable
{
AdminInt1 ref;
String user;
JLabel l1;
JTextField t1;
JTextArea ta;
JButton b1,b2,b3;
JList lst;
Vector v1=new Vector();
Thread th1,th2;
Font f,f1;
ChatWin( AdminInt1 ref, String user)

{ //design chat window


this.ref=ref;
this.user=user;
setTitle("Current_Login -- // set title to frame
>>"+user); setSize(750,500); //set size of frame
setLayout(new BorderLayout());
setVisible(true);
f=new Font("Arial",1,16); //set font
f1=new Font("Arial",1,14);
l1=new JLabel("Message"); //create new message
b1=new JButton("Send"); label //create new button ‘send’
b2=new JButton("Send2All");
b3=new JButton("Logout");
b1.addActionListener(this);
b1.setBackground(Color.darkGray);
b1.setForeground(Color.white);
b2.addActionListener(this);
b2.setBackground(Color.darkGray);
b2.setForeground(Color.white);
b3.addActionListener(this);
b3.setBackground(Color.darkGray);
b3.setForeground(Color.white);
t1=new JTextField(20);
t1.setFont(f1);
ta=new JTextArea();
ta.setBackground(Color.orange);
ta.setFont(f1);
ta.setEditable(false);
lst=new JList();
lst.setFont(f);
lst.setBackground(Color.pink);
JScrollPane jsp1=new JScrollPane(ta,20,30);
JScrollPane jsp2=new JScrollPane(lst,20,30);
JPanel p1=new JPanel();
p1.add(l1);
p1.add(t1);
p1.add(b1);
p1.add(b2);
p1.add(b3);
p1.setBackground(Color.lightGray);
add(p1,BorderLayout.NORTH);
add(jsp1);
add(jsp2,BorderLayout.WEST);
th1=new Thread(this,"A");
th2=new Thread(this,"B");
th1.start();
th2.start();
}
public void run()
{
while(true)
{
try
{
Thread temp=Thread.currentThread();
if(temp.getName().equals("A"))
{
v1=ref.getAllUser(); //get client list
lst.setListData(v1);
th1.sleep(15000);
}
else
if(temp.getName().equals("B"))
{
String msg=ref.readMsg(user); //read msg
if(msg==null)
msg="";
if(msg.length()>0) // check msg length i.e. msg is written or not
ta.append(msg+"\n"); //print msg in textarea
th2.sleep(5000);
}
addWindowListener( // after windows dispose stop all thread
new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
try{
ref.logout(user); //call function logout
th1.stop();
th2.stop();
dispose();
}
catch(Exception e)
{
System.out.println("ERROR"+e); //show errors
}
}
}
);
}
catch(Exception e)
{
System.out.println("Error in run is "+e); //show error
}
}
}
public void actionPerformed(ActionEvent ae)
{
try
{
if(ae.getSource()==b1) //click for send msg
{
if(t1.getText().trim().length()>0)
{
if(lst.getSelectedIndex()>=0)
{
String to=(String)v1.get(lst.getSelectedIndex());
ref.sendMessage(to,t1.getText()+"---"+user); // call function sendMessage
JOptionPane.showMessageDialog(this,"Msg Sent "); //display that “Msg Sent”
}
}
}
else
if(ae.getSource()==b2) //click for send to all
{
if(t1.getText().trim().length()>0)
{
ref.sendToAll(t1.getText()+"---"+user,user); // call function sendToAll
JOptionPane.showMessageDialog(this,"Msgs Sent "); }

}
else
if(ae.getSource()==b3) //click for logout
{
ref.logout(user); //call function logout
th1.stop(); // stop thread
th2.stop(); // stop thread
dispose(); // dispose windows
}
}
catch(Exception e)
{ // show errors
JOptionPane.showMessageDialog(this,"Error is "+e);
}
}
}

Thank You

You might also like