Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Reaver - Command line processing functions
- * Copyright (c) 2011, Tactical Network Solutions, Craig Heffner <cheffner@tacnetsol.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. * If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. * If you
- * do not wish to do so, delete this exception statement from your
- * version. * If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
- #include "argsparser.h"
- #include "pixie.h"
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- #include <math.h>
- #include <stdlib.h>
- char* conv (unsigned int pin) {
- char* c;
- c = (char *)malloc(10 * sizeof(char));
- int v = 0;
- while (pin > 9)
- {
- c[v++] = (pin % 10) + '0';
- pin = pin / 10;
- }
- c[v++] = pin + '0';
- c[v] = '\0';
- char t;
- int i;
- for (i = 0; i < v / 2; i++)
- {
- t = c[i];
- c[i] = c[v - 1 - i];
- c[v - 1 - i] = t;
- }
- v = 0;
- return c;
- free(c);
- }
- bool startsWith(const char *pre, const char *str)
- {
- size_t lenpre = strlen(pre),
- lenstr = strlen(str);
- return lenstr < lenpre ? false : strncmp(pre, str, lenpre) == 0;
- }
- int ipow(int base, int exp) {
- int result = 1;
- while (exp) {
- if (exp & 1) {
- result *=base;
- }
- exp >>= 1;
- base *= base;
- }
- return result;
- }
- unsigned int nic_from_mac(unsigned int values[6])
- {
- unsigned int s = 0;
- int k = 0;
- int i;
- for (i = 3; i <= 5; i++) {
- s += values[8 - i] * ipow(16, k);
- k += 2;
- }
- return s;
- }
- unsigned int wpss_pin_checksum(unsigned int pin)
- {
- unsigned int accum = 0;
- while (pin)
- {
- accum += 3 * (pin % 10);
- pin /= 10;
- accum += pin % 10;
- pin /= 10;
- }
- return (10 - accum % 10) % 10;
- }
- unsigned int dlinkpin(unsigned int nic, bool modified_algorithm)
- {
- int pin;
- if (modified_algorithm) {
- pin = ((nic + 1) ^ 0x55AA55);
- } else {
- pin = (nic ^ 0x55AA55);
- }
- pin = pin ^ (((pin & 0x0F) << 4) +
- ((pin & 0x0F) << 8) +
- ((pin & 0x0F) << 12) +
- ((pin & 0x0F) << 16) +
- ((pin & 0x0F) << 20));
- pin = pin % 10000000;
- if (pin < 1000000)
- {
- pin += ((pin % 9) * 1000000) + 1000000;
- }
- pin = ((pin * 10) + wpss_pin_checksum(pin));
- return pin;
- }
- unsigned int twenty_four_bitpin(unsigned int values[6])
- {
- unsigned int pin = 0;
- int k = 0;
- int i;
- for (i = 3; i <= 5; i++) {
- pin += values[8 - i] * ipow(16, k);
- k += 2;
- }
- if (pin >= 10000000) {
- pin %= 10000000;
- }
- pin = ((pin * 10) + wpss_pin_checksum(pin));
- return pin;
- }
- unsigned int twenty_eight_bitpin(unsigned int values[6])
- {
- unsigned int pin = 0;
- int k = 0;
- int i;
- for (i = 3; i <= 5; i++) {
- pin += values[8 - i] * ipow(16, k);
- k += 2;
- }
- pin += (values[2] % 16) * ipow(16, k);
- if (pin >= 10000000) {
- pin %= 10000000;
- }
- pin = ((pin * 10) + wpss_pin_checksum(pin));
- return pin;
- }
- unsigned int thirty_two_bitpin(unsigned int values[6])
- {
- unsigned int pin = 0;
- int k = 0;
- int i;
- for (i = 3; i <= 6; i++) {
- pin += values[8 - i] * ipow(16, k);
- k += 2;
- }
- if (pin >= 10000000) {
- pin %= 10000000;
- }
- pin = ((pin * 10) + wpss_pin_checksum(pin));
- return pin;
- }
- unsigned int airocon_realtek(unsigned int values[6])
- {
- unsigned int p[7], pin = 0;
- int i;
- for (i = 0; i <= 6; i++) {
- p[i] = (values[(i % 6)] + values[(i + 1) % 6]) % 10;
- }
- for (i = 0; i <= 6; i++) {
- pin += p[6 - i] * ipow(10, i);
- }
- pin = ((pin * 10) + wpss_pin_checksum(pin));
- return pin;
- }
- unsigned int asus_pin(unsigned int values[6])
- {
- unsigned int p[7], pin = 0;
- int i, s = 0;
- for (i = 1; i <= 5; i++) {
- s += values[i];
- }
- for (i = 0; i <= 6; i++) {
- p[i] = (values[i % 6] + values[5]) % (10 - (i + s) % 7);
- }
- for (i = 0; i <= 6; i++) {
- pin += p[6 - i] * ipow(10, i);
- }
- pin = ((pin * 10) + wpss_pin_checksum(pin));
- return pin;
- }
- /* Processes Reaver command line options */
- int process_arguments(int argc, char **argv)
- {
- int ret_val = EXIT_SUCCESS;
- int c = 0, channel = 0;
- int long_opt_index = 0;
- char bssid[MAC_ADDR_LEN] = { 0 };
- char mac[MAC_ADDR_LEN] = { 0 };
- char *short_options = "KZb:e:m:i:t:d:c:T:x:r:g:l:o:p:z:s:C:A5ELfnqvDShwN";
- struct option long_options[] = {
- { "pixie-dust", no_argument, NULL, 'K' },
- { "interface", required_argument, NULL, 'i' },
- { "bssid", required_argument, NULL, 'b' },
- { "essid", required_argument, NULL, 'e' },
- { "mac", required_argument, NULL, 'm' },
- { "timeout", required_argument, NULL, 't' },
- { "m57-timeout", required_argument, NULL, 'T' },
- { "delay", required_argument, NULL, 'd' },
- { "lock-delay", required_argument, NULL, 'l' },
- { "fail-wait", required_argument, NULL, 'x' },
- { "channel", required_argument, NULL, 'c' },
- { "session", required_argument, NULL, 's' },
- { "recurring-delay", required_argument, NULL, 'r' },
- { "max-attempts", required_argument, NULL, 'g' },
- { "out-file", required_argument, NULL, 'o' },
- { "pin", required_argument, NULL, 'p' },
- { "helen", required_argument, NULL, 'z'},
- { "exec", required_argument, NULL, 'C' },
- { "no-associate", no_argument, NULL, 'A' },
- { "ignore-locks", no_argument, NULL, 'L' },
- { "no-nacks", no_argument, NULL, 'N' },
- { "eap-terminate", no_argument, NULL, 'E' },
- { "dh-small", no_argument, NULL, 'S' },
- { "fixed", no_argument, NULL, 'f' },
- { "daemonize", no_argument, NULL, 'D' },
- { "5ghz", no_argument, NULL, '5' },
- { "nack", no_argument, NULL, 'n' },
- { "quiet", no_argument, NULL, 'q' },
- { "verbose", no_argument, NULL, 'v' },
- { "win7", no_argument, NULL, 'w' },
- { "help", no_argument, NULL, 'h' },
- { 0, 0, 0, 0 }
- };
- /* Since this function may be called multiple times, be sure to set opt index to 0 each time */
- optind = 0;
- while((c = getopt_long(argc, argv, short_options, long_options, &long_opt_index)) != -1)
- {
- switch(c)
- {
- case 'Z':
- case 'K':
- pixie.do_pixie = 1;
- break;
- case 'i':
- set_iface(optarg);
- break;
- case 'b':
- str2mac(optarg, (unsigned char *) &bssid);
- set_bssid((unsigned char *) &bssid);
- break;
- case 'e':
- set_ssid(optarg);
- break;
- case 'm':
- str2mac(optarg, (unsigned char *) &mac);
- set_mac((unsigned char *) &mac);
- break;
- case 't':
- set_rx_timeout(atoi(optarg));
- break;
- case 'T':
- set_m57_timeout(strtof(optarg, NULL) * SEC_TO_US);
- break;
- case 'c':
- channel = strtod(optarg, NULL);
- set_fixed_channel(1);
- break;
- case '5':
- set_wifi_band(AN_BAND);
- break;
- case 'd':
- set_delay(atoi(optarg));
- break;
- case 'l':
- set_lock_delay(atoi(optarg));
- break;
- case 'p':
- parse_static_pin(optarg);
- break;
- case 'z':
- if ((startsWith("F8:D1:11", optarg)) || (startsWith("F8:1A:67", optarg)) ||
- (startsWith("B0:48:7A", optarg)) || (startsWith("64:70:02", optarg)) ||
- (startsWith("00:A0:26", optarg)) || (startsWith("E4:7C:F9", optarg)) ||
- (startsWith("DC:71:44", optarg)) || (startsWith("08:BE:AC", optarg)) ||
- (startsWith("D8:6C:E9", optarg)) || (startsWith("5C:A3:9D", optarg)) ||
- (startsWith("E2:41:36", optarg)) || (startsWith("B2:46:FC", optarg)) ||
- (startsWith("E0:41:36", optarg)) || (startsWith("98:97:D1", optarg)) ||
- (startsWith("00:26:CE", optarg)) || (startsWith("72:E8:7B", optarg)) ||
- (startsWith("72:D1:5E", optarg)) || (startsWith("00:1C:DF", optarg)) ||
- (startsWith("72:CD:BE", optarg)) || (startsWith("72:CB:A8", optarg)) ||
- (startsWith("72:C7:14", optarg)) || (startsWith("72:C6:1F", optarg)) ||
- (startsWith("72:C0:6F", optarg)) || (startsWith("72:A8:E4", optarg)) ||
- (startsWith("72:96:BF", optarg)) || (startsWith("72:7D:5E", optarg)) ||
- (startsWith("72:6B:D3", optarg)) || (startsWith("72:55:9C", optarg)) ||
- (startsWith("72:53:D4", optarg)) || (startsWith("72:3D:FF", optarg)) ||
- (startsWith("72:3C:E4", optarg)) || (startsWith("72:23:3D", optarg)) ||
- (startsWith("72:1D:67", optarg)) || (startsWith("6A:D1:67", optarg)) ||
- (startsWith("6A:D1:5E", optarg)) || (startsWith("6A:CD:BE", optarg)) ||
- (startsWith("6A:CB:A8", optarg)) || (startsWith("6A:C7:14", optarg)) ||
- (startsWith("6A:C6:1F", optarg)) || (startsWith("6A:C0:6F", optarg)) ||
- (startsWith("6A:A8:E4", optarg)) || (startsWith("6A:7D:5E", optarg)) ||
- (startsWith("6A:96:BF", optarg)) || (startsWith("6A:6B:D3", optarg)) ||
- (startsWith("6A:55:9C", optarg)) || (startsWith("6A:53:D4", optarg)) ||
- (startsWith("6A:3D:FF", optarg)) || (startsWith("6A:23:3D", optarg)) ||
- (startsWith("6A:1D:67", optarg)) || (startsWith("64:16:F0", optarg)) ||
- (startsWith("62:E8:7B", optarg)) || (startsWith("62:CD:BE", optarg)) ||
- (startsWith("62:CB:A8", optarg)) || (startsWith("62:C7:14", optarg)) ||
- (startsWith("62:C6:1F", optarg)) || (startsWith("62:C0:6F", optarg)) ||
- (startsWith("62:B6:86", optarg)) || (startsWith("62:A8:E4", optarg)) ||
- (startsWith("62:96:BF", optarg)) || (startsWith("62:7D:5E", optarg)) ||
- (startsWith("62:6B:D3", optarg)) || (startsWith("62:55:9C", optarg)) ||
- (startsWith("62:53:D4", optarg)) || (startsWith("62:3D:FF", optarg)) ||
- (startsWith("62:3C:E4", optarg)) || (startsWith("62:23:3D", optarg)) ||
- (startsWith("5C:4C:A9", optarg)) || (startsWith("30:87:30", optarg)) ||
- (startsWith("20:2B:C1", optarg)) || (startsWith("BC:14:01", optarg)) ||
- (startsWith("78:8D:F7", optarg)) || (startsWith("68:B6:CF", optarg)) ||
- (startsWith("00:26:5B", optarg)) || (startsWith("00:1F:1F", optarg)) ||
- (startsWith("00:22:F7", optarg)) || (startsWith("C8:3A:35", optarg)) ||
- (startsWith("08:10:75", optarg)) || (startsWith("00:B0:0C", optarg)) ||
- (startsWith("08:86:3B", optarg)) || (startsWith("00:22:75", optarg)) ||
- (startsWith("90:E6:BA", optarg)) || (startsWith("00:00:B4", optarg)) ||
- (startsWith("F4:9F:F3", optarg)) || (startsWith("EC:CB:30", optarg)) ||
- (startsWith("D4:6E:5C", optarg)) || (startsWith("24:DF:6A", optarg)) ||
- (startsWith("4C:ED:DE", optarg)) || (startsWith("20:08:ED", optarg)) ||
- (startsWith("08:7A:4C", optarg)) || (startsWith("00:50:FC", optarg)) ||
- (startsWith("BC:F6:85", optarg)) || (startsWith("90:94:E4", optarg)) ||
- (startsWith("FE:F5:28", optarg)) || (startsWith("10:7B:EF", optarg)) ||
- (startsWith("FC:F5:28", optarg)) || (startsWith("F2:B2:DC", optarg)) ||
- (startsWith("EE:43:F6", optarg)) || (startsWith("EC:43:F6", optarg)) ||
- (startsWith("EA:28:5D", optarg)) || (startsWith("CC:5D:4E", optarg)) ||
- (startsWith("C8:6C:87", optarg)) || (startsWith("B0:B2:DC", optarg)) ||
- (startsWith("AA:28:5D", optarg)) || (startsWith("6A:28:5D", optarg)) ||
- (startsWith("5C:F4:AB", optarg)) || (startsWith("50:67:F0", optarg)) ||
- (startsWith("28:28:5D", optarg)) || (startsWith("14:A9:E3", optarg)) ||
- (startsWith("00:E0:18", optarg)) || (startsWith("C0:A0:BB", optarg)) ||
- (startsWith("00:0C:6E", optarg)) || (startsWith("00:15:F2", optarg)) ||
- (startsWith("00:05:FC", optarg)) || (startsWith("00:11:2F", optarg)) ||
- (startsWith("00:11:D8", optarg)) || (startsWith("F4:6D:04", optarg)) ||
- (startsWith("00:17:31", optarg)) || (startsWith("00:04:0F", optarg)) ||
- (startsWith("10:7B:44", optarg)) || (startsWith("00:13:D4", optarg)) ||
- (startsWith("B0:6E:BF", optarg)) || (startsWith("00:1A:92", optarg)) ||
- (startsWith("00:1D:60", optarg)) || (startsWith("B8:A3:86", optarg)) ||
- (startsWith("EC:22:80", optarg)) || (startsWith("74:DA:38", optarg)) ||
- (startsWith("78:F5:FD", optarg)) || (startsWith("80:B6:86", optarg)) ||
- (startsWith("40:4D:8E", optarg)) || (startsWith("3C:DF:BD", optarg)) ||
- (startsWith("80:71:7A", optarg)) || (startsWith("84:DB:AC", optarg)) ||
- (startsWith("E0:19:1D", optarg)) || (startsWith("B8:BC:1B", optarg)) ||
- (startsWith("F4:55:9C", optarg)) || (startsWith("04:C0:6F", optarg)) ||
- (startsWith("68:A0:F6", optarg)) || (startsWith("B4:30:52", optarg)) ||
- (startsWith("58:2A:F7", optarg)) || (startsWith("24:69:A5", optarg)) ||
- (startsWith("F4:8E:92", optarg)) || (startsWith("F8:3D:FF", optarg)) ||
- (startsWith("40:CB:A8", optarg)) || (startsWith("C8:D1:5E", optarg)) ||
- (startsWith("24:00:BA", optarg)) || (startsWith("24:09:95", optarg)) ||
- (startsWith("F4:E3:FB", optarg)) || (startsWith("D0:2D:B3", optarg)) ||
- (startsWith("5C:7D:5E", optarg)) || (startsWith("4C:8B:EF", optarg)) ||
- (startsWith("20:F3:A3", optarg)) || (startsWith("AC:E8:7B", optarg)) ||
- (startsWith("F4:C7:14", optarg)) || (startsWith("7C:7D:3D", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- parse_static_pin(conv(twenty_four_bitpin(values)));
- } else if ((startsWith("80:1F:02", optarg)) || (startsWith("D4:40:F0", optarg)) ||
- (startsWith("CC:96:A0", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- parse_static_pin(conv(twenty_eight_bitpin(values)));
- } else if ((startsWith("30:85:A9", optarg)) || (startsWith("FC:8B:97", optarg)) ||
- (startsWith("54:04:A6", optarg)) || (startsWith("14:DA:E9", optarg)) ||
- (startsWith("2C:AB:25", optarg)) || (startsWith("C4:A8:1D", optarg)) ||
- (startsWith("10:62:EB", optarg)) || (startsWith("00:07:26", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- parse_static_pin(conv(thirty_two_bitpin(values)));
- } else if ((startsWith("FC:75:16", optarg)) ||
- (startsWith("00:14:D1", optarg)) || (startsWith("D8:EB:97", optarg)) ||
- (startsWith("78:2D:7E", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- parse_static_pin(conv(dlinkpin(nic_from_mac(values), false)));
- } else if ((startsWith("00:18:E7", optarg)) || (startsWith("00:19:5B", optarg)) ||
- (startsWith("00:1C:F0", optarg)) || (startsWith("00:1E:58", optarg)) ||
- (startsWith("00:21:91", optarg)) || (startsWith("00:22:B0", optarg)) ||
- (startsWith("00:24:01", optarg)) || (startsWith("00:26:5A", optarg)) ||
- (startsWith("14:D6:4D", optarg)) || (startsWith("C8:BE:19", optarg)) ||
- (startsWith("00:50:BA", optarg)) || (startsWith("00:17:9A", optarg)) ||
- (startsWith("34:08:04", optarg)) || (startsWith("C8:D3:A3", optarg)) ||
- (startsWith("00:80:C8", optarg)) || (startsWith("40:9B:CD", optarg)) ||
- (startsWith("00:0F:3D", optarg)) || (startsWith("00:11:95", optarg)) ||
- (startsWith("00:15:E9", optarg)) || (startsWith("00:05:5D", optarg)) ||
- (startsWith("78:32:1B", optarg)) || (startsWith("00:0D:88", optarg)) ||
- (startsWith("00:13:46", optarg)) || (startsWith("74:DA:DA", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- parse_static_pin(conv(dlinkpin(nic_from_mac(values), true)));
- } else if ((startsWith("08:60:6E", optarg)) || (startsWith("08:62:66", optarg)) ||
- (startsWith("10:BF:48", optarg)) || (startsWith("10:C3:7B", optarg)) ||
- (startsWith("14:DD:A9", optarg)) || (startsWith("1C:87:2C", optarg)) ||
- (startsWith("1C:B7:2C", optarg)) || (startsWith("2C:56:DC", optarg)) ||
- (startsWith("30:5A:3A", optarg)) || (startsWith("38:2C:4A", optarg)) ||
- (startsWith("40:16:7E", optarg)) || (startsWith("50:46:5D", optarg)) ||
- (startsWith("54:A0:50", optarg)) || (startsWith("60:45:CB", optarg)) ||
- (startsWith("60:A4:4C", optarg)) || (startsWith("74:D0:2B", optarg)) ||
- (startsWith("78:24:AF", optarg)) || (startsWith("9C:5C:8E", optarg)) ||
- (startsWith("AC:22:0B", optarg)) || (startsWith("AC:9E:17", optarg)) ||
- (startsWith("BC:EE:7B", optarg)) || (startsWith("C8:60:00", optarg)) ||
- (startsWith("D8:50:E6", optarg)) || (startsWith("E0:3F:49", optarg)) ||
- (startsWith("F0:79:59", optarg)) || (startsWith("F8:32:E4", optarg)) ||
- (startsWith("00:08:A1", optarg)) || (startsWith("10:FE:ED", optarg)) ||
- (startsWith("00:1E:A6", optarg)) || (startsWith("00:30:4F", optarg)) ||
- (startsWith("04:8D:38", optarg)) || (startsWith("F4:28:53", optarg)) ||
- (startsWith("08:10:78", optarg)) || (startsWith("08:10:79", optarg)) ||
- (startsWith("3C:1E:04", optarg)) || (startsWith("C4:12:F5", optarg)) ||
- (startsWith("48:EE:0C", optarg)) || (startsWith("54:B8:0A", optarg)) ||
- (startsWith("58:7B:E9", optarg)) || (startsWith("60:D1:AA", optarg)) ||
- (startsWith("64:51:7E", optarg)) || (startsWith("64:D9:54", optarg)) ||
- (startsWith("6C:19:8F", optarg)) || (startsWith("6C:72:20", optarg)) ||
- (startsWith("6C:FD:B9", optarg)) || (startsWith("78:D9:9F", optarg)) ||
- (startsWith("8C:88:2B", optarg)) || (startsWith("90:F6:52", optarg)) ||
- (startsWith("A0:F3:C1", optarg)) || (startsWith("A8:F7:E0", optarg)) ||
- (startsWith("AC:A2:13", optarg)) || (startsWith("B8:55:10", optarg)) ||
- (startsWith("BC:34:00", optarg)) || (startsWith("70:62:B8", optarg)) ||
- (startsWith("D0:0E:D9", optarg)) || (startsWith("D8:FE:E3", optarg)) ||
- (startsWith("E8:94:F6", optarg)) || (startsWith("EC:1A:59", optarg)) ||
- (startsWith("E8:CC:18", optarg)) || (startsWith("90:8D:78", optarg)) ||
- (startsWith("F8:E9:03", optarg)) || (startsWith("E4:6F:13", optarg)) ||
- (startsWith("70:4D:7B", optarg)) || (startsWith("88:D7:F6", optarg)) ||
- (startsWith("D0:17:C2", optarg)) || (startsWith("38:D5:47", optarg)) ||
- (startsWith("2C:4D:54", optarg)) || (startsWith("70:8B:CD", optarg)) ||
- (startsWith("B0:C5:54", optarg)) || (startsWith("1C:5F:2B", optarg)) ||
- (startsWith("34:97:F6", optarg)) || (startsWith("10:BE:F5", optarg)) ||
- (startsWith("A0:AB:1B", optarg)) || (startsWith("80:26:89", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- parse_static_pin(conv(asus_pin(values)));
- } else if ((startsWith("F4:3E:61", optarg)) || (startsWith("78:8C:54", optarg)) ||
- (startsWith("94:FB:B2", optarg)) || (startsWith("08:10:73", optarg)) ||
- (startsWith("10:13:EE", optarg)) || (startsWith("00:0B:2B", optarg)) ||
- (startsWith("02:10:18", optarg)) || (startsWith("00:E0:4B", optarg)) ||
- (startsWith("00:1A:EF", optarg)) || (startsWith("00:17:7C", optarg)) ||
- (startsWith("00:13:33", optarg)) || (startsWith("00:0E:F4", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- parse_static_pin(conv(airocon_realtek(values)));
- } else if ((startsWith("00:24:8C", optarg)) || (startsWith("00:26:18", optarg)) ||
- (startsWith("34:4D:EB", optarg)) || (startsWith("70:71:BC", optarg)) ||
- (startsWith("E0:69:95", optarg)) || (startsWith("84:C9:B2", optarg)) ||
- (startsWith("E0:CB:4E", optarg)) || (startsWith("00:1B:FC", optarg)) ||
- (startsWith("00:1E:8C", optarg)) || (startsWith("00:23:54", optarg)) ||
- (startsWith("00:1F:C6", optarg)) || (startsWith("00:18:F3", optarg)) ||
- (startsWith("48:5B:39", optarg)) || (startsWith("BC:AE:C5", optarg)) ||
- (startsWith("00:0E:A6", optarg)) || (startsWith("20:CF:30", optarg)) ||
- (startsWith("00:22:15", optarg)) || (startsWith("00:0E:2E", optarg)) ||
- (startsWith("9C:D6:43", optarg)) || (startsWith("48:AD:08", optarg)) ||
- (startsWith("2C:AB:00", optarg)) || (startsWith("80:38:BC", optarg)) ||
- (startsWith("0C:45:BA", optarg)) || (startsWith("AC:85:3D", optarg)) ||
- (startsWith("74:88:2A", optarg)) || (startsWith("78:D7:52", optarg)) ||
- (startsWith("E0:24:7F", optarg)) || (startsWith("00:46:4B", optarg)) ||
- (startsWith("70:7B:E8", optarg)) || (startsWith("54:89:98", optarg)) ||
- (startsWith("08:19:A6", optarg)) || (startsWith("3C:F8:08", optarg)) ||
- (startsWith("B4:15:13", optarg)) || (startsWith("28:31:52", optarg)) ||
- (startsWith("DC:D2:FC", optarg)) || (startsWith("78:1D:BA", optarg)) ||
- (startsWith("D0:3E:5C", optarg)) || (startsWith("F8:98:B9", optarg)) ||
- (startsWith("2C:CF:58", optarg)) || (startsWith("E4:C2:D1", optarg)) ||
- (startsWith("88:A2:D7", optarg)) || (startsWith("D0:D0:4B", optarg)) ||
- (startsWith("90:03:25", optarg)) || (startsWith("58:60:5F", optarg)) ||
- (startsWith("2C:9D:1E", optarg)) || (startsWith("C8:8D:83", optarg)) ||
- (startsWith("F0:98:38", optarg)) || (startsWith("18:DE:D7", optarg)) ||
- (startsWith("04:25:C5", optarg)) || (startsWith("A8:CA:7B", optarg)) ||
- (startsWith("EC:4D:47", optarg)) || (startsWith("88:CF:98", optarg)) ||
- (startsWith("D8:49:0B", optarg)) || (startsWith("88:86:03", optarg)) ||
- (startsWith("F8:E8:11", optarg)) || (startsWith("E0:97:96", optarg)) ||
- (startsWith("CC:CC:81", optarg)) || (startsWith("10:1B:54", optarg)) ||
- (startsWith("70:54:F5", optarg)) || (startsWith("C0:70:09", optarg)) ||
- (startsWith("08:E8:4F", optarg)) || (startsWith("04:BD:70", optarg)) ||
- (startsWith("18:C5:8A", optarg)) || (startsWith("00:25:9E", optarg)) ||
- (startsWith("D4:94:E8", optarg)) || (startsWith("44:55:B1", optarg)) ||
- (startsWith("30:F3:35", optarg)) || (startsWith("74:5A:AA", optarg)) ||
- (startsWith("7C:1C:F1", optarg)) || (startsWith("94:DB:DA", optarg)) ||
- (startsWith("38:4C:4F", optarg)) || (startsWith("E4:A8:B6", optarg)) ||
- (startsWith("24:4C:07", optarg)) || (startsWith("08:C0:21", optarg)) ||
- (startsWith("48:43:5A", optarg)) || (startsWith("9C:E3:74", optarg)) ||
- (startsWith("04:9F:CA", optarg)) || (startsWith("C8:1F:BE", optarg)) ||
- (startsWith("20:3D:B2", optarg)) || (startsWith("48:D5:39", optarg)) ||
- (startsWith("A4:C6:4F", optarg)) || (startsWith("48:7B:6B", optarg)) ||
- (startsWith("80:D4:A5", optarg)) || (startsWith("38:BC:01", optarg)) ||
- (startsWith("04:B0:E7", optarg)) || (startsWith("D4:6A:A8", optarg)) ||
- (startsWith("44:6A:2E", optarg)) || (startsWith("48:46:FB", optarg)) ||
- (startsWith("2C:55:D3", optarg)) || (startsWith("20:0B:C7", optarg)) ||
- (startsWith("54:39:DF", optarg)) || (startsWith("10:47:80", optarg)) ||
- (startsWith("30:D1:7E", optarg)) || (startsWith("9C:28:EF", optarg)) ||
- (startsWith("7C:60:97", optarg)) || (startsWith("60:DE:44", optarg)) ||
- (startsWith("34:00:A3", optarg)) || (startsWith("64:3E:8C", optarg)) ||
- (startsWith("E0:36:76", optarg)) || (startsWith("7C:A2:3E", optarg)) ||
- (startsWith("E8:BD:D1", optarg)) || (startsWith("FC:E3:3C", optarg)) ||
- (startsWith("24:9E:AB", optarg)) || (startsWith("74:A0:63", optarg)) ||
- (startsWith("54:51:1B", optarg)) || (startsWith("9C:74:1A", optarg)) ||
- (startsWith("04:27:58", optarg)) || (startsWith("48:FD:8E", optarg)) ||
- (startsWith("24:44:27", optarg)) || (startsWith("4C:F9:5D", optarg)) ||
- (startsWith("70:79:90", optarg)) || (startsWith("C0:BF:C0", optarg)) ||
- (startsWith("A0:8C:F8", optarg)) || (startsWith("F8:75:88", optarg)) ||
- (startsWith("E8:4D:D0", optarg)) || (startsWith("68:8F:84", optarg)) ||
- (startsWith("54:A5:1B", optarg)) || (startsWith("28:6E:D4", optarg)) ||
- (startsWith("04:F9:38", optarg)) || (startsWith("FC:48:EF", optarg)) ||
- (startsWith("80:FB:06", optarg)) || (startsWith("D4:B1:10", optarg)) ||
- (startsWith("CC:53:B5", optarg)) || (startsWith("EC:38:8F", optarg)) ||
- (startsWith("BC:9C:31", optarg)) || (startsWith("E4:35:C8", optarg)) ||
- (startsWith("F8:BF:09", optarg)) || (startsWith("9C:37:F4", optarg)) ||
- (startsWith("BC:62:0E", optarg)) || (startsWith("78:F5:57", optarg)) ||
- (startsWith("78:F5:57", optarg)) || (startsWith("E0:28:61", optarg)) ||
- (startsWith("C4:47:3F", optarg)) || (startsWith("34:A2:A2", optarg)) ||
- (startsWith("20:F1:7C", optarg)) || (startsWith("34:B3:54", optarg)) ||
- (startsWith("74:9D:8F", optarg)) || (startsWith("34:6A:C2", optarg)) ||
- (startsWith("9C:7D:A3", optarg)) || (startsWith("F0:2F:A7", optarg)) ||
- (startsWith("F8:4A:BF", optarg)) || (startsWith("88:3F:D3", optarg)) ||
- (startsWith("44:82:E5", optarg)) || (startsWith("70:A8:E3", optarg)) ||
- (startsWith("4C:B1:6C", optarg)) || (startsWith("4C:1F:CC", optarg)) ||
- (startsWith("48:62:76", optarg)) || (startsWith("AC:4E:91", optarg)) ||
- (startsWith("E4:68:A3", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 1234567;
- pin = (12345670 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("AC:F1:DF", optarg)) || (startsWith("EC:62:64", optarg)) ||
- (startsWith("98:8B:5D", optarg)) || (startsWith("00:1A:A9", optarg)) ||
- (startsWith("14:14:4B", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 2017252;
- pin = (20172520 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("1C:7E:E5", optarg)) || (startsWith("28:10:7B", optarg)) ||
- (startsWith("78:54:2E", optarg)) || (startsWith("CC:B2:55", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 4626484;
- pin = (46264840 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("4C:17:EB", optarg)) || (startsWith("20:4E:7F", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 6232714;
- pin = (62327140 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("1C:BD:B9", optarg)) || (startsWith("5C:D9:98", optarg)) ||
- (startsWith("F0:7D:68", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 6817554;
- pin = (68175540 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("00:0C:42", optarg)) || (startsWith("00:0E:E8", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 9566146;
- pin = (95661460 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("F8:C0:91", optarg)) || (startsWith("78:44:76", optarg)) ||
- (startsWith("3C:8C:F8", optarg)) || (startsWith("D4:BF:7F", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 9995604;
- pin = (99956040 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("00:26:24", optarg)) || (startsWith("44:32:C8", optarg)) ||
- (startsWith("88:F7:C7", optarg)) || (startsWith("CC:03:FA", optarg)) ||
- (startsWith("00:1D:68", optarg)) || (startsWith("00:1E:69", optarg)) ||
- (startsWith("00:14:7F", optarg)) || (startsWith("00:07:C3", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 6795814;
- pin = (67958140 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("78:6A:89", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 9756922;
- pin = (97569220 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("50:A7:2B", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 2079327;
- pin = (20793270 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("00:E0:4C", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 4062466;
- pin = (40624660 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("80:3F:5D", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 0026686;
- pin = (00266860 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("28:5F:DB", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 0582967;
- pin = (05829670 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("08:10:77", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 8242515;
- pin = (82425150 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("64:A6:51", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 4284174;
- pin = (42841740 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("10:C6:1F", optarg)) || (startsWith("88:53:D4", optarg)) ||
- (startsWith("BC:76:70", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 5238273;
- pin = (52382730 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if (startsWith("BC:96:80", optarg)) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 1209418;
- pin = (12094180 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("88:CE:FA", optarg)) || (startsWith("24:7F:3C", optarg)) ||
- (startsWith("00:34:FE", optarg)) || (startsWith("B0:5B:67", optarg)) ||
- (startsWith("F4:DC:F9", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 0000000;
- pin = (00000000 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- } else if ((startsWith("00:66:4B", optarg)) || (startsWith("08:63:61", optarg)) ||
- (startsWith("0C:96:BF", optarg)) || (startsWith("14:B9:68", optarg)) ||
- (startsWith("34:6B:D3", optarg)) || (startsWith("60:E7:01", optarg)) ||
- (startsWith("88:E3:AB", optarg)) || (startsWith("28:3C:E4", optarg)) ||
- (startsWith("9C:C1:72", optarg)) || (startsWith("AC:E2:15", optarg)) ||
- (startsWith("D0:7A:B5", optarg)) || (startsWith("CC:A2:23", optarg)) ||
- (startsWith("EC:23:3D", optarg)) || (startsWith("E8:CD:2D", optarg)) ||
- (startsWith("F8:01:13", optarg)) || (startsWith("34:CD:BE", optarg)) ||
- (startsWith("70:72:3C", optarg))) {
- unsigned int values[6];
- sscanf(optarg, "%x:%x:%x:%x:%x:%x", &values[0], &values[1], &values[2], &values[3], &values[4], &values[5]);
- int pin = 3425928;
- pin = (34259280 + wpss_pin_checksum(pin));
- parse_static_pin(conv(pin));
- }
- break;
- case 's':
- set_session(optarg);
- break;
- case 'C':
- set_exec_string(optarg);
- break;
- case 'A':
- set_external_association(1);
- break;
- case 'L':
- set_ignore_locks(1);
- break;
- case 'o':
- set_log_file(fopen(optarg, "w"));
- break;
- case 'x':
- set_fail_delay(atoi(optarg));
- break;
- case 'r':
- parse_recurring_delay(optarg);
- break;
- case 'g':
- set_max_pin_attempts(atoi(optarg));
- break;
- case 'D':
- daemonize();
- break;
- case 'E':
- set_eap_terminate(1);
- break;
- case 'S':
- set_dh_small(1);
- break;
- case 'n':
- set_timeout_is_nack(0);
- break;
- case 'f':
- set_fixed_channel(1);
- break;
- case 'v':
- set_debug(get_debug() + 1);
- break;
- case 'q':
- set_debug(CRITICAL);
- break;
- case 'w':
- set_win7_compat(1);
- break;
- case 'N':
- set_oo_send_nack(0);
- break;
- default:
- ret_val = EXIT_FAILURE;
- }
- }
- if(channel)
- {
- change_channel(channel);
- }
- return ret_val;
- }
- /* Initialize some basic config settings */
- void init_default_settings(void)
- {
- set_log_file(stdout);
- set_max_pin_attempts(P1_SIZE + P2_SIZE);
- set_delay(DEFAULT_DELAY);
- set_lock_delay(DEFAULT_LOCK_DELAY);
- set_debug(INFO);
- set_auto_channel_select(1);
- set_timeout_is_nack(1);
- set_oo_send_nack(1);
- set_wifi_band(BG_BAND);
- pixie.do_pixie = 0;
- set_pin_string_mode(0);
- }
- /* Parses the recurring delay optarg */
- void parse_recurring_delay(char *arg)
- {
- char *x = NULL, *y = NULL;
- x = strdup(arg);
- y = strchr(x, ':');
- if(y)
- {
- memset(y, 0, 1);
- y++;
- set_recurring_delay_count(atoi(x));
- set_recurring_delay(atoi(y));
- }
- free(x);
- }
- int is_valid_pin(char *pin)
- {
- if(!pin)
- return 0;
- int i;
- for (i = 0; i < strlen(pin); i++)
- {
- if(!isdigit(pin[i]))
- return 0;
- }
- if(strlen(pin) == 8)
- {
- char pin7[8] = { 0 };
- char pin8[9] = { 0 };
- memcpy((void *) &pin7, pin, sizeof(pin7)-1);
- snprintf(pin8, 9, "%s%d", pin7, wps_pin_checksum(atoi(pin7)));
- if (strcmp(pin, pin8) != 0)
- return 0;
- }
- return 1;
- }
- /* Parse the WPS pin to use into p1 and p2 */
- void parse_static_pin(char *pin)
- {
- int len = 0;
- char p1[5] = { 0 };
- char p2[4] = { 0 };
- if(pin)
- {
- len = strlen(pin);
- if((len == 4 || len == 7 || len == 8) && is_valid_pin(pin) != 0)
- {
- memcpy((void *) &p1, pin, sizeof(p1)-1);
- set_static_p1((char *) &p1);
- set_key_status(KEY2_WIP);
- if(len > 4)
- {
- memcpy((void *) &p2, pin+sizeof(p1)-1, sizeof(p2)-1);
- set_static_p2((char *) &p2);
- }
- }
- else
- {
- //cprintf(CRITICAL, "[X] ERROR: Invalid pin specified! Ignoring '%s'.\n", pin);
- set_max_pin_attempts(1);
- set_pin_string_mode(1);
- set_static_p1(pin);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement