rendered paste body//-----------------------Includes
#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 */
int TheRawSocket()
{
return 0;
}
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()
//The Raw Socket============================================================================================================
SOCKET s;
s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); //Create a RAW socket
int optval=1;
setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&optval, sizeof optval); //Set it to include the header
//End The Raw Socket=========================================================================================================
//Variables
int ret;
//Connect====================================================================================
char DEST_IP[25];
int DEST_PORT = 20;
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 < 200)
{
int sockfd;
struct sockaddr_in dest_addr; // will hold the destination addr
sockfd = s; // do some error checking!
dest_addr.sin_family = AF_INET; // host byte order
dest_addr.sin_port = htons(DEST_PORT); // 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;
DEST_PORT+=1;
if(ret != -1)
cout << "[Socket] Port [" << DEST_PORT << "] = OPEN" << endl;
else
cout << "[Socket] Port [" << DEST_PORT << "] = CLOSED" << endl;
}
//Connect====================================================================================
cin.get();
}