Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial support for wireless monitor mode

Add option to put wireless interface into monitor mode. Untested as,
at least with my wireless interface, pcap thinks monitor mode is not
supported.
  • Loading branch information...
commit 1f342c18bb8776e423a3ae2202411dda80243beb 1 parent 15fdc07
@msantos authored
Showing with 14 additions and 4 deletions.
  1. +2 −1  README.md
  2. +9 −3 c_src/epcap.c
  3. +1 −0  c_src/epcap.h
  4. +2 −0  src/epcap.erl
View
3  README.md
@@ -37,7 +37,8 @@ epcap includes a small example program called sniff.
Types Args = [Options]
Options = {chroot, string()} | {group, string()} | {interface, string()} | {promiscuous, boolean()} |
- {user, string()} | {filter, string()} | {progname, string()} | {file, string()}
+ {user, string()} | {filter, string()} | {progname, string()} | {file, string()} |
+ {monitor, boolean()}
Packets are delivered as messages:
View
12 c_src/epcap.c
@@ -56,7 +56,7 @@ main(int argc, char *argv[])
ep->snaplen = SNAPLEN;
ep->timeout = TIMEOUT;
- while ( (ch = getopt(argc, argv, "d:f:g:hi:Ps:t:u:v")) != -1) {
+ while ( (ch = getopt(argc, argv, "d:f:g:hi:MPs:t:u:v")) != -1) {
switch (ch) {
case 'd': /* chroot directory */
IS_NULL(ep->chroot = strdup(optarg));
@@ -71,6 +71,9 @@ main(int argc, char *argv[])
case 'i':
IS_NULL(ep->dev = strdup(optarg));
break;
+ case 'M':
+ ep->rfmon = 1;
+ break;
case 'P':
ep->promisc = 1;
break;
@@ -151,6 +154,10 @@ epcap_open(EPCAP_STATE *ep)
PCAP_ERRBUF(ep->dev = pcap_lookupdev(errbuf));
PCAP_ERRBUF(ep->p = pcap_open_live(ep->dev, ep->snaplen, ep->promisc, ep->timeout, errbuf));
+
+ /* monitor mode */
+ if (pcap_can_set_rfmon(ep->p) == 1)
+ (void)pcap_set_rfmon(ep->p, ep->rfmon);
}
return (0);
@@ -289,6 +296,7 @@ usage(EPCAP_STATE *ep)
" -d <directory> chroot directory\n"
" -i <interface> interface to snoop\n"
" -f <filename> read from file instead of live capture\n"
+ " -M wireless monitor (rfmon) mode\n"
" -P promiscuous mode\n"
" -g <group> unprivileged group\n"
" -u <user> unprivileged user\n"
@@ -300,5 +308,3 @@ usage(EPCAP_STATE *ep)
exit (EXIT_FAILURE);
}
-
-
View
1  c_src/epcap.h
@@ -85,6 +85,7 @@ extern char *__progname;
typedef struct {
pcap_t *p; /* pcap handle */
int promisc; /* promiscuous mode */
+ int rfmon; /* monitor mode */
int verbose; /* debugging messages */
int runasuser; /* if setuid, run as the calling user */
size_t snaplen; /* packet capture length */
View
2  src/epcap.erl
@@ -119,6 +119,7 @@ make_args(PL) ->
group,
interface,
file,
+ monitor,
promiscuous,
user,
snaplen,
@@ -132,6 +133,7 @@ get_switch({chroot, Arg}) -> "-d " ++ Arg;
get_switch({file, Arg}) -> "-f " ++ Arg;
get_switch({group, Arg}) -> "-g " ++ Arg;
get_switch({interface, Arg}) -> "-i " ++ Arg;
+get_switch({monitor, true}) -> "-M";
get_switch({promiscuous, true}) -> "-P";
get_switch({snaplen, Arg}) -> "-s " ++ integer_to_list(Arg);
get_switch({timeout, Arg}) -> "-t " ++ integer_to_list(Arg);
Please sign in to comment.
Something went wrong with that request. Please try again.