--- /dev/null
+# Makefile of hdw-sniff
+
+INCLUDEDIR = /usr/include
+
+CFLAGS = -DDEBUG -O3 -Wall
+LIBS = -lpcap
+
+API_OBJS = network.o event.o input.o display.o audio.o
+
+api: links $(API_OBJS)
+
+hdw-sniff: $(API_OBJS)
+ $(CC) $(CFLAGS) -o $@ $(API_OBJS) hdw-sniff.c $(LIBS)
+all: hdw-sniff
+
+clean:
+ rm -f $(API_OBJS) {event,input,display,audio,network,list}.{c,h}
+ rm -f hdw-sniff
+
+links:
+ ln -sf ../api/event/event.{c,h} .
+ ln -sf ../api/input/input.{c,h} .
+ ln -sf ../api/display/display.{c,h} .
+ ln -sf ../api/audio/audio.{c,h} .
+ ln -sf ../api/network/network.{c,h} .
+ ln -sf ../api/list/list.{c,h} .
+
+remake: clean all
+++ /dev/null
-/*
- * list.h - list header file
- *
- * author: hackbard@hackdaworld.dyndns.org
- *
- */
-
-#define MAX_BSSID_CHARS 6
-#define MAX_SSID_CHARS 32
-
-struct bssid
-{
- char bssid[MAX_BSSID_CHARS]; /* the bssid mac address */
- struct bss *next; /* next bssid */
-}
-
-struct bsslist
-{
- char ssid[MAX_SSID_CHARS]; /* network name of this bss */
- char struct *bssid; /* pointer to bssid mac addresses of this bss */
- struct bsslist *next; /* next sniffed bss */
-}
/*
* main.c - main hdw-sniff
*
- * author: hackbard@hackdaworld.dyndns.org
+ * Copyright (C) 2004 hackbard@hackdaworld.dyndns.org
*
*/
-#include <stdio.h>
#include "main.h"
/* functions */
-int usage(void)
-{
- puts("usage: hdw-sniff <options>");
- puts("\toptions:\t-m <mode> \t1 monitoring, 2 managed");
- puts("\t\t-d <device> \twlan0,eth0");
- puts("\t\t-l <logfile>");
- puts("\t\t-h \tdisplay this help message");
- return -23;
-}
-int hop_channel(info_struct *info)
-{
- struct iwreq iwreq;
- if(info->current_channel>=CHANNEL_MAX) info->current_channel=1;
- memset(&iwreq,0,sizeof(iwreq));
- strcpy(iwreq.ifr_name,info->device);
- iwreq.u.freq.e=0;
- iwreq.u.freq.m=info->current_channel;
- if(ioctl(info->channel_hop_fd,SIOCSIWFREQ,&iwreq)<0)
- {
- puts("unable to hop channel");
- perror("ioctl");
- return -23;
- }
- ++(info->current_channel);
- return 23;
+int usage(void) {
+ puts("usage: hdw-sniff <options>");
+ puts("\toptions:\t-m <mode> \t1 monitoring, 2 managed");
+ puts("\t\t-d <device> \twlan0,eth0");
+ puts("\t\t-l <logfile>");
+ puts("\t\t-k <key> \t(string)");
+ puts("\t\t-h \tdisplay this help message");
+ puts("");
}
-int main(int argc, char **argv)
-{
- /* local variables */
- char pcap_error[PCAP_ERRBUF_SIZE];
- char sys_call[SYSCALL_MAX];
+int hop_channel(t_info *info) {
- int pcap_fd,channel_hop_fd;;
- int i;
+ struct iwreq iwreq;
- fd_set pcap_fd_set;
- struct timeval pcap_fd_set_tv;
+ if(info->current_channel>=CHANNEL_MAX) info->current_channel=1;
+ memset(&iwreq,0,sizeof(iwreq));
+ strcpy(iwreq.ifr_name,info->device);
+ iwreq.u.freq.e=0;
+ iwreq.u.freq.m=info->current_channel;
+ if(ioctl(info->channel_hop_fd,SIOCSIWFREQ,&iwreq)<0) {
+ puts("unable to hop channel");
+ perror("ioctl");
+ return -23;
+ }
+ ++(info->current_channel);
+ return 23;
+}
- struct info_struct info;
+int main(int argc, char **argv) {
+ t_info info;
- memset(&info,0,sizeof(struct info_struct));
- /* default values */
- info.caps=0;
- info.logfile_fd=0;
- info.quit=0;
+ memset(&info,0,sizeof(t_info));
/* parse arguments */
for(i=1;i<argc;i++)
*
*/
+#define _GNU_SOURCE
#include <stdio.h>
-
+#include <string.h>
+#include <stdlib.h>
#define SYSCALL_MAX 32
#define MAX_DEV_CHARS 6
-#define PCAP_SELECT_SEC 0
-#define PCAP_SELECT_USEC 200000
-
-#define CAP_MODE_MASK 0x01
-#define CAP_QUIT_MASK 0x02
+#define SELECT_SEC 0
+#define SELECT_USEC 200000
+/* modes */
#define MONITORING_MODE 0x01
#define MANAGED_MODE 0x00
#define QUIT_MODE 0x02
-#define IWPRIV_M_MODE 3
-
-
-/* typedefinitions */
-struct info_struct
-{
- unsigned char caps; /* capabilities */
- int logfile_fd; /* file descriptof for logfile */
- char device[MAX_DEV_CHARS]; /* sniffed devie */
- int channel_hop_fd; /* fd for channel hopping */
-};
+#define MAX_BYTE_WEP 13 /* maximal 104 bit key */
+
+/* type definitions */
+typedef struct s_info {
+ unsigned char mode; /* monitoring/managed mode */
+ char device[MAX_DEV_CHARS]; /* sniffed devie */
+ int logfile_fd; /* file descriptof for logfile */
+ int pcap_fd; /* fd for reading pcap events */
+ char key[13]; /* wep key */
+
+} t_info;
/* function prototypes */