Codebase list reaver / upstream/1.6.1+git20170715
New upstream version 1.6.1+git20170715 Sophie Brun 6 years ago
8 changed file(s) with 262 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
1010
1111 CFLAGS=-DCONF_DIR='"$(CONFDIR)"' $(CFLAGS_USER) $(DISABLED_WARNINGS)
1212 CFLAGS += $(INC)
13 CFLAGS += -DCONFIG_IPV6
14
15 UTILS_OBJS= \
16 utils/base64.o \
17 utils/common.o \
18 utils/ip_addr.o \
19 utils/radiotap.o \
20 utils/trace.o \
21 utils/uuid.o \
22 utils/wpa_debug.o \
23 utils/wpabuf.o \
24 utils/os_unix.o \
25 utils/eloop.o
26
1327
1428 WPS_OBJS=wps/wps_attr_build.o wps/wps_attr_parse.o wps/wps_attr_process.o \
1529 wps/wps.o wps/wps_common.o wps/wps_dev_attr.o wps/wps_enrollee.o \
1731
1832 LWE_OBJS=lwe/iwlib.o
1933
20 LIB_OBJS=libwps/libwps.o $(WPS_OBJS) utils/libutils.a \
34 LIB_OBJS=libwps/libwps.o $(WPS_OBJS) $(UTILS_OBJS) \
2135 crypto/libcrypto.a tls/libtls.a $(LWE_OBJS)
2236
2337 WASH_OBJS=globule.o init.o misc.o 80211.o iface.o \
24 builder.o crc.o pixie.o
38 builder.o crc.o pixie.o wpsmon.o
2539 REAVER_OBJS=argsparser.o globule.o init.o sigint.o iface.o sigalrm.o \
2640 misc.o cracker.o session.o send.o pins.o 80211.o exchange.o builder.o \
27 keys.o crc.o pixie.o
41 keys.o crc.o pixie.o wpscrack.o
2842
2943 # Version of the Wireless Tools
3044 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < lwe/iwlib.h )
3953 $(WPS_OBJS): CFLAGS+=-I. -Iutils
4054
4155 wash: $(WASH_OBJS) $(LIB_OBJS)
42 $(CC) $(CFLAGS) $(INC) wpsmon.c $(WASH_OBJS) $(LIB_OBJS) $(LDFLAGS) -o wash
56 $(CC) $(CFLAGS) $(INC) $(WASH_OBJS) $(LIB_OBJS) $(LDFLAGS) -o wash
4357
4458 reaver: $(REAVER_OBJS) $(LIB_OBJS)
45 $(CC) $(CFLAGS) $(INC) wpscrack.c $(REAVER_OBJS) $(LIB_OBJS) $(LDFLAGS) -o reaver
46
47 utils/libutils.a:
48 (cd utils && make)
59 $(CC) $(CFLAGS) $(INC) $(REAVER_OBJS) $(LIB_OBJS) $(LDFLAGS) -o reaver
4960
5061 crypto/libcrypto.a: tls/libtls.a
5162 (cd crypto && make)
1111 #define LIBWPS_C
1212
1313 #include "libwps.h"
14
15 char *wps_data_to_json(const char*bssid, const char *ssid, int channel, int rssi,struct libwps_data *wps) {
16 size_t ol = 0, nl = 0, ns = 0;
17 char *json_str = 0, *old = strdup("{");
18 char buf[1024];
19
20 nl = snprintf(buf, sizeof buf, "\"bssid\" : \"%s\", ", bssid);
21 ol = strlen(old);
22 ns = ol + nl + 1;
23 json_str = malloc(ns);
24 snprintf(json_str, ns, "%s%s", old, buf);
25 free(old);
26 old = json_str;
27
28 nl = snprintf(buf, sizeof buf, "\"essid\" : \"%s\", ", ssid);
29 ol = strlen(old);
30 ns = ol + nl + 1;
31 json_str = malloc(ns);
32 snprintf(json_str, ns, "%s%s", old, buf);
33 free(old);
34 old = json_str;
35
36 nl = snprintf(buf, sizeof buf, "\"channel\" : %d, ", channel);
37 ol = strlen(old);
38 ns = ol + nl + 1;
39 json_str = malloc(ns);
40 snprintf(json_str, ns, "%s%s", old, buf);
41 free(old);
42 old = json_str;
43
44 nl = snprintf(buf, sizeof buf, "\"rssi\" : %d, ", rssi);
45 ol = strlen(old);
46 ns = ol + nl + 1;
47 json_str = malloc(ns);
48 snprintf(json_str, ns, "%s%s", old, buf);
49 free(old);
50 old = json_str;
51
52 if(wps->version) {
53 nl = snprintf(buf, sizeof buf, "\"wps_version\" : %d, ", wps->version);
54 ol = strlen(old);
55 ns = ol + nl + 1;
56 json_str = malloc(ns);
57 snprintf(json_str, ns, "%s%s", old, buf);
58 free(old);
59 old = json_str;
60 }
61 if(wps->state) {
62 nl = snprintf(buf, sizeof buf, "\"wps_state\" : %d, ", wps->state);
63 ol = strlen(old);
64 ns = ol + nl + 1;
65 json_str = malloc(ns);
66 snprintf(json_str, ns, "%s%s", old, buf);
67 free(old);
68 old = json_str;
69 }
70 if(wps->locked) {
71 nl = snprintf(buf, sizeof buf, "\"wps_locked\" : %d, ", wps->locked);
72 ol = strlen(old);
73 ns = ol + nl + 1;
74 json_str = malloc(ns);
75 snprintf(json_str, ns, "%s%s", old, buf);
76 free(old);
77 old = json_str;
78 }
79 if(*wps->manufacturer) {
80 nl = snprintf(buf, sizeof buf, "\"wps_manufacturer\" : \"%s\", ", wps->manufacturer);
81 ol = strlen(old);
82 ns = ol + nl + 1;
83 json_str = malloc(ns);
84 snprintf(json_str, ns, "%s%s", old, buf);
85 free(old);
86 old = json_str;
87 }
88 if(*wps->model_name) {
89 nl = snprintf(buf, sizeof buf, "\"wps_model_name\" : \"%s\", ", wps->model_name);
90 ol = strlen(old);
91 ns = ol + nl + 1;
92 json_str = malloc(ns);
93 snprintf(json_str, ns, "%s%s", old, buf);
94 free(old);
95 old = json_str;
96 }
97 if(*wps->model_number) {
98 nl = snprintf(buf, sizeof buf, "\"wps_model_number\" : \"%s\", ", wps->model_number);
99 ol = strlen(old);
100 ns = ol + nl + 1;
101 json_str = malloc(ns);
102 snprintf(json_str, ns, "%s%s", old, buf);
103 free(old);
104 old = json_str;
105 }
106 if(*wps->device_name) {
107 nl = snprintf(buf, sizeof buf, "\"wps_device_name\" : \"%s\", ", wps->device_name);
108 ol = strlen(old);
109 ns = ol + nl + 1;
110 json_str = malloc(ns);
111 snprintf(json_str, ns, "%s%s", old, buf);
112 free(old);
113 old = json_str;
114 }
115 if(*wps->ssid) {
116 nl = snprintf(buf, sizeof buf, "\"wps_ssid\" : \"%s\", ", wps->ssid);
117 ol = strlen(old);
118 ns = ol + nl + 1;
119 json_str = malloc(ns);
120 snprintf(json_str, ns, "%s%s", old, buf);
121 free(old);
122 old = json_str;
123 }
124 if(*wps->serial) {
125 nl = snprintf(buf, sizeof buf, "\"wps_serial\" : \"%s\", ", wps->serial);
126 ol = strlen(old);
127 ns = ol + nl + 1;
128 json_str = malloc(ns);
129 snprintf(json_str, ns, "%s%s", old, buf);
130 free(old);
131 old = json_str;
132 }
133 if(*wps->os_version) {
134 nl = snprintf(buf, sizeof buf, "\"wps_os_version\" : \"%s\", ", wps->os_version);
135 ol = strlen(old);
136 ns = ol + nl + 1;
137 json_str = malloc(ns);
138 snprintf(json_str, ns, "%s%s", old, buf);
139 free(old);
140 old = json_str;
141 }
142 if(*wps->uuid) {
143 nl = snprintf(buf, sizeof buf, "\"wps_uuid\" : \"%s\", ", wps->uuid);
144 ol = strlen(old);
145 ns = ol + nl + 1;
146 json_str = malloc(ns);
147 snprintf(json_str, ns, "%s%s", old, buf);
148 free(old);
149 old = json_str;
150 }
151 if(*wps->selected_registrar) {
152 nl = snprintf(buf, sizeof buf, "\"wps_selected_registrar\" : \"%s\", ", wps->selected_registrar);
153 ol = strlen(old);
154 ns = ol + nl + 1;
155 json_str = malloc(ns);
156 snprintf(json_str, ns, "%s%s", old, buf);
157 free(old);
158 old = json_str;
159 }
160 if(*wps->response_type) {
161 nl = snprintf(buf, sizeof buf, "\"wps_response_type\" : \"%s\", ", wps->response_type);
162 ol = strlen(old);
163 ns = ol + nl + 1;
164 json_str = malloc(ns);
165 snprintf(json_str, ns, "%s%s", old, buf);
166 free(old);
167 old = json_str;
168 }
169 if(*wps->primary_device_type) {
170 nl = snprintf(buf, sizeof buf, "\"wps_primary_device_type\" : \"%s\", ", wps->primary_device_type);
171 ol = strlen(old);
172 ns = ol + nl + 1;
173 json_str = malloc(ns);
174 snprintf(json_str, ns, "%s%s", old, buf);
175 free(old);
176 old = json_str;
177 }
178 if(*wps->config_methods) {
179 nl = snprintf(buf, sizeof buf, "\"wps_config_methods\" : \"%s\", ", wps->config_methods);
180 ol = strlen(old);
181 ns = ol + nl + 1;
182 json_str = malloc(ns);
183 snprintf(json_str, ns, "%s%s", old, buf);
184 free(old);
185 old = json_str;
186 }
187 if(*wps->rf_bands) {
188 nl = snprintf(buf, sizeof buf, "\"wps_rf_bands\" : \"%s\", ", wps->rf_bands);
189 ol = strlen(old);
190 ns = ol + nl + 1;
191 json_str = malloc(ns);
192 snprintf(json_str, ns, "%s%s", old, buf);
193 free(old);
194 old = json_str;
195 }
196
197 nl = snprintf(buf, sizeof buf, "\"dummy\": 0}");
198 ol = strlen(old);
199 ns = ol + nl + 1;
200 json_str = malloc(ns);
201 snprintf(json_str, ns, "%s%s", old, buf);
202 free(old);
203 old = json_str;
204
205 return json_str;
206 }
14207
15208 /*
16209 * This is the only function that external code should call.
124317 ptr = wps->uuid;
125318 break;
126319 case SERIAL:
127 src = hex2str(el, el_len);
128320 ptr = wps->serial;
129321 break;
130322 case SELECTED_REGISTRAR:
148340 ptr = wps->rf_bands;
149341 break;
150342 case OS_VERSION:
151 src = hex2str(el, el_len);
152343 ptr = wps->os_version;
153344 break;
154345 default:
5050 };
5151
5252 int parse_wps_parameters(const u_char *packet, size_t len, struct libwps_data *wps);
53 char *wps_data_to_json(const char*bssid, const char *ssid, int channel, int rssi, struct libwps_data *wps);
5354
5455 #ifdef LIBWPS_C
5556
+0
-36
src/utils/Makefile less more
0 all: libutils.a
1
2 clean:
3 rm -f *~ *.o *.d libutils.a
4
5 install:
6 @echo Nothing to be made.
7
8
9 include ../common/lib.rules
10
11 #CFLAGS += -DWPA_TRACE
12 CFLAGS += -DCONFIG_IPV6
13
14 LIB_OBJS= \
15 base64.o \
16 common.o \
17 ip_addr.o \
18 radiotap.o \
19 trace.o \
20 uuid.o \
21 wpa_debug.o \
22 wpabuf.o
23
24 # Pick correct OS wrapper implementation
25 LIB_OBJS += os_unix.o
26
27 # Pick correct event loop implementation
28 LIB_OBJS += eloop.o
29
30 #LIB_OBJS += pcsc_funcs.o
31
32 libutils.a: $(LIB_OBJS)
33 $(AR) crT $@ $?
34
35 -include $(OBJS:%.o=%.d)
0 #include <stdlib.h>
1 #include <stdio.h>
2 #include <string.h>
3 #include <assert.h>
4
5 char *gettempfilename(void) {
6 char buf[256];
7 strcpy(buf, "/tmp/reaver-XXXXXX");
8 char *s;
9 if(!(s = mkdtemp(buf))) return 0;
10 else assert(s == buf);
11 strcat(buf, ".tmp");
12 return strdup(buf);
13 }
14
15 void writefile(const char* fn, const char* contents) {
16 FILE *f = fopen(fn, "w");
17 size_t l = strlen(contents);
18 fwrite(contents, l, 1, f);
19 fclose(f);
20 }
0 #ifndef UTILS_FILE_H
1 #define UTILS_FILE_H
2
3 char *gettempfilename(void);
4 void writefile(const char* fn, const char* contents);
5
6 #endif
173173 fprintf(stderr, "\t-E, --eap-terminate Terminate each WPS session with an EAP FAIL packet\n");
174174 fprintf(stderr, "\t-n, --nack Target AP always sends a NACK [Auto]\n");
175175 fprintf(stderr, "\t-w, --win7 Mimic a Windows 7 registrar [False]\n");
176 fprintf(stderr, "\t-K, --pixie-dust Run pixiedust attack\n");
177 fprintf(stderr, "\t-Z Run pixiedust attack\n");
176178
177179 fprintf(stderr, "\nExample:\n\t%s -i mon0 -b 00:90:4C:C1:AC:21 -vv\n\n", prog_name);
178180
3131 */
3232
3333 #include "wpsmon.h"
34 #include "utils/file.h"
3435
3536 int show_all_aps = 0;
37 int json_mode = 0;
3638
3739 static struct mac {
3840 unsigned char mac[6];
9092 int source = INTERFACE, ret_val = EXIT_FAILURE;
9193 struct bpf_program bpf = { 0 };
9294 char *out_file = NULL, *last_optarg = NULL, *target = NULL, *bssid = NULL;
93 char *short_options = "i:c:n:o:b:5sfuDha";
95 char *short_options = "i:c:n:o:b:5sfuDhaj";
9496 struct option long_options[] = {
9597 { "bssid", required_argument, NULL, 'b' },
9698 { "interface", required_argument, NULL, 'i' },
103105 { "scan", no_argument, NULL, 's' },
104106 { "survey", no_argument, NULL, 'u' },
105107 { "all", no_argument, NULL, 'a' },
108 { "json", no_argument, NULL, 'j' },
106109 { "help", no_argument, NULL, 'h' },
107110 { 0, 0, 0, 0 }
108111 };
144147 case 'o':
145148 out_file = strdup(optarg);
146149 break;
150 case 'j':
151 json_mode = 1;
152 break;
147153 case 's':
148154 mode = SCAN;
149155 break;
308314
309315 if(!header_printed)
310316 {
311 cprintf (INFO, "BSSID Ch dBm WPS Lck ESSID\n");
312 //cprintf(INFO, "00:11:22:33:44:55 12 -77 1.0 Yes 0123456789abcdef0123456789abcdef\n");
313 cprintf (INFO, "--------------------------------------------------------------------------------\n");
317 if(!json_mode) {
318 cprintf (INFO, "BSSID Ch dBm WPS Lck ESSID\n");
319 //cprintf(INFO, "00:11:22:33:44:55 12 -77 1.0 Yes 0123456789abcdef0123456789abcdef\n");
320 cprintf (INFO, "--------------------------------------------------------------------------------\n");
321 }
314322 header_printed = 1;
315323 }
316324
390398 probe_sent = 1;
391399 }
392400
393 if(!was_printed(bssid) && (wps->version > 0 || show_all_aps == 1))
401 if(!json_mode && (!was_printed(bssid) && (wps->version > 0 || show_all_aps == 1)))
394402 {
395403 if(wps->version > 0) switch(wps->locked)
396404 {
421429 if(!wps_parsed || fsub_type == __cpu_to_le16(IEEE80211_STYPE_PROBE_RESP))
422430 {
423431 mark_ap_complete(bssid);
432 if(json_mode && (show_all_aps || wps->version > 0)) {
433 char *json_string = wps_data_to_json(bssid, ssid, channel, rssi, wps);
434 printf("%s\n", json_string);
435 free(json_string);
436 }
424437 }
425438
426439 }
474487 fprintf(stderr, "\t-s, --scan Use scan mode\n");
475488 fprintf(stderr, "\t-u, --survey Use survey mode [default]\n");
476489 fprintf(stderr, "\t-a, --all Show all APs, even those without WPS\n");
490 fprintf(stderr, "\t-j, --json print extended WPS info as json\n");
477491 fprintf(stderr, "\t-h, --help Show help\n");
478492
479493 fprintf(stderr, "\nExample:\n");