| [C++] Port Scanner Have a look at our store
/*
** C++ Port Scanner
** Written by Kr3w
*/
#include <iostream>
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
#define MAX 65536
using namespace std;
int main(int argc, char *argv[])
{
WSADATA sox;
WSAStartup(0x0202, &sox);
int x, s, con, open[MAX], temp;
LPHOSTENT ip;
cout << "Scanning: " << argv[1] << endl;
x = 1;
while(x < MAX-1) {
s = socket(2, 1, 6);
ip = gethostbyname(argv[1]);
struct sockaddr_in pscan;
pscan.sin_family = 2;
pscan.sin_port = htons(x);
pscan.sin_addr = *((LPIN_ADDR)*ip->h_addr_list);
con = connect(s, (struct sockaddr *)&pscan, sizeof(pscan));
if(con == -1) {
cout << "Closed " << x << endl; open
* = 0; }
else {
open
* = x; cout << "Opened: " << x << endl; }
closesocket(s);
++x;
}
temp = 1;
while(temp < MAX) {
++temp;
if(open[temp] != 0)
cout << "Open: " << open[temp] << endl; }
getchar(); // wait
WSACleanup();
return 0;
} Check out our store |