131
ACKNOWLEDGEMENT In connection with the preparation of this project I want to convey my sincere gratitude and appreciation to Mrs.Swarna, Head of Computer Engineering KGPTC Westhill.I am sincerely thankful to my project guide and respect teacher Mrs.Sreetha CK for the completion of this application. I convey my thanks to teachers who had given us finely advice and guidance to make this application a reality.I am very thanks to my classmates and friends to their valuable suggestions and co-operation. Thanking you By Jaseela K Faseela KP 1

NIDS Report

Embed Size (px)

Citation preview

1

ACKNOWLEDGEMENT In connection with the preparation of this project I want to convey my sincere gratitude and appreciation to Mrs.Swarna, Head of Computer Engineering KGPTC Westhill.I am sincerely thankful to my project guide and respect teacher Mrs.Sreetha CK for the completion of this application. I convey my thanks to teachers who had given us finely advice and guidance to make this application a reality.I am very thanks to my classmates and friends to their valuable suggestions and co-operation. Thanking you By Jaseela K

Faseela KP Anju Anilkumar M Irfan VP Shiju P

2

PREFACE Computer made a great impact on our society.The presence of computer in our day to day life simply cannot be denied or ignored.The ability to do different jobs on the same machine distinguishes computers from other machines.Computers have very considerable influence in various aspects of our society,such as education, examinations, banking, health, business, industrial ,airlines ,architects, commerce, scientific, government, defence etc. Computers are now inevitable and useful machine in our life.Computer is the most powerful machine used by modern society.It has made great impact on several activities.Computer become so versatale and its presence is felt in almost all walks of life.

3

1. ABSTRACT

The project entitled NETWORK INTRUSION DETECTION SYSTEM is objective with the responsible for detecting any information of the about a kind of intruder that come in to the network. It achieves its predetermined Just as the rest particular intruder, Anti-viruses

got updated and also other NIDSs we are updating manually by inserting necessary information that it need to detect.

4

CONTENTS 1. INTRODUCTION

5

INTRODUCTION

6

1.1 INTRODUCTION

The development in science and technology are so rapid that the development and existence of mankind is dependent on the implementation of scientific knowledge. The entire world is paying much attention to improve the file style by synthesizing the result of gaining the classical as well as modern knowledge. No country can move in phase with the time. Under such circumstances computerization techniques takes its role. The main problem arising in a network is the question of security, which means protection from attacks. The project entitled Network Intrusion Detection System tries to trace out the intruder packets using IP Address or data and decides if it is to be forwarded and assures security. The project entitled Network Intrusion Detection System is an IDS where it monitors packets on the network wire and attempts to the discovery of hacker/cracker who is attempting to break into system This discovery is being performed by comparing the captured packet with the intruder details stored in the database .If the packet is found to be an intruder it is then forwarded to the firewall with the respective message for blocking. The software is developed using C#.Net as the frontend and SQL Server as the Back-end. The system can be implemented in Windows NT Platform. The project ensures more security, accuracy, and efficiency to the system. All intrusion-detection systems tested were susceptible to

packet spoofing which tricks the server into thinking packets have come from a trusted host or into using its own intrusiondetection counter measures to cut connectivity to legitimate

7 sites. The systems were also found that flood networks devices with to too be many vulnerable requests to for packet fragmentation attacks, and to denial-of-service attacks connections, which can cause them to shut down. The project entitled NETWORK INTRUSION DETECTION SYSTEM provides server side security for network intrusion through packet sniffing and analysis and pattern matching. The filtering mechanism usually can filter IP packets based on some or all of the following conditions: Source IP address, the system from which the packet originated Destination IP address, the system for which the packet is destined Protocol Source TCP/UDP port, the port number of the service on the host originating connection Destination TCP/UDP port String match in a packet.

8

SYSTEM ANALYSIS PHASE

9

2.1 Existing system

The existing Network Intrusion Detection System is a Windows based system developed internally by the company. It is the manual encoding of the expert system hence responding properly only to known attacks. This is an ordinary system that can be used to detect only a known or ungeneralised set of users. The main drawback lies in the fact that the system cannot be generalized. The system acts as a subsystem of the firewall itself. The system contains the details of the intruder, which is then forwarded to the firewall.

10 2.2. Proposed system The proposed system is a Network Intrusion Detection System that is an enhancement of the existing system. It is a system level program that works as the lower layer for of the firewall. The system checks If the database the already registered intruders. found

intruding, they are forwarded to the firewall for blocking. The firewall is responsible for the blocking of the packet.

11

DESIGN PHASE

12

3.1 Module design

Modular design means breaking the program tasks into small parts. The advantage of modularity is in easy accessing of coding and debugging, also more number of programs can engage in a Software development and the work could be finished within a targeted minimum span of time by splitting the program into small parts.

This project is mainly classified into seven modules Action Intrusion Modal Traffic Sniffing Detection Reports

13 Main modules are sub divided follows. ACTION - Security Application Lock Application Exit INTRUSION - Registration (IP) Reg.Alter Reg.Removal MODAL - Registration Name Reg.Alter Reg.Removal TRAFFIC - IP Request Port Scanning Ping Machine SNIFFING - TCP Protocol UDP Protocol All Sniffing DETECTION - Detect New Data Mining REPORTS - Intruder Details Modal Details Detection Details into small parts, called sub modules and the details regarding these modules are as

14 The project is mainly developed in the background view of administrator. This Software has been mainly divided into seven to eight modules, starting with Action to Reports. The first module Action expresses the ability of administrator to handle the entire control by providing security using password, also through locking application. The second module Intrusion does the job of fixing IP addresses of systems with the assumption that they are intruders. It also provides the options for updating/dropping of registration. The third module Modal also has the same work of Intrusion except the fact that it registers the intruder with the predetermined information about intruder. The fourth module Traffic displays the packet details based on the source or destination IP. It displays the available ports in the system, also the connectivity between systems in the network are checked and give the responds through the ping machine form. The fifth module Sniffing gives the details of packets on the basis of different network protocols. In the Detection module new and existing intruders are detected and displayed. It also monitors the data part included in the packets. The last module Report gives the entire details of intruder.

15 3.2 Input design

To ensure that input is understood by the user. Input design is one of the most expensive phases of the operation of computerized system and is often the major problem of a system. A larger number of problems with a system can usually be traced back to fault input design and method. Needless to say, therefore that the input data is the life block of a system and has to be analyzed and designed with the most consideration. The decisions made during the input design are: To provide cost effective method of input. To achieve the highest possible level of accuracy. System analysts decide the following input design details like, what data item to input, what medium to use, how the data should be arranged or coded data items and transaction needing validations to detect errors and at last the dialogue to guide users in providing input. Input data of a system may not be necessarily a raw data captured in the system form scratch. These can also be the output of another system or sub-system. The design of input covers all phases of input from the certain of initial data to actual entering the data to the system for processing. The design of inputs data involves for identifying the data and needed, ensuring specifying the characteristics of each data item, capturing and preparing computer processing correctness of data.

16 Input forms are: Login Form Using this form the administrator can login to the application. Change Security Form By using this form the administrator can change his password. Intruder registration Form This form used for the registration of new intruders. Intruder alteration Form Intruder alteration is performed by the use of this form. Adaptive model registration Form New unwanted commands are registered in this form. Adaptive model modification Form Using this form we can modify unwanted commands. Locking Form Using this form the administrator can lock the application from the unauthorized users.

17 3.3 Database design Database design is required to manage the large bodies of information. definition addition of the The management of the must of data involves of for both the and of to structure db storage provide the information the safety due

provisions of mechanism for the manipulation of information. In system information handled, despite system crashes

attempts art unauthorized access. For developing an efficient db, we will have to fulfill certain condition such as: Control redundancy. Ease of use. Data independence. Accuracy and integrity. Avoiding inordinate delays. Recovery form failure. Privacy and security. Performance. There are 6 major steps in design process. The first 5 steps are usually done on paper and finally the design is implemented. Identify the table and relationships Identify the data that is needed for each table and relationship Resolve the relationship. Verify the design. Implement the design

18

Table structure: Table number: 1 Title Table Name Description : : : Administrator Login Login The table stores in the login user ID and the

password for the authorization checking. It is used both during login and locking. Constraint Field name Username Password Table Number: 2 Title Table name Description Constraints Null. Field Name Intcode Ipaddress Intdesc Regdate Start time End time Type Numeric Varchar Varchar DateTime DateTime DateTime Length 9 25 25 8 8 8 Description Intruder Code Ip Address Intruder Description Registration Date Start Time End Time : : : : Intruder Registration Details Intruder The details of already known intruders The intcode is the primary key, Ipaddress Not : The user ID is the primary key. Type Varchar Varchar Length 25 25 Description User Identification User Password

19

Table number: 3 Title Table name Description Constraints : : : : Adaptive Model Table Model The Adaptive model is created and stored The Modcode is the primary key

Fieldname Modcode Regdate Pattern

Type Numeric DateTime Varchar

Length 9 8 200

Description Model Code Registration date Model Pattern

Table Number: 4 Title Table name Description here. Constraints : The Detipaddr is the primary key : : : The Intrusion block details Detection The packets detected of intrusion are stored

Field name Detipaddr Detdate Dettime Protocol Dettype

Type Varchar2 DateTime DateTime Varchar2 Varchar2

Length 25 8 8 10 25

Description Detected IP Address Detection Date Detection Time Protocol Detection Type

3.4 DATA FLOW DIAGRAM

20 Data Flow Diagram (DFD) is used to define the flow of the system and its resources such as information. Data Flow Diagrams are a way of expressing system requirements in a graphical manner. DFD represents one of the most ingenious tools used for structured analysis. A DFD is also known as a bubble chart. It has the purpose of clarifying system requirements and identifying major transformations that will become programs in system design. In the normal convention, logical DFD can be completed using only 4 notations. : Represents source or destination of data.

Represents data flow.

Represents a process that transforms incoming data into outgoing flow.

Represents data store.

21 The DFD at the simplest level is referred to as the CONTEXT ANALYSIS DIAGRAM. These are expanded by level, each explaining its process in detail. Processes are numbered for easy identification and are normally labeled in block letters. Each Data flow is labeled for easy understanding.

22 Level 0

USER

NIDS

DATABASE

23 Level 1

USER

NIDS

Login

Change password Intcode Add/delete intruder Intruder register

Set/delete model

Modcod e

Model

Detipaddr View reports Intruder Detection

24

REQUIREMENTS

25

4.1 Hardware requirements Processor Speed RAM Hard Disk Disk Drives Monitor : Pentium lll or higher : 433 MHZ : 128 : 20 GB or higher

MB or higher or higher

: 1.44 Floppy Drives, 52 X Compact Disk : 15 color monitor

4.2 Software requirements Front End Back End Operating System Other Software Used : Microsoft Visual C#.NET : SQL Server : MS Windows 2000 or higher : WIN P CAP, Packet X

26

4.3. SOFTWARE DESCRIPTION

The software NIDS is going to develop under the background of .NET framework. Even though .NET frame work support more than 20 languages, C# is the powerful language that has the ability to compete with JAVA, since it is the only .NET language that comes under the ECMA (European Computer Manufacturing Association) standard. VB.net has backward compatibility with old Visual basic. So, it supports old vb functions. C# is a fresh, clean language. So strongly support using C# instead of VB.net just for this clean compiler. An important factor in .NET framework, called optimization makes a big difference between JAVA and C# and it takes C# to sit in front of JAVA. Finally the splendid features of .NET, like object oriented, platform independence (at certain limits), etc makes the language C# more closer to the users mind.

4.3.1 . VISUAL C# .NETVisual C# .NET is currently part of the Visual Studio .NET. Microsoft Visual C# .NET is the tool set for creating XML Web services and Microsoft.NETconnected applications for Microsoft Windows and the Web.

This offers a language for

27 robust development package, which and environment C# .NET for creating next-

uses the component-oriented C# development language, generation functionality including: Rapid design, development, and deployment support for Form designers and visual controls for creating rich Authoring tools and services for building powerful software. Visual delivers superior

streamlining

business

processes,

creating and consuming XML Web services. Windows-based applications. Microsoft .NET server-based solutions. Migration tools for converting Java-based projects to With solutions for Visual the C# .NET, range developers of clients, can build the Microsoft .NET development environment. broadest including

Windows, the Web, and mobile or embedded devices. Using this elegant programming language and tool, developers can leverage their existing C++ and Java skills and knowledge to be successful in the .NET environment. Some of the main features that make this language so special are 1. 2. 3. 4. 5. 6. 7. 8. Object Oriented Language. Powerful Language for making applications. Security. Multithreading and Multitasking. Internet Programming. Intranet Programming. .Interoperability. Easily Understanding code. INTUITIVE C++ BASED LANGUAGE Use a language modeled on C++ syntax, immediately familiar to C++ and Java developers, as well

LANGUAGE FEATURES

28 as intuitive new language constructs that greatly simplify development tasks. RELIABLE INTEROPERABILITY Employ code to call native Windows APIs, use prebuilt COM components, and leverage existing ActiveX controls to seamless integrate existing applications and components. MODERN, COMPONENT-ORIENTED LANGUAGE Take advantage of inherent support for properties, indexers, delegates, single and multidimensional arrays, advanced comments. COMPLETE With WINDOWS-BASED visual inheritance, APPLICATION can greatly DEVELOPMENT ENVIRONMENT developers simplify the creation of Windows-based applications by centralizing in parent forms the common logic and user interface for their entire solution. Using control anchoring and docking, programmers while the can build menu resizable editor forms automatically, in-place enables inheritance, attributes, versioning, and XML

developers to visually author menus directly from within the Forms Designer. POWERFUL DEBUGGING AND TESTING TOOLS Visual C# .NET includes a powerful remote and multi-language process debugger, and enabling are developers written in to test applications and build reliable multi-tier solutions that span boundaries multiple programming languages.

NET FRAMEWORK CLASS LIBRARY Gain mature and powerful, built-in functionality, including support, a rich set of collection support, classes, string networking regular multithreading and

29 expression classes, and broad support for XML, XML schemas, XML namespaces, XSLT, XPath, and SOAP. ROBUST WEB DEVELOPMENT ENVIRONMENT Create Web-based solutions in C# using the shared Web Forms Designer and XML Designer. Developers can also use IntelliSense features and tag completion or choose the WYSIWYG editor for drag-and-drop authoring to build interactive Web applications. MOBILE WEB APPLICATION DEVELOPMENT Available Professional as part native of Visual Studio .NET enables Edition, device support

developers to construct solutions for a wide variety of mobile devices, including Pocket PCs, Tablet PCs, and mobile phones. Become immediately successful by using the same programming model and techniques for building mobile applications as desktop and Web-based applications. SOFTWARE TOOLS accessing data in task. USED ADO.NET Microsoft In Windows ADO programs introduced a the ADO introduced a simple object model that made straightforward addition,

concept of disconnected record sets as a way to transport data between the tires of distributed applications. The lowlevel API behind ADO which is called OLE DB.ADO.NET was designed with the disconnected data in mind, because this stateless approach works best for distributed Internet applications. ADO.NET contains two sets of similar classes. One set is a generic set of classes that can be used to access all databases that have OLE DB provider and a set of classes for Microsofts SQL Server. ADO.NET COMPONENTS The ADO.NET components have been designed to factor data access from data manipulation. There are two

30 central components of ADO.NET that accomplish this the Dataset, and the .NET data provider, which is a set of components including the Connection, Command, Data Reader, and Data Adapter objects. The ADO.NET Dataset is the core component of the disconnected architecture of ADO.NET. The Dataset is explicitly designed for data access independent of any data source. As a result it can be used with multiple and differing of any data sources, used with XML data, or used to manage data local to the application.

The

other

core

element data

of

the

ADO.NET and fast,

architecture is the .NET data provider whose components are explicitly designed for manipulation forward-only, read -only access to data. The connection object provides connectivity to a data source. The Common objects enables access to database commands to return data, modify data, run stored procedures, and sends or retrieve parameter information. The Data Reader provides a high - performance stream of data from the data source. Finally, the Data Adapter provides the bridge between the Dataset object and the data source.Implementing OLEDB is ADO.NET. applications (XML). ADO.Net and it supports also supports traditional futuristic database technology

ADO.Net also gives synchronization between old

data (traditional database applications) and new data (XML based data access and storage).

31

A S P. N E T ASP.NET is a unified Web development platform that provides the services necessary to build enterpriseclass Web applications. While ASP.NET is largely syntax compatible allows with a Active Server new by Pages class the (ASP), of it also provides a new programming model and infrastructure that creating is powerful supported applications. Framework, ASP.NET fully .NET

allowing one to take full advantage of the Common Language Runtime (CLR), type safety, inheritance, and all of the other features of that platform.

ASP.NET is a compiled. NET-based environment; one can author applications in any .NET compatible language,

32 including include ASP.NET WYSIWYG Visual a has Basic, C# and VJ#. Developers can easily access the benefits of these technologies, which managed type been Common to Language and work Runtime so on. with tools, environment, safety, designed and inheritance, other

seamlessly

HTML

editors

programming

including Microsoft Visual Studio.NET. Not only does this make Web development easier, but it also provides all the benefits that these tools have to offer, including a GUI that developers can use to drop server controls onto a Web page, as well as fully integrated debugging support. ASP.NET Web Forms: Web Forms are an ASP.NET technology used to create programmable web pages. They can present information, using any mark-up language, to the user in any browser and use code on the server to implement application logic. ASP.NET is the next version of Active Server Pages (ASP); it is a unified Web development platform that provides the services necessary for developers to build enterprise-class Web applications. Developers can choose from the following two features when creating an ASP.NET application, Web Forms and Web services, or combine these in any way they see fit. Web Forms allows you to build powerful forms-based Web pages. When building these pages, you can use ASP.NET server controls to create common UI elements, and program them for common tasks. These controls allow you to rapidly build a Web Form out of reusable built-in or custom components, simplifying the code of a page. ASP.NET ARCHITECTURE

33

As deciphers finds the

the and

illustration optionally

shows,

all the as

Web

clients If

communicate with ASP.NET applications through IIS.IIS authenticates (such request. Anonymous is turned on, no authentication occurs. IIS also requested resource an ASP.NET application), and, if the client is authorized returns the appropriate resource. In addition to the built-in ASP.NET security

features, an ASP.NET application can use the low-level security features of the .NET Framework.

SOAP A World Wide Web Consortium (W3C) standard, lightweight protocol for exchange of information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: An envelope that defines a framework for describing

what is in a message and how to process it, a set of encoding rules for expressing instances of applicationdefined remote data types, and a and convention responses. for representing computer procedure calls One

makes a method call, and the other computer performs some computation or services and then returns a result to the calling application.

34 The 1) 2) 3) important features of SOAP are:

SOAP is Platform Independent. SOAP is easy to integrate into disparate Systems. SOAP Poses Fewer Security Risks.

Web Service Consumer

Web Service Server

Serialization

In te rn et

Serialization

Proxy

Invocation

Method Call

Processing

35

4.3.2 . MICROSOFT SQL SERVER 7.0 Relational database systems are the most

important database systems used in the software industry today. One of the most outstanding systems is Microsoft SQL Server. SQL Server is a relational database system developed and marketed by Microsoft. This system is the most important part of Microsoft Back Office, an enterprise suite of client server applications .It runs exclusively under Windows NT, Windows 95/98, and Windows 2000 Server. The most important aspects of SQL Server 7 are:

SQL Server works as a natural extension of Windows NT because it is so closely integrated with this operating system. As such the user does not have to learn another user interface to work with this database system.

SQL Server is easy to use. SQL Server has the same easy set up and maintenance SQL Server uses services of Windows NT to offer new or extended security. database capabilities such as sending and receiving messages, and managing login SQL Server scales from a mobile laptop to symmetric multiprocessor system.

of Windows NT.

36 SQL Server provides data more expensive DBMS. warehousing features that until now have only been available in Oracle and other

37

DEVELOPMENT PHASE

38 5.1 Source code

Class1using using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Data; System.Data.SqlClient;

namespace kgptc { class Class1 { SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\jaseela\kgptc\kgptc \login.mdf;Integrated Security=True;User Instance=True"); public int nonquery(String s) { int i=0; con.Open(); try { SqlCommand cmd = new SqlCommand(s, con); i = cmd.ExecuteNonQuery(); } catch { } con.Close(); return i; } public string scalar(String s) { String str = ""; try { con.Open(); SqlCommand cmd = new SqlCommand(s, con); str = cmd.ExecuteScalar().ToString(); }

catch { } con.Close(); return str; }

39

public DataTable table(string s) { con.Open(); SqlCommand cmd=new SqlCommand(s,con); SqlDataAdapter da=new SqlDataAdapter(cmd); DataTable dt=new DataTable(); da.Fill(dt); return dt; } } }

Class2using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Data;

namespace kgptc { class Class2 { public static string s1; public static string s2; } }

40

Login Form

using using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Diagnostics;

namespace kgptc { public partial class login : Form { public login() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { label3.Text = ""; try { PacketXLib.PacketXClass pkt = new PacketXLib.PacketXClass(); pkt.Start(); pkt.Stop(); } catch { MessageBox.Show("Please install Both 'WinPcap' and 'PacketX' softwares or Check your network connection ", "Error"); System.Environment.Exit(0); } } private void button2_Click(object sender, EventArgs e)

{ }

41

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { registration f = new registration(); f.Show(); } private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { textBox1.Clear(); textBox2.Clear(); frgt_password frm = new frgt_password(); this.Hide(); frm.ShowDialog(); } private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start(@"D:\jaseela\NETWORK.ppt"); } private void label5_Click(object sender, EventArgs e) { } private void vistaButton1_Click(object sender, EventArgs e) { Class1 db1 = new Class1(); Class2 db2 = new Class2(); string i = ""; string j = ""; i = db1.scalar("select loginname from registry where loginname='" + textBox1.Text + "'"); j = db1.scalar("select password from registry where password='" + textBox2.Text + "'"); if (i != "" && j != "") { mainmenu f = new mainmenu(); f.Show();

this.Hide(); } else {

42

if (i == "" || j == "") { label3.Text = ""; label3.Text = " Incorrect username or password"; label3.Enabled = true; textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } else if (j == "") { textBox2.Text = ""; label3.Text = " Incorrect password"; label3.Enabled = true; } } Class2.s1 = i; Class2.s2 = j; } private void vistaButton2_Click(object sender, EventArgs e) { Application.Exit(); }

} }

43

Main formusing using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace kgptc { public partial class mainmenu : Form { public mainmenu() { InitializeComponent(); } private void lockToolStripMenuItem_Click(object sender, EventArgs e) { Form5 f = new Form5(); f.ShowDialog(); } private void securityToolStripMenuItem_Click(object sender, EventArgs e) { password_change f = new password_change(); f.MdiParent = this; f.Show(); } private void exitCtrlEToolStripMenuItem_Click(object sender, EventArgs e) { Close(); }

44 private void registrationIPToolStripMenuItem_Click(object sender, EventArgs e) { intrder_reg f = new intrder_reg(); f.MdiParent = this; f.Show(); } private void alterRemoveToolStripMenuItem_Click(object sender, EventArgs e) { intruder_modi f = new intruder_modi(); f.MdiParent = this; f.Show(); } private void newToolStripMenuItem_Click(object sender, EventArgs e) { detect f = new detect(); f.MdiParent = this; f.Show(); } private void registrationToolStripMenuItem_Click(object sender, EventArgs e) { model_reg f = new model_reg(); f.MdiParent = this; f.Show(); } private void alterRemoveToolStripMenuItem1_Click(object sender, EventArgs e) { model_modi f = new model_modi(); f.MdiParent = this; f.Show(); } private void dataToolStripMenuItem_Click(object sender, EventArgs e) { datamining f = new datamining(); f.MdiParent = this; f.Show(); }

45 private void iPRequestToolStripMenuItem_Click(object sender, EventArgs e) { iprequest f = new iprequest(); f.MdiParent = this; f.Show(); } private void portScanningToolStripMenuItem_Click(object sender, EventArgs e) { portscan f = new portscan(); f.MdiParent = this; f.Show(); } private void pingMaToolStripMenuItem_Click(object sender, EventArgs e) { ping_machine f = new ping_machine(); f.MdiParent = this; f.Show(); } private void tCPSniffingToolStripMenuItem_Click(object sender, EventArgs e) { tcpsniffing f = new tcpsniffing(); f.MdiParent = this; f.Show(); } private void uDPSniffingToolStripMenuItem_Click(object sender, EventArgs e) { udpsniffing f = new udpsniffing(); f.MdiParent = this; f.Show(); } private void allSniffingToolStripMenuItem_Click(object sender, EventArgs e) { allsniffing f = new allsniffing(); f.MdiParent = this; f.Show();

46 } private void intruderDetailsToolStripMenuItem_Click(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); dt = db.table("select * from intruder"); intruder_det f = new intruder_det(); f.MdiParent = this; f.print(dt); f.Show(); } private void modelDetailsToolStripMenuItem_Click(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); dt = db.table("select * from model"); model_det f = new model_det(); f.MdiParent = this; f.print(dt); f.Show(); } private void registrationDetailsToolStripMenuItem_Click(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); dt = db.table("select * from detect"); detection_det f = new detection_det(); f.MdiParent = this; f.print(dt); f.Show(); } private void registrationToolStripMenuItem_Click_1(object sender, EventArgs e) { model_reg f = new model_reg(); f.MdiParent = this; f.Show(); }

47 private void alterRemoveToolStripMenuItem1_Click_1(object sender, EventArgs e) { model_modi f = new model_modi(); f.MdiParent = this; f.Show(); } } }

Registration Formusing using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace kgptc { public partial class registration : Form { public registration() { InitializeComponent(); }

private void vistaButton1_Click(object sender, EventArgs e) { textBox4.Focus(); Class1 db = new Class1(); int l = 0; string s = ""; if (radioButton1.Checked == true) s = "male";

48 else s = "female"; if (textBox2.Text != textBox3.Text) { textBox2.Text = ""; textBox3.Text = ""; MessageBox.Show("Password mismatch,re enter"); textBox2.Focus(); } else { l = db.nonquery("insert into registry values('" + textBox4.Text + "','" + s + "','" + richTextBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox5.Text + "','" + comboBox1.Text + "','" + textBox1.Text + "','" + textBox6.Text + "','" + textBox2.Text + "','" + comboBox2.Text + "','" + textBox7.Text + "')"); if (l > 0) { MessageBox.Show("Congragulations!!"); } else MessageBox.Show("error"); } } private void vistaButton2_Click(object sender, EventArgs e) { this.Close(); } private void vistaButton1_Click_1(object sender, EventArgs e) { textBox4.Focus(); Class1 db = new Class1(); int l = 0; string s = ""; if (radioButton1.Checked == true) s = "male"; else s = "female"; if (textBox2.Text != textBox3.Text) { textBox2.Text = ""; textBox3.Text = "";

MessageBox.Sh enter"); }

49

ow("Password mismatch,re

textBox2.Focus(); else { l = db.nonquery("insert into registry values('" + textBox4.Text + "','" + s + "','" + richTextBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox5.Text + "','" + comboBox1.Text + "','" + textBox1.Text + "','" + textBox6.Text + "','" + textBox2.Text + "','" + comboBox2.Text + "','" + textBox7.Text + "')"); if (l > 0) { MessageBox.Show("Congragulations!!"); } else MessageBox.Show("error"); } } private void vistaButton2_Click_1(object sender, EventArgs e) { this.Close(); } } }

Forgett password formusing using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace kgptc { public partial class frgt_password : Form

{

50 public frgt_password() { InitializeComponent(); }

private void vistaButton1_Click(object sender, EventArgs e) { Class1 db1 = new Class1(); string i = ""; i = db1.scalar("select password from registry where loginname='" + textBox1.Text + "' and sqstn='" + comboBox1.Text + "' and sans='" + textBox2.Text + "' "); label5.Text = i; if (i == "") { MessageBox.Show("Invalid Attempt"); } } private void vistaButton2_Click(object sender, EventArgs e) { this.Close(); login f = new login(); f.Show(); } } }

Lock formusing using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq;

using System.Text; using System.Windows.Forms;

51

namespace kgptc { public partial class Form5 : Form { public Form5() { InitializeComponent(); } private void vistaButton1_Click(object sender, EventArgs e) { Class1 db1 = new Class1();

if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Please specify the User name and Password"); } else { if (Class2.s1 == textBox1.Text && Class2.s2 == textBox2.Text) { this.ControlBox = false; vistaButton1.Enabled = false; textBox1.Text = ""; textBox2.Text = ""; label1.Visible = true; } else { MessageBox.Show("Unauthorised Access"); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } } textBox1.Focus(); } private void vistaButton2_Click(object sender, EventArgs e)

{

52

Class1 db1 = new Class1(); string i = ""; string j = ""; textBox1.Focus(); if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Please specify the User name and Password"); } else { i = db1.scalar("select loginname from registry where loginname='" + textBox1.Text + "' "); j = db1.scalar("select password from registry where password='" + textBox2.Text + "'"); if (i == "" || j == "") { MessageBox.Show("Invalid user name or password"); } else { this.ControlBox = true; vistaButton1.Enabled = true; label1.Visible = false; } } textBox1.Text = ""; textBox2.Text = ""; } } }

Security formusing using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

53 namespace kgptc { public partial class password_change : Form { public password_change() { InitializeComponent(); } private void vistaButton2_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Please fill all fields"); return; } Class1 db1 = new Class1(); string i = ""; int j = 0; try { i = db1.scalar("select password from registry where loginname='" + textBox1.Text + "' and password='" + textBox2.Text + "'"); if (i == "") { MessageBox.Show("Invalid user Id or Password"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox1.Focus(); } else { if (textBox3.Text != textBox4.Text) { MessageBox.Show("Password Mismatch,Re-enter"); textBox3.Text = ""; textBox4.Text = ""; } else { j = db1.nonquery("update registry set password='" + textBox3.Text + "' where loginname='" + textBox1.Text + "'");

54 if (j > 0) MessageBox.Show("Password Changed !!"); else MessageBox.Show("Password changing failed,Retry"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void vistaButton3_Click(object sender, EventArgs e) { this.Close(); } private void pictureBox1_Click(object sender, EventArgs e) { } } }

Intruder Registrationusing using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace kgptc { public partial class intrder_reg : Form {

55 public intrder_reg() { InitializeComponent(); } private void Form8_Load(object sender, EventArgs e) { Class1 db1 = new Class1(); DataTable dt = new DataTable(); try { dt = db1.table("select * from intruder"); dataGridView1.DataSource = dt; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void vistaButton1_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox1.Focus(); } private void vistaButton4_Click(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); string k = ""; int s = 0; try { k = db.scalar("select code from intruder where code='" + textBox1.Text + "'"); if (k != "") { MessageBox.Show("Intruder code Already Exist"); } else {

56 if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("Please fill all fields"); } else { s = db.nonquery("insert into intruder values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + dateTimePicker1.Value + "')"); if (s > 0) { MessageBox.Show("saved"); } else MessageBox.Show("error"); } } dt = db.table("select * from intruder"); dataGridView1.DataSource = dt; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void vistaButton5_Click(object sender, EventArgs e) { this.Close(); } private void vistaButton1_Click_1(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox1.Focus(); } private void vistaButton4_Click_1(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); string k = "";

57 int s = 0; try { k = db.scalar("select code from intruder where code='" + textBox1.Text + "'"); if (k != "") { MessageBox.Show("Intruder code Already Exist"); } else { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("Please fill all fields"); } else { s = db.nonquery("insert into intruder values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + dateTimePicker1.Value + "')"); if (s > 0) { MessageBox.Show("saved"); } else MessageBox.Show("error"); } } dt = db.table("select * from intruder"); dataGridView1.DataSource = dt; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void vistaButton5_Click_1(object sender, EventArgs e) { this.Close(); } } }

Intruder modification

58 using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace kgptc { public partial class intruder_modi : Form { public intruder_modi() { InitializeComponent(); } private void Form3_Load(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); dt = db.table("select * from intruder"); int i; for (i = 0; i < dt.Rows.Count; i++) { comboBox1.Items.Add(dt.Rows[i] [0].ToString()); } } private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); dt = db.table("select * from intruder where code='"+comboBox1.Text+"'"); try { textBox2.Text = dt.Rows[0][1].ToString(); textBox3.Text = dt.Rows[0][2].ToString(); DateTime d = DateTime.Parse(dt.Rows[0] [3].ToString()); dateTimePicker1.Value = d; } catch

{ } }

59

private void button3_Click_1(object sender, EventArgs e) { } private void vistaButton1_Click(object sender, EventArgs e) { Class1 db = new Class1(); int j = 0; if (comboBox1.Text == "") { MessageBox.Show("Please select Intruder Code"); } else { j = db.nonquery("update intruder set ipaddress='" + textBox2.Text + "',intdes='" + textBox3.Text + "',regdate='" + dateTimePicker1.Value + "' where code='" + comboBox1.Text + "'"); textBox2.Text = ""; textBox3.Text = ""; if (j > 0) MessageBox.Show("Intruder Updated !!"); else MessageBox.Show("Updation Failed,Retry"); } } private void vistaButton2_Click(object sender, EventArgs e) { Class1 db = new Class1(); int j = 0; if (comboBox1.Text == "") { MessageBox.Show("Please select Intruder Code"); } else {

60 if (MessageBox.Show("Are you sure", "Deletion", MessageBoxButtons.YesNo) == DialogResult.Yes) { j = db.nonquery("delete from intruder where code='" + comboBox1.Text + "'"); textBox2.Text = ""; textBox3.Text = ""; if (j > 0) { MessageBox.Show("Intruder deleted"); } else MessageBox.Show("Deletion failed,Retry"); } else { this.Close(); } } } private void vistaButton3_Click(object sender, EventArgs e) { this.Close(); } } }

Model Registrationusing using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

61 namespace kgptc { public partial class model_reg : Form { public model_reg() { InitializeComponent(); } private void Form9_Load(object sender, EventArgs e) { Class1 db1 = new Class1(); DataTable dt = new DataTable(); dt = db1.table("select * from model"); dataGridView1.DataSource = dt; } private void vistaButton1_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } private void vistaButton3_Click(object sender, EventArgs e) { this.Close(); } private void vistaButton2_Click(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); string k = ""; int s = 0; k = db.scalar("select mcode from model where mcode='" + textBox1.Text + "'"); if (k != "") { MessageBox.Show("Model code Already Exist"); } else { if (textBox1.Text == "" || textBox2.Text == "") {

MessageBo fields");

62

x.Show("Please fill all

} else { s = db.nonquery("insert into model values('" + textBox1.Text + "','" + dateTimePicker1.Value + "','" + textBox2.Text + "')"); if (s > 0) { MessageBox.Show("saved"); } else MessageBox.Show("error"); } } dt = db.table("select * from model"); dataGridView1.DataSource = dt; } } }

Model modificationusing using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace kgptc { public partial class model_modi : Form { public model_modi() { InitializeComponent(); } {

63 private void Form10_Load(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); dt = db.table("select * from model"); int i; for (i = 0; i < dt.Rows.Count; i++) { comboBox1.Items.Add(dt.Rows[i] [0].ToString()); } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Class1 db = new Class1(); DataTable dt = new DataTable(); dt = db.table("select * from model where mcode='" + comboBox1.Text + "'"); try { textBox2.Text = dt.Rows[0][2].ToString(); DateTime d = DateTime.Parse(dt.Rows[0] [1].ToString()); dateTimePicker1.Value = d; } catch { }

} private void vistaButton1_Click(object sender, EventArgs e) { Class1 db = new Class1(); int j = 0; if (comboBox1.Text == "") { MessageBox.Show("Please select Model Code"); } else { j = db.nonquery("update model set pattern='" + textBox2.Text + "',rdate='" + dateTimePicker1.Value + "' where mcode='" + comboBox1.Text + "'"); textBox2.Text = ""; if (j > 0)

MessageBo else Failed,Retry"); } }

64

x.Show("Model Updated !!");

MessageBox.Show("Updation

private void vistaButton2_Click(object sender, EventArgs e) { Class1 db = new Class1(); int j = 0; if (comboBox1.Text == "") { MessageBox.Show("Please select Model Code"); } else { if (MessageBox.Show("Are you sure", "Deletion", MessageBoxButtons.YesNo) == DialogResult.Yes) { j = db.nonquery("delete from model where mcode='" + comboBox1.Text + "'"); textBox2.Text = ""; if (j > 0) { MessageBox.Show("Model deleted"); DataTable dt = new DataTable(); dt = db.table("select * from model where mcode='" + comboBox1.Text + "'"); try { textBox2.Text = dt.Rows[0] [2].ToString(); DateTime d = DateTime.Parse(dt.Rows[0][1].ToString()); dateTimePicker1.Value = d; } catch { } } else MessageBox.Show("Deletion failed,Retry"); }

else { }

65 this.Close();

} } private void vistaButton3_Click(object sender, EventArgs e) { this.Close(); } } }

Detectusing using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; PacketXLib; System.Diagnostics;

namespace kgptc { public partial class detect : Form { public detect() { InitializeComponent(); Load += Detect_Load; FormClosed += detect_FormClosed; } PacketXClass pkt = new PacketXClass(); string protocol; string s; Class1 db = new Class1(); int i;

66 int j; DataTable dt=new DataTable(); private void OnPacket1(PacketXLib.Packet pPacket) { ListViewItem mitem = default(ListViewItem); int ippresent = 2; mitem = listView1.Items.Add(pPacket.SourceIpAddress.ToString()); mitem.SubItems.Add(pPacket.SourcePort.ToString( )); mitem.SubItems.Add(pPacket.DestIpAddress.ToStri ng()); mitem.SubItems.Add(pPacket.DestPort.ToString()); if ((pPacket.Protocol == PacketXLib.PktXProtocolType.PktXProtocolTypeTCP)) { protocol = "TCP"; } else if ((pPacket.Protocol == PacketXLib.PktXProtocolType.PktXProtocolTypeUDP)) { protocol = "UDP"; } else if ((pPacket.Protocol == PacketXLib.PktXProtocolType.PktXProtocolTypeEthernet)) { protocol = "Ethernet"; } else { protocol = "Unknown Protocol"; } try { DataTable dt = new DataTable(); dt = db.table("select * from intruder where ipaddress='" + pPacket.SourceIpAddress.ToString() + "'"); if(dt.Rows.Count>0) { ListViewItem mlist1; mlist1 = listView2.Items.Add(pPacket.SourceIpAddress.ToString()); mlist1.SubItems.Add(pPacket.Date.ToShor tDateString()); mlist1.SubItems.Add(pPacket.Date.TimeOf Day.ToString()); mlist1.SubItems.Add(protocol); mlist1.SubItems.Add("Existing IP");

67 i =db.nonquery( "insert into detect values('" + pPacket.SourceIpAddress.ToString() + "','" + pPacket.Date.ToShortDateString() + "','" + pPacket.Date.TimeOfDay.ToString() + "','" + protocol + "','Existing')"); } else { ippresent = 0; } } catch { } if ((ippresent == 0)) { Array marray = null; marray = pPacket.DataArray; char datachar = '\0'; string datastring = ""; string patternmatch = ""; datastring = ""; for (i = 0; i 65 & datachar < 122)) { datastring = datastring + Convert.ToChar(datachar); } else { datastring = datastring + datachar.ToString(); } } try { s = db.scalar("select pattern from model"); while (dt.Rows.Count > 0) { patternmatch = dt.Rows[0][0].ToString(); if ((datastring.IndexOf(patternmatch) > 0)) { ListViewItem mlist2; mlist2 = listView2.Items.Add(pPacket.SourceIpAddress);

68 ate.ToString());

mlist2.SubItems.Add(pPacket.D

mlist2.SubItems.Add(pPacket.TimeSec. ToString()); mlist2.SubItems.Add(protocol); mlist2.SubItems.Add("Existing dt"); j = db.nonquery("insert into detect values('" + pPacket.SourceIpAddress.ToString() + "','" + pPacket.Date + "','" + pPacket.Date.TimeOfDay.ToString() + "','" + protocol + "','Intruder data' )"); } } } catch { } } }

private void detect_FormClosed(object sender, FormClosedEventArgs e) { try { pkt.Stop(); } catch { } } private void Detect_Load(object sender, EventArgs e) { pkt.OnPacket += this.OnPacket1; }

private void vistaButton1_Click(object sender, EventArgs e) { try { pkt.Start(); } catch

{

69

MessageBox.Show("Adapter is Already Started Or Invalid Data Adapter ", "Information"); } } private void vistaButton2_Click(object sender, EventArgs e) { try { pkt.Stop(); } catch { MessageBox.Show("Already Stoped"); } } private void vistaButton3_Click(object sender, EventArgs e) { this.Close(); } } }

Data miningusing using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; PacketXLib;

namespace kgptc { public partial class datamining : Form { public datamining() { InitializeComponent(); }

string[] collector = int count = 0; int i;

70

new string[90001];

PacketXClass pkt = new PacketXClass(); public void OnPacket(Packet pPacket) { ListViewItem mitem = default(ListViewItem); mitem = listView1.Items.Add(pPacket.SourceIpAddress.ToString()); mitem.SubItems.Add(pPacket.DestIpAddress.ToStri ng()); mitem.SubItems.Add(pPacket.SourcePort.ToString( )); mitem.SubItems.Add(pPacket.DestPort.ToString()); Array marray = null; marray = pPacket.DataArray; char datachar = '\0'; string datastring = ""; i = 0; while ((i < marray.GetUpperBound(0))) { datachar = Convert.ToChar(marray.GetValue(i)); if ((datachar > 65 & datachar < 122)) { datastring = datastring + datachar; } else { datastring = datastring + Convert.ToInt32(datachar).ToString(); } i = (i + 1); } collector[count] = datastring; count = count + 1; } private void datamining_Load(object sender, EventArgs e) { pkt.OnPacket += this.OnPacket; } private void datamining_FormClosed(object sender, FormClosedEventArgs e) { try { pkt.Stop();

} catch { } }

71

private void listView1_SelectedIndexChanged(object sender, EventArgs e) { try { i = listView1.FocusedItem.Index; richTextBox1.Text = ""; richTextBox1.Text = collector[i].ToString(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void vistaButton1_Click(object sender, EventArgs e) { try { pkt.Start(); } catch { MessageBox.Show("Adapter is Already Started Or Invalid Data Adapter "); } } private void vistaButton2_Click(object sender, EventArgs e) { try { pkt.Stop(); } catch { MessageBox.Show("Already Stoped"); } } private void vistaButton3_Click(object sender, EventArgs e) {

this.Close(); } } }

72

Iprequestusing using using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; PacketXLib; System.IO; System.Net;

namespace kgptc { public partial class iprequest : Form { public iprequest() { InitializeComponent(); Load += iprequest_Load; FormClosed += iprequest_FormClosed; } string strtip; string endip; string strtport; string endport; PacketXClass pkt = new PacketXClass(); public void OnPacket(Packet packet) { strtip = packet.SourceIpAddress.ToString(); endip = packet.DestIpAddress.ToString(); strtport = packet.SourcePort.ToString(); endport = packet.DestPort.ToString(); if ((radioButton1.Checked)) { try { if ((strtip.Equals(textBox1.Text))) {

ListV default(ListViewItem);

73

iewItem list1 =

list1 = listView1.Items.Add(strtip); list1.SubItems.Add(strtport); list1.SubItems.Add(endip); list1.SubItems.Add(endport); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } if ((radioButton1.Checked)) { try { if ((endip.Equals(textBox1.Text))) { ListViewItem list1 = default(ListViewItem); list1 = listView1.Items.Add(strtip); list1.SubItems.Add(strtport); list1.SubItems.Add(endip); list1.SubItems.Add(endport); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } private void iprequest_Load(object sender, EventArgs e) { pkt.OnPacket += this.OnPacket; } private void iprequest_FormClosed(object sender, FormClosedEventArgs e) { try { pkt.Stop(); } catch { } }

74 private void radioButton1_CheckedChanged(object sender, EventArgs e) { try { pkt.Stop(); } catch { } listView1.Items.Clear(); } private void radioButton2_CheckedChanged(object sender, EventArgs e) { try { pkt.Stop(); } catch { } listView1.Items.Clear(); }

private void vistaButton1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Please enter Machine Name/IP "); textBox1.Focus(); return; } try { IPAddress hostIPAddress = IPAddress.Parse(textBox1.Text); try { pkt.Start(); } catch { MessageBox.Show("Adapter is Already Started Or Invalid Data Adapter ");

}

75

} catch { MessageBox.Show("Entered IPAddress is invalid,Re-enter"); textBox1.Text = ""; textBox1.Focus(); }

} private void vistaButton2_Click(object sender, EventArgs e) { try { pkt.Stop(); } catch { MessageBox.Show("Already Stopped"); } } private void vistaButton3_Click(object sender, EventArgs e) { this.Close(); } } }

76

Portscanusing using using using using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Diagnostics; System.Windows.Forms; PacketXLib; System.Net; System.IO; System.Threading;

namespace kgptc { public partial class portscan : Form { public portscan() { InitializeComponent(); } int StartPort; int EndPort; int CurrPort; public bool allport; PacketXClass pkt = new PacketXClass(); System.Net.Sockets.TcpClient tcpscan = new System.Net.Sockets.TcpClient(); private void radioButton1_CheckedChanged(object sender, EventArgs e) { allport = true; textBox2.Enabled = false; textBox3.Enabled = false; textBox2.Clear(); textBox3.Clear(); } private void radioButton2_CheckedChanged(object sender, EventArgs e) { allport = false; textBox2.Enabled = true; textBox3.Enabled = true; }

private void EventArgs e) { }

77

button2_Click(object sender,

private void label2_Click(object sender, EventArgs e) { } //public void a() //{ // this.BeginInvoke(new aa(port)); //} //public void port() //{ // if (textBox1.Text == "") // { // MessageBox.Show("Please specify the IP Address"); // textBox1.Focus(); // return; // } // try // { // IPAddress hostIPAddress = IPAddress.Parse(textBox1.Text); // textBox4.Clear(); // // // // // // // if ((allport)) { StartPort = 1; EndPort = 65530; } else {

// try // { // if ((int.Parse(textBox2.Text) < 1 | int.Parse(textBox3.Text) > 65530) | (textBox2.Text == "") | (textBox3.Text == "")) // { // MessageBox.Show("Please enter the ports between 1 and 65530 "); // return; // } // } // catch // {

78 // MessageBox.Show("Please Enter All Fields"); // textBox1.Focus(); // return; // } // StartPort = Convert.ToInt32(textBox2.Text); // EndPort = Convert.ToInt32(textBox3.Text); // } // progressBar1.Value = 0; // progressBar1.Maximum = EndPort StartPort + 1; // CurrPort = StartPort; // while ((CurrPort 65530) | (textBox2.Text == "") | (textBox3.Text == "")) { MessageBox.Show("Please enter the ports between 1 and 65530 "); return; } } catch { MessageBox.Show("Please Enter All Fields"); textBox1.Focus(); return; } StartPort = Convert.ToInt32(textBox2.Text); EndPort = Convert.ToInt32(textBox3.Text); } progressBar1.Value = 0; progressBar1.Maximum = EndPort - StartPort + 1; CurrPort = StartPort; while ((CurrPort