Underc0de

Redes y Comunicación => Phreak => Mensaje iniciado por: ANTRAX en Febrero 23, 2010, 12:28:49 PM

Título: Mi Profanador de Bluetooth en C
Publicado por: ANTRAX en Febrero 23, 2010, 12:28:49 PM
Bueno pues esta tool fue cambiada mejor dicho esta tool fue hecha en Java Por un colega Pedi Permiso para cambiarla de lenguaje de Programacion a C y asi lo hice =)



#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>

#include <termios.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <asm/types.h>
#include <netinet/in.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

extern int optind,opterr,optopt;
extern char *optarg;

#define for_each_opt(opt, long, short) while ((opt=getopt_long(argc, argv, short ? short:"+", long, NULL)) != -1)

static void usage(void);

static struct option hunt_options[] = {
  {"Ayuda", 0,0, 'A'},
  {0, 0, 0, 0}
};

static char *hunt_help =
  "Usage:\n"
  "\thunt <timeout>\n";

static void cmd_hunt(int dev_id, int argc, char **argv)
{
  bdaddr_t bdaddr;
  char name[248];
 
  int opt, dd, num=0, num2=0, num3=0, num4=0, num5=0, num6=0;
  int btout=50000;

  unsigned char lame[16][2] = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F", };

  char addtobrute[248];

  printf("Profanador Bluetooth by Codeboy\n");
  printf("Codeboy Productions(c)\n");
  printf("Autor: Codeboy www.codeboy.es - e-r00t user - [email protected]\n");

  argc -= optind;
        argv += optind;

  if (argc < 2) {
    printf(hunt_help);
    exit(1);
  }

  if (argc >= 1) {
    btout=atoi(argv[1]);
  }

  printf("timeout: %d\n", btout);

  printf("Comensando...\n");

  while (num <= 15)
  {
    while(num2 <= 15)
    {
      while(num3 <= 15)
      {
        while(num4 <= 15)
        {
          while(num5 <= 15)
          {
            while(num6 <= 15)
            {
              strcpy(addtobrute,"00:80:98:");
              strcat(addtobrute,lame[num]);
              strcat(addtobrute,lame[num2]);
              strcat(addtobrute,":");
              strcat(addtobrute,lame[num3]);
              strcat(addtobrute,lame[num4]);
              strcat(addtobrute,":");
              strcat(addtobrute,lame[num5]);
              strcat(addtobrute,lame[num6]);
           
              /* Solo Debug */
              printf("%s\n",addtobrute);

              baswap(&bdaddr, strtoba(addtobrute));
                     
              dev_id = hci_get_route(&bdaddr);
              if (dev_id < 0) {
                fprintf(stderr,"Dispocitivo no es posible de alcanzar");
                exit(1);
              }
             

             
              dd = hci_open_dev(dev_id);
              if (dd < 0) {
                fprintf(stderr,"HCI Dispositivo alcanzado y conectado");
                exit(1);
              }
             
             
              /* Consiguiendo informacion del otro dispositivo */
              if (hci_read_remote_name(dd,&bdaddr,sizeof(name), name, btout) == 0)
                printf("\n.start--->\naddress :- %s\nname :- %s\n<.end-----\n",batostr(&bdaddr),name);
             
              close(dd);

              num6++;
              }
              num6=0;
              num5++;

            }
            num5=0;
            num4++;
          }
          num4=0;
          num3++;
      }
      num3=0;
      num2++;
    }
    num2=0;
    num++;
  }
}

struct {
  char *cmd;
  void (*func)(int dev_id, int argc, char **argv);
  char *doc;
} command[] = {
  { "Profanar", cmd_Profanar, "Encontrar el nombre del dispositivo" },
  { NULL, NULL, 0}
};

static void usage(void)
{
  int i;

  printf("Profanador Bluetooth by Codeboy\n");
  printf("uso:\n"
    "\tfang [opciones] <Comando> [Parametros de lo elejido]\n");
  printf("Opciones:\n"
    "\t--Ayuda\tMostrar help\n"
    "\t-i Ver\tHCI Ver\n");
  printf("Comandos:\n");
  for (i=0; command[i].cmd; i++)
    printf("\t%-4s\t%s\n", command[i].cmd,
    command[i].doc);
  printf("\n"
    "Para mas informacion use el comando help:\n"
    "\tfang <Comando> --help\n" );
}

static struct option main_options[] = {
  {"Ayuda", 0,0, 'h'},
  {"Ver", 1,0, 'i'},
  {0, 0, 0, 0}
};

int main(int argc, char **argv)
{
  int opt, i, dev_id = -1;
  bdaddr_t ba;

  while ((opt=getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
    switch(opt) {
    case 'i':
      dev_id = hci_devid(optarg);
      if (dev_id < 0) {
        perror("Dispositivo no valido");
        exit(1);
      }
      break;

    case 'h':
    default:
      usage();
      exit(0);
    }
  }

  argc -= optind;
  argv += optind;
  optind = 0;

  if (argc < 1) {
    usage();
    exit(0);
  }

  if (dev_id != -1 && hci_devba(dev_id, &ba) < 0) {
    perror("Dispositivo no es alcansable");
    exit(1);
  }

  for (i=0; command[i].cmd; i++) {
    if (strncmp(command[i].cmd, argv[0], 3))
      continue;
    command[i].func(dev_id, argc, argv);
    break;
  }
  return 0;
}

/*Coded by Codeboy */


Bueno pues lo mas probable es que no entiendan o si lo entienden lo vean inserbible bueno como explique este programa fuue hecho en java hace un tiempo, pero ahora lo hago yo en C, este programa es muy util pero para usarlo en PDAs o Telefonos casi computadoras, de que me sirve este programa?? pues solo te da la minima informacion de tu objetivo pero para que quieres esa info?? por que con esa info una ves hecha la conexion podras modificar tu configuracion con la del otro equipo es decir que podras manejarlo obviamente con su permiso pero hay dispositivos (no moviles) que se manejan por bluetooth y seria un exito que las editen (ejemplo puede ser una pantalla de publicidad)....

Saludos
Codeboy


EDIT: Solo usenlo en cuanto crean que tienen un poco mas que el conocimiento basico y con precaucion