rendered paste body//-----------------------Includes
//#include "Structor.h"
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#include <iostream>
//-----------------------
#define MAXDATASIZE 100
//-----------------------MISC
#pragma comment(lib, "wsock32")
using namespace std;
//-----------------------
/* Open a raw socket, ready for IP header creation and broadcast addresses */
void WSA()
{
//Check WSA
WSADATA wsaData; // if this doesn't work
//WSAData wsaData; // then try this instead
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
fprintf(stderr, "WSAStartup failed.\n");
exit(1);
}
}
int main()
{
//Always check WSA :)
WSA(); //Gota Declare WSA_STARTUP()
//Variables
int ret;
int x = 0;
//Connect====================================================================================
char DEST_IP[25];
int DEST_PORT[12] = {20, 21, 22, 23, 53, 80, 109, 137, 138, 139, 156, 3306}; //The Ports
cout << "Socket Port Scanner Created BY: Graham Castronovo, AKA Teln3t" << endl;
cout << "[Socket] IP Please: ";
cin >> DEST_IP;
system("CLS");
cout << "[Socket] Scan On [" << DEST_IP << "] In Progress." << endl;
while(DEST_PORT[x] < 200)
{
int sockfd;
struct sockaddr_in dest_addr; // will hold the destination addr
sockfd = socket(PF_INET, SOCK_STREAM, 0); // do some error checking!
dest_addr.sin_family = AF_INET; // host byte order
dest_addr.sin_port = htons(DEST_PORT[x]); // short, network byte order
dest_addr.sin_addr.s_addr = inet_addr(DEST_IP);
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
ret = connect(sockfd, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)); //Connect
//Just an error check, its printing atm
if(sockfd == INVALID_SOCKET)
cout << "sockfd is not working..." << endl;
//OPEN or CLOSED
if(ret != -1)
cout << "[Socket] Port [" << DEST_PORT[x] << "] = OPEN" << endl;
else
cout << "[Socket] Port [" << DEST_PORT[x] << "] = CLOSED" << endl;
x+=1;
}
//Connect====================================================================================
cin.get();
}