...
 
Commits (22)
......@@ -24,6 +24,9 @@ LIBNL=3.0
OSX=0
NAME=horst
VERSION=5.1
#VERSION=$(shell git describe --tags)
OBJS= \
average.o \
capture$(if $(filter 1,$(PCAP)),-pcap).o \
......@@ -52,13 +55,14 @@ OBJS= \
util.o \
wlan_util.o
LIBS=-lncurses -lm
CFLAGS+=-std=gnu99 -Wall -Wextra -g -I.
CFLAGS+=-std=gnu99 -Wall -Wextra -g -I. -DVERSION=\"$(VERSION)\"
ifeq ($(OSX),1)
PCAP=1
WEXT=0
LIBNL=0
LIBS+=-framework CoreWLAN -framework CoreData -framework Foundation
OBJS+=mach_clock_gettime.o
endif
ifeq ($(DEBUG),1)
......@@ -88,6 +92,8 @@ else
endif
endif
DESTDIR?=/usr/local
.PHONY: all check clean force
all: $(NAME)
......@@ -118,5 +124,15 @@ clean:
-rm -f .buildflags
-rm -f .objdeps.mk
install:
mkdir -p $(DESTDIR)/sbin/
mkdir -p $(DESTDIR)/etc
mkdir -p $(DESTDIR)/man/man8/
mkdir -p $(DESTDIR)/man/man5
cp horst $(DESTDIR)/sbin/
cp horst.conf $(DESTDIR)/etc/
gzip horst.8 -c > $(DESTDIR)/man/man8/horst.8.gz
gzip horst.conf.5 -c > $(DESTDIR)/man/man5/horst.conf.5.gz
.buildflags: force
echo '$(CFLAGS)' | cmp -s - $@ || echo '$(CFLAGS)' > $@
......@@ -43,15 +43,28 @@ problems.
supports monitor mode. The latest stable version is 5.0 from July 01 2016.
## Building
## Checkout
If you just want to use `horst`, the recommended way is to download the latest
stable version from https://github.com/br101/horst/releases or to use the
stable branch:
git clone -b stable https://github.com/br101/horst
git clone https://github.com/br101/horst
## Dependencies
`horst` is just a simple tool, and `libncurses` and header files is the only
hard requirement. Recently we have added support for `nl80211` via `libnl`, so
normally you need `libnl3` + header files as well.
on Linux normally you need `libnl3` + header files as well. On Debian/Ubuntu
based distros you can install them with:
sudo apt-get install libncurses5-dev libnl-3-dev libnl-genl-3-dev
## Building
Building is as simple as typing:
Building is normally done with:
make
......@@ -77,6 +90,27 @@ To build for Mac OSX:
Please note that PCAP and OSX support is not so well tested and some features
may be missing.
To install (with optional `DESTDIR=/path`):
make install
## Config and other files
`horst` by default reads a config file `/etc/horst.conf`. The location of the file
can be changed with the `-c file` command line option. See the file itself or
`man horst.conf` for a description of the options.
You can use `-Mfilename` to define a MAC address to host name mapping file which
can either be a `dhcp.leases` file or simply contain `MAC-Address<whitesspace>Name`
one each line.
`-o outfile` can write the packets to a comma separated list file.
`-X[filename]` is not a real file, but allows a control socket named pipe which can
later be used with `-x command` to send commands in the same format as the options
in the config file.
## Usage notes
......@@ -107,18 +141,18 @@ Usually you have to start `horst` as root:
To do remote monitoring over the network you can start a server (-q without a
user interface), usually on your AP or device with
horst -i wlan0 -C -q
horst -i wlan0 -N -q
and connect a client (only one client is allowed at a time), usually from your
PC with
horst -c IP
horst -n IP
Please read the man page for more details about the options, output and
abbreviations. It should be be part of your distribution package, but you can
read it in the source code locally with:
man -l horst.1
man -l horst.8
man -l horst.conf.5
Please contact me if you have any problems or questions. New feature ideas,
......
......@@ -36,8 +36,8 @@ uint32_t channel_get_remaining_dwell_time(void)
return UINT32_MAX;
int64_t ret = (int64_t)conf.channel_time
- (the_time.tv_sec - last_channelchange.tv_sec) * 1000000
- (the_time.tv_nsec - last_channelchange.tv_nsec) / 1000;
- (time_mono.tv_sec - last_channelchange.tv_sec) * 1000000
- (time_mono.tv_nsec - last_channelchange.tv_nsec) / 1000;
if (ret < 0)
return 0;
......@@ -178,17 +178,19 @@ bool channel_change(int idx, enum chan_width width, bool ht40plus)
return false;
}
#if 0
printlog("Set CH %d (%d MHz) %s center %d after %ldms",
channels.chan[idx].chan, channels.chan[idx].freq,
channel_width_string(width, ht40plus),
center1, (the_time.tv_sec - last_channelchange.tv_sec) * 1000
+ (the_time.tv_nsec - last_channelchange.tv_nsec) / 1000000);
#endif
conf.channel_idx = idx;
conf.channel_width = width;
conf.channel_ht40plus = ht40plus;
conf.max_phy_rate = get_phy_thruput(width, channel_get_band_from_idx(idx).streams_rx);
last_channelchange = the_time;
last_channelchange = time_mono;
return true;
}
......
......@@ -452,9 +452,7 @@ static char* config_get_getopt_string(char* buf, size_t maxlen, const char* add)
static void print_usage(const char* name)
{
printf("\nUsage: %s [-v] [-h] [-q] [-D] [-a] [-c file] [-i interface] [-t sec] [-d ms] [-V view] [-b bytes]\n"
"\t\t[-s] [-u] [-N] [-n IP] [-p port] [-o file] [-X[name]] [-x command]\n"
"\t\t[][-e MAC] [-f PKT_NAME] [-m MODE] [-B BSSID]\n\n"
printf("\nUsage: %s [options]\n\n"
"General Options: Description (default value)\n"
" -v\t\tshow version\n"
......@@ -521,7 +519,7 @@ void config_parse_file_and_cmdline(int argc, char** argv)
conf_filename = optarg;
break;
case 'v':
printf("Version %s (build date: %s %s)\n", VERSION, __DATE__, __TIME__);
printf("%s (build date: %s %s)\n", VERSION, __DATE__, __TIME__);
exit(0);
case 'h':
case '?':
......
/* Generated by CCAN configurator */
#ifndef CCAN_CONFIG_H
#define CCAN_CONFIG_H
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* Always use GNU extensions. */
#endif
#define HAVE_TYPEOF 1
#endif /* CCAN_CONFIG_H */
horst (5.0-3) UNRELEASED; urgency=medium
horst (5.1-1) unstable; urgency=medium
[ Ondřej Nový ]
* d/copyright: Use https protocol in Format field
* d/rules: Remove trailing whitespaces
* d/control: Set Vcs-* to salsa.debian.org
-- Ondřej Nový <onovy@debian.org> Mon, 01 Oct 2018 10:13:10 +0200
[ Antoine Beaupré ]
* new upstream release (Closes: #917333, #889472)
* follow upstream tag naming changes in gbp.conf and watch file
* disable sparse checks as they now fail everywhere (Closes: #911102)
* tweak upstream Makefile to follow standards (reported upstream)
* fix control file syntax error
-- Antoine Beaupré <anarcat@debian.org> Wed, 09 Jan 2019 20:34:06 -0500
horst (5.0-2) unstable; urgency=medium
......
......@@ -9,7 +9,6 @@ Build-Depends: debhelper (>= 10.0.0~)
, libpcap0.8-dev
, libnl-3-dev
, libnl-genl-3-dev
, sparse
Standards-Version: 4.1.0
Homepage: https://github.com/br101/horst
Vcs-Git: https://salsa.debian.org/debian/horst.git
......@@ -45,6 +44,6 @@ Description: Highly Optimized Radio Scanning Tool
or BSSIDs
* Client/server support for monitoring on remote nodes
* Automatically adds and removes monitor interface
.
horst is a Linux program and can be used on any wireless LAN interface
which supports monitor mode.
.
horst is a Linux program and can be used on any wireless LAN interface
which supports monitor mode.
[DEFAULT]
upstream-tag=version-%(version)s
upstream-tag=v%(version)s
debian-branch=debian
From 76e22aada843351a683c9462a2f678dacc900462 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@debian.org>
Date: Wed, 9 Jan 2019 21:00:15 -0500
Subject: [PATCH] add support for PREFIX
---
Makefile | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 7a75fc2..68825f9 100644
--- a/Makefile
+++ b/Makefile
@@ -92,7 +92,8 @@ else
endif
endif
-DESTDIR?=/usr/local
+PREFIX?=/usr/local
+DESTDIR?=/
.PHONY: all check clean force
@@ -125,14 +126,14 @@ clean:
-rm -f .objdeps.mk
install:
- mkdir -p $(DESTDIR)/sbin/
+ mkdir -p $(DESTDIR)$(PREFIX)/sbin/
mkdir -p $(DESTDIR)/etc
- mkdir -p $(DESTDIR)/man/man8/
- mkdir -p $(DESTDIR)/man/man5
- cp horst $(DESTDIR)/sbin/
+ mkdir -p $(DESTDIR)$(PREFIX)/man/man8/
+ mkdir -p $(DESTDIR)$(PREFIX)/man/man5
+ cp horst $(DESTDIR)$(PREFIX)/sbin/
cp horst.conf $(DESTDIR)/etc/
- gzip horst.8 -c > $(DESTDIR)/man/man8/horst.8.gz
- gzip horst.conf.5 -c > $(DESTDIR)/man/man5/horst.conf.5.gz
+ gzip horst.8 -c > $(DESTDIR)$(PREFIX)/man/man8/horst.8.gz
+ gzip horst.conf.5 -c > $(DESTDIR)$(PREFIX)/man/man5/horst.conf.5.gz
.buildflags: force
echo '$(CFLAGS)' | cmp -s - $@ || echo '$(CFLAGS)' > $@
--
2.19.2
From f3474f22a1649c0730b6297daca97c288ea4455d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@debian.org>
Date: Wed, 9 Jan 2019 21:00:52 -0500
Subject: [PATCH] install manpages in share properly (Closes: #91)
---
Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 68825f9..6687965 100644
--- a/Makefile
+++ b/Makefile
@@ -128,12 +128,12 @@ clean:
install:
mkdir -p $(DESTDIR)$(PREFIX)/sbin/
mkdir -p $(DESTDIR)/etc
- mkdir -p $(DESTDIR)$(PREFIX)/man/man8/
- mkdir -p $(DESTDIR)$(PREFIX)/man/man5
+ mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8/
+ mkdir -p $(DESTDIR)$(PREFIX)/share/man/man5
cp horst $(DESTDIR)$(PREFIX)/sbin/
cp horst.conf $(DESTDIR)/etc/
- gzip horst.8 -c > $(DESTDIR)$(PREFIX)/man/man8/horst.8.gz
- gzip horst.conf.5 -c > $(DESTDIR)$(PREFIX)/man/man5/horst.conf.5.gz
+ gzip horst.8 -c > $(DESTDIR)$(PREFIX)/share/man/man8/horst.8.gz
+ gzip horst.conf.5 -c > $(DESTDIR)$(PREFIX)/share/man/man5/horst.conf.5.gz
.buildflags: force
echo '$(CFLAGS)' | cmp -s - $@ || echo '$(CFLAGS)' > $@
--
2.19.2
0001-add-support-for-PREFIX.patch
0001-install-manpages-in-share-properly-Closes-91.patch
......@@ -12,10 +12,11 @@
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
# sparse fails on some architectures: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=873508
ifneq (,$(filter $(DEB_HOST_ARCH), ppc64el s390x ppc64 sparc64))
DEB_BUILD_OPTS+=nocheck
endif
# sparse now fails on *all* architectures, see #911102 and #873508
DEB_BUILD_OPTIONS+=nocheck
%:
dh $@
override_dh_auto_install:
dh_auto_install -- PREFIX=/usr
# Compulsory line, this is a version 3 file
version=3
https://github.com/br101/horst/releases .*/archive/version-?((?:\d+\.?)*)\.tar\.gz
https://github.com/br101/horst/releases .*/archive/v?((?:\d+\.?)*)\.tar\.gz
......@@ -59,7 +59,7 @@ void update_essid_win(WINDOW *win)
if (line > LINES-3)
break;
if (n->last_seen > (the_time.tv_sec - conf.node_timeout / 2))
if (n->last_seen > (time_mono.tv_sec - conf.node_timeout / 2))
wattron(win, A_BOLD);
else
wattroff(win, A_BOLD);
......
......@@ -235,7 +235,7 @@ static void print_node_list_line(int line, struct node_info* n)
if (n->pkt_types & PKT_TYPE_OLSR)
wattron(list_win, GREEN);
if (n->last_seen > (the_time.tv_sec - conf.node_timeout / 2))
if (n->last_seen > (time_mono.tv_sec - conf.node_timeout / 2))
wattron(list_win, A_BOLD);
else
wattron(list_win, A_NORMAL);
......
......@@ -53,14 +53,14 @@ void get_per_second(unsigned long bytes, unsigned long duration,
float timediff;
/* reacalculate only every second or more */
timediff = (the_time.tv_sec + the_time.tv_nsec/1000000000.0) -
timediff = (time_mono.tv_sec + time_mono.tv_nsec/1000000000.0) -
(last.tv_sec + last.tv_nsec/1000000000.0);
if (timediff >= 1.0) {
last_dps = (1.0*(duration - last_dur)) / timediff;
last_bps = (1.0*(bytes - last_bytes)) / timediff;
last_pps = (1.0*(packets - last_pkts)) / timediff;
last_rps = (1.0*(retries - last_retr)) / timediff;
last = the_time;
last = time_mono;
last_dur = duration;
last_bytes = bytes;
last_pkts = packets;
......@@ -238,7 +238,7 @@ static void update_menu(void)
wattroff(stdscr, BLACKONWHITE);
update_mini_status();
update_clock(&the_time.tv_sec);
update_clock(&time_real.tv_sec);
}
/******************* WINDOW MANAGEMENT / UPDATE *******************/
......@@ -305,8 +305,8 @@ static void show_conf_window(int key)
void update_display_clock(void)
{
/* helper to update just the clock every second */
if (the_time.tv_sec > last_time.tv_sec) {
update_clock(&the_time.tv_sec);
if (time_mono.tv_sec > time_mono.tv_sec) {
update_clock(&time_real.tv_sec);
doupdate();
}
}
......@@ -323,8 +323,8 @@ void update_display(struct packet_info* pkt)
* if pkt is NULL we want to force an update
*/
if (pkt != NULL &&
the_time.tv_sec == last_time.tv_sec &&
(the_time.tv_nsec - last_time.tv_nsec) / 1000 < conf.display_interval ) {
time_mono.tv_sec == last_time.tv_sec &&
(time_mono.tv_nsec - last_time.tv_nsec) / 1000 < conf.display_interval ) {
/* just add the line to dump win so we don't loose it */
update_dump_win(pkt);
return;
......@@ -338,10 +338,10 @@ void update_display(struct packet_info* pkt)
update_menu();
/* update clock every second */
if (the_time.tv_sec > last_time.tv_sec)
update_clock(&the_time.tv_sec);
if (time_mono.tv_sec > time_mono.tv_sec)
update_clock(&time_real.tv_sec);
last_time = the_time;
last_time = time_mono;
if (show_win != NULL)
update_show_win();
......
......@@ -2,10 +2,10 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH HORST.CONF 5 "October 18, 2015"
.TH HORST.CONF 5 "September 29, 2016"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
horst.conf \- configuration file for \fBhorst(1)\fP
horst.conf \- configuration file for \fBhorst(8)\fP
.SH SYNOPSIS
/etc/horst.conf
......@@ -123,4 +123,4 @@ memory consumption and reduce packet loss under high load.
\p Run \fBhorst\fP in server mode.
.SH SEE ALSO
.BR horst (1)
.BR horst (8)
/*
* mach_clock_gettime --- an emulation of POSIX's `clock_gettime` for
* Mach / Mac OS X.
*
* This library emulates a function from the POSIX Realtime Extensions
* for getting monotonically increasing clock readings (`clock_gettime`
* with a `clock_id` of `CLOCK_MONOTONIC`) using Mac OS X's `clock_get_time`
* call on the monotonically increasing `SYSTEM_CLOCK` clock service.
*
* It is designed as a drop-in replacement for that specific purpose:
* Do a conditional include of this library on systems that define
* __MACH__, then use `clock_gettime(CLOCK_MONOTONIC, &...)` as if on
* a system that implements the POSIX Realtime Extensions.
*
* Other clock sources, alarms, etc. are currently not supported.
*
* This library is based on material by
* - The Open Group, see
* http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html
* - the Linux kernel headers, see time.h, posix_types.h and types.h
* - The XNU man pages, see host_get_clock_service, clock_get_time and
tvalspec under https://opensource.apple.com/source/xnu/xnu-3248.60.10/osfmk/man/
* - https://stackoverflow.com/questions/11680461/monotonic-clock-on-osx
*
* Other similar (and probably more complete) approaches exist and inspired
* this implementation, see for instance
* - https://gist.github.com/jbenet/1087739
* - https://gist.github.com/alfwatt/3588c5aa1f7a1ef7a3bb
* - https://github.com/ChisholmKyle/PosixMachTiming
*
* Licensing note: Given its vanishing amount of originality, this library
* is placed under a CC0 license, i.e. I release it into the public domain.
* See also https://creativecommons.org/publicdomain/zero/1.0/legalcode
*
* Please send bug reports to albert.rafetseder@univie.ac.at
*/
#include <sys/types.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <err.h>
#include "mach_clock_gettime.h"
int clock_gettime(clockid_t clock_id, struct timespec *tp)
{
/* The XNU docs prescribe `clock_t` and `tvalspec_t` for the
* first two variables; we however use what the header file
* in /usr/include/mach/clock.h tells us to (or else the
* preprocessor complains). */
clock_serv_t clock_name;
mach_timespec_t current_clock_value;
kern_return_t retval;
/* Bail out on clock_id's that we don't emulate */
if (clock_id != CLOCK_MONOTONIC)
err(1, "Unsupported clock_id for mach_clock_gettime emulation");
/* XXX This could use some more error checking... */
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock_name);
retval = clock_get_time(clock_name, &current_clock_value);
mach_port_deallocate(mach_task_self(), clock_name);
tp->tv_sec = current_clock_value.tv_sec;
tp->tv_nsec = current_clock_value.tv_nsec;
return retval;
}
/*
* mach_clock_gettime --- an emulation of POSIX's `clock_gettime` for
* Mach / Mac OS X.
*
* See mach_clock_gettime.c for details.
*/
#ifndef _MACH_CLOCK_GETTIME_H_
#define _MACH_CLOCK_GETTIME_H_
#include <time.h>
#define CLOCK_MONOTONIC 1 /* Per Linux's time.h */
typedef int clockid_t; /* Per Linux's types.h, posix_types.h */
/* Per the POSIX Realtime Extensions */
int clock_gettime(clockid_t clock_id, struct timespec *tp);
#endif
......@@ -44,6 +44,10 @@
#include "conf_options.h"
#include "ifctrl.h"
#ifdef __MACH__
#include "mach_clock_gettime.h"
#endif
struct list_head nodes;
struct essid_meta_info essids;
struct history hist;
......@@ -53,7 +57,8 @@ struct node_names_info node_names;
struct config conf;
struct timespec the_time;
struct timespec time_mono;
struct timespec time_real;
int mon; /* monitoring socket */
......@@ -210,11 +215,11 @@ static void write_to_file(struct packet_info* p)
{
char buf[40];
int i;
struct tm* ltm = localtime(&the_time.tv_sec);
struct tm* ltm = localtime(&time_real.tv_sec);
//timestamp, e.g. 2015-05-16 15:05:44.338806 +0300
i = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ltm);
i += snprintf(buf + i, sizeof(buf) - i, ".%06ld", (long)(the_time.tv_nsec / 1000));
i += snprintf(buf + i, sizeof(buf) - i, ".%06ld", (long)(time_mono.tv_nsec / 1000));
i += strftime(buf + i, sizeof(buf) - i, " %z", ltm);
fprintf(DF, "%s, ", buf);
......@@ -635,7 +640,7 @@ int main(int argc, char** argv)
atexit(exit_handler);
clock_gettime(CLOCK_MONOTONIC, &stats.stats_time);
clock_gettime(CLOCK_MONOTONIC, &the_time);
clock_gettime(CLOCK_MONOTONIC, &time_mono);
conf.channel_idx = -1;
......@@ -720,7 +725,9 @@ int main(int argc, char** argv)
if (is_sigint_caught)
exit(1);
clock_gettime(CLOCK_MONOTONIC, &the_time);
clock_gettime(CLOCK_MONOTONIC, &time_mono);
clock_gettime(CLOCK_REALTIME, &time_real);
node_timeout();
if (conf.serveraddr[0] == '\0') { /* server */
......
......@@ -29,7 +29,6 @@
#include "channel.h"
#include "wlan80211.h"
#define VERSION "5.0-pre"
#define CONFIG_FILE "/etc/horst.conf"
#ifndef DO_DEBUG
......@@ -345,7 +344,8 @@ struct config {
extern struct config conf;
extern struct timespec the_time;
extern struct timespec time_mono;
extern struct timespec time_real;
void free_lists(void);
void init_spectrum(void);
......
......@@ -34,7 +34,7 @@ static void copy_nodeinfo(struct node_info* n, struct packet_info* p)
memcpy(&(n->last_pkt), p, sizeof(struct packet_info));
// update timestamp
n->last_seen = time(NULL);
n->last_seen = time_mono.tv_sec;
n->pkt_count++;
n->pkt_types |= p->pkt_types;
if (p->ip_src)
......@@ -167,11 +167,11 @@ void node_timeout(void)
struct node_info *n, *m, *n2, *m2;
struct chan_node *cn, *cn2;
if ((the_time.tv_sec - last_nodetimeout.tv_sec) < conf.node_timeout )
if ((time_mono.tv_sec - last_nodetimeout.tv_sec) < conf.node_timeout )
return;
list_for_each_safe(&nodes, n, m, list) {
if (n->last_seen < (the_time.tv_sec - conf.node_timeout)) {
if (n->last_seen < (time_mono.tv_sec - conf.node_timeout)) {
list_del(&n->list);
if (n->essid != NULL)
remove_node_from_essid(n);
......@@ -191,5 +191,5 @@ void node_timeout(void)
free(n);
}
}
last_nodetimeout = the_time;
last_nodetimeout = time_mono;
}