📄 portscan.c
字号:
/* this has been tested already, it works... * * feed the ascii ip address and port number, and return true * or false if the port is open or closed.... **/#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>int portscan(char *ip, int port){ int sockfd, test; struct sockaddr_in addr; sockfd=socket(AF_INET, SOCK_STREAM, 0); // fuck error checking addr.sin_port = htons(port); addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr(ip); test = connect_timeo(sockfd, (struct sockaddr *)&addr, sizeof(addr), 2); close(sockfd); if (test == -1) return (1 == 0); /* (false) */ return (1 == 1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -