- 论坛徽章:
- 0
|
#include <stdio.h>;
#include <stdlib.h>;
#include <string.h>;
#include <unistd.h>;
#include <netdb.h>;
#include <sys/types.h>;
#include <sys/socket.h>;
#include <netinet/in.h>;
#include <arpa/inet.h>;
enum
{ CMD_NAME, DST_IP, START_PORT, LAST_PORT };
enum
{ CONNECT, NOCONNECT };
int tcpportscan (u_int dst_ip, int dst_port);
int
main (int argc, char *argv[])
{
u_long dst_ip;
int dst_port;
int start;
int end;
if (argc != 4)
{
fprintf (stderr, "usage:%s dst_ip start_port last_port\n",
argv[CMD_NAME]);
exit (EXIT_FAILURE);
}
if ((dst_ip = inet_addr (argv[DST_IP])) == INADDR_NONE)
{
struct hostent *he;
if ((he = gethostbyname (argv[DST_IP])) == NULL)
{
fprintf(stderr,"gethostbyname error\n" ;
exit (EXIT_FAILURE);
}
memcpy((char *)&dst_ip,(char *)he->;h_addr,he->;h_length);
printf("scan %s(%s) tcp port\n",argv[DST_IP],inet_ntoa(*(struct in_addr *)&dst_ip));
}
start = atoi (argv[START_PORT]);
end = atoi (argv[LAST_PORT]); |
|