Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.

Join the forum, it's quick and easy

Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.
Evo. G Tech Team Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

C++编译的端口扫描器,大家可以研究一下

Go down

C++编译的端口扫描器,大家可以研究一下 Empty C++编译的端口扫描器,大家可以研究一下

Post by cyjian December 13th 2014, 09:56

#include
#include
#include
int main(int argc, char *argv[]) {
int mysocket;
int pcount = 0;
struct sockaddr_in my_addr;
WSADATA wsaData;
WORD wVersionRequested=MAKEWORD(1,1);

if(argc < 3) {
printf("usage: %s \n", argv[0]);
exit(1);
}

if (WSAStartup(wVersionRequested , &wsaData)){
printf("Winsock Initialization failed.\n");
exit(1);
}

for(int i=1; i < atoi(argv[2]); i++){
if((mysocket = socket(AF_INET, SOCK_STREAM,0)) == INVALID_SOCKET){
printf("Socket Error");
exit(1);
}

my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(i);
my_addr.sin_addr.s_addr = inet_addr(argv[1]);

if(connect(mysocket, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == SOCKET_ERROR)
closesocket(mysocket);
else{
pcount++;
printf("Port %d - open\n", i);
}}

printf("%d ports open on host - %s\n", pcount, argv[1]);
closesocket(mysocket);
WSACleanup();
return 0;
}

cyjian
Spammer
Spammer

Posts : 211
Points : 72975
Reputation : 0
Join date : 2014-06-18

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum