?? test.c
字號(hào):
#include <sys/time.h>#include <netinet/in.h>#include <arpa/inet.h>#include <stdlib.h>#include <stdio.h>#include <tcp_scan.h>int info(const struct sockaddr *sockaddr, socklen_t addrlen, int state, void *arg){ struct sockaddr_in *sin = (struct sockaddr_in *)sockaddr; printf("%s:%d ", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port)); switch (state) { case TS_ACCEPTED: printf("Connection accepted\n"); break; case TS_REFUSED: printf("Connection refused\n"); break; case TS_UNREACH: printf("Destination unreachable\n"); break; } return 0;}int main(int argc, char *argv[]){ struct addrseg head; struct addrseg *cur, *new; struct in_addr mask; FILE *file; char buf1[16], buf2[16], buf3[16]; unsigned short ports[] = { 21, 0 }; unsigned int bit; time_t curtime; if (argc != 2) { fprintf(stderr, "USAGE: test <address scope file>\n"); exit(1); } if (!(file = fopen(argv[1], "r"))) { perror("fopen"); exit(1); } cur = &head; while (fscanf(file, "%16s%16s%16s\n", buf1, buf2, buf3) != EOF) { if (new = (struct addrseg *)malloc(sizeof (struct addrseg))) { new->as_family = AF_INET; if (new->as_address = malloc(sizeof (struct in_addr))) { inet_pton(AF_INET, buf1, new->as_address); inet_pton(AF_INET, buf3, &mask); new->as_bits = 0; for (bit = 0xa0000000; bit & ntohl(mask.s_addr); bit >>= 1) new->as_bits++; cur->as_next = new; cur = new; continue; } } perror("malloc"); exit(1); } cur->as_next = NULL; curtime = time(NULL); printf("Start at: %s\n", ctime(&curtime)); tcp_scan(head.as_next, ports, 0, "eth0", 1, info, NULL); curtime = time(NULL); printf("\nEnd at: %s", ctime(&curtime));}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -