add some test code for WPS exchange
this allows to test the WPS exchange code with a .pcap file.
This commit is contained in:
parent
375973b5d4
commit
f813196b39
13
src/Makefile
13
src/Makefile
|
@ -93,9 +93,11 @@ LIB_OBJS=libwps/libwps.o $(WPS_OBJS) $(UTILS_OBJS) \
|
||||||
$(TLS_OBJS) $(CRYPTO_OBJS) $(LWE_OBJS)
|
$(TLS_OBJS) $(CRYPTO_OBJS) $(LWE_OBJS)
|
||||||
|
|
||||||
|
|
||||||
PROG_OBJS=argsparser.o globule.o init.o sigint.o iface.o sigalrm.o \
|
MAIN_OBJS=globule.o init.o sigint.o iface.o sigalrm.o \
|
||||||
misc.o cracker.o session.o send.o pins.o 80211.o exchange.o builder.o \
|
misc.o session.o send.o pins.o 80211.o builder.o \
|
||||||
keys.o crc.o pixie.o wpscrack.o wpsmon.o main.o version.o
|
keys.o crc.o pixie.o version.o
|
||||||
|
|
||||||
|
PROG_OBJS=$(MAIN_OBJS) exchange.o argsparser.o wpscrack.o wpsmon.o cracker.o main.o
|
||||||
|
|
||||||
# Version of the Wireless Tools
|
# Version of the Wireless Tools
|
||||||
WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < lwe/iwlib.h )
|
WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < lwe/iwlib.h )
|
||||||
|
@ -120,6 +122,11 @@ wash: reaver
|
||||||
reaver: $(PROG_OBJS) $(LIB_OBJS)
|
reaver: $(PROG_OBJS) $(LIB_OBJS)
|
||||||
$(CC) $(CFLAGS) $(INC) $(PROG_OBJS) $(LIB_OBJS) $(LDFLAGS) -o reaver
|
$(CC) $(CFLAGS) $(INC) $(PROG_OBJS) $(LIB_OBJS) $(LDFLAGS) -o reaver
|
||||||
|
|
||||||
|
extest.o: exchange.c
|
||||||
|
$(CC) $(CFLAGS) -g3 -O0 -DEX_TEST -c exchange.c -o extest.o
|
||||||
|
extest: extest.o $(LIB_OBJS) $(MAIN_OBJS)
|
||||||
|
$(CC) $(LIB_OBJS) extest.o $(MAIN_OBJS) $(LDFLAGS) -o extest
|
||||||
|
|
||||||
version.o: version.h
|
version.o: version.h
|
||||||
version.h: $(wildcard $(srcdir)/VERSION $(srcdir)/../.git)
|
version.h: $(wildcard $(srcdir)/VERSION $(srcdir)/../.git)
|
||||||
printf '#define R_VERSION "%s"\n' "$$(cd $(srcdir); sh version.sh)" > $@
|
printf '#define R_VERSION "%s"\n' "$$(cd $(srcdir); sh version.sh)" > $@
|
||||||
|
|
|
@ -512,3 +512,58 @@ int parse_nack(const void *data, size_t data_size)
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef EX_TEST
|
||||||
|
|
||||||
|
#include "wpsmon.h"
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
globule_init();
|
||||||
|
// arg 1: filename of cap
|
||||||
|
set_handle(capture_init(argv[1]));
|
||||||
|
if(!get_handle()) {
|
||||||
|
cprintf(CRITICAL, "[X] ERROR: Failed to open '%s' for capturing\n", get_iface());
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
struct bpf_program bpf = { 0 };
|
||||||
|
if(pcap_compile(get_handle(), &bpf, PACKET_FILTER, 0, 0) != 0) {
|
||||||
|
cprintf(CRITICAL, "[X] ERROR: Failed to compile packet filter\n");
|
||||||
|
cprintf(CRITICAL, "[X] PCAP: %s\n", pcap_geterr(get_handle()));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
//arg 2: "our" mac for testing
|
||||||
|
unsigned char mac[6];
|
||||||
|
str2mac(argv[2], mac);
|
||||||
|
set_mac(mac);
|
||||||
|
|
||||||
|
//arg 3: bssid of "target" AP
|
||||||
|
str2mac(argv[3], mac);
|
||||||
|
set_bssid(mac);
|
||||||
|
|
||||||
|
struct pcap_pkthdr header;
|
||||||
|
const unsigned char *packet;
|
||||||
|
enum wps_type packet_type = UNKNOWN;
|
||||||
|
|
||||||
|
unsigned long packet_number = 0;
|
||||||
|
|
||||||
|
while((packet = next_packet(&header))) {
|
||||||
|
packet_number++;
|
||||||
|
packet_type = process_packet(packet, &header);
|
||||||
|
switch(packet_type) {
|
||||||
|
case UNKNOWN:
|
||||||
|
dprintf(2, "UNK\n");
|
||||||
|
break;
|
||||||
|
case WPS_PT_DEAUTH:
|
||||||
|
dprintf(2, "DEAUTH\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
globule_deinit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue