Code:
#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<stdlib.h>
#include<netdb.h>
#include"simple_port_scanner.h"
#include"dev_net.h"
#include"sniff.h"
#include<pcap.h>
int main()
{
char ans;
int choice;
again:
printf("***************WELCOME************* \n");
printf("\nPlease look at the menu and enter the corresponding choice\n");
printf("\n");
printf("1.Simple Port Scan :\n");
printf("2.Check you device name,net address and subnet mask\n");
printf("3.Let's Sniff\n");
printf("\n");
scanf("%d",&choice);
switch(choice)
{
case(1):
{
simple_port_scanner();
break;
}
case(2):
{
dev_net();
break;
}
case(3):
{
sniff();
break;
}
}
printf("Do you wish to continue ??");
scanf("%s",&ans);
if(ans=='y')
{
goto again;
}
else
{
printf("exit");
exit(1);
}
return 0;
}
Code:
#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<stdlib.h>
#include<netdb.h>
void simple_port_scanner()
{
char ip[16];
int i,net,new;
struct sockaddr_in sa;
printf("enter the ip");
scanf("%s",ip);
sa.sin_addr.s_addr=inet_addr(ip);
for(i=1;i<20000;i++)
{
sa.sin_family=AF_INET;
sa.sin_port=htons(i);
net=socket(AF_INET,SOCK_STREAM,0);
if((new=connect(net,(struct sockaddr *)&sa,sizeof(sa)))>=0)
{
printf("\n%d is open",i);
close(new);
}
}
printf("now exit scanner \n");
}
Please look at the menu and enter the corresponding choice
1.Simple Port Scan :
2.Check you device name,net address and subnet mask
3.Let's Sniff
1
enter the ip127.0.0.1
22 is open
25 is open
111 is open
631 is open
now exit scanner
Do you wish to continue ??exit
//end of output
The problem is after do you wish to continue it does not wait for an input and just exits.This problem is only there when I choose option 1 that is simple port scan otherwise on choosing any other option the program keeps workin fine.Any clue or suggestion would be great.Thanks


