Quantcast
Channel: Assignment
Viewing all articles
Browse latest Browse all 9608

Man in middle attack

$
0
0
by fyproject 13.  

Man in middle attack

 

#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<dos.h>

 

void main()

  {

   int a,q,i;

   int Xa,Ya,Xb,Yb,Ya1,Yb1,Kab1,Kab;

 

   int gd,gm;

   clrscr();

   printf("\n Man in Middle attack.");

   printf("\n Trudy make keys with Alice stating that I am Bob.");

 

   do

     {

      printf("\n enter value of prime number q (1-15):: ");

      scanf("%d",&q);

     }while(q>15);

   for(i=0;;i++)

            {

               printf("\n enter the primitive root a :: ");

               scanf("%d",&a);

               if(a<q)

                        break;

               printf("\n a>q so enter again !!!");

            }

 

   printf("\n for sender station.........");

   do

     {

      printf("\n enter the private number of station A (1-5):: ");

      scanf("%d",&Xa);

     }while(Xa>5);

 

   Ya1=pow(a,Xa);

   Ya=Ya1%q;

   printf("\n the public number generated is as :: %d",Ya);

 

   printf("\n for receiver station .....");

   do

     {

      printf("\n enter the private number of station B (1-5):: ");

      scanf("%d",&Xb);

     }while(Xb>5);

 

   Yb1=pow(a,Xb);

   Yb=Yb1%q;

   printf("\n the public number generated is as :: %d",Yb);

 

   Kab1=pow(Yb,Xa);

   Kab=Kab1%q;

   printf("\n\n\t\t shared secret key form as :: %d",Kab);

 

   printf("\n Unfortunately Alice has recognized Trudy as Bob");

 

   sound(100);

   delay(1000);

   nosound();

 

   //now shared key between trudy and bob

   clrscr();

   printf("\n Trudy make new key with Bob.");

   do

     {

      printf("\n enter value of prime number q (1-15):: ");

      scanf("%d",&q);

     }while(q>15);

   for(i=0;;i++)

            {

               printf("\n enter the primitive root a :: ");

               scanf("%d",&a);

               if(a<q)

                        break;

               printf("\n a>q so enter again !!!");

            }

 

   printf("\n for sender station.........");

   do

     {

      printf("\n enter the private number of station A (1-5):: ");

      scanf("%d",&Xa);

     }while(Xa>5);

 

   Ya1=pow(a,Xa);

   Ya=Ya1%q;

   printf("\n the public number generated is as :: %d",Ya);

 

   printf("\n for receiver station .....");

   do

     {

      printf("\n enter the private number of station B :: ");

      scanf("%d",&Xb);

     }while(Xb>5);

 

   Yb1=pow(a,Xb);

   Yb=Yb1%q;

   printf("\n the public number generated is as :: %d",Yb);

 

   Kab1=pow(Yb,Xa);

   Kab=Kab1%q;

   printf("\n\n\t shared secret key form as :: %d",Kab);

   printf("\n\n\n\t Trudy has intrruted the communication between Alice and Bob");

 

   printf("\n\n\n Alice is communicating with Bob.");

   printf("\n\n\n But actual communication is taking place between Alice and Trudy then Trudy to Bob.");

 

   getch();

  }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OUTPUT:

 

 Man in Middle attack.

 Trudy make keys with Alice stating that I am Bob.

 enter value of prime number q (1-15):: 5

 

 enter the primitive root a :: 2

 

 for sender station.........

 enter the private number of station A (1-5):: 4

 

 the public number generated is as :: 1

 for receiver station .....

 enter the private number of station B (1-5):: 4

 

 the public number generated is as :: 1

 

                 shared secret key form as :: 1

 Unfortunately Alice has recognized Trudy as Bob

 

 

Trudy make new key with Bob.

 enter value of prime number q (1-15):: 3

 

 enter the primitive root a :: 2

 

 for sender station.........

 enter the private number of station A (1-5):: 3

 

 the public number generated is as :: 2

 for receiver station .....

 enter the private number of station B :: 4

 

 the public number generated is as :: 1

 

         shared secret key form as :: 1

 

 

         Trudy has intrruted the communication between Alice and Bob

 

 

 Alice is communicating with Bob.

 

 

 But actual communication is taking place between Alice and Trudy then Trudy to

Bob.


Viewing all articles
Browse latest Browse all 9608

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>