author | mjm <mjm> | 2002-11-12 22:12:33 (UTC) |
---|---|---|
committer | mjm <mjm> | 2002-11-12 22:12:33 (UTC) |
commit | eaecbed44924ece119c5b41db2828b4554f263d2 (patch) (unidiff) | |
tree | b87dd3d049ea1768b20192f6c674f8684a41282c | |
parent | 15bc80dffd7a4c52985a742cb3a439da42692478 (diff) | |
download | opie-eaecbed44924ece119c5b41db2828b4554f263d2.zip opie-eaecbed44924ece119c5b41db2828b4554f263d2.tar.gz opie-eaecbed44924ece119c5b41db2828b4554f263d2.tar.bz2 |
pre-alpha version, most things does not work yet.
todo: communication protocol with GUI and implementation of sniffer
16 files changed, 437 insertions, 93 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/Makefile b/noncore/net/wellenreiter/daemon/source/Makefile new file mode 100644 index 0000000..dc459af --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/Makefile | |||
@@ -0,0 +1,31 @@ | |||
1 | # $Id$ | ||
2 | |||
3 | CPP = g++ | ||
4 | |||
5 | CFLAGS= | ||
6 | OPTIMFLAGS= -g | ||
7 | WARNFLAGS= -Wall -pedantic -DDEBUG | ||
8 | LDFLAGS = | ||
9 | LIBS = -lpcap | ||
10 | OBJ = daemon.o log.o sendgui.o getgui.o sniffer.o | ||
11 | |||
12 | .SUFFIXES: | ||
13 | .PHONY: all wellenreiterd clean distclean realclean | ||
14 | |||
15 | %.o : %.cc | ||
16 | $(CPP) $(CFLAGS) $(WARNFLAGS) $(OPTIMFLAGS) -c $< -o $@ | ||
17 | |||
18 | all:wellenreiterd | ||
19 | |||
20 | wellenreiterd:$(OBJ) | ||
21 | $(CPP) $(OPTIMFLAGS) $(WARNFLAGS) $(CFLAGS) $(OBJ) $(LDFLAGS) $(LIBS) -o $@ | ||
22 | @echo Build wellenreiterd | ||
23 | |||
24 | clean distclean realclean: | ||
25 | @rm -rf wellenreiterd *~ *.o | ||
26 | @echo All dependent files have been removed. | ||
27 | |||
28 | wellenreiterd.o:config.hh | ||
29 | serve.o: config.hh | ||
30 | log.o: config.hh | ||
31 | sendgui.o: config.hh | ||
diff --git a/noncore/net/wellenreiter/daemon/source/README b/noncore/net/wellenreiter/daemon/source/README deleted file mode 100644 index 249d950..0000000 --- a/noncore/net/wellenreiter/daemon/source/README +++ b/dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | compile it using: | ||
2 | |||
3 | gcc -o sniffer ./sniffer.c -lpcap | ||
4 | |||
5 | |||
diff --git a/noncore/net/wellenreiter/daemon/source/TODO b/noncore/net/wellenreiter/daemon/source/TODO new file mode 100644 index 0000000..39b1a05 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/TODO | |||
@@ -0,0 +1,5 @@ | |||
1 | implement communication protocol | ||
2 | security analysis | ||
3 | implement sniffer (last step) | ||
4 | security analysis | ||
5 | code cleanup \ No newline at end of file | ||
diff --git a/noncore/net/wellenreiter/daemon/source/config.hh b/noncore/net/wellenreiter/daemon/source/config.hh new file mode 100644 index 0000000..b124f41 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/config.hh | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Global configuration for wellenreiter | ||
4 | * | ||
5 | * $Id$ | ||
6 | * | ||
7 | * Written by Martin J. Muench <mjm@codito.de> | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #ifndef CONFIG_HH | ||
12 | #define CONFIG_HH | ||
13 | |||
14 | #define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */ | ||
15 | #define VERSION "0.2" /* Version of wellenreiter */ | ||
16 | |||
17 | #define DAEMONPORT 37772 /* Port of Daemon */ | ||
18 | |||
19 | #define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ | ||
20 | #define GUIPORT 37773 /* Port of GUI, " " */ | ||
21 | |||
22 | #endif /* CONFIG_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc new file mode 100644 index 0000000..7972c0f --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * Startup functions of wellenreiter | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "config.hh" | ||
8 | #include "daemon.hh" | ||
9 | #include "log.hh" | ||
10 | #include "sendgui.hh" | ||
11 | #include "getgui.hh" | ||
12 | |||
13 | /* Main function of wellenreiterd */ | ||
14 | int main(int argc, char **argv) | ||
15 | { | ||
16 | int sock, maxfd; | ||
17 | struct sockaddr_in *cliaddr; | ||
18 | socklen_t len=sizeof(struct sockaddr); | ||
19 | char buffer[128]; | ||
20 | FILE *fp=stdin; /* Will be replaced with sniffer */ | ||
21 | fd_set rset; | ||
22 | |||
23 | fprintf(stderr, "wellenreiterd %s\n\n", VERSION); | ||
24 | |||
25 | /* Setup socket for incoming commands */ | ||
26 | if(!commsock(&sock)) | ||
27 | return 0; | ||
28 | |||
29 | log_info("Set up socket '%d' for GUI communication", sock); | ||
30 | |||
31 | FD_ZERO(&rset); | ||
32 | |||
33 | /* Start main loop */ | ||
34 | log_info("Starting main loop"); | ||
35 | while(1) | ||
36 | { | ||
37 | |||
38 | FD_SET(sock, &rset); | ||
39 | FD_SET(fileno(fp), &rset); | ||
40 | maxfd=sock+fileno(fp)+1; | ||
41 | if(select(maxfd, &rset, NULL, NULL, NULL) < 0) | ||
42 | { | ||
43 | log_err("Error calling select: %s", strerror(errno)); | ||
44 | break; | ||
45 | } | ||
46 | |||
47 | /* Got data on local socket from GUI */ | ||
48 | if(FD_ISSET(sock, &rset)) | ||
49 | { | ||
50 | memset(buffer, 0, sizeof(buffer)); | ||
51 | if(recvfrom(sock, buffer, sizeof(buffer)-1, 0, (struct sockaddr *)cliaddr, &len) < 0) | ||
52 | { | ||
53 | log_err("Cannot read from socket: %s", strerror(errno)); | ||
54 | break; | ||
55 | } | ||
56 | log_info("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer); | ||
57 | |||
58 | /* Pass string to analyze function */ | ||
59 | commstring(buffer); | ||
60 | |||
61 | } | ||
62 | |||
63 | /* Will be replaced with sniffer ... later */ | ||
64 | if(FD_ISSET(fileno(fp), &rset)) | ||
65 | { | ||
66 | memset(buffer, 0, sizeof(buffer)); | ||
67 | if(fgets(buffer, sizeof(buffer) - 1, fp) == NULL) | ||
68 | { | ||
69 | log_err("Cannot read from stdin: %s", strerror(errno)); | ||
70 | break; | ||
71 | } | ||
72 | |||
73 | /* Send string to GUI */ | ||
74 | sendgui("%d: %s", 1234, buffer); | ||
75 | |||
76 | } | ||
77 | |||
78 | } | ||
79 | |||
80 | close(sock); | ||
81 | return 0; | ||
82 | } | ||
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.hh b/noncore/net/wellenreiter/daemon/source/daemon.hh new file mode 100644 index 0000000..6776d37 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/daemon.hh | |||
@@ -0,0 +1,16 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef DAEMON_HH | ||
4 | #define DAEMON_HH | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <string.h> | ||
8 | #include <sys/types.h> | ||
9 | #include <sys/time.h> | ||
10 | #include <sys/socket.h> | ||
11 | #include <netinet/in.h> | ||
12 | #include <arpa/inet.h> | ||
13 | #include <unistd.h> | ||
14 | #include <errno.h> | ||
15 | |||
16 | #endif /* DAEMON_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/extract.h b/noncore/net/wellenreiter/daemon/source/extract.hh index c1bcdcd..21dcffa 100644 --- a/noncore/net/wellenreiter/daemon/source/extract.h +++ b/noncore/net/wellenreiter/daemon/source/extract.hh | |||
@@ -1 +1,2 @@ | |||
1 | /* $Id */ | ||
1 | /* | 2 | /* |
@@ -19,8 +20,8 @@ | |||
19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
20 | * | ||
21 | * @(#) $Header$ (LBL) | ||
22 | */ | 21 | */ |
23 | |||
24 | /* Network to host order macros */ | 22 | /* Network to host order macros */ |
25 | 23 | ||
24 | #ifndef EXTRACT_HH | ||
25 | #define EXTRACT_HH | ||
26 | |||
26 | #ifdef LBL_ALIGN | 27 | #ifdef LBL_ALIGN |
@@ -57 +58,3 @@ | |||
57 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | 58 | (u_int32_t)*((const u_int8_t *)(p) + 0))) |
59 | |||
60 | #endif /* EXTRACT_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/getgui.cc b/noncore/net/wellenreiter/daemon/source/getgui.cc new file mode 100644 index 0000000..f56f40b --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/getgui.cc | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Setup UDP socket for commands | ||
3 | * Misc wrapper functions for incoming commands | ||
4 | * | ||
5 | * $Id$ | ||
6 | */ | ||
7 | |||
8 | #include "config.hh" | ||
9 | #include "getgui.hh" | ||
10 | #include "log.hh" | ||
11 | |||
12 | struct sockaddr_in saddr; | ||
13 | |||
14 | /* Setup UDP Socket for incoming commands */ | ||
15 | int commsock(int *sock) | ||
16 | { | ||
17 | |||
18 | if((*sock=socket(AF_INET, SOCK_DGRAM, 0)) < 0) | ||
19 | { | ||
20 | log_err("Cannot set up socket: %s", strerror(errno)); | ||
21 | return 0; | ||
22 | } | ||
23 | |||
24 | memset(&saddr, 0, sizeof(saddr)); | ||
25 | saddr.sin_family = PF_INET; | ||
26 | saddr.sin_port = htons(DAEMONPORT); | ||
27 | saddr.sin_addr.s_addr = htonl(INADDR_ANY); | ||
28 | |||
29 | if(bind(*sock,(struct sockaddr *)&saddr, sizeof(saddr)) < 0) | ||
30 | { | ||
31 | log_err("Cannot bind socket: %s", strerror(errno)); | ||
32 | close(*sock); | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | return 1; | ||
37 | } | ||
38 | |||
39 | int commstring(const char *input) | ||
40 | { | ||
41 | |||
42 | return 1; | ||
43 | } | ||
diff --git a/noncore/net/wellenreiter/daemon/source/getgui.hh b/noncore/net/wellenreiter/daemon/source/getgui.hh new file mode 100644 index 0000000..f5a37f9 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/getgui.hh | |||
@@ -0,0 +1,16 @@ | |||
1 | /* $id */ | ||
2 | |||
3 | #ifndef GETGUI_HH | ||
4 | #define GETGUI_HH | ||
5 | |||
6 | #include <sys/types.h> | ||
7 | #include <sys/socket.h> | ||
8 | #include <netinet/in.h> | ||
9 | #include <string.h> | ||
10 | #include <unistd.h> | ||
11 | #include <errno.h> | ||
12 | |||
13 | int commsock(int *); | ||
14 | int commstring(const char *); | ||
15 | |||
16 | #endif /* GETGUI_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/ieee802_11.h b/noncore/net/wellenreiter/daemon/source/ieee802_11.hh index 497e6ed..3cc5343 100644 --- a/noncore/net/wellenreiter/daemon/source/ieee802_11.h +++ b/noncore/net/wellenreiter/daemon/source/ieee802_11.hh | |||
@@ -1,2 +1,2 @@ | |||
1 | /* @(#) $Header$ (LBL) */ | 1 | /* $Id$ */ |
2 | /* | 2 | /* |
@@ -23,2 +23,5 @@ | |||
23 | 23 | ||
24 | #ifndef IEEE802_11_HH | ||
25 | #define IEEE802_11_HH | ||
26 | |||
24 | #define IEEE802_11_FC_LEN2 | 27 | #define IEEE802_11_FC_LEN2 |
@@ -245 +248,3 @@ struct ctrl_end_ack_t { | |||
245 | #define IV_KEYID(iv)(((iv) >> 30) & 0x03) | 248 | #define IV_KEYID(iv)(((iv) >> 30) & 0x03) |
249 | |||
250 | #endif /* IEEE802_11_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/log.cc b/noncore/net/wellenreiter/daemon/source/log.cc new file mode 100644 index 0000000..47589d2 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/log.cc | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Small functions to log to syslog | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "config.hh" | ||
8 | #include "log.hh" | ||
9 | |||
10 | /* Log to syslog INFO */ | ||
11 | void log_info(const char *fmt,...) | ||
12 | { | ||
13 | |||
14 | char buffer[4096]; | ||
15 | va_list ap; | ||
16 | |||
17 | memset(buffer, 0, sizeof(buffer)), | ||
18 | va_start(ap, fmt); | ||
19 | vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); | ||
20 | va_end(ap); | ||
21 | |||
22 | openlog(PROGNAME, LOG_PID, LOG_SYSLOG); | ||
23 | syslog(LOG_INFO, "(info) %s", buffer); | ||
24 | closelog(); | ||
25 | |||
26 | #ifdef DEBUG | ||
27 | fprintf(stderr, "(info) %s\n", buffer); | ||
28 | #endif | ||
29 | |||
30 | } | ||
31 | |||
32 | /* Log to syslog ERR */ | ||
33 | void log_err(const char *fmt,...) | ||
34 | { | ||
35 | |||
36 | char buffer[4096]; | ||
37 | va_list ap; | ||
38 | |||
39 | memset(buffer, 0, sizeof(buffer)); | ||
40 | va_start(ap, fmt); | ||
41 | vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); | ||
42 | va_end(ap); | ||
43 | |||
44 | openlog(PROGNAME, LOG_PID, LOG_SYSLOG); | ||
45 | syslog(LOG_INFO, "(err) %s", buffer); | ||
46 | closelog(); | ||
47 | |||
48 | #ifdef DEBUG | ||
49 | fprintf(stderr, "(err) %s\n", buffer); | ||
50 | #endif | ||
51 | |||
52 | } | ||
diff --git a/noncore/net/wellenreiter/daemon/source/log.hh b/noncore/net/wellenreiter/daemon/source/log.hh new file mode 100644 index 0000000..bdea7e4 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/log.hh | |||
@@ -0,0 +1,14 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef LOG_HH | ||
4 | #define LOG_HH | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <syslog.h> | ||
8 | #include <stdarg.h> | ||
9 | #include <string.h> | ||
10 | |||
11 | void log_info(const char *, ...); | ||
12 | void log_err(const char *, ...); | ||
13 | |||
14 | #endif /* LOG_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/sendgui.cc b/noncore/net/wellenreiter/daemon/source/sendgui.cc new file mode 100644 index 0000000..48ad5b8 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/sendgui.cc | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * Send string to GUI | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "config.hh" | ||
8 | #include "sendgui.hh" | ||
9 | #include "log.hh" | ||
10 | |||
11 | /* Simple dummy for alarm timer */ | ||
12 | static void alarmdummy(int signo) | ||
13 | { | ||
14 | alarm (0); | ||
15 | } | ||
16 | |||
17 | /* Connect to given IP on given port */ | ||
18 | int connect_server(int *sock, unsigned int ipaddr, int port) | ||
19 | { | ||
20 | struct sockaddr_in saddr; | ||
21 | int retval=0; | ||
22 | |||
23 | *sock = socket (PF_INET, SOCK_STREAM, 0); | ||
24 | saddr.sin_family = PF_INET; | ||
25 | saddr.sin_port = htons (port); | ||
26 | saddr.sin_addr.s_addr = ipaddr; | ||
27 | |||
28 | signal (SIGALRM, alarmdummy); | ||
29 | siginterrupt (SIGALRM, 1); | ||
30 | |||
31 | alarm(5); | ||
32 | retval=connect (*sock, (struct sockaddr *) &saddr, sizeof (saddr)); | ||
33 | alarm(0); | ||
34 | |||
35 | if(retval < 0) | ||
36 | { | ||
37 | close (*sock); | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | return 1; | ||
42 | } | ||
43 | |||
44 | /* Send a string to the GUI */ | ||
45 | int sendgui(const char *string, ...) | ||
46 | { | ||
47 | int sock=0; | ||
48 | char buffer[4096]; | ||
49 | va_list ap; | ||
50 | |||
51 | /* Generate string */ | ||
52 | memset(buffer, 0, sizeof(buffer)); | ||
53 | va_start(ap, string); | ||
54 | vsnprintf(buffer, sizeof(buffer)-1, string, ap); | ||
55 | va_end(ap); | ||
56 | |||
57 | if(!connect_server(&sock, inet_addr(GUIADDR), GUIPORT)) | ||
58 | { | ||
59 | log_err("Connect to GUI at '%s' failed: %s", GUIADDR, strerror(errno)); | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | if(write(sock, buffer, sizeof(buffer)) < 0) | ||
64 | { | ||
65 | log_err("Cannot write to socket: %s", strerror(errno)); | ||
66 | close(sock); | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | if(close(sock) < 0) | ||
71 | log_err("Cannot close socket: %s", strerror(errno)); | ||
72 | |||
73 | return 1; | ||
74 | } | ||
75 | |||
diff --git a/noncore/net/wellenreiter/daemon/source/sendgui.hh b/noncore/net/wellenreiter/daemon/source/sendgui.hh new file mode 100644 index 0000000..e083704 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/sendgui.hh | |||
@@ -0,0 +1,20 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef SENDGUI_HH | ||
4 | #define SENDGUI_HH | ||
5 | |||
6 | #include <sys/types.h> | ||
7 | #include <sys/socket.h> | ||
8 | #include <netinet/in.h> | ||
9 | #include <arpa/inet.h> | ||
10 | #include <signal.h> | ||
11 | #include <errno.h> | ||
12 | #include <string.h> | ||
13 | #include <stdio.h> | ||
14 | #include <unistd.h> | ||
15 | #include <stdlib.h> | ||
16 | |||
17 | int connect_server(int *, unsigned int, int); | ||
18 | int sendgui(const char *string, ...); | ||
19 | |||
20 | #endif /* SENDGUI_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/sniffer.c b/noncore/net/wellenreiter/daemon/source/sniffer.cc index 31a5d13..c837505 100644 --- a/noncore/net/wellenreiter/daemon/source/sniffer.c +++ b/noncore/net/wellenreiter/daemon/source/sniffer.cc | |||
@@ -1,30 +1,26 @@ | |||
1 | /* Its just a simple rfmon mode sniffer | 1 | /* |
2 | i hope my C is at last a bit better then in my | 2 | * rfmon mode sniffer |
3 | early days :-). | 3 | * This works only with cisco wireless cards with an rfmon |
4 | This works only with cisco wireless cards with an rfmon | 4 | * able driver and not with wifi stuff. |
5 | able driver and not with wifi stuff. | 5 | * |
6 | Btw. did i mention that i hate C? | 6 | * $Id$ |
7 | 7 | */ | |
8 | To compile use: | 8 | |
9 | gcc sniffer.c -o wlan-sniffer -lpcap | 9 | #include "config.hh" |
10 | 10 | #include "sniffer.hh" | |
11 | */ | 11 | #include "ieee802_11.hh" |
12 | #include "sniffer.h" | 12 | #include "extract.hh" |
13 | 13 | ||
14 | int main(int argc, char **argv) | 14 | int sniffer(void) |
15 | { | 15 | { |
16 | int ret; /* return code */ | 16 | if(card_into_monitormode (SNIFFER_DEVICE, CARD_TYPE_NG) < 0) |
17 | ret = card_into_monitormode (SNIFFER_DEVICE, CARD_TYPE_NG); | 17 | return 0; |
18 | if (ret == -1) | ||
19 | { | ||
20 | exit(-1); | ||
21 | } | ||
22 | start_sniffing (SNIFFER_DEVICE); | 18 | start_sniffing (SNIFFER_DEVICE); |
23 | 19 | ||
24 | return 0; | 20 | return 1; |
25 | } | 21 | } |
26 | 22 | ||
27 | int card_into_monitormode (char * device, int cardtype) | 23 | int card_into_monitormode (char *device, int cardtype) |
28 | { | 24 | { |
29 | int ret = -1; | 25 | |
30 | int datalink; /* used for getting the pcap datalink type */ | 26 | int datalink; /* used for getting the pcap datalink type */ |
@@ -39,3 +35,3 @@ int card_into_monitormode (char * device, int cardtype) | |||
39 | printf ("Fatal error i did not have any interfaces to sniff on\n"); | 35 | printf ("Fatal error i did not have any interfaces to sniff on\n"); |
40 | exit(1); | 36 | return 0; |
41 | } | 37 | } |
@@ -63,6 +59,6 @@ int card_into_monitormode (char * device, int cardtype) | |||
63 | snprintf(wlanngcmd, sizeof(wlanngcmd),"%s %s lnxreq_wlansniff channel=1 enable=true",WLANCTL_PATH,device); | 59 | snprintf(wlanngcmd, sizeof(wlanngcmd),"%s %s lnxreq_wlansniff channel=1 enable=true",WLANCTL_PATH,device); |
64 | if (ret = (system (wlanngcmd)) != 0) | 60 | if (system (wlanngcmd) != 0) |
65 | { | 61 | { |
66 | printf ("\n Fatal error could not set %s in raw mode, check cardtype\n",device); | 62 | printf ("\n Fatal error could not set %s in raw mode, check cardtype\n",device); |
67 | exit(1); | 63 | return 0; |
68 | } | 64 | } |
@@ -84,4 +80,4 @@ int card_into_monitormode (char * device, int cardtype) | |||
84 | printf ("Your successfully listen on %s in 802.11 raw mode\n",device); | 80 | printf ("Your successfully listen on %s in 802.11 raw mode\n",device); |
85 | pcap_close(handle); | 81 | pcap_close(handle); |
86 | return (0); | 82 | return 0; |
87 | 83 | ||
@@ -91,4 +87,4 @@ int card_into_monitormode (char * device, int cardtype) | |||
91 | printf ("Fatal error, cannot continue, your interface %s does not work in the correct 802.11 raw mode, check you driver please\n",device); | 87 | printf ("Fatal error, cannot continue, your interface %s does not work in the correct 802.11 raw mode, check you driver please\n",device); |
92 | pcap_close(handle); | 88 | pcap_close(handle); |
93 | exit(1); | 89 | return 0; |
94 | } | 90 | } |
@@ -105,5 +101,5 @@ int card_set_promisc_up (char * device) | |||
105 | printf ("\nFatal error, could not execute %s please check your card,binary location and permission\n",ifconfigcmd); | 101 | printf ("\nFatal error, could not execute %s please check your card,binary location and permission\n",ifconfigcmd); |
106 | exit(1); | 102 | return 0; |
107 | } | 103 | } |
108 | return(0); | 104 | return 1; |
109 | } | 105 | } |
@@ -112,10 +108,8 @@ int start_sniffing (char * device) | |||
112 | { | 108 | { |
113 | int ret; /* return code */ | 109 | |
114 | pcap_t *handletopcap; | 110 | pcap_t *handletopcap; |
115 | char errbuf[PCAP_ERRBUF_SIZE]; | 111 | char errbuf[PCAP_ERRBUF_SIZE]; |
116 | struct pcap_pkthdr header; /* The header that pcap gives us */ | ||
117 | const u_char *packet; /* The actual packet */ | ||
118 | 112 | ||
119 | /* opening the pcap for sniffing */ | 113 | /* opening the pcap for sniffing */ |
120 | handletopcap = pcap_open_live(device, BUFSIZ, 1, 1000, errbuf); | 114 | handletopcap = pcap_open_live(device, BUFSIZ, 1, 1000, errbuf); |
121 | 115 | ||
@@ -127,6 +121,6 @@ int start_sniffing (char * device) | |||
127 | /*start scanning */ | 121 | /*start scanning */ |
128 | pcap_loop(handletopcap,-1,process_packets,NULL); | 122 | pcap_loop(handletopcap,-1,process_packets,NULL); |
129 | 123 | ||
130 | printf("\nDone processing packets... wheew!\n"); | 124 | printf("\nDone processing packets... wheew!\n"); |
131 | return 0; | 125 | return 1; |
132 | } | 126 | } |
@@ -139,5 +133,3 @@ void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_ch | |||
139 | u_int HEADER_LENGTH; | 133 | u_int HEADER_LENGTH; |
140 | u_short extracted_ethertype; | 134 | |
141 | int snapend; | ||
142 | int ret; | ||
143 | /* pinfo holds all interresting information for us */ | 135 | /* pinfo holds all interresting information for us */ |
@@ -265,7 +257,5 @@ int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) | |||
265 | { | 257 | { |
266 | char * ret; | ||
267 | char testme[16]; | ||
268 | const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; | 258 | const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; |
269 | ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); | 259 | ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); |
270 | 260 | ||
271 | /* Get the sender, bssid and dest mac address */ | 261 | /* Get the sender, bssid and dest mac address */ |
@@ -275,3 +265,3 @@ int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) | |||
275 | ppinfo->fc_wep = FC_WEP(mgthdr->fc); | 265 | ppinfo->fc_wep = FC_WEP(mgthdr->fc); |
276 | return(0); | 266 | return 0; |
277 | } | 267 | } |
@@ -297,3 +287,2 @@ void etheraddr_string(register const u_char *ep,char * text) | |||
297 | strcpy(text,buf); | 287 | strcpy(text,buf); |
298 | return; | ||
299 | } | 288 | } |
@@ -330,3 +319,3 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
330 | pbody.ssid.ssid[pbody.ssid.length]='\0'; | 319 | pbody.ssid.ssid[pbody.ssid.length]='\0'; |
331 | if (strcmp(pbody.ssid.ssid,"")==0) | 320 | if (strcmp((char *)pbody.ssid.ssid,"")==0) |
332 | { | 321 | { |
@@ -336,3 +325,3 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
336 | { | 325 | { |
337 | ppinfo->ssid = pbody.ssid.ssid; | 326 | ppinfo->ssid = (char *)pbody.ssid.ssid; |
338 | } | 327 | } |
@@ -372,5 +361,3 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
372 | default: | 361 | default: |
373 | #if 0 | 362 | |
374 | printf("(1) unhandled element_id (%d) ", *(p+offset) ); | ||
375 | #endif | ||
376 | offset+= *(p+offset+1) + 2; | 363 | offset+= *(p+offset+1) + 2; |
@@ -379,6 +366,3 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
379 | } /* end of for loop */ | 366 | } /* end of for loop */ |
380 | return(0); | 367 | return 1; |
381 | |||
382 | |||
383 | |||
384 | 368 | ||
diff --git a/noncore/net/wellenreiter/daemon/source/sniffer.h b/noncore/net/wellenreiter/daemon/source/sniffer.hh index b880b68..7f45be6 100644 --- a/noncore/net/wellenreiter/daemon/source/sniffer.h +++ b/noncore/net/wellenreiter/daemon/source/sniffer.hh | |||
@@ -1,2 +1,5 @@ | |||
1 | // Wellenreiter-sniffer-code header file | 1 | /* $Id$ */ |
2 | |||
3 | #ifndef SNIFFER_HH | ||
4 | #define SNIFFER_HH | ||
2 | 5 | ||
@@ -11,4 +14,2 @@ | |||
11 | #include <net/bpf.h> | 14 | #include <net/bpf.h> |
12 | #include "ieee802_11.h" | ||
13 | #include "extract.h" | ||
14 | 15 | ||
@@ -49,14 +50,10 @@ struct packetinfo | |||
49 | /* Prototypes */ | 50 | /* Prototypes */ |
50 | int card_into_monitormode (char * device, int cardtype); | ||
51 | 51 | ||
52 | int sniffer(void); | ||
53 | int card_into_monitormode (char * device, int cardtype); | ||
52 | int card_set_promisc_up (char * device); | 54 | int card_set_promisc_up (char * device); |
53 | |||
54 | int start_sniffing (char * device); | 55 | int start_sniffing (char * device); |
55 | |||
56 | void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet); | 56 | void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet); |
57 | |||
58 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); | 57 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); |
59 | |||
60 | void etheraddr_string(register const u_char *ep,char * text); | 58 | void etheraddr_string(register const u_char *ep,char * text); |
61 | |||
62 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); | 59 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); |
@@ -65,20 +62,2 @@ static int GetHeaderLength(u_int16_t fc); | |||
65 | 62 | ||
66 | static const char *subtype_text[]={ | ||
67 | "Assoc Request", | ||
68 | "Assoc Response", | ||
69 | "ReAssoc Request", | ||
70 | "ReAssoc Response", | ||
71 | "Probe Request", | ||
72 | "Probe Response", | ||
73 | "RESERVED", | ||
74 | "RESERVED", | ||
75 | "Beacon", | ||
76 | "ATIM", | ||
77 | "Disassociation", | ||
78 | "Authentication", | ||
79 | "DeAuthentication", | ||
80 | "RESERVED", | ||
81 | "RESERVED" | ||
82 | }; | ||
83 | |||
84 | /* | 63 | /* |
@@ -102 +81,3 @@ static const char *subtype_text[]={ | |||
102 | #define TCHECK(var) TCHECK2(var, sizeof(var)) | 81 | #define TCHECK(var) TCHECK2(var, sizeof(var)) |
82 | |||
83 | #endif /* SNIFFER_HH */ | ||