bueno es que trato de hacer un programa que verifique si el ciertos puertos estan abiertos o no pero a la hora de ejecutar e programa me dice que todos los puertos estan habierto esperoque me puedan ayudar.
Código
#include <winsock2.h> #include <windows.h> #include <iostream> #include <sys/types.h> #pragma comment(lib, "Ws2_32.lib") using namespace std; char IP[20]; int startPort, endPort, err, nret; int main() { int i; struct sockaddr_in conect; SOCKET iSocket; WSADATA wsaData; if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0 ) { cout << "Winsock Error, Exiting..." << endl; cin.get(); return 0; } cout << "Target IP: "; cin>>IP; cout << "Starting Port: "; cin>>startPort; cout << "End Port: "; cin>>endPort; cin.ignore(); cout << endl << endl << "Scanning..." << endl << endl; for( i=startPort; i <= endPort; i++) { iSocket = socket(AF_INET, SOCK_STREAM, 0); if (iSocket == -1) cout<<"error al abrir el socket"; conect.sin_addr.S_un.S_addr = inet_addr(IP); conect.sin_family = AF_INET; conect.sin_port = htons(startPort); nret = bind(iSocket, (struct sockaddr *)&conect, sizeof(conect)); if( nret == 0) { cout << "Port " << i << " - OPEN! " << endl; } else { cout <<"puerto no abir}erto"; } closesocket(iSocket); } cout << endl << "Finished With Scan..." << endl; cin.get(); WSACleanup(); }