int DbgPrintEthHeader(struct ether_header* eh) { #ifdef DEBUGPRINT char buf[80]; DebugPrintf("ether_header----------------------------\n"); DebugPrintf("ether_dhost=%s\n", mac2str(eh->ether_dhost, buf, sizeof(buf))); DebugPrintf("ether_shost=%s\n", mac2str(eh->ether_shost, buf, sizeof(buf))); DebugPrintf("ether_type=%02X", ntohs(eh->ether_type)); switch(ntohs(eh->ether_type)){ case ETH_P_IP: DebugPrintf("(IP)\n"); break; case ETH_P_IPV6: DebugPrintf("(IPv6)\n"); break; case ETH_P_ARP: DebugPrintf("(ARP)\n"); break; default: DebugPrintf("(unknown)\n"); break; } #endif return(0); }
static void proc_data(struct wstate *ws, struct ieee80211_frame *wh, int len) { int dlen; dlen = len - sizeof(*wh) - 4 -4; if (!(wh->i_fc[1] & IEEE80211_FC1_WEP)) { time_print("WARNING: Got NON wep packet from %s dlen %d\n", mac2str(wh->i_addr2), dlen); return; } assert (wh->i_fc[1] & IEEE80211_FC1_WEP); if ((dlen == 36 || dlen == PADDED_ARPLEN) && ws->ws_rtrmac == (unsigned char*) 1) { ws->ws_rtrmac = (unsigned char *) malloc(6); if (!ws->ws_rtrmac) { perror("malloc()"); exit(1); } assert( ws->ws_rtrmac > (unsigned char*) 1); memcpy (ws->ws_rtrmac, wh->i_addr3, 6); time_print("Got arp reply from (%s)\n", mac2str(ws->ws_rtrmac)); return; } }
void CSwitchMgr::delMacMap(const INT1* mac) { if (NULL == mac) return; INT1 macStr[20] = {0}; mac2str((UINT1*)mac, macStr); LOG_DEBUG_FMT("before delete mapping mac[%s], m_macMap size[%lu] ...", macStr, m_macMap.size()); #if 0 //m_mutex.lock(); m_rwlock.wlock(); #if 1 m_macSockfdMap.erase(macStr); #else m_macSockfdMap.remove(macStr); #endif //m_mutex.unlock(); m_rwlock.unlock(); #else m_macMap.erase(macStr); #endif LOG_DEBUG_FMT("after delete mapping mac[%s], m_macMap size[%lu] ...", macStr, m_macMap.size()); }
int send_mac( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, uint8_t *value) { char *Buffer = (char*)mac2str(value); int ret = send_line( client, msg_type, msg_extra, fmt, Buffer); free(Buffer); return ret; }
void save_state() { FILE* f; struct node_info* node = nodes; f = fopen("stumbler.log", "w"); if (!f) { perror("fopen()"); exit(1); } while (node) { struct tm* t; char tim[16]; t = localtime( (time_t*) &node->seen.tv_sec); if (!t) { perror("localtime()"); exit(1); } tim[0] = 0; strftime(tim, sizeof(tim), "%H:%M:%S", t); fprintf(f, "%s %s %s %2d %s 0x%.2x\n", tim, mac2str(node->mac), wep2str(node->wep), node->chan, ssid2str(node), node->max); node = node->next; } fclose(f); }
void display_node(struct node_info* node) { int x = 0; int y = 0; int i; char chan[3]; char* ssid = 0; int sig, max, left, noise; char* wep = 0; y = node->pos; if (y == -1) // offscreen return; assert(y < LINES); // MAC mvaddstr(y, x, mac2str(node->mac)); x += 6*3; // WEP wep = wep2str(node->wep); assert(wep); mvaddstr(y, x, wep); x += strlen(wep); x++; // CHAN sprintf(chan, "%.2d", node->chan); mvaddstr(y, x, chan); x += 3; // ssid ssid = ssid2str(node); assert(ssid); mvaddstr(y, x, ssid); x += strlen(ssid); x++; left = COLS - x - 1; sig = (int) ( ((double)node->signal)*left/100.0 ); noise=(int) ( ((double)node->noise)*left/100.0 ); max = (int) ( ((double)node->max)*left/100.0 ); // SIGNAL BAR for (i = 0; i < noise; i++) mvaddch(y, x++, 'N'); for (; i < sig; i++) mvaddch(y,x++, 'X'); for (; i < max; i++) mvaddch(y,x++, ' '); mvaddch(y,x++, '|'); for (; x < COLS-1; x++) mvaddch(y, x, ' '); assert (x <= COLS); }
static void stuff_for_us(struct wstate *ws, struct ieee80211_frame* wh, int len) { int type,stype; unsigned char *body = (unsigned char*) (wh+1); type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; // CTL if (type == IEEE80211_FC0_TYPE_CTL) { proc_ctl(ws, stype); return; } // MGM if (type == IEEE80211_FC0_TYPE_MGT) { proc_mgt(ws, stype, body); return; } /* Data */ if (type == IEEE80211_FC0_TYPE_DATA && stype == IEEE80211_FC0_SUBTYPE_DATA) { proc_data(ws, wh, len); return; } #if 0 printf ("Got frame for us (type=%x stype=%x) from=(%s) len=%d\n", type, stype, mac2str(wh->i_addr2), len); #endif }
void read_preq(struct params *p, struct ieee80211_frame *wh, int len) { unsigned char *ptr; unsigned char *end; unsigned char macs[6*3]; ptr = (unsigned char*) (wh+1); /* ssid */ if (*ptr != 0) { printf("weird pr %x\n", *ptr); return; } ptr++; end = ptr + (*ptr) + 1; *end = 0; ptr++; mac2str(macs, wh->i_addr2); printf("Probe request for [%s] from %s\n", ptr, macs); if ((strcmp(ptr, "") == 0) || (strcmp(ptr, p->ssid) == 0)) send_pres(p, wh->i_addr2); }
void read_assoc(struct params *p, struct ieee80211_frame *wh, int len) { unsigned char *ptr; unsigned char *end; unsigned char macs[6*3]; if (memcmp(wh->i_addr1, p->mac, 6) != 0) return; ptr = (unsigned char*) (wh+1); ptr += 2; /* capa */ ptr += 2; /* list interval */ /* ssid */ if (*ptr != 0) { printf("weird pr %x\n", *ptr); return; } ptr++; end = ptr + (*ptr) + 1; *end = 0; ptr++; mac2str(macs, wh->i_addr2); printf("Assoc request for [%s] from %s\n", ptr, macs); if (strcmp(ptr, p->ssid) == 0) send_assoc(p, wh->i_addr2); }
void CSwitchMgr::addMacMap(const INT1* mac, CSmartPtr<CSwitch>& sw) { if (NULL == mac) return; INT1 macStr[20] = {0}; mac2str((UINT1*)mac, macStr); LOG_DEBUG_FMT("before add mapping mac[%s], m_macMap size[%lu] ...", macStr, m_macMap.size()); #if 0 //m_mutex.lock(); m_rwlock.wlock(); #if 1 m_macSockfdMap.insert(CMacSockfdMap::value_type(macStr, sockfd)); #else m_macSockfdMap.insert(macStr, sockfd); #endif //m_mutex.unlock(); m_rwlock.unlock(); #else if (!m_macMap.insert(macStr, sw)) LOG_WARN_FMT("add mapping mac[%s] failed !", macStr); #endif LOG_DEBUG_FMT("after add mapping mac[%s], m_macMap size[%lu] ...", macStr, m_macMap.size()); }
static void stuff_for_net(struct wstate *ws, struct ieee80211_frame* wh, int rd) { int type, stype; type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; if (type == IEEE80211_FC0_TYPE_DATA && stype == IEEE80211_FC0_SUBTYPE_DATA) { int dlen = rd - sizeof(struct ieee80211_frame); if (ws->ws_state == SPOOF_MAC) { unsigned char mac[6]; if (wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) { memcpy(mac, wh->i_addr3, 6); } else if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) { memcpy(mac, wh->i_addr1, 6); } else assert(0); if (mac[0] == 0xff || mac[0] == 0x1) return; memcpy(ws->ws_mymac, mac, 6); time_print("Trying to use MAC=(%s)\n", mac2str(ws->ws_mymac)); ws->ws_state = FOUND_VICTIM; return; } // wep data! if ( (wh->i_fc[1] & IEEE80211_FC1_WEP) && dlen > (4+8+4)) { got_wep(ws, wh, rd); } } }
int get_packet_info(struct ieee80211_frame* wh, unsigned char* body, int bodylen, struct node_info* node) { int type, stype; node->chan = chaninfo.chan; node->wep = -1; node->ssid[0] = 0; node->ap = -1; type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; if (type == IEEE80211_FC0_TYPE_CTL) return 0; #if 0 if (wh->i_addr2[0] != 0) { mvprintw(30,30,"%s %x",mac2str(wh->i_addr2), wh->i_fc[0]); } #endif stype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; if (type == IEEE80211_FC0_TYPE_MGT && stype == IEEE80211_FC0_SUBTYPE_BEACON) { get_beacon_info(body, bodylen, node); node->ap = 1; } else if (type == IEEE80211_FC0_TYPE_DATA && stype == IEEE80211_FC0_SUBTYPE_DATA) { if (wh->i_fc[1] & IEEE80211_FC1_WEP) { unsigned char* iv; node->wep = CRYPT_WEP; iv = body; iv += 3; // extended IV? if (*iv & (1 << 1)) { #if 0 node->wep = CRYPT_WPA; mvprintw(20,20, "shei"); exit(1); #endif } } if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) node->ap = 1; else node->ap = 0; } memcpy(node->mac, wh->i_addr2, 6); return 1; }
/* * arp_callback_duplicated -- IP アドレス重複検出用コールバック関数 */ BOOL arp_callback_duplicated (UB *shost) { static UB shost_addr[sizeof("00:00:00:00:00:00")]; mac2str((char*)shost_addr, shost); syslog(LOG_ERROR, "[Pico_Std_Sample] IP address duplicated: %s", shost_addr); return FALSE; }
BOOL arp_callback_duplicated (UB *shost) { static UB shost_addr[sizeof("00:00:00:00:00:00")]; mac2str(shost_addr, shost); syslog(LOG_ERROR, "[NSERV] IP address duplicated: %s", shost_addr); return FALSE; }
void PadMac(PCHAR pDst) { PCHAR pCur; pCur = pDst; strcpy(pCur, "hwid=01+"); pCur += 8; mac2str(Sys_pMacAddress, pCur); ChangeSeparator(pCur, '-', '+'); }
static void decrypt_arpreq(struct wstate *ws, struct ieee80211_frame* wh, int rd) { unsigned char* body; int bodylen; unsigned char clear[36]; unsigned char* ptr; struct arphdr* h; int i; body = (unsigned char*) wh+sizeof(*wh); ptr = clear; // calculate clear-text memcpy(ptr, S_LLC_SNAP_ARP, sizeof(S_LLC_SNAP_ARP)-1); ptr += sizeof(S_LLC_SNAP_ARP) -1; h = (struct arphdr*)ptr; h->ar_hrd = htons(ARPHRD_ETHER); h->ar_pro = htons(ETHERTYPE_IP); h->ar_hln = 6; h->ar_pln = 4; h->ar_op = htons(ARPOP_REQUEST); ptr += sizeof(*h); memcpy(ptr, wh->i_addr3, 6); bodylen = rd - sizeof(*wh) - 4 - 4; ws->ws_clen = bodylen; ws->ws_cipher = (unsigned char*) malloc(ws->ws_clen); if (!ws->ws_cipher) { perror("malloc()"); exit(1); } ws->ws_dpi.pi_prga = (unsigned char*) malloc(ws->ws_clen); if (!ws->ws_dpi.pi_prga) { perror("malloc()"); exit(1); } memcpy(ws->ws_cipher, &body[4], ws->ws_clen); memcpy(ws->ws_dpi.pi_iv, body, 3); memset(ws->ws_dpi.pi_prga, 0, ws->ws_clen); for(i = 0; i < (8+8+6); i++) { ws->ws_dpi.pi_prga[i] = ws->ws_cipher[i] ^ clear[i]; } ws->ws_dpi.pi_len = i; time_print("Got ARP request from (%s)\n", mac2str(wh->i_addr3)); }
void client_insert(struct params *p, struct client *c) { #if 1 do { char mac[6*3]; mac2str(mac, c->mac); printf("Adding client %s\n", mac); } while(0); #endif c->next = p->clients; p->clients = c; }
int main(int argc,char **argv) { struct sockaddr_in *addr; struct ifreq ifr; char *name,*address; int sockfd; u_int8_t mac[IFHWADDRLEN]; if(argc != 2) usage(argv[0]); else name = argv[1]; sockfd = socket(AF_INET,SOCK_DGRAM,0); strncpy(ifr.ifr_name,name,IFNAMSIZ-1); if(ioctl(sockfd,SIOCGIFADDR,&ifr) == -1) { perror("ioctl error"); exit(1); } addr = (struct sockaddr_in *)&(ifr.ifr_addr); address = inet_ntoa(addr->sin_addr); printf("inet addr: %s ",address); if(ioctl(sockfd,SIOCGIFBRDADDR,&ifr) == -1) { perror("ioctl error"); exit(1); } addr = (struct sockaddr_in *)&ifr.ifr_broadaddr; address = inet_ntoa(addr->sin_addr); printf("broad addr: %s ",address); if(ioctl(sockfd,SIOCGIFNETMASK,&ifr) == -1) { perror("ioctl error"); exit(1); } addr = (struct sockaddr_in *)&ifr.ifr_addr; address = inet_ntoa(addr->sin_addr); printf("inet mask: %s ",address); strncpy(ifr.ifr_name,name,IFNAMSIZ-1); if(ioctl(sockfd,SIOCGIFHWADDR,&ifr) == -1) { perror("ioctl error"); exit(1); } memcpy(mac,ifr.ifr_hwaddr.sa_data,IFHWADDRLEN); printf("mac addr is: %s\n",mac2str(mac)); return 0; }
CSmartPtr<CSwitch> CSwitchMgr::getSwitchByMac(const INT1* mac) { CSmartPtr<CSwitch> sw(NULL); if (NULL == mac) return sw; INT1 macStr[20] = {0}; mac2str((UINT1*)mac, macStr); CMacHMap::CPair* item = NULL; if (m_macMap.find(macStr, &item)) sw = item->second; return sw; }
/* Saves the union ipt_targinfo in parsable form to stdout. */ static void CLUSTERIP_save(const void *ip, const struct xt_entry_target *target) { const struct ipt_clusterip_tgt_info *cipinfo = (const struct ipt_clusterip_tgt_info *)target->data; /* if this is not a new entry, we don't need to save target * parameters */ if (!cipinfo->flags & CLUSTERIP_FLAG_NEW) return; printf("--new --hashmode %s --clustermac %s --total-nodes %d --local-node %d --hash-init %u", hashmode2str(cipinfo->hash_mode), mac2str(cipinfo->clustermac), cipinfo->num_total_nodes, cipinfo->local_nodes[0], cipinfo->hash_initval); }
int duplicate(struct params *p, struct ieee80211_frame *wh, int rc) { struct client *c; int s; if (!frame_type(wh, IEEE80211_FC0_TYPE_DATA, IEEE80211_FC0_SUBTYPE_DATA)) return 0; s = seqno(wh); c = client_find(p, wh->i_addr2); if (!c) { c = malloc(sizeof(*c)); if (!c) err(1, "malloc()"); memset(c, 0, sizeof(*c)); memcpy(c->mac, wh->i_addr2, 6); c->seq = s-1; client_insert(p, c); } if (wh->i_fc[1] & IEEE80211_FC1_RETRY) { if ( (s <= c->seq) && ((c->seq - s ) < 5)) { #if 0 printf("Dup seq %d prev %d\n", s, c->seq); #endif return 1; } } #if 0 do { char mac[3*6]; mac2str(mac, c->mac); printf("%s seq %d prev %d\n", mac, s, c->seq); } while (0); #endif c->seq = s; return 0; }
/* Prints out the targinfo. */ static void CLUSTERIP_print(const void *ip, const struct xt_entry_target *target, int numeric) { const struct ipt_clusterip_tgt_info *cipinfo = (const struct ipt_clusterip_tgt_info *)target->data; if (!cipinfo->flags & CLUSTERIP_FLAG_NEW) { printf("CLUSTERIP"); return; } printf("CLUSTERIP hashmode=%s clustermac=%s total_nodes=%u local_node=%u hash_init=%u", hashmode2str(cipinfo->hash_mode), mac2str(cipinfo->clustermac), cipinfo->num_total_nodes, cipinfo->local_nodes[0], cipinfo->hash_initval); }
/* Process auto-applied options from the database. read_ap_beacon should be called before this. */ void process_auto_options(void) { char **argv = NULL; int argc = 0, i = 0; char *bssid = NULL, *ssid = NULL; if(get_auto_detect_options()) { bssid = (char *) mac2str(get_bssid(), ':'); if(bssid) { /* If we didn't get the SSID from the beacon packet, check the database */ if(get_ssid() == NULL) { ssid = get_db_ssid(bssid); if(ssid) { set_ssid(ssid); free(ssid); } } argv = auto_detect_settings(bssid, &argc); if(argc > 1 && argv != NULL) { /* Process the command line arguments */ process_arguments(argc, argv); /* Clean up argument memory allocation */ for(i=0; i<argc; i++) { free(argv[i]); } free(argv); } free(bssid); } } return; }
void print_network(struct wl_network_t* wl_network) { printk("%s ", mac2str(wl_network->bssid.octet)); printk("\"%s\"", ssid2str(&wl_network->ssid)); printk(" RSSI %d dBm ", wl_network->rssi); switch (wl_network->enc_type) { case ENC_TYPE_WEP : printk(" (WEP encryption)"); break; case ENC_TYPE_TKIP : printk(" (TKIP encryption)"); break; case ENC_TYPE_CCMP : printk(" (CCMP encryption)"); break; case ENC_TYPE_NONE : break; } printk("\n"); }
ER dhcp_open(T_IF_SOFTC *ic) { static UB shost_addr[sizeof("00:00:00:00:00:00") + 1]; ER ercd; /* DHCPによるIPアドレス取得 */ memcpy(Dhcp.macaddr, ic->ifaddr.lladdr, ETHER_ADDR_LEN); mac2str(shost_addr, Dhcp.macaddr); syslog(LOG_NOTICE, "[get_dhcp_addr] started on MAC Addr: %s.", shost_addr); dhcp_packet = (DHCP_PACKET *)udp_rbuf; ercd = get_dhcp_addr(&Dhcp); if(ercd == E_OK) { /* インタフェースにIPv4アドレスを設定する */ in4_add_ifaddr((T_IN4_ADDR)str2ip(Dhcp.ipaddr), (T_IN4_ADDR)str2ip(Dhcp.maskaddr)); } return ercd; }
cmd_state_t cmd_status(int argc, char* argv[], void* ctx) { struct net_cfg *ncfg = ctx; struct wl_network_t* net; uint8_t mac[WL_MAC_ADDR_LENGTH]; printk("wl_api version " WL_API_RELEASE_NAME "\n"); /* print mac address */ if (wl_get_mac_addr(mac) != WL_SUCCESS) { printk("failed to get mac address\n"); return CMD_DONE; } printk("hw addr: %s\n", mac2str(mac)); /* print network info */ net = wl_get_current_network(); printk("link status: "); if (!net) { printk("down\n"); return CMD_DONE; } print_network(net); /* print ip address */ if (netif_is_up(netif_default)) printk("ip addr: %s\n", ip2str(netif_default->ip_addr)); else printk("ip addr: none\n"); printk("dhcp : "); if (ncfg->dhcp_enabled) { printk("enabled\n"); } else { printk("disabled\n"); } return CMD_DONE; }
void read_auth(struct params *p, struct ieee80211_frame *wh, int len) { unsigned short *ptr; char mac[6*3]; if (memcmp(wh->i_addr1, p->mac, 6) != 0) return; ptr = (unsigned short*) (wh+1); if (le16toh(*ptr) != 0) { printf("Unknown auth algo %d\n", le16toh(*ptr)); return; } ptr++; if (le16toh(*ptr) == 1) { mac2str(mac, wh->i_addr2); printf("Got auth from %s\n", mac); send_auth(p, wh->i_addr2); } else { printf("Weird seq in auth %d\n", le16toh(*ptr)); } }
static void read_mac(char *ifname, n2n_mac_t mac_addr) { int _sock, res; struct ifreq ifr; macstr_t mac_addr_buf; memset(&ifr, 0, sizeof(struct ifreq)); /* Dummy socket, just to make ioctls with */ _sock = socket(PF_INET, SOCK_DGRAM, 0); strcpy(ifr.ifr_name, ifname); res = ioctl(_sock, SIOCGIFHWADDR, &ifr); if (res < 0) { perror("Get hw addr"); } else memcpy(mac_addr, ifr.ifr_ifru.ifru_hwaddr.sa_data, 6); traceNormal("Interface %s has MAC %s", ifname, mac2str(mac_addr_buf, mac_addr)); close(_sock); }
void parse_wps_settings(const u_char *packet, struct pcap_pkthdr *header, char *target, int passive, int mode, int source) { struct radio_tap_header *rt_header = NULL; struct dot11_frame_header *frame_header = NULL; struct libwps_data *wps = NULL; enum encryption_type encryption = NONE; char *bssid = NULL, *ssid = NULL, *lock_display = NULL; int wps_parsed = 0, probe_sent = 0, channel = 0, rssi = 0; static int channel_changed = 0; wps = malloc(sizeof(struct libwps_data)); memset(wps, 0, sizeof(struct libwps_data)); if(packet == NULL || header == NULL || header->len < MIN_BEACON_SIZE) { goto end; } rt_header = (struct radio_tap_header *) radio_header(packet, header->len); frame_header = (struct dot11_frame_header *) (packet + rt_header->len); /* If a specific BSSID was specified, only parse packets from that BSSID */ if(!is_target(frame_header)) { goto end; } set_ssid(NULL); bssid = (char *) mac2str(frame_header->addr3, ':'); if(bssid) { if((target == NULL) || (target != NULL && strcmp(bssid, target) == 0)) { channel = parse_beacon_tags(packet, header->len); rssi = signal_strength(packet, header->len); ssid = (char *) get_ssid(); if(target != NULL && channel_changed == 0) { ualarm(0, 0); change_channel(channel); channel_changed = 1; } if(frame_header->fc.sub_type == PROBE_RESPONSE || frame_header->fc.sub_type == SUBTYPE_BEACON) { wps_parsed = parse_wps_parameters(packet, header->len, wps); } if(!is_done(bssid) && (get_channel() == channel || source == PCAP_FILE || !get_channel())) { if(frame_header->fc.sub_type == SUBTYPE_BEACON && mode == SCAN && !passive && should_probe(bssid)) { send_probe_request(get_bssid(), get_ssid()); probe_sent = 1; } if(!insert(bssid, ssid, wps, encryption, rssi)) { update(bssid, ssid, wps, encryption); } else if(wps->version > 0) { switch(wps->locked) { case WPSLOCKED: lock_display = YES; break; case UNLOCKED: case UNSPECIFIED: lock_display = NO; break; } cprintf(INFO, "%17s %2d %.2d %d.%d %s %s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid); } if(probe_sent) { update_probe_count(bssid); } /* * If there was no WPS information, then the AP does not support WPS and we should ignore it from here on. * If this was a probe response, then we've gotten all WPS info we can get from this AP and should ignore it from here on. */ if(!wps_parsed || frame_header->fc.sub_type == PROBE_RESPONSE) { mark_ap_complete(bssid); } } } /* Only update received signal strength if we are on the same channel as the AP, otherwise power measurements are screwy */ if(channel == get_channel()) { update_ap_power(bssid, rssi); } free(bssid); bssid = NULL; }
void parse_wps_settings(const u_char *packet, struct pcap_pkthdr *header, char *target, int passive, int mode, int source) { struct radio_tap_header *rt_header = NULL; struct dot11_frame_header *frame_header = NULL; struct libwps_data *wps = NULL; enum encryption_type encryption = NONE; char *bssid = NULL, *ssid = NULL, *lock_display = NULL; int wps_parsed = 0, probe_sent = 0, channel = 0, rssi = 0; static int channel_changed = 0; char info_manufac[500]; char info_modelnum[500]; char info_modelserial[500]; wps = malloc(sizeof(struct libwps_data)); memset(wps, 0, sizeof(struct libwps_data)); if(packet == NULL || header == NULL || header->len < MIN_BEACON_SIZE) { goto end; } rt_header = (struct radio_tap_header *) radio_header(packet, header->len); frame_header = (struct dot11_frame_header *) (packet + rt_header->len); /* If a specific BSSID was specified, only parse packets from that BSSID */ if(!is_target(frame_header)) { goto end; } set_ssid(NULL); bssid = (char *) mac2str(frame_header->addr3, ':'); set_bssid((unsigned char *) frame_header->addr3); if(bssid) { if((target == NULL) || (target != NULL && strcmp(bssid, target) == 0)) { channel = parse_beacon_tags(packet, header->len); rssi = signal_strength(packet, header->len); ssid = (char *) get_ssid(); if(target != NULL && channel_changed == 0) { ualarm(0, 0); change_channel(channel); channel_changed = 1; } if(frame_header->fc.sub_type == PROBE_RESPONSE || frame_header->fc.sub_type == SUBTYPE_BEACON) { wps_parsed = parse_wps_parameters(packet, header->len, wps); } if(!is_done(bssid) && (get_channel() == channel || source == PCAP_FILE)) { if(frame_header->fc.sub_type == SUBTYPE_BEACON && mode == SCAN && !passive && should_probe(bssid)) { send_probe_request(get_bssid(), get_ssid()); probe_sent = 1; } if(!insert(bssid, ssid, wps, encryption, rssi)) { update(bssid, ssid, wps, encryption); } else if(wps->version > 0) { switch(wps->locked) { case WPSLOCKED: lock_display = YES; break; case UNLOCKED: case UNSPECIFIED: lock_display = NO; break; } //ideas made by kcdtv if(get_chipset_output == 1) //if(1) { if (c_fix == 0) { //no use a fixed channel cprintf(INFO,"Option (-g) REQUIRES a channel to be set with (-c)\n"); exit(0); } FILE *fgchipset=NULL; char cmd_chipset[4000]; char cmd_chipset_buf[4000]; char buffint[5]; char *aux_cmd_chipset=NULL; memset(cmd_chipset, 0, sizeof(cmd_chipset)); memset(cmd_chipset_buf, 0, sizeof(cmd_chipset_buf)); memset(info_manufac, 0, sizeof(info_manufac)); memset(info_modelnum, 0, sizeof(info_modelnum)); memset(info_modelserial, 0, sizeof(info_modelserial)); strcat(cmd_chipset,"reaver -0 -s y -vv -i "); //need option to stop reaver in m1 stage strcat(cmd_chipset,get_iface()); strcat(cmd_chipset, " -b "); strcat(cmd_chipset, mac2str(get_bssid(),':')); strcat(cmd_chipset," -c "); snprintf(buffint, sizeof(buffint), "%d",channel); strcat(cmd_chipset, buffint); //cprintf(INFO,"\n%s\n",cmd_chipset); if ((fgchipset = popen(cmd_chipset, "r")) == NULL) { printf("Error opening pipe!\n"); //return -1; } while (fgets(cmd_chipset_buf, 4000, fgchipset) != NULL) { //[P] WPS Manufacturer: xxx //[P] WPS Model Number: yyy //[P] WPS Model Serial Number: zzz //cprintf(INFO,"\n%s\n",cmd_chipset_buf); aux_cmd_chipset = strstr(cmd_chipset_buf,"[P] WPS Manufacturer:"); if(aux_cmd_chipset != NULL) { //bug fix by alxchk strncpy(info_manufac, aux_cmd_chipset+21, sizeof(info_manufac)); } aux_cmd_chipset = strstr(cmd_chipset_buf,"[P] WPS Model Number:"); if(aux_cmd_chipset != NULL) { //bug fix by alxchk strncpy(info_modelnum, aux_cmd_chipset+21, sizeof(info_modelnum)); } aux_cmd_chipset = strstr(cmd_chipset_buf,"[P] WPS Model Serial Number:"); if(aux_cmd_chipset != NULL) { //bug fix by alxchk strncpy(info_modelserial, aux_cmd_chipset+28, sizeof(info_modelserial)); } } //cprintf(INFO,"\n%s\n",info_manufac); info_manufac[strcspn ( info_manufac, "\n" )] = '\0'; info_modelnum[strcspn ( info_modelnum, "\n" )] = '\0'; info_modelserial[strcspn ( info_modelserial, "\n" )] = '\0'; if(pclose(fgchipset)) { //printf("Command not found or exited with error status\n"); //return -1; } } if (o_file_p == 0) { cprintf(INFO, "%17s %2d %.2d %d.%d %s %s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid); } else { if(get_chipset_output == 1) { cprintf(INFO, "%17s|%2d|%.2d|%d.%d|%s|%s|%s|%s|%s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid, info_manufac, info_modelnum, info_modelserial); }else { cprintf(INFO, "%17s|%2d|%.2d|%d.%d|%s|%s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid); } }