Network Security Manual_ccs354 (Edited)
Network Security Manual_ccs354 (Edited)
AND ENGINEERING
REG.NO…………………………………..…
NAME……………………………………….
SRI RANGAPOOPATHI COLLEGE OF ENGINEERING
Alampoondi-604 151, Gingee - TK
BONAFIDE CERTIFICATE
NAME :
REGISTER NO. :
Certified that this is a bonafide record of work done by the above student in the
MARKS/
S.NO. DATE EXPERIMENT TITLE SIGN.
10
6. EXPERIMENT EAVESDROPPING,
DICTIONARY ATTACKS, MITM
ATTACKS
7. EXPERIMENT WITH SNIFF TRAFFIC
USING ARP POISONING
8. DEMONSTRATE INTRUSION
DETECTION SYSTEM USING SNORT
SOFTWARE TOOL
9. EXPLORE NETWORK MONITORING
TOOLS
AIM:
To use Data Encryption Standard (DES) Algorithm for a practical application like
User MessageEncryption.
ALGORITHM:
1. Create a DES Key.
2. Create a Cipher instance from Cipher class, specify the following
information and separated by a slash (/).
a. Algorithmname
b. Mode(optional)
c. Paddingscheme(optional)
3. Convert String into Byte[] array format.
4. Make Cipher in encrypt mode, and encrypt it with Cipher.doFinal() method.
5. Make Cipher in decrypt mode, and decrypt it with Cipher.doFinal() method.
PROGRAM:
DES.java
Import java.security.InvalidKeyException;
Import java.security.NoSuchAlgorithmException;
Import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuch Padding Exception;
import javax.crypto.Secretey;
public class DES
{
Public static void main(String[] argv)
{
try{
System.out.println("MessageEncryptionUsingDESAlgorithm\n ---------- ");
KeyGeneratorkeygenerator=KeyGenerator.getInstance("DES");
SecretKeymyDesKey=keygenerator.generateKey();
CipherdesCipher;
desCipher=Cipher.getInstance("DES/ECB/PKCS5Padding");
desCipher.init(Cipher.ENCRYPT_MODE,myDesKey);
byte[] text = "Secret Information ".getBytes();
System.out.println("Message [Byte Format] : " + text);
System.out.println("Message :"+new String(text));
byte[] textEncrypted = desCipher.doFinal(text);
System.out.println("EncryptedMessage:"+textEncrypted);
desCipher.init(Cipher.DECRYPT_MODE, myDesKey);
byte[]textDecrypted=desCipher.doFinal(textEncrypted);
System.out.println("Decrypted Message:"+newString(textDecrypted));
}catch(NoSuchAlgorithmException e){
e.printStackTrace();
}catch(NoSuchPaddingException e){
e.printStackTrace();
}catch(InvalidKeyException e){
e.printStackTrace();
}catch(IllegalBlockSizeException e){
e.printStackTrace();
}catch(BlockPaddingException e){
e.printStackTrace();
}}}
OUTPUT:
RESULT:
Thus the java program for DES Algorithm has been implemented and the output
verified successfully.
EX.No:2a IMPLEMENT ASYMMETRIC KEY ALGORITHMS AND KEY
EXCHANGE ALGORITHMS – RSA ALGORITHM
AIM:
To implement RSA (Rivest–Shamir–Adleman) algorithm by using HTML and Java
script.
ALGORITHM:
1. Choosetwoprime numberpand q
2. Compute thevalue ofnandp
3. Findthevalue ofe (public key)
4. Compute the value of d(private key) using gcd()
5. Dotheencryptionanddecryption
a. Encryptionisgivenas,
c=te mod n
b. Decryption is given as,
t=cd mod n
PROGRAM:rsa.html
<html>
<head>
<title>RSAEncryption</title>
<metaname="viewport"content="width=device-width,initial-scale=1.0">
</head>
<body>
<center>
<h1>RSAAlgorithm</h1>
<h2>Implemented Using HTML&Javascript</h2>
<hr>
<table>
<tr>
<td>Enter FirstPrimeNumber:</td>
<td><inputtype="number"value="53"id="p"></td>
</tr>
<tr>
<td>EnterSecondPrimeNumber:</td>
<td><inputtype="number"value="59"id="q"></p>
</td>
</tr>
<tr>
<td>Enter the Message (ciphertext):<br>[A=1,B=2,...]</td>
<td><inputtype="number"value="89"id="msg"></p>
</td>
</tr>
<tr>
<td>PublicKey:</td>
<td>
<pid="publickey"></p>
</td>
</tr>
<tr>
<td>Exponent:</td>
<td>
<pid="exponent"></p>
</td>
</tr>
<tr>
<td>PrivateKey:</td>
<td>
<pid="privatekey"></p>
</td></tr>
<tr>
<td>CipherText:</td>
<td>
<pid="ciphertext"></p>
</td></tr>
<tr>
<td><buttononclick="RSA();">ApplyRSA</button></td>
<\tr>
<\table></center></body>
<scripttype="text/javascript">
Function RSA(){
vargcd,p,q, no,n, t,e,i,x;
gcd = function (a, b) { return (!b) ? a : gcd(b, a % b); };
p= document.getElementById('p').value;
q=document.getElementById('q').value;
no=document.getElementById('msg').value;
n = p * q;
t= (p - 1) * (q- 1);
for(e=2;e<t;e++){
if(gcd(e,t)==1){
break;
}}
for(i=0;i<10;i++){
x = 1 +i* t
if (x % e == 0) {
d = x / e;
break;
} }
ctt=Math.pow(no,e).toFixed(0);
ct =ctt% n;
dtt=Math.pow(ct,d).toFixed(0);
dt= dtt% n;
document.getElementById('publickey').innerHTML = n;
document.getElementById('exponent').innerHTML = e;
document.getElementById('privatekey').innerHTML=d;
document.getElementById('ciphertext').innerHTML=ct;
}
</script>
</html>
OUTPUT:
RESULT:
Thus the RSA algorithm has been implemented using HTML & CSS and the
output has been verified successfully.
EX.No:2b IMPLEMENT ASYMMETRIC KEY ALGORITHMS AND KEY
EXCHANGE ALGORITHMS –
DIFFIE-HELLMANKEYEXCHANGEALGORITHM
AIM:
To implement the Diffie-Hellman Key Exchange algorithm for a given problem.
ALGORITHM:
1. Alice and Bob publicly agree to use a modulus p=23 and base g=5 (which
is a primitive root modulo 23).
2. Alice chooses a secret integer a=4,thensendsBob A =gamodp
o A=54mod 23=4
3. Bob chooses a secret integerb=3,thensends Alice B=gbmodp
o B=53mod 23=10
4. Alicecomputess=Bamod p
o s=104 mod 23=18
5. Bob computes s=Abmodp
o s=43 mod 23=18
6. Alice and Bob now share a secret(the number18).
PROGRAM:
DiffieHellman.java
Class DiffieHellman{
Public static void main(Stringargs[]){
int p=23;/* publiclyknown(prime number)*/
int g = 5; /* publicly known (primitive root) */
int x=4;/*onlyAlice knowsthissecret*/
int y = 3; /* only Bob knows this secret */
double alice Sends =(Math.pow(g, x))%p;
double bob Computes=(Math.pow(aliceSends,y))%p;
double bob Sends = (Math.pow(g,y)) %p;
double alice Computes =(Math.pow(bobSends,x))%p;
double shared Secret =(Math.pow(g,(x* y)))% p;
System.out.println("simulationofDiffie-Hellman keyexchangealgorithm\n----
");
System.out.println("Alice Sends : " + aliceSends);
System.out.println("Bob Computes : " + bobComputes);
System.out.println("Bob Sends : " + bobSends);
System.out.println("AliceComputes:"+aliceComputes);
System.out.println("SharedSecret :"+sharedSecret);
/*sharedsecretsshould matchandequality istransitive*/
if((aliceComputes==sharedSecret)&&(aliceComputes==bobComputes))
System.out.println("Success:SharedSecretsMatches!"+sharedSecret);
else
System.out.println("Error:SharedSecretsdoesnotMatch");
}}
OUTPUT:
Simulation of Diffie-Hellman key exchange algorithm
Alice Sends:4.0
Bob Computes:18.0
Bob Sends:10.0
Alice Computes:18.0
Shared Secret :18.0
Success:SharedSecretsMatches!18.0
RESULT:
Thus the Diffie-Hellman key exchange algorithm has been implemented using Java
Program and the output has been verified successfully.
EX.No:3 IMPLEMENT DIGITAL SIGNATURE SCHEMES
AIM:
To implement the SIGNATURE SCHEME –Digital Signature Standard.
ALGORITHM:
1. Create a Key Pair Generator object.
2. Initialize the Key Pair Generator object.
3. Generate the Key Pair Generator.
4. Get the private key from the pair.
5. Create a signature object.
6. Initialize the Signature object.
7. Add data to the Signature object.
8. Calculate the Signature
PROGRAM:
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Scanner;
public classCreatingDigitalSignature{
public static void main(Stringargs[])throwsException{
Scanner sc = new Scanner(System.in);
System.out.println("Enter some text");
Stringmsg =sc.nextLine();
KeyPairGenerator keyPair Gen=KeyPairGenerator.getInstance("DSA");
keyPairGen.initialize(2048);
KeyPairpair=keyPairGen.generateKeyPair();
OUTPUT:
Entersometext
Hihoware you
Digitalsignatureforgiventext:0=@gRD???-?.????/yGL?i??a!?
RESULT:
Thus the Digital Signature Standard Signature Scheme has been implemented and
the output has been verified successfully.
AIM:
PROCEDURE:
The first part of the lab introduces packet sniffer, Wireshark. Wiresharkis a
freeopen-source network protocol analyzer. It is used for network troubleshooting and
communicationprotocol analysis. Wireshark captures network packets in real time and
display them inhuman-readable format. It provides many advanced features Including live
capture and offline analysis, three-pane packet browser, coloring rules for analysis. This
document usesWireshark for the experiments, and it covers Wireshark installation, packet
capturing, andprotocol analysis.
Figure1:Wireshark in KaliLinux
Figure2:EncapsulationofDatain theTCP/IPNetworkStack
PacketSniffer
StartingWireshark:
WhenyouruntheWiresharkprogram,theWiresharkgraphicuserinterface
Figure: Currently,theprogramisnotcapturingthepackets
any interfacebut that does not mean that traffic will flow through that interface. The
network interfaces (i.e.,the physical connections) that your computer has to the network
are shown.
Afteryouselecttheinterface,youcanclickstartto capturethepackets asbelow.
After downloading and installing Wireshark, you can launch it and click the name of an
interfaceunder Interface List to start capturing packets on that interface. For example, if
you want tocapture trafficonthewirelessnetwork,click yourwirelessinterface.
TestRun
Dothefollowingsteps:
1. Startup the Wireshark program (selectaninterfaceandpressstarttocapturepackets).
2. Startup your favourite browser (ceweaselinKaliLinux).
3. In your browser, goto Wayne State home page by typing www.wayne.edu.
4. After your browser has displayed the http://www.wayne.edupage, stop Wireshark
packet capture by selecting stop in the Wireshark capture window. This will cause the
Wireshark capture window to disappear and the main Wireshark window to display all
packets captured since you began packet capture see image below:
AIM:
To check the Message Integrity and Confidentiality using SSL.
PROCEDURE:
Forexample,
Server_Hello:
The server sends its digital certificate to the client, which is supposedly signed by a
root CA. Theclient uses the root CA'spublic key to verify the server's certificate (trusted
root-CAs' public keyare pre-installed inside the browser). It then retrieves the server's
public key from the server'scertificate.(If the server'scertificateis signed by a sub-CA, the
clienthas to build a digitalcertificate chain, leadingtoatrustedroot CA,toverifythe
server'scertificate.)
Thenextstepisto establishtheSession Key:
1. The client generates a 48-byte (384-bit) random number called pre_master_secret,
encrypts it using the verified server's public key and sends it to the server.
2. Server decrypts the pre_master_secret using its own private key. Eavesdroppers
cannot decrypt the pre_master_secret, as they do not possess thes ever's private key.
3. Client and serverthen independently and simultaneously create the session key,
based onthe pre_master_secret, client_random and server_random. Notice that both the
server andclient contribute to the session key,through the inclusion of the random number
exchangein the hello messages. Eavesdroppers can intercept client_random and
server_random as they are sent in plaintext,but cannot decrypt the pre_master_secret.
4. In a SSL/TLS session, the session key consist so f6 secret keys(tothwart crypto-
analysis).3 secret keys are used for client-to-server messages, and the other 3 secret keys
are used for server-to-client messages. Among the 3 secret keys, one is used for encryption
(e.g., DESsecret key), one is used for message integrity (e.g., HMAC) and one is used for
cipherinitialization. (Cipher initialization uses a random plaintext called Initial Vector (IV)
toprime thecipherpump.)
5. Client and server use the pre_master_secret (48-byte random number created by the
clientandexchangesecurely),client_random,server_random,andapseudo-
Sendingmessages:
1. The sender compresses the message using the agreed-upon compression
method(e.g.,PKZip,gzip).
2. The sender has the compressed data and the secret HMAC key to make an HMAC,to
assure message integrity.
3. The sender encrypts the compressed data and HMAC using encryption/decryption
secretkey, to assure message confidentiality.
ASSLSessionTrace
We could use Open SSL'ss_client(with debug option)to produce a SSL session trace
> openssls_client?
(Displaytheavailableoptions)
The following command turns on the debug option and forces the protocol to beTLSv1:
openssls_client -connectlocalhost:443-CAfile ca.crt-debug-tls1
Loading'screen'intorandomstate–done
CONNECTED(00000760)
writeto00988EB0[009952C8](102bytes=>102 (0x66))
0000- 16 03 01 00 61 01 00 00-5d03 01 40 44 35 27 5c....a...]..@D5'\
0010-5ae8 74 26e9 49 37 e2-063b 1c6d 7737 d1aeZ.t&.I7..;.mw7..
TraceAnalysis
The data to be transmitted is broken up into series of fragments. Each fragment is
protected forintegrityusingHMAC.
EachSSLrecordbeginswith a5-byteheader:
Byte0:Record Content Type.
Four Content Types are defined, as follows:
Content Type HexCode Description
Handshake 0x16 The record carries a handshaking message
Application_Data 0x17 Encrypted Application Data
Change_Cipher_Spec 0x14 To indicate a change in encryption methods.
Alert 0x15 To signal various types of errors
Client_Hello
The first handshake message is always sent by the client, called client_hello message. In
thismessage, the client tells the server its preferences in terms of protocol version, cipher
suit, and compression method. The client also includes a 32-byte random number
Certificate_Verify Change_Cipher_Spec
UnknownHandshakingMessage(D4) -tocheck
Application_Data
Client-to-Server-the HTTP request message:GET/test.html HTTP/1.0
Server-to-Client –the HTTP response message Alert
RESULT:
Thus the confidentiality and Integrity using SSL was verified.
AIM:
To experiment eaves dropping, Dictionary attacks, MITM attacks.
PROCEDURE:
Password cracking is a term used to describe the penetration of a network, system,
or resourcewith or without the use of tools to unlock a resource that has been secured with
a password.Password cracking tools may seem like powerful decryptors, but in reality are
little more thanfast,sophisticatedguessingmachines.
Step 5: After running the first password auditing session, check to see if Office key has
crackedthe password. If the password has not been cracked press the Settings button on
theuppertoolbar.
RESULT:
Thus the experiment for Eavesdropping, Dictionary attacks, MITM attacks was
done successfully.
AIM
To perform an experiment to Sniff Traffic using ARP Poisoning.
PROCEDURE:
ARP is the acronym for Address Resolution Protocol. It is used to convert IP
address to physicaladdresses [MAC address] on a switch. The host sends an ARP
broadcast on the network, and therecipient computer responds with its physical address
[MAC Address]. The resolved IP/MAC address is then used to communicate. ARP
poisoning is sending fake MAC addresses to the switch so thatit can associate the fake
MAC addresses with the IP address of a genuine computer onanetworkandhijack the
traffic.
ARP Poisoning Counter measures:
Static ARP entries: these can be defined in the local ARP cache and the switch
configured to ignore all auto ARP reply packets. The disadvantage of this method is, it’s
difficult to maintain on large networks. IP/MAC address mapping has to be distributed to
all the computers on the network.
ARP poisoning detection software: These systems can be used to cross check the
IP/MAC address resolution and certify them if they are authenticated. Uncertified IP/MAC
addressresolutionscanthenbeblocked.
Whatisnetworksniffing?
ComputerscommunicatebybroadcastingmessagesonanetworkusingIPaddresses.Onc
eamessage has been sent on a network, the recipient computer with the matching IP
addressrespondswithits MACaddress.
Network sniffing is the process of intercepting data packets sent over a
network.
Ahubworksbysendingbroadcastmessagestoalloutputportsonitexcepttheonethathassent
thebroadcast.
Select the network interface you want to sniff. Note for this demonstration, we are using a
wireless network connection. If you are on a local area network, then you should select the
local area network interface.
• Click onstart buttonas shownabove
• GobacktoWiresharkandstopthelivecapture
• Locate the Info column and look for entries with the HTTP verb POST and click on it
• Just below the log entries, there is a panel with a summary of captured data. Look for
the summary that says Line-based text data: application/x-www-form-url encoded
• You should be able to view the plaintext values of all the POST variables submitted
totheserver viaHTTP protocol.
Result:
Thus the experiment to Sniff Traffic using ARP Poisoning was performed
successfully.
AIM:
To demonstrate Intrusion Detection System (IDS) using Snort software tool.
Finding an interface
You can tell which interface to use by looking at the Index number and finding Microsoft.
As you can see in the above example, the other interfaces are for VMWare.
To run snort in IDS mode, you will need to configure the file “snort.conf” according to
your networkenvironment.
To specify the network address that you want to protect in snort.conf file, look for the
following line.varHOME_NET192.168.1.0/24(You willnormallysee anyhere)
Youmay alsowantto settheaddressesofDNS_SERVERS, ifyouhavesomeonyournetwork.
Example snort
Change the RULE_PATH variable to the path of rules folder.var
RULE_PATHc:\snort\rules
pathtorules
Change the path of all library files with the name and path on your system. And you must
change the path of snort_dynamic preprocessor variable.
C:\Snort\lib\snort_dynamic c preprocessor
RESULT:
Thus the Intrusion Detection System(IDS) has been demonstrated by using the
Open SourceSnortIntrusion DetectionTool.
AIM:
To explore about Network monitoring tools
Network monitoring is an essential part of network management. It involves using
various tools to monitor a system network and determines lowness and weak connections,
among other issues. Knowing more about these tools can help you understand them better
and use the right ones that suityour requirements.
PROCEDURE:
What Are Network Monitoring Tools?
Network monitoring tools are software that you can use to evaluate network
connections. Thesesoftware programs can help you monitor a network connection and
identify network issues, which may include failing network components, slow connection
speed, network out age or unidentifiable connections. Network management and
monitoring tools can also help you resolve these issues or establish solutions that prevent
specific issues from occurring in the future.
Nagios Core: Nagios Core is a monitoring engine that works as the primary
application for al l Nagios projects, including the Nagios Network Analyser. It integrates
with other Nagios applications and provides users with features like a visual dashboard,
custom application monitoring, automated alert system, advanced user management and
network security monitoring.
Zabbix: Zabbix provides a thorough network monitoring solution with features like
server monitoring, cloud monitoring, application monitoring and service monitoring. The
tool also includes features like metric collection; business monitoring and root cause
analyses of network issues, and allows users to establish a threshold for connection
anomalies.
RESULT:
Thus the network monitoring tools was explored.
EX.No:10 STUDY TO CONFIGURE FIREWALL, VPN
AIM:
To study the features of firewall in providing network security and to set Firewall
Security in windows.
PROCEDURE:
FirewallinWindows7
Windows 7 comes with two firewalls that work together. One is the Windows
Firewall, and the other is Windows Firewall with Advanced Security (WFAS).The main
difference between them is the complexity of the rules configuration. Windows Firewall
uses simple rules that directly relate to a program or a service. The rules in WFAS can be
configured based on protocols, ports, addresses andauthentication. By default, both
firewalls come with predefined set of rules that allow us to utilizenetwork resources. This
includes things like browsing the web, receiving e-mails, etc. Other standardfirewall
exceptions are File and Printer Sharing, Network Discovery, Performance Logs and Alerts,
Remote Administration, Windows Remote Management, Remote Assistance, Remote
Desktop, Windows Media Player, Windows Media Player Network Sharing Service with
firewall in Windows 7 we can configure inbound and outbound rules. By default, all
outboundtraffic is allowed, and inbound responses to that traffic are also allowed. Inbound
trafficinitiatedfrom externalsourcesis automaticallyblocked.
When we first connect to some network, we are prompted toselecta network location.
This featureis known as Network Location Awareness(NLA). This feature enables us to
assign a network profileto the connection based on the location. Different network profiles
contain different collections offirewall rules. In Windows 7, different network profiles can
be configured on different interfaces. Forexample, our wired interface can have different
profile than our wireless interface.
There are threedifferentnetworkprofilesavailable:
• Public
• Home/Work-privatenetwork
• Domain-usedwithinadomain
Configuring Windows Firewall
To open Windows Firewall we can goto Start>ControlPanel>Windows
FirewallService
In our case the service is running.Ifwestop it, wewillgeta warningthatwe shouldturnon
ourWindowsFirewall.
How to Start & Use the Windows Firewall with Advanced Security
The Windows Firewall with Advanced Security is a tool which gives you detailed
controlovertherulesthatareappliedbytheWindowsFirewall.Youcanviewallthe rulesthatare
used by the Windows Firewall, change their properties, create new rules or
disableexistingones.
You have several alternatives to opening the Windows Firewall with Advanced Security:
OneistoopenthestandardWindowsFirewallwindow,bygoingto"ControlPanel-
>SystemandSecurity->WindowsFirewall".Then,click ortapAdvanced settings.
InWindows7,anothermethodistosearchforthewordfirewallintheStartMenusearchboxandclic
kthe"WindowsFirewall withAdvanced Security"result.
What Are The Inbound & Outbound Rules?
In order to provide the security you need, the Windows Firewall has a standard set
ofinbound and outbound rules, which are enabled depending on the location of the network
you are connected to.
Inbound rules are applied to the traffic that is coming from the network and the
Internet toyour computer or device. Outbound rules apply to the traffic from your computer
to the network or the Internet.
These rules can be configured so that they are specific to: computers, users,
programs, services, ports or protocols. You can also specify to which type of network
adapter (e.g.wireless,cable,virtualprivatenetwork)or user profile it is applied to.
In the Windows Firewall withAdvancedSecurity,youcanaccessallrules and edittheir
properties. All you have to do is clickor tap the appropriate unit in the left-side panel.
What are the Connection Security Rules?
Connection security rules are used to secure traffic between two computers while
itcrosses the network. One example would be a rule which defines that
connectionsbetweentwospecificcomputersmustbeencrypted
If you want to see if there are any such rules on your computer, click or tap"
Connection Security Rules" on the panel on the left. By default, there are no such rules
defined on Windows computers and devices. They are generally used in business
environments and such rules are set by the network administrator.
What does the Windows Firewall with Advanced Security Monitor?
The Windows Firewall with Advanced Security includes some monitoring features
aswell. Inthe Monitoring section you can find the following information: the
firewallrulesthatareactive (both inbound and outbound), the connection security rules that
are active and whetherthere areany activesecurity associations.
RESULT:
Thus study of the features of firewall in providing network security and to set
Firewall Security in windows.