#include <windows.h>
#include <string>
#include <winsock2.h>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <iostream>

using namespace std;

char target[MAX_PATH];
int ports = 21;
int http = 80;
SOCKET Socket;
WSADATA WsaDat;
SOCKADDR_IN server;


int core()
{
	if (WSAStartup(MAKEWORD(2,2), &WsaDat) != 0){
		return 0;
	}
	Socket = socket(AF_INET, SOCK_STREAM, 0);
	if (Socket == SOCKET_ERROR){
		return 0;
	}

	server.sin_port=htons (ports);
	server.sin_family = AF_INET;
	server.sin_addr.s_addr=inet_addr(target);

	if(connect(Socket,(SOCKADDR*)(&server),sizeof(server))==SOCKET_ERROR)
	{
		cout<<"";
	}
	else {
		cin.get();
		cout<<"21 (ftp) is open\n";
		cin.get();
		closesocket(Socket);
	}
	SOCKADDR_IN meow;

	meow.sin_port=htons (http);
	meow.sin_family = AF_INET;
	server.sin_addr.s_addr=inet_addr (target);

	if (connect(Socket, (SOCKADDR *) (&meow), sizeof (meow))==SOCKET_ERROR){
		cin.get();
		cout<<"No ports opened on system!\n";
		cin.get();
	}
	else {
		cin.get();
		cout<<"80 (http) is open\n";
		cin.get();
		closesocket(Socket);
		WSACleanup();
	}
}
int main()
{
	cout<<"Welcome to Portscanner tester 2.0\n";
	cout<<"Please enter a target...: ";
	cin>> target;
	cout<<"Ok lets begin.....\n";
	Sleep(3000);
	core();
	return 0;
}