Exemplo n.º 1
0
int main( int argc, char ** argv )
{
	int opt;
	char type;
	char * dst_ip_str;

	type = '.';
	while( ( opt = getopt(argc, argv, "s:f:") ) != -1 ){
		switch( opt ){
		case 's':
			printf( "option s: %s\n", optarg );
			type = 's';
			dst_ip_str = optarg;
			break;
		case 'f':
			printf( "option f: %s\n", optarg );
			type = 'f';
			dst_ip_str = optarg;
			break;
		default:
			display_usage( argv[0] );
			exit( -1 );
		}
	}

	if( type == '.' ){
		display_usage( argv[0] );
		exit(-1);
	}

	port_scan( type, dst_ip_str );
	return 0;
}
Exemplo n.º 2
0
int CHostScan::local_scan_start()
{
	WORD wVersionRequested;
	WSADATA wsaData;
	char name[255];
	PHOSTENT hostinfo;
	wVersionRequested = MAKEWORD(1, 1);
	char* ip;

	if (WSAStartup(wVersionRequested, &wsaData) == 0)
		if (gethostname(name, sizeof(name)) == 0)
		{
#ifndef _REAL
			DebugMessageA("Host name: %s\n", name);
#endif
			if ((hostinfo = gethostbyname(name)) != NULL)
			{
				for (int nCount = 0; hostinfo->h_addr_list[nCount]; nCount++)
				{
					ip = inet_ntoa(*(struct in_addr *)hostinfo->h_addr_list[nCount]);
#ifndef _REAL
//					DebugMessageA("IP #%d: %s\n", nCount, ip);
#endif
					char* ip_temp;
					char ip_target[16] = { 0, };
					ip_temp = strtok(ip, ".");
					for (int i = 0; i < 3; i++)
					{
						strcat(ip_target, ip_temp);
						strcat(ip_target, ".");

						ip_temp = strtok(NULL, ".");
					}

					for (int i = m_start; i <=m_end; i++)
					{
						char ip_target_temp[16] = { 0, };
						char host_temp[4] = { 0, };
						sprintf(host_temp, "%d", i);
						strcat(ip_target_temp, ip_target);
						strcat(ip_target_temp, host_temp);

						if (port_scan(ip_target_temp, 445) == 1)
						{
#ifndef _REAL
							Worker(ip_target_temp, "445");
							DebugMessageA("port_scan %s\n", ip_target_temp);
#endif
						}
					}

				}
			}
		}
	return 0;
}