*/
/*
* $Id: fang.c,v 1.00 2003/04/20 13:00:00 ollie Exp $
*/
#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[] = {
{"help", 0,0, 'h'},
{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("redfang - the bluetooth hunter ver 1.00.alpha\n"); printf("(c)2003 \@stake Inc\n"); printf("author: Ollie Whitehouse (ollie@atstake.com)\n");
argc -= optind;
argv += optind;
if (argc < 2) {
}
if (argc >= 1) {
}
printf("timeout: %d\n", btout
);
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
[num2
]); strcat(addtobrute
,lame
[num3
]); strcat(addtobrute
,lame
[num4
]); strcat(addtobrute
,lame
[num5
]); strcat(addtobrute
,lame
[num6
]);
/* debug purposes */
baswap(&bdaddr, strtoba(addtobrute));
dev_id = hci_get_route(&bdaddr);
if (dev_id < 0) {
fprintf(stderr
,"Device not availible"); }
dd = hci_open_dev(dev_id);
if (dd < 0) {
fprintf(stderr
,"HCI device open failed"); }
/* try to get name of remote device - timeout is the int) */
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[] = {
{ "hunt", cmd_hunt, "Get name from remote device" },
{ NULL, NULL, 0}
};
static void usage(void)
{
int i;
printf("redfang - the bluetooth hunter ver 1.00.alpha\n"); "\tfang [options] <command> [command parameters]\n");
"\t--help\tDisplay help\n"
"\t-i dev\tHCI device\n");
for (i=0; command[i].cmd; i++)
printf("\t%-4s\t%s\n", command
[i
].
cmd, command[i].doc);
"For more information on the usage of each command use:\n"
"\tfang <command> --help\n" );
}
static struct option main_options[] = {
{"help", 0,0, 'h'},
{"device", 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) {
}
break;
case 'h':
default:
usage();
}
}
argc -= optind;
argv += optind;
optind = 0;
if (argc < 1) {
usage();
}
if (dev_id != -1 && hci_devba(dev_id, &ba) < 0) {
perror("Device is not available"); }
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;
}
Ki8KCi8qCsKgKiAkSWQ6IGZhbmcuYyx2IDEuMDAgMjAwMy8wNC8yMCAxMzowMDowMCBvbGxpZSBFeHAgJArCoCovCgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDxzdHJp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