├── wobs ├── wobs.png ├── src ├── obj │ └── .gitignore ├── wlan.c ├── add_dev.c └── wobs.c ├── include ├── wlan.h ├── global.h └── wobs.h ├── makefile ├── TODO ├── README.md └── LICENSE /wobs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/observ3r/wobs/HEAD/wobs -------------------------------------------------------------------------------- /wobs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/observ3r/wobs/HEAD/wobs.png -------------------------------------------------------------------------------- /src/obj/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /include/wlan.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define BUFSIZE 1024 6 | 7 | void wlan_proc(u_char *buf); 8 | void *wlan_snif(void* unused); 9 | gchar *get_src_mac(u_char buf[]); 10 | char get_type(char buf); 11 | 12 | pthread_t listener_thread; 13 | -------------------------------------------------------------------------------- /include/global.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef struct device { 5 | gchar *mac; 6 | char probes[80]; 7 | gchar ven[9]; 8 | gchar *time; 9 | int ap; 10 | GtkTreeIter iter; 11 | }device; 12 | 13 | struct node { 14 | device data; 15 | struct node *next; 16 | }; 17 | 18 | GtkWidget *g_interface_input; 19 | struct node* g_head; 20 | 21 | device *add_dev(gchar *input_mac); 22 | int *mac_trans(char *input_mac,char *ven); 23 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | IDIR =./include 2 | CC=gcc 3 | CFLAGS=-I$(IDIR) `pkg-config --cflags gtk+-2.0` 4 | 5 | SDIR=./src 6 | ODIR=./src/obj 7 | LDIR =./lib 8 | 9 | LIBS=`pkg-config --libs gtk+-2.0` 10 | 11 | _DEPS = wobs.h wlan.h global.h 12 | DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) 13 | 14 | _OBJ = wobs.o wlan.o add_dev.o 15 | OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) 16 | 17 | 18 | $(ODIR)/%.o: $(SDIR)/%.c $(DEPS) 19 | $(CC) -c -o $@ $< $(CFLAGS) 20 | 21 | wobs: $(OBJ) 22 | gcc -o $@ $^ $(CFLAGS) $(LIBS) 23 | 24 | .PHONY: clean 25 | 26 | clean: 27 | rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ 28 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | ----------------------------------------- 2 | ------------- WOBS ---------------------- 3 | ----------------------------------------- 4 | -Fix Update segfault 5 | -monitor mode still not implemented. 6 | -show most recent packet.. or all packets. 7 | -finish parsing probes 8 | -Icons for listen and device(s). Insert icon txt 9 | -listening 10 | change to fixed size (mac) 11 | enter inferface name in GUI 12 | -more error handling 13 | -about 14 | -add settings panel 15 | Collect only APs or only Clients 16 | timeout value 17 | max devices 18 | verbosity, how much to collect 19 | -Save list 20 | -Open list 21 | -Triangulate signal 22 | -Single out only related to certain device(s), tiers.. 23 | -simplify create_list and stuff 24 | -run cppcheck 25 | -------------------------------------------------------------------------------- /include/wobs.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef struct gui_list { 6 | GtkListStore *model; 7 | GtkTreeIter iter; 8 | GtkWidget *tree_view; 9 | GtkCellRenderer *cell; 10 | GtkTreeViewColumn *column; 11 | GtkWidget *scrolled_window; 12 | }gui_list; 13 | 14 | gui_list devices; 15 | gui_list info; 16 | 17 | void lstn(); 18 | void del_dev(gchar *mac); 19 | 20 | static void info_popup(GtkTreeView *view, 21 | GtkTreePath *ipath, 22 | GtkTreeViewColumn *col, 23 | gpointer user_data); 24 | 25 | gui_list create_list(char *title,gui_list liststruct); 26 | 27 | static void update_settings(GtkWidget *widget, 28 | gpointer data); 29 | 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ======= 2 | wobs 3 | ==== 4 | 5 | Detects near-by devices such as cell phones, tablets, and laptops. Does this through 802.11, Bluetooth, cell phone protocols, etc.. 6 | 7 | WOBS: A wireless observer. The final release will passively detect devices through 802.11 (WiFi), Bluetooth, and cell phone traffic. It will also display information about each device; i.e. MAC address, last time heard from, probes (networks the device is searching for or its SSID), capabilities, signal strength, device name, etc... Also, if enough data from multiple points (multiple other, observing, devices) is collected, the device in question's location through trilateration. There could also be a notification system that would send a email out when a new device has been spotted. 8 | 9 | So, basically, if someone brings a cell phone near your house (or wherever you have this setup) this system will alert you to its presence. Actually, not just cell phones, but tablets, laptops, etc... 10 | 11 | I know projects like Kismet already do most of this. WOBS would be more of a GUI alternative and more aimed at passively detecting ANY device in the area. 12 | 13 | ====== 14 | COMPILE 15 | ====== 16 | Just run make: 17 | make 18 | 19 | ====== 20 | RUNNING 21 | ====== 22 | ./wobs 23 | 24 | Currently it will not set the "Type". The default is client, so you won't see any Access Points. This is because I changed the way it's parsing packets.. and have not finished it. 25 | 26 | Another note, it doesn't know how to handle some packets; so for best results, be sure you're not connected to a network. 27 | 28 | And another note, wobs will create an interface called "wob0". It will do this with whatever interface is entered in the "Interface" text box at the moment of clicking "Listen". Currently, if you run two instances of wobs at once, one of them will try to create another wob0 interface, so watch out. 29 | >>>>>>> 0c22cfab609204d2ca4a3339678b71d5a982834f 30 | -------------------------------------------------------------------------------- /src/wlan.c: -------------------------------------------------------------------------------- 1 | #include "wlan.h" 2 | #include "global.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | void *wlan_snif(void *unused) { 13 | int sok; 14 | int sockopt; 15 | u_char buf[BUFSIZE]; 16 | struct ifreq ifopts; 17 | 18 | if ((sok = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) == -1) { 19 | perror("sniffer: socket"); 20 | exit(-1); 21 | } 22 | const char *if_name=gtk_entry_get_text((GtkEntry*)g_interface_input); 23 | char iw_command[50]; 24 | char wob_if[] = "wob0"; 25 | 26 | /* Not very robust.. the new interface name */ 27 | if (sizeof(if_name)>10) { 28 | sprintf(iw_command,"iw dev wlan0 interface add wob0 type monitor"); 29 | } else { 30 | sprintf(iw_command,"iw dev %s interface add wob0 type monitor",if_name); 31 | } 32 | 33 | system(iw_command); 34 | system("ifconfig wob0 up"); 35 | 36 | strncpy(ifopts.ifr_name,wob_if,4); 37 | ioctl(sok, SIOCGIFFLAGS, &ifopts); 38 | ifopts.ifr_flags |= IFF_PROMISC; 39 | ioctl(sok, SIOCSIFFLAGS, &ifopts); 40 | 41 | setsockopt(sok,SOL_SOCKET,SO_BINDTODEVICE,wob_if,4); 42 | 43 | while(1){ 44 | recvfrom(sok,buf,BUFSIZE,0,NULL,NULL); 45 | wlan_proc(buf); 46 | } 47 | return; 48 | } 49 | 50 | void wlan_proc(u_char *buf) { 51 | /* TODO: Make time function */ 52 | 53 | /************ Note ******************** 54 | * Was getting strange packets, could * 55 | * not interpret them correctly. This * 56 | * way of parsing (tree parsing?) * 57 | * probably isn't the best... Email me* 58 | * with suggestions or ideas. Thanks! * 59 | *************************************/ 60 | if (buf[2]>50) { 61 | //printf("Strange! %02x\n",buf[2]); 62 | //g_printf("mac:%s\n",get_src_mac(buf)); 63 | 64 | return; 65 | } 66 | //printf("Good! %02x\n",buf[2]); 67 | /************************************** 68 | * Get the input mac, then send it to * 69 | * the add_dev function so it can add * 70 | * it and perform other processing. * 71 | * add_dev returns a pointer to the * 72 | * device struct that we can fill. * 73 | **************************************/ 74 | 75 | gchar *input_mac = get_src_mac(buf); 76 | device *cdev = add_dev(input_mac); 77 | 78 | /* Now fill the device struct with * 79 | * more information from the packet */ 80 | 81 | /* Time */ 82 | time_t btime; 83 | struct tm *time_s; 84 | time(&btime); 85 | time_s=localtime(&btime); 86 | 87 | cdev->time=asctime(time_s); 88 | cdev->time[24]=0x00; 89 | 90 | /* Probes (will be specific to packet types) */ 91 | //g_scanf(cdev->probes,"none"); 92 | cdev->probes[0]=0x00; 93 | 94 | return; 95 | } 96 | 97 | gchar *get_src_mac(u_char buf[]) { 98 | uint s = (uint) buf[2]+10; 99 | gchar *src = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X", 100 | buf[s],buf[s+1],buf[s+2],buf[s+3],buf[s+4],buf[s+5]); 101 | return src; 102 | } 103 | 104 | char get_type(char buf) { 105 | return; 106 | } 107 | -------------------------------------------------------------------------------- /src/add_dev.c: -------------------------------------------------------------------------------- 1 | #include "wobs.h" 2 | #include "global.h" 3 | 4 | #include 5 | #include 6 | 7 | device *add_dev(gchar *input_mac) { 8 | /* Print time to test how long it takes */ 9 | #if 0 10 | time_s=localtime(&btime); 11 | printf("Loop through llist... Start: %s",asctime(time_s)); 12 | #endif 13 | 14 | device *dev; 15 | int known = 0; 16 | struct node *current = g_head; 17 | while (current != NULL) { 18 | if (strncmp(input_mac,current->data.mac,17)==0) { 19 | known = 1; 20 | dev = ¤t->data; 21 | break; 22 | } 23 | current = current->next; 24 | } 25 | 26 | /* print time to test how long it takes */ 27 | #if 0 28 | time_s=localtime(&btime); 29 | printf(" End: %s Done.\n",asctime(time_s)); 30 | #endif 31 | 32 | if (!known) { 33 | struct node* nDevice = malloc(sizeof(struct node)); 34 | nDevice->data.mac = g_strdup_printf("%s",input_mac); 35 | dev = &nDevice->data; 36 | nDevice->next = g_head; 37 | g_head = nDevice; 38 | mac_trans(dev->mac,dev->ven); 39 | 40 | GError *gerror; 41 | GdkPixbuf *pixbuf; 42 | GtkTextIter iter; 43 | 44 | /* For inserting Image 45 | * GtkTextIter txt_iter; 46 | * GtkTextBuffer *txt; 47 | * gtk_text_buffer_get_start_iter(txt,&txt_iter); 48 | * pixbuf = gdk_pixbuf_new_from_file("icon.ico",&gerror); 49 | * gtk_text_buffer_insert(txt,&txt_iter, 50 | * g_strdup_printf("MAC: %s",dev.mac),-1); 51 | * gtk_text_buffer_insert_pixbuf(txt,&txt_iter,pixbuf); 52 | */ 53 | 54 | gchar *txt; 55 | txt = g_strdup_printf("%s: %s device",dev->mac,dev->ven); 56 | gtk_list_store_prepend(GTK_LIST_STORE(devices.model),&dev->iter); 57 | gtk_list_store_set(GTK_LIST_STORE(devices.model), 58 | &dev->iter,0,txt,-1); 59 | } 60 | return dev; 61 | } 62 | 63 | int *mac_trans(char *input_mac,char *ven) { 64 | /* Using Wireshark's manuf file */ 65 | FILE *manuf; 66 | manuf = fopen("manuf.txt","r"); 67 | if (manuf!=NULL) { 68 | int ch; 69 | int i=1; 70 | int v=0; 71 | int o=0; 72 | char oth_mac[9]={0}; 73 | char working_mac[9]={0}; 74 | strncpy(working_mac,input_mac,8); 75 | while ((ch=fgetc(manuf))!=EOF) { 76 | switch(i) { 77 | case 1: /* Reading Mac */ 78 | switch (ch) { 79 | case 0x20: 80 | case 0x09: 81 | case 0x23: 82 | case 0x0a: 83 | if (strcmp(oth_mac,working_mac)==0) { 84 | i=2; 85 | } else { 86 | i=3; 87 | } 88 | break; 89 | default: 90 | oth_mac[o]=ch; 91 | o++; 92 | break; 93 | } 94 | break; 95 | case 2: /* Reading Vendor */ 96 | switch (ch) { 97 | case 0x20: 98 | case 0x09: 99 | case 0x0a: 100 | if (v!=0) { 101 | ven[v]=0x00; 102 | fclose(manuf); 103 | return 0; 104 | } 105 | break; 106 | default: 107 | ven[v]=ch; 108 | v++; 109 | } 110 | break; 111 | case 3: /* Reading Comment */ 112 | if (ch==0x0a) { 113 | v=0; 114 | o=0; 115 | i=1; 116 | } 117 | break; 118 | default: 119 | printf("Error at switch\n"); 120 | break; 121 | } 122 | 123 | } 124 | sprintf(ven,"Unknown"); 125 | } else { 126 | printf("Error: manuf.txt not found.\n\ 127 | Mac translation will be unavailable."); 128 | } 129 | fclose(manuf); 130 | } 131 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | <<<<<<< HEAD 202 | limitations under the License. 203 | ======= 204 | limitations under the License. 205 | >>>>>>> 0c22cfab609204d2ca4a3339678b71d5a982834f 206 | -------------------------------------------------------------------------------- /src/wobs.c: -------------------------------------------------------------------------------- 1 | #include "wobs.h" 2 | #include "wlan.h" 3 | #include "global.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int listener_state = 0; 11 | 12 | void lstn() { 13 | if (listener_state==0){ 14 | g_print("Starting listener...\n\n"); 15 | 16 | /* Spawn thread(s) */ 17 | if (pthread_create(&listener_thread, NULL, &wlan_snif, NULL)!=0) { 18 | g_print("ERROR: Failed to start 802.11 listener!\n"); 19 | return; 20 | } 21 | 22 | /* Add additional sniffers for new protocols here */ 23 | 24 | listener_state=1; 25 | }else{ 26 | g_print("Stopping listener...\n\n"); 27 | /* Send kill to thread */ 28 | int i; 29 | if (i=pthread_cancel(listener_thread)!=0) { 30 | g_print("ERROR %d: Failed to stop listener! (maybe already stopped)\n",i); 31 | } 32 | listener_state=0; 33 | 34 | /************************************************ 35 | * Clean up WLAN interface... Policy is that * 36 | * this function should not have to do anything * 37 | * with specific sniffers, so this is a bit of * 38 | * an exception. * 39 | ************************************************/ 40 | system("iw dev wob0 del"); 41 | } 42 | } 43 | 44 | void del_dev(gchar *mac) { 45 | struct node* current = g_head; 46 | struct node* previous; 47 | while (current != NULL) { 48 | if (mac==current->data.mac) { 49 | gtk_list_store_remove(GTK_LIST_STORE(devices.model), 50 | ¤t->data.iter); 51 | previous->next = current->next; 52 | free(current); 53 | break; 54 | } 55 | previous = current; 56 | current = current->next; 57 | } 58 | } 59 | 60 | static void info_popup(GtkTreeView *view, 61 | GtkTreePath *ipath, 62 | GtkTreeViewColumn *col, 63 | gpointer user_data) { 64 | GtkTreePath *dpath; 65 | GtkTreeIter iter; 66 | GtkWidget *popup=gtk_window_new(GTK_WINDOW_TOPLEVEL); 67 | g_signal_connect(G_OBJECT(popup),"destroy", 68 | G_CALLBACK(gtk_widget_destroy),NULL); 69 | gtk_container_set_border_width(GTK_CONTAINER(popup),5); 70 | gtk_widget_set_size_request(GTK_WIDGET(popup),300,200); 71 | gtk_window_set_resizable(GTK_WINDOW(popup),FALSE); 72 | gtk_window_set_position(GTK_WINDOW(popup), GTK_WIN_POS_CENTER); 73 | 74 | GtkWidget *mp_cont=gtk_vbox_new(FALSE,0); 75 | gtk_container_add(GTK_CONTAINER(popup),mp_cont); 76 | 77 | /* Frame */ 78 | GtkWidget *popup_frame = gtk_frame_new(""); 79 | gtk_frame_set_shadow_type(GTK_FRAME(popup_frame),GTK_SHADOW_ETCHED_IN); 80 | gtk_box_pack_start(GTK_BOX(mp_cont),popup_frame,TRUE,TRUE,0); 81 | GtkWidget *p_cont=gtk_vbox_new(FALSE,9); 82 | gtk_container_add(GTK_CONTAINER(popup_frame),p_cont); 83 | 84 | /* Close Button */ 85 | GtkWidget *close_button_cont=gtk_hbox_new(FALSE,0); 86 | gtk_box_pack_end(GTK_BOX(mp_cont),close_button_cont,FALSE,FALSE,3); 87 | GtkWidget *close_button=gtk_toggle_button_new_with_label("Close"); 88 | gtk_widget_set_size_request(GTK_WIDGET(close_button),60,35); 89 | gtk_box_pack_start(GTK_BOX(close_button_cont),close_button,TRUE,FALSE,0); 90 | g_signal_connect_swapped (close_button, "clicked", 91 | G_CALLBACK (gtk_widget_destroy),popup); 92 | 93 | struct node* current = g_head; 94 | gtk_tree_model_get_iter((GtkTreeModel*)devices.model,&iter,ipath); 95 | while (current != NULL) { 96 | dpath = gtk_tree_model_get_path((GtkTreeModel*)devices.model, 97 | ¤t->data.iter); 98 | if (gtk_tree_path_compare(dpath,ipath)==0) { 99 | /* Title */ 100 | gchar *mact=g_strdup_printf("Device %s\n",current->data.mac); 101 | gtk_window_set_title(GTK_WINDOW(popup),mact); 102 | 103 | /* MAC */ 104 | GtkWidget *mac_box=gtk_hbox_new(FALSE,0); 105 | gtk_box_pack_start(GTK_BOX(p_cont),mac_box,FALSE,FALSE,0); 106 | GtkWidget *mac_label=gtk_label_new("MAC:"); 107 | gtk_box_pack_start(GTK_BOX(mac_box),mac_label,FALSE,FALSE,2); 108 | gchar *mac_addr_label=g_strdup_printf("%s",current->data.mac); 109 | GtkWidget *mac_addr=gtk_label_new(mac_addr_label); 110 | gtk_box_pack_end(GTK_BOX(mac_box),mac_addr,FALSE,FALSE,2); 111 | 112 | /* Type */ 113 | GtkWidget *type_box=gtk_hbox_new(FALSE,0); 114 | gtk_box_pack_start(GTK_BOX(p_cont),type_box,FALSE,FALSE,0); 115 | GtkWidget *type_label=gtk_label_new("Type:"); 116 | gtk_box_pack_start(GTK_BOX(type_box),type_label,FALSE,FALSE,2); 117 | 118 | if (current->data.ap==1) { 119 | GtkWidget *type=gtk_label_new("Access Point"); 120 | gtk_box_pack_end(GTK_BOX(type_box),type,FALSE,FALSE,2); 121 | 122 | /* SSID */ 123 | GtkWidget *ssid_box=gtk_hbox_new(FALSE,0); 124 | gtk_box_pack_start(GTK_BOX(p_cont),ssid_box,FALSE,FALSE,0); 125 | GtkWidget *ssid_label=gtk_label_new("SSID:"); 126 | gtk_box_pack_start(GTK_BOX(ssid_box),ssid_label,FALSE,FALSE,2); 127 | gchar *ssidt=g_strdup_printf("%s",current->data.probes); 128 | GtkWidget *ssid=gtk_label_new(ssidt); 129 | gtk_box_pack_end(GTK_BOX(ssid_box),ssid,FALSE,FALSE,2); 130 | } else { 131 | GtkWidget *type=gtk_label_new("Client"); 132 | gtk_box_pack_end(GTK_BOX(type_box),type,FALSE,FALSE,2); 133 | 134 | /* Probes */ 135 | GtkWidget *prob_box=gtk_hbox_new(FALSE,0); 136 | gtk_box_pack_start(GTK_BOX(p_cont),prob_box,FALSE,FALSE,0); 137 | GtkWidget *probes_label=gtk_label_new("Probes:"); 138 | gtk_box_pack_start(GTK_BOX(prob_box),probes_label,FALSE,FALSE,2); 139 | gchar *probest=g_strdup_printf("%s",current->data.probes); 140 | GtkWidget *probes=gtk_label_new(probest); 141 | gtk_box_pack_end(GTK_BOX(prob_box),probes,FALSE,FALSE,2); 142 | } 143 | 144 | /* Vendor */ 145 | GtkWidget *ven_box=gtk_hbox_new(FALSE,0); 146 | gtk_box_pack_start(GTK_BOX(p_cont),ven_box,FALSE,FALSE,0); 147 | GtkWidget *ven_label=gtk_label_new("Vendor:"); 148 | gtk_box_pack_start(GTK_BOX(ven_box),ven_label,FALSE,FALSE,2); 149 | gchar *vent=g_strdup_printf("%s",current->data.ven); 150 | GtkWidget *ven=gtk_label_new(vent); 151 | gtk_box_pack_end(GTK_BOX(ven_box),ven,FALSE,FALSE,2); 152 | 153 | /* Time */ 154 | GtkWidget *time_box=gtk_hbox_new(FALSE,0); 155 | gtk_box_pack_start(GTK_BOX(p_cont),time_box,FALSE,FALSE,0); 156 | GtkWidget *time_label=gtk_label_new("Last Observed:"); 157 | gtk_box_pack_start(GTK_BOX(time_box),time_label,FALSE,FALSE,2); 158 | gchar *timet=g_strdup_printf("%s",current->data.time); 159 | GtkWidget *time=gtk_label_new(timet); 160 | gtk_box_pack_end(GTK_BOX(time_box),time,FALSE,FALSE,2); 161 | 162 | gtk_widget_show_all(popup); 163 | break; 164 | } 165 | current = current->next; 166 | } 167 | } 168 | 169 | gui_list create_list(char *title,gui_list liststruct) { 170 | liststruct.scrolled_window = gtk_scrolled_window_new(NULL,NULL); 171 | gtk_scrolled_window_set_policy( 172 | GTK_SCROLLED_WINDOW(liststruct.scrolled_window), 173 | GTK_POLICY_AUTOMATIC, 174 | GTK_POLICY_AUTOMATIC); 175 | 176 | liststruct.model=gtk_list_store_new(1,G_TYPE_STRING); 177 | liststruct.tree_view=gtk_tree_view_new(); 178 | gtk_scrolled_window_add_with_viewport( 179 | GTK_SCROLLED_WINDOW(liststruct.scrolled_window), 180 | liststruct.tree_view); 181 | gtk_tree_view_set_model(GTK_TREE_VIEW(liststruct.tree_view), 182 | GTK_TREE_MODEL(liststruct.model)); 183 | gtk_widget_show(liststruct.tree_view); 184 | 185 | liststruct.cell = gtk_cell_renderer_text_new (); 186 | liststruct.column = gtk_tree_view_column_new_with_attributes(title, 187 | liststruct.cell,"text", 0,NULL); 188 | 189 | gtk_tree_view_append_column(GTK_TREE_VIEW(liststruct.tree_view), 190 | GTK_TREE_VIEW_COLUMN(liststruct.column)); 191 | return liststruct; 192 | } 193 | static void update_settings(GtkWidget *widget, 194 | gpointer data) { 195 | printf("Updating\n\n"); 196 | int was_on; 197 | if (listener_state!=0){ 198 | lstn(); 199 | was_on=1; 200 | } 201 | gtk_list_store_remove(GTK_LIST_STORE(devices.model), 202 | &g_head->data.iter); 203 | struct node* del; 204 | if (g_head->next) { 205 | struct node* current = g_head->next; 206 | while (current != NULL) { 207 | gtk_list_store_remove(GTK_LIST_STORE(devices.model), 208 | ¤t->data.iter); 209 | del = current; 210 | current = current->next; 211 | free(del); 212 | } 213 | } 214 | memset(&g_head,0,sizeof(&g_head)); 215 | if (was_on){ 216 | lstn(); 217 | } 218 | printf("Done Updating\n\n"); 219 | } 220 | 221 | int main(int argc,char *argv[]) { 222 | GtkWidget *window; 223 | GtkWidget *main_view; 224 | GtkWidget *listen_button; 225 | GtkWidget *update_button; 226 | GtkWidget *cont; 227 | GtkWidget *top_bar; 228 | GtkWidget *bot_bar; 229 | 230 | GtkWidget *menu_bar; 231 | GtkWidget *file_menu; 232 | GtkWidget *file; 233 | GtkWidget *quit; 234 | GtkWidget *help; 235 | GtkWidget *edit; 236 | GtkWidget *pref; 237 | GtkWidget *save; 238 | GtkWidget *open; 239 | GtkWidget *about; 240 | GtkWidget *edit_menu; 241 | GtkWidget *help_menu; 242 | 243 | GtkWidget *promi; 244 | GtkWidget *moni; 245 | GtkWidget *interface_label; 246 | GtkWidget *interface_box; 247 | GtkWidget *settings_p; 248 | 249 | GtkWidget *ptext; 250 | GtkWidget *settings_frame; 251 | GtkWidget *icon; 252 | 253 | 254 | gtk_init(&argc,&argv); 255 | PangoFontDescription *monospace; 256 | PangoFontDescription *title_font; 257 | monospace = pango_font_description_from_string("Monospace"); 258 | title_font = pango_font_description_from_string("Sans"); 259 | pango_font_description_set_size(title_font,15*PANGO_SCALE); 260 | 261 | /* Setup the window */ 262 | window=gtk_window_new(GTK_WINDOW_TOPLEVEL); 263 | gtk_window_set_title(GTK_WINDOW(window),"WOBS - Wireless Observer"); 264 | g_signal_connect(G_OBJECT(window),"destroy", 265 | G_CALLBACK(gtk_main_quit),NULL); 266 | gtk_container_set_border_width(GTK_CONTAINER(window),10); 267 | gtk_widget_set_size_request(GTK_WIDGET(window),500,550); 268 | cont=gtk_vbox_new(FALSE,0); 269 | gtk_container_add(GTK_CONTAINER(window),cont); 270 | 271 | /* Menu Bar */ 272 | menu_bar=gtk_menu_bar_new(); 273 | file_menu=gtk_menu_new(); 274 | edit_menu=gtk_menu_new(); 275 | help_menu=gtk_menu_new(); 276 | file=gtk_menu_item_new_with_label("File"); 277 | help=gtk_menu_item_new_with_label("Help"); 278 | edit=gtk_menu_item_new_with_label("Edit"); 279 | pref=gtk_menu_item_new_with_label("Preferences"); 280 | save=gtk_menu_item_new_with_label("Save List"); 281 | open=gtk_menu_item_new_with_label("Open List"); 282 | quit=gtk_menu_item_new_with_label("Quit"); 283 | about=gtk_menu_item_new_with_label("About"); 284 | 285 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(file),file_menu); 286 | gtk_menu_shell_append(GTK_MENU_SHELL(file_menu),open); 287 | gtk_menu_shell_append(GTK_MENU_SHELL(file_menu),save); 288 | gtk_menu_shell_append(GTK_MENU_SHELL(file_menu),quit); 289 | gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar),file); 290 | 291 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit),edit_menu); 292 | gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu),pref); 293 | gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar),edit); 294 | 295 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(help),help_menu); 296 | gtk_menu_shell_append(GTK_MENU_SHELL(help_menu),about); 297 | gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar),help); 298 | 299 | gtk_box_pack_start(GTK_BOX(cont),menu_bar,FALSE,FALSE,0); 300 | 301 | g_signal_connect(G_OBJECT(quit),"activate", 302 | G_CALLBACK(gtk_main_quit),NULL); 303 | 304 | /* The top bar */ 305 | top_bar=gtk_hbox_new(FALSE,0); 306 | gtk_box_pack_start(GTK_BOX(cont),top_bar,FALSE,FALSE,4); 307 | gtk_widget_show(top_bar); 308 | 309 | /* Add the Listen button */ 310 | listen_button=gtk_toggle_button_new_with_label("Listen"); 311 | gtk_widget_set_size_request(GTK_WIDGET(listen_button),100,40); 312 | gtk_box_pack_start(GTK_BOX(top_bar),listen_button,FALSE,FALSE,0); 313 | g_signal_connect(G_OBJECT(listen_button),"toggled", 314 | G_CALLBACK(lstn),NULL); 315 | gtk_widget_show(listen_button); 316 | 317 | /* Add the Icon */ 318 | icon = gtk_image_new_from_file("wobs.png"); 319 | gtk_box_pack_end(GTK_BOX(top_bar),icon,FALSE,FALSE,0); 320 | 321 | /* The Bottom Bar */ 322 | bot_bar=gtk_hbox_new(FALSE,5); 323 | gtk_box_pack_start(GTK_BOX(cont),bot_bar,TRUE,TRUE,3); 324 | 325 | /* Add settings frame */ 326 | settings_frame = gtk_frame_new("Settings"); 327 | gtk_frame_set_shadow_type(GTK_FRAME(settings_frame),GTK_SHADOW_ETCHED_IN); 328 | gtk_box_pack_start(GTK_BOX(bot_bar),settings_frame,FALSE,FALSE,0); 329 | 330 | settings_p=gtk_vbox_new(FALSE,3); 331 | gtk_container_add(GTK_CONTAINER(settings_frame),settings_p); 332 | 333 | /* The Interface box */ 334 | interface_box=gtk_vbox_new(FALSE,0); 335 | gtk_box_pack_start(GTK_BOX(settings_p),interface_box,FALSE,FALSE,0); 336 | 337 | interface_label=gtk_label_new("Interface: "); 338 | gtk_box_pack_start(GTK_BOX(interface_box),interface_label,FALSE,FALSE,0); 339 | 340 | g_interface_input=gtk_entry_new(); 341 | gtk_entry_set_text((GtkEntry*)g_interface_input,"wlan0"); 342 | gtk_box_pack_start(GTK_BOX(interface_box),g_interface_input,FALSE,FALSE,0); 343 | 344 | /* Modes */ 345 | #if 0 346 | promi=gtk_check_button_new_with_label("Promiscuous mode"); 347 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promi), TRUE); 348 | gtk_box_pack_start(GTK_BOX(settings_p),promi,FALSE,FALSE,0); 349 | 350 | moni=gtk_check_button_new_with_label("Monitor mode"); 351 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(moni), TRUE); 352 | gtk_box_pack_start(GTK_BOX(settings_p),moni,FALSE,FALSE,0); 353 | #endif 354 | 355 | /* Update Button */ 356 | ptext=gtk_label_new( 357 | "NOTE: Clicking 'Update'\nwill clear the Devices list."); 358 | gtk_box_pack_start(GTK_BOX(settings_p),ptext,FALSE,FALSE,20); 359 | gtk_widget_show(ptext); 360 | 361 | update_button=gtk_button_new_with_label("Update"); 362 | gtk_widget_set_size_request(GTK_WIDGET(update_button),100,30); 363 | gtk_box_pack_start(GTK_BOX(settings_p),update_button,FALSE,FALSE,0); 364 | g_signal_connect(G_OBJECT(update_button),"clicked", 365 | G_CALLBACK(update_settings),NULL); 366 | gtk_widget_show(update_button); 367 | 368 | /* Setup the Main View */ 369 | main_view=gtk_hpaned_new (); 370 | gtk_box_pack_start(GTK_BOX(bot_bar),main_view,TRUE,TRUE,0); 371 | gtk_widget_show(main_view); 372 | 373 | /* Add the info pane */ 374 | #if 0 375 | info=create_list("Info",info); 376 | gtk_paned_add1(GTK_PANED(main_view),info.scrolled_window); 377 | gtk_widget_show(info.scrolled_window); 378 | #endif 379 | 380 | /* Add the list of devices */ 381 | devices=create_list("Devices",devices); 382 | gtk_widget_modify_font(devices.tree_view, monospace); 383 | gtk_paned_add2(GTK_PANED(main_view),devices.scrolled_window); 384 | gtk_widget_show(devices.scrolled_window); 385 | g_signal_connect(devices.tree_view,"row_activated", 386 | (GCallback)info_popup,NULL); 387 | 388 | /* Show */ 389 | gtk_widget_show(cont); 390 | gtk_widget_show_all(window); 391 | 392 | gtk_main(); 393 | return 0; 394 | } 395 | --------------------------------------------------------------------------------