source:
freewrt/package/kismet/patches/120-cleanup.patch@
0949a4d
| Last change on this file since 0949a4d was 475ad56, checked in by , 20 years ago | |
|---|---|
|
|
| File size: 113.2 KB | |
-
cursesfront.cc
diff -urN kismet.dev/cursesfront.cc kismet.dev2/cursesfront.cc
old new 30 30 // Enable the protocols we can use 31 31 void NCurseFront::AddClient(TcpClient *in_client) { 32 32 client = in_client; 33 client->EnableProtocol("GPS");34 33 client->EnableProtocol("INFO"); 35 34 client->EnableProtocol("REMOVE"); 36 35 client->EnableProtocol("NETWORK"); … … 88 87 mvwaddstr(netborder, 1, 2, " SSID T W Ch Data LLC Crypt Wk Flags"); 89 88 } 90 89 91 char gpsdata[1024];92 float lat, lon, alt, spd, heading;93 90 int mode; 94 91 95 client->FetchLoc(&lat, &lon, &alt, &spd, &heading, &mode);96 97 if (!(lat == 0 && lon == 0 && alt == 0 && spd == 0 && mode == 0)) {98 99 char fix[16];100 101 if (mode == -1)102 snprintf(fix, 16, "No signal");103 else if (mode == 2)104 snprintf(fix, 5, "2D");105 else if (mode == 3)106 snprintf(fix, 5, "3D");107 else108 snprintf(fix, 5, "NONE");109 110 snprintf(gpsdata, 1024, "Lat %.3f Lon %.3f Alt %.3f Spd %.3f Fix %s",111 lat, lon, alt, spd, fix);112 113 mvwaddstr(netborder, LINES-statheight-1, 2, gpsdata);114 115 }116 117 92 box(infoborder, '|', '-'); 118 93 mvwaddstr(infoborder, 0, 2, "Info"); 119 94 -
dronesource.cc
diff -urN kismet.dev/dronesource.cc kismet.dev2/dronesource.cc
old new 201 201 return -1; 202 202 } 203 203 204 // Grab the GPS info205 gps_enabled = vpkt.gps_enabled;206 207 204 stream_recv_bytes = 0; 208 205 209 206 // printf("debug - version packet valid\n\n"); … … 336 333 packet->encoding = (encoding_type) phdr.encoding; 337 334 packet->datarate = (uint32_t) ntohl(phdr.datarate); 338 335 339 if (gps_enabled) {340 // If the drone is sending us GPS data, use it341 packet->gps_lat = Pair2Float((int16_t) ntohs(phdr.gps_lat),342 (int64_t) kis_ntoh64(phdr.gps_lat_mant));343 packet->gps_lon = Pair2Float((int16_t) ntohs(phdr.gps_lon),344 (int64_t) kis_ntoh64(phdr.gps_lon_mant));345 packet->gps_alt = Pair2Float((int16_t) ntohs(phdr.gps_alt),346 (int64_t) kis_ntoh64(phdr.gps_alt_mant));347 packet->gps_spd = Pair2Float((int16_t) ntohs(phdr.gps_spd),348 (int64_t) kis_ntoh64(phdr.gps_spd_mant));349 packet->gps_heading = Pair2Float((int16_t) ntohs(phdr.gps_heading),350 (int64_t) kis_ntoh64(phdr.gps_heading_mant));351 packet->gps_fix = phdr.gps_fix;352 } else if (gpsd != NULL) {353 // Otherwise, no354 gpsd->FetchLoc(&packet->gps_lat, &packet->gps_lon, &packet->gps_alt,355 &packet->gps_spd, &packet->gps_heading, &packet->gps_fix);356 }357 358 336 packet->data = data; 359 337 packet->moddata = moddata; 360 338 packet->modified = 0; -
dronesource.h
diff -urN kismet.dev/dronesource.h kismet.dev2/dronesource.h
old new 79 79 uint8_t databuf[MAX_PACKET_LEN]; 80 80 81 81 unsigned int resyncing; 82 83 // Is the drone pushing GPS data to us?84 int gps_enabled;85 82 }; 86 83 87 84 // Nothing but a registrant for us -
frontend.cc
diff -urN kismet.dev/frontend.cc kismet.dev2/frontend.cc
old new 248 248 249 249 } 250 250 251 // Aggregate the GPS data252 if (wnet->aggregate_points > 0) {253 dnet->virtnet->aggregate_lat += wnet->aggregate_lat;254 dnet->virtnet->aggregate_lon += wnet->aggregate_lon;255 dnet->virtnet->aggregate_alt += wnet->aggregate_alt;256 dnet->virtnet->aggregate_points += wnet->aggregate_points;257 }258 259 if (wnet->gps_fixed > dnet->virtnet->gps_fixed)260 dnet->virtnet->gps_fixed = wnet->gps_fixed;261 if (wnet->min_lat < dnet->virtnet->min_lat || dnet->virtnet->min_lat == 0)262 dnet->virtnet->min_lat = wnet->min_lat;263 if (wnet->min_lon < dnet->virtnet->min_lon || dnet->virtnet->min_lon == 0)264 dnet->virtnet->min_lon = wnet->min_lon;265 if (wnet->min_alt < dnet->virtnet->min_alt || dnet->virtnet->min_alt == 0)266 dnet->virtnet->min_alt = wnet->min_alt;267 if (wnet->min_spd < dnet->virtnet->min_spd || dnet->virtnet->min_spd == 0)268 dnet->virtnet->min_spd = wnet->min_spd;269 if (wnet->max_lat > dnet->virtnet->max_lat || dnet->virtnet->max_lat == 0)270 dnet->virtnet->max_lat = wnet->max_lat;271 if (wnet->max_lon > dnet->virtnet->max_lon || dnet->virtnet->max_lon == 0)272 dnet->virtnet->max_lon = wnet->max_lon;273 if (wnet->max_alt > dnet->virtnet->max_alt || dnet->virtnet->max_alt == 0)274 dnet->virtnet->max_alt = wnet->max_alt;275 if (wnet->max_spd > dnet->virtnet->max_spd || dnet->virtnet->max_spd == 0)276 dnet->virtnet->max_spd = wnet->max_spd;277 278 251 // Aggregate the carriers and encodings 279 252 dnet->virtnet->carrier_set |= wnet->carrier_set; 280 253 dnet->virtnet->encoding_set |= wnet->encoding_set; -
kismet_client.cc
diff -urN kismet.dev/kismet_client.cc kismet.dev2/kismet_client.cc
old new 28 28 #include "cursesfront.h" 29 29 #include "panelfront.h" 30 30 #include "configfile.h" 31 #include "speech.h"32 31 33 32 #ifndef exec_name 34 33 char *exec_name; … … 47 46 char *configfile; 48 47 char *uiconfigfile; 49 48 char *server = NULL; 50 int sound = -1;51 int speech = -1;52 49 int flite = 0; 53 int speech_encoding = 0;54 string speech_sentence_encrypted, speech_sentence_unencrypted;55 50 unsigned int metric = 0; 56 51 unsigned int reconnect = 0; 57 52 … … 59 54 string configdir, groupfile; 60 55 FILE *group_file = NULL; 61 56 62 // Pipe file descriptor pairs and fd's63 int soundpair[2];64 int speechpair[2];65 pid_t soundpid = -1, speechpid = -1;66 67 57 // Catch our interrupt 68 58 void CatchShutdown(int sig) { 69 59 70 // Kill our sound players71 if (soundpid > 0)72 kill(soundpid, 9);73 if (speechpid > 0)74 kill(speechpid, 9);75 76 60 if (group_track) { 77 61 if ((group_file = fopen(groupfile.c_str(), "w")) == NULL) { 78 62 fprintf(stderr, "WARNING: Unable to open '%s' for writing, groups will not be saved.\n", … … 116 100 exit(0); 117 101 } 118 102 119 // Subprocess sound handler120 void SoundHandler(int *fds, const char *player, map<string, string> soundmap) {121 int read_sock = fds[0];122 123 close(fds[1]);124 125 signal(SIGPIPE, PipeHandler);126 127 fd_set rset;128 129 char data[1024];130 131 pid_t sndpid = -1;132 int harvested = 1;133 134 while (1) {135 FD_ZERO(&rset);136 FD_SET(read_sock, &rset);137 char *end;138 139 memset(data, 0, 1024);140 141 if (harvested == 0) {142 // We consider a wait error to be a sign that the child pid died143 // so we flag it as harvested and keep on going144 pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);145 if (harvestpid == -1 || harvestpid == sndpid)146 harvested = 1;147 }148 149 struct timeval tim;150 tim.tv_sec = 1;151 tim.tv_usec = 0;152 153 if (select(read_sock + 1, &rset, NULL, NULL, &tim) < 0) {154 if (errno != EINTR) {155 exit(1);156 }157 }158 159 if (FD_ISSET(read_sock, &rset)) {160 int ret;161 ret = read(read_sock, data, 1024);162 163 // We'll die off if we get a read error, and we'll let kismet on the164 // other side detact that it died165 if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))166 exit(1);167 168 if ((end = strstr(data, "\n")) == NULL)169 continue;170 171 end[0] = '\0';172 }173 174 if (data[0] == '\0')175 continue;176 177 // If we've harvested the process, spawn a new one and watch it178 // instead. Otherwise, we just let go of the data we read179 if (harvested == 1) {180 // Only take the first line181 char *nl;182 if ((nl = strchr(data, '\n')) != NULL)183 *nl = '\0';184 185 char snd[1024];186 187 if (soundmap.size() == 0)188 snprintf(snd, 1024, "%s", data);189 if (soundmap.find(data) != soundmap.end())190 snprintf(snd, 1024, "%s", soundmap[data].c_str());191 else192 continue;193 194 char plr[1024];195 snprintf(plr, 1024, "%s", player);196 197 harvested = 0;198 if ((sndpid = fork()) == 0) {199 // Suppress errors200 int nulfd = open("/dev/null", O_RDWR);201 dup2(nulfd, 1);202 dup2(nulfd, 2);203 204 char * const echoarg[] = { plr, snd, NULL };205 execve(echoarg[0], echoarg, NULL);206 }207 }208 209 data[0] = '\0';210 }211 }212 213 // Subprocess speech handler214 void SpeechHandler(int *fds, const char *player) {215 int read_sock = fds[0];216 close(fds[1]);217 218 fd_set rset;219 220 char data[1024];221 222 pid_t sndpid = -1;223 int harvested = 1;224 225 while (1) {226 FD_ZERO(&rset);227 FD_SET(read_sock, &rset);228 //char *end;229 230 memset(data, 0, 1024);231 232 struct timeval tim;233 tim.tv_sec = 1;234 tim.tv_usec = 0;235 236 if (select(read_sock + 1, &rset, NULL, NULL, &tim) < 0) {237 if (errno != EINTR) {238 exit(1);239 }240 }241 242 if (harvested == 0) {243 // We consider a wait error to be a sign that the child pid died244 // so we flag it as harvested and keep on going245 pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);246 if (harvestpid == -1 || harvestpid == sndpid)247 harvested = 1;248 }249 250 if (FD_ISSET(read_sock, &rset)) {251 int ret;252 ret = read(read_sock, data, 1024);253 254 // We'll die off if we get a read error, and we'll let kismet on the255 // other side detact that it died256 if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))257 exit(1);258 259 data[ret] = '\0';260 261 }262 263 if (data[0] == '\0')264 continue;265 266 // If we've harvested the process, spawn a new one and watch it267 // instead. Otherwise, we just let go of the data we read268 if (harvested == 1) {269 harvested = 0;270 if ((sndpid = fork()) == 0) {271 // Only take the first line272 char *nl;273 if ((nl = strchr(data, '\n')) != NULL)274 *nl = '\0';275 276 // Make sure it's shell-clean277 MungeToShell(data, strlen(data));278 char spk_call[1024];279 snprintf(spk_call, 1024, "echo \"(%s\\\"%s\\\")\" | %s "280 ">/dev/null 2>/dev/null",281 flite ? "": "SayText ", data, player);282 283 system(spk_call);284 285 exit(0);286 }287 }288 289 data[0] = '\0';290 }291 }292 293 294 int PlaySound(string in_sound) {295 296 char snd[1024];297 298 snprintf(snd, 1024, "%s\n", in_sound.c_str());299 300 if (write(soundpair[1], snd, strlen(snd)) < 0) {301 char status[STATUS_MAX];302 snprintf(status, STATUS_MAX,303 "ERROR: Could not write to sound pipe. Stopping sound.");304 gui->WriteStatus(status);305 306 return 0;307 }308 309 return 1;310 }311 312 int SayText(string in_text) {313 char snd[1024];314 315 snprintf(snd, 1024, "%s\n", in_text.c_str());316 317 if (write(speechpair[1], snd, strlen(snd)) < 0) {318 char status[STATUS_MAX];319 snprintf(status, STATUS_MAX,320 "ERROR: Could not write to speech pipe. Stopping speech.");321 gui->WriteStatus(status);322 323 return 0;324 }325 326 return 1;327 }328 103 329 104 int main(int argc, char *argv[]) { 330 105 exec_name = argv[0]; … … 345 120 char guihost[1024]; 346 121 int guiport = -1; 347 122 348 int gpsmode = -1;349 350 123 configfile = NULL; 351 124 uiconfigfile = NULL; 352 125 … … 391 164 fprintf(stderr, "Using alternate UI config file: %s\n", uiconfigfile); 392 165 break; 393 166 case 'q': 394 sound = 0;395 167 break; 396 168 case 'g': 397 169 reqgui = strdup(optarg); … … 515 287 server = strdup(gui_conf->FetchOpt("host").c_str()); 516 288 } 517 289 518 if (gui_conf->FetchOpt("sound") == "true" && sound == -1) {519 if (gui_conf->FetchOpt("soundplay") != "") {520 sndplay = gui_conf->FetchOpt("soundplay");521 sound = 1;522 523 if (gui_conf->FetchOpt("soundopts") != "")524 sndplay += " " + gui_conf->FetchOpt("soundopts");525 526 if (gui_conf->FetchOpt("sound_new") != "")527 wav_map["new"] = gui_conf->FetchOpt("sound_new");528 if (gui_conf->FetchOpt("sound_new_wep") != "")529 wav_map["new_wep"] = gui_conf->FetchOpt("sound_new_wep");530 if (gui_conf->FetchOpt("sound_traffic") != "")531 wav_map["traffic"] = gui_conf->FetchOpt("sound_traffic");532 if (gui_conf->FetchOpt("sound_junktraffic") != "")533 wav_map["junktraffic"] = gui_conf->FetchOpt("sound_junktraffic");534 if (gui_conf->FetchOpt("sound_gpslock") != "")535 wav_map["gpslock"] = gui_conf->FetchOpt("sound_gpslock");536 if (gui_conf->FetchOpt("sound_gpslost") != "")537 wav_map["gpslost"] = gui_conf->FetchOpt("sound_gpslost");538 if (gui_conf->FetchOpt("sound_alert") != "")539 wav_map["alert"] = gui_conf->FetchOpt("sound_alert");540 541 } else {542 fprintf(stderr, "ERROR: Sound alerts enabled but no sound playing binary specified.\n");543 sound = 0;544 }545 } else if (sound == -1)546 sound = 0;547 548 /* Added by Shaw Innes 17/2/02 */549 if (gui_conf->FetchOpt("speech") == "true" && speech == -1) {550 if (gui_conf->FetchOpt("festival") != "") {551 festival = strdup(gui_conf->FetchOpt("festival").c_str());552 speech = 1;553 554 if (gui_conf->FetchOpt("flite") == "true")555 flite = 1;556 557 string speechtype = gui_conf->FetchOpt("speech_type");558 559 if (!strcasecmp(speechtype.c_str(), "nato"))560 speech_encoding = SPEECH_ENCODING_NATO;561 else if (!strcasecmp(speechtype.c_str(), "spell"))562 speech_encoding = SPEECH_ENCODING_SPELL;563 else564 speech_encoding = SPEECH_ENCODING_NORMAL;565 566 // Make sure we have encrypted text lines567 if (gui_conf->FetchOpt("speech_encrypted") == "" || gui_conf->FetchOpt("speech_unencrypted") == "") {568 fprintf(stderr, "ERROR: Speech request but speech_encrypted or speech_unencrypted line missing.\n");569 speech = 0;570 }571 572 speech_sentence_encrypted = gui_conf->FetchOpt("speech_encrypted");573 speech_sentence_unencrypted = gui_conf->FetchOpt("speech_unencrypted");574 575 } else {576 fprintf(stderr, "ERROR: Speech alerts enabled but no path to festival has been specified.\n");577 speech = 0;578 }579 } else if (speech == -1)580 speech = 0;581 582 290 if (gui_conf->FetchOpt("decay") != "") { 583 291 if (sscanf(gui_conf->FetchOpt("decay").c_str(), "%d", &decay) != 1) { 584 292 fprintf(stderr, "FATAL: Illegal config file value for decay.\n"); … … 636 344 } 637 345 } 638 346 639 // Fork and find the sound options640 if (sound) {641 if (pipe(soundpair) == -1) {642 fprintf(stderr, "WARNING: Unable to create pipe for audio. Disabling sound.\n");643 sound = 0;644 } else {645 soundpid = fork();646 647 if (soundpid < 0) {648 fprintf(stderr, "WARNING: Unable to fork for audio. Disabling sound.\n");649 sound = 0;650 } else if (soundpid == 0) {651 SoundHandler(soundpair, sndplay.c_str(), wav_map);652 exit(0);653 }654 655 close(soundpair[0]);656 }657 }658 659 if (speech) {660 if (pipe(speechpair) == -1) {661 fprintf(stderr, "WARNING: Unable to create pipe for speech. Disabling speech.\n");662 speech = 0;663 } else {664 speechpid = fork();665 666 if (speechpid < 0) {667 fprintf(stderr, "WARNING: Unable to fork for speech. Disabling speech.\n");668 speech = 0;669 } else if (speechpid == 0) {670 SpeechHandler(speechpair, festival);671 exit(0);672 }673 674 close(speechpair[0]);675 }676 }677 678 347 if (kismet_serv.Connect(guiport, guihost) < 0) { 679 348 fprintf(stderr, "FATAL: Could not connect to %s:%d.\n", guihost, guiport); 680 349 CatchShutdown(-1); … … 884 553 } 885 554 886 555 if (pollret != 0) { 887 if (pollret == CLIENT_ALERT)888 if (sound == 1)889 sound = PlaySound("alert");890 891 556 if (strlen(tcpcli->FetchStatus()) != 0) { 892 557 gui->WriteStatus(tcpcli->FetchStatus()); 893 558 // gui->DrawDisplay(); 894 559 } 895 560 896 // The GPS only gets updated for the primary client897 if (tcpcli == primary_client) {898 if (tcpcli->FetchMode() == 0 && gpsmode != 0) {899 if (sound == 1 && gpsmode != -1)900 sound = PlaySound("gpslost");901 gpsmode = 0;902 } else if (tcpcli->FetchMode() != 0 && gpsmode == 0) {903 if (sound == 1 && gpsmode != -1)904 sound = PlaySound("gpslock");905 gpsmode = 1;906 }907 }908 909 561 if (tcpcli->FetchDeltaNumNetworks() > 0) { 910 562 wireless_network *newnet = tcpcli->FetchLastNewNetwork(); 911 912 if (sound == 1 && newnet != lastspoken) {913 if (newnet->crypt_set &&914 wav_map.find("new_wep") != wav_map.end())915 sound = PlaySound("new_wep");916 else917 sound = PlaySound("new");918 }919 920 if (speech == 1 && newnet != lastspoken) {921 string text;922 923 if (newnet != NULL) {924 if (newnet->crypt_set)925 text = ExpandSpeechString(speech_sentence_encrypted, newnet, speech_encoding);926 else927 text = ExpandSpeechString(speech_sentence_unencrypted, newnet, speech_encoding);928 929 speech = SayText(text.c_str());930 }931 }932 933 lastspoken = newnet;934 563 } 935 564 936 565 num_networks += tcpcli->FetchNumNetworks(); … … 938 567 num_noise += tcpcli->FetchNumNoise(); 939 568 num_dropped += tcpcli->FetchNumDropped(); 940 569 941 if (tcpcli->FetchDeltaNumPackets() != 0) { 942 if (time(0) - last_click >= decay && sound == 1) { 943 if (tcpcli->FetchDeltaNumPackets() > tcpcli->FetchDeltaNumDropped()) { 944 sound = PlaySound("traffic"); 945 } else { 946 sound = PlaySound("junktraffic"); 947 } 948 949 last_click = time(0); 950 } 951 } 570 tcpcli->FetchDeltaNumPackets(); 952 571 } 953 572 } 954 573 } else { -
kismet_drone.cc
diff -urN kismet.dev/kismet_drone.cc kismet.dev2/kismet_drone.cc
old new 32 32 #include "packet.h" 33 33 34 34 #include "packetsource.h" 35 #include "prism2source.h"36 35 #include "pcapsource.h" 37 #include "wtapfilesource.h"38 #include "wsp100source.h"39 #include "vihasource.h"40 36 #include "dronesource.h" 41 37 #include "packetsourcetracker.h" 42 38 #include "kis_packsources.h" 43 39 44 #include "gpsd.h"45 40 #include "tcpstreamer.h" 46 41 #include "configfile.h" 47 42 … … 53 48 54 49 const char *config_base = "kismet_drone.conf"; 55 50 56 GPSD *gps = NULL;57 int gpsmode = 0;58 int gps_enable = 0;59 60 51 // Unused, only here to make packetsourcetracker link 61 52 int retain_monitor = 0; 62 53 … … 84 75 exit(0); 85 76 } 86 77 87 int GpsEvent(Timetracker::timer_event *evt, void *parm) {88 // The GPS only provides us a new update once per second we might89 // as well only update it here once a second90 if (gps_enable) {91 int gpsret;92 gpsret = gps->Scan();93 if (gpsret < 0) {94 if (!silent)95 fprintf(stderr, "GPS error fetching data: %s\n",96 gps->FetchError());97 98 gps_enable = 0;99 }100 101 }102 103 // We want to be rescheduled104 return 1;105 }106 107 78 // Handle channel hopping... this is actually really simple. 108 79 int ChannelHopEvent(Timetracker::timer_event *evt, void *parm) { 109 80 sourcetracker.AdvanceChannel(); … … 151 122 152 123 TcpStreamer streamer; 153 124 154 char gpshost[1024];155 int gpsport = -1;156 157 125 int channel_hop = -1; 158 126 int channel_velocity = 1; 159 127 int channel_dwell = 0; … … 354 322 exit(1); 355 323 } 356 324 357 if (conf->FetchOpt("gps") == "true") {358 if (sscanf(conf->FetchOpt("gpshost").c_str(), "%1023[^:]:%d", gpshost, &gpsport) != 2) {359 fprintf(stderr, "Invalid GPS host in config (host:port required)\n");360 exit(1);361 }362 363 gps_enable = 1;364 } else {365 gps_enable = 0;366 }367 368 if (gps_enable == 1) {369 // Open the GPS370 gps = new GPSD(gpshost, gpsport);371 372 // Lock GPS position373 if (conf->FetchOpt("gpsmodelock") == "true") {374 fprintf(stderr, "Enabling GPS position lock override (broken GPS unit reports 0 always)\n");375 gps->SetOptions(GPSD_OPT_FORCEMODE);376 }377 378 if (gps->OpenGPSD() < 0) {379 fprintf(stderr, "%s\n", gps->FetchError());380 381 gps_enable = 0;382 } else {383 fprintf(stderr, "Opened GPS connection to %s port %d\n",384 gpshost, gpsport);385 386 }387 }388 389 // Update GPS coordinates and handle signal loss if defined390 timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &GpsEvent, NULL);391 392 // Add the GPS to the tcpstreamer393 streamer.AddGpstracker(gps);394 395 // Register the gps and timetracker with the sourcetracker396 sourcetracker.AddGpstracker(gps);397 325 sourcetracker.AddTimetracker(&timetracker); 398 326 399 327 // Register the sources -
kismet_server.cc
diff -urN kismet.dev/kismet_server.cc kismet.dev2/kismet_server.cc
old new 37 37 #include "packet.h" 38 38 39 39 #include "packetsource.h" 40 #include "prism2source.h"41 40 #include "pcapsource.h" 42 #include "wtapfilesource.h"43 #include "wsp100source.h"44 #include "vihasource.h"45 41 #include "dronesource.h" 46 42 #include "packetsourcetracker.h" 47 43 #include "kis_packsources.h" … … 51 47 #include "wtaplocaldump.h" 52 48 #include "airsnortdump.h" 53 49 #include "fifodump.h" 54 #include "gpsdump.h"55 56 #include "gpsd.h"57 50 58 51 #include "packetracker.h" 59 52 #include "timetracker.h" 60 53 #include "alertracker.h" 61 54 62 #include "speech.h"63 55 #include "tcpserver.h" 64 56 #include "server_globals.h" 65 57 #include "kismet_server.h" … … 89 81 Alertracker alertracker; 90 82 Timetracker timetracker; 91 83 92 GPSD *gps = NULL;93 int gpsmode = 0;94 GPSDump gpsdump;95 96 // Last time we tried to reconnect to the gps97 time_t last_gpsd_reconnect = 0;98 int gpsd_reconnect_attempt = 0;99 100 84 FifoDumpFile fifodump; 101 85 TcpServer ui_server; 102 int sound = -1;103 86 packet_info last_info; 104 87 int decay; 105 88 channel_power channel_graph[CHANNEL_MAX]; … … 112 95 // Wep keys 113 96 macmap<wep_key_info *> bssid_wep_map; 114 97 115 // Pipe file descriptor pairs and fd's116 int soundpair[2];117 int speechpair[2];118 98 int chanpair[2]; 119 pid_t soundpid = -1, speechpid = -1,chanpid = -1;99 pid_t chanpid = -1; 120 100 121 101 // Past alerts 122 102 unsigned int max_alerts = 50; … … 177 157 int tcpport = -1; 178 158 int tcpmax; 179 159 180 //const char *sndplay = NULL;181 string sndplay;182 183 const char *festival = NULL;184 int speech = -1;185 int flite = 0;186 int speech_encoding = 0;187 string speech_sentence_encrypted, speech_sentence_unencrypted;188 189 map<string, string> wav_map;190 191 160 int beacon_log = 1; 192 161 int phy_log = 1; 193 162 int mangle_log = 0; … … 348 317 // delete cryptfile; 349 318 } 350 319 351 if (gps_log == 1) {352 if (gpsdump.CloseDump(1) < 0)353 fprintf(stderr, "Didn't log any GPS coordinates, unlinking gps file\n");354 }355 356 // Kill our sound players357 if (soundpid > 0)358 kill(soundpid, 9);359 if (speechpid > 0)360 kill(speechpid, 9);361 362 320 // Shut down the packet sources 363 321 sourcetracker.CloseSources(); 364 322 … … 369 327 exit(0); 370 328 } 371 329 372 // Subprocess sound handler373 void SoundHandler(int *fds, const char *player, map<string, string> soundmap) {374 int read_sock = fds[0];375 close(fds[1]);376 377 fd_set rset;378 379 char data[1024];380 381 pid_t sndpid = -1;382 int harvested = 1;383 384 while (1) {385 FD_ZERO(&rset);386 FD_SET(read_sock, &rset);387 char *end;388 389 memset(data, 0, 1024);390 391 struct timeval tm;392 tm.tv_sec = 1;393 tm.tv_usec = 0;394 395 if (select(read_sock + 1, &rset, NULL, NULL, &tm) < 0) {396 if (errno != EINTR) {397 exit(1);398 }399 }400 401 if (harvested == 0) {402 // We consider a wait error to be a sign that the child pid died403 // so we flag it as harvested and keep on going404 pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);405 if (harvestpid == -1 || harvestpid == sndpid)406 harvested = 1;407 }408 409 if (FD_ISSET(read_sock, &rset)) {410 int ret;411 ret = read(read_sock, data, 1024);412 413 // We'll die off if we get a read error, and we'll let kismet on the414 // other side detact that it died415 if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))416 exit(1);417 418 if ((end = strstr(data, "\n")) == NULL)419 continue;420 421 end[0] = '\0';422 }423 424 if (data[0] == '\0')425 continue;426 427 428 // If we've harvested the process, spawn a new one and watch it429 // instead. Otherwise, we just let go of the data we read430 if (harvested == 1) {431 // Only take the first line432 char *nl;433 if ((nl = strchr(data, '\n')) != NULL)434 *nl = '\0';435 436 // Make sure it's shell-clean437 438 char snd[1024];439 440 if (soundmap.size() == 0)441 snprintf(snd, 1024, "%s", data);442 if (soundmap.find(data) != soundmap.end())443 snprintf(snd, 1024, "%s", soundmap[data].c_str());444 else445 continue;446 447 char plr[1024];448 snprintf(plr, 1024, "%s", player);449 450 harvested = 0;451 if ((sndpid = fork()) == 0) {452 // Suppress errors453 if (silent) {454 int nulfd = open("/dev/null", O_RDWR);455 dup2(nulfd, 1);456 dup2(nulfd, 2);457 }458 459 char * const echoarg[] = { plr, snd, NULL };460 execve(echoarg[0], echoarg, NULL);461 }462 }463 data[0] = '\0';464 }465 }466 467 // Subprocess speech handler468 void SpeechHandler(int *fds, const char *player) {469 int read_sock = fds[0];470 close(fds[1]);471 472 fd_set rset;473 474 char data[1024];475 476 pid_t sndpid = -1;477 int harvested = 1;478 479 while (1) {480 FD_ZERO(&rset);481 FD_SET(read_sock, &rset);482 //char *end;483 484 memset(data, 0, 1024);485 486 if (harvested == 0) {487 // We consider a wait error to be a sign that the child pid died488 // so we flag it as harvested and keep on going489 pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);490 if (harvestpid == -1 || harvestpid == sndpid)491 harvested = 1;492 }493 494 struct timeval tm;495 tm.tv_sec = 1;496 tm.tv_usec = 0;497 498 if (select(read_sock + 1, &rset, NULL, NULL, &tm) < 0) {499 if (errno != EINTR) {500 exit(1);501 }502 }503 504 if (FD_ISSET(read_sock, &rset)) {505 int ret;506 ret = read(read_sock, data, 1024);507 508 // We'll die off if we get a read error, and we'll let kismet on the509 // other side detact that it died510 if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))511 exit(1);512 513 data[ret] = '\0';514 }515 516 if (data[0] == '\0')517 continue;518 519 // If we've harvested the process, spawn a new one and watch it520 // instead. Otherwise, we just let go of the data we read521 if (harvested == 1) {522 harvested = 0;523 if ((sndpid = fork()) == 0) {524 // Only take the first line525 char *nl;526 if ((nl = strchr(data, '\n')) != NULL)527 *nl = '\0';528 529 // Make sure it's shell-clean530 MungeToShell(data, strlen(data));531 char spk_call[1024];532 snprintf(spk_call, 1024, "echo \"(%s\\\"%s\\\")\" | %s "533 ">/dev/null 2>/dev/null",534 flite ? "" : "SayText ", data, player);535 system(spk_call);536 537 exit(0);538 }539 }540 541 data[0] = '\0';542 }543 }544 545 546 // Fork and run a system call to play a sound547 int PlaySound(string in_sound) {548 549 char snd[1024];550 551 snprintf(snd, 1024, "%s\n", in_sound.c_str());552 553 if (write(soundpair[1], snd, strlen(snd)) < 0) {554 char status[STATUS_MAX];555 if (!silent)556 fprintf(stderr, "ERROR: Write error, closing sound pipe.\n");557 snprintf(status, STATUS_MAX, "ERROR: Write error on sound pipe, closing sound connection");558 NetWriteStatus(status);559 560 return 0;561 }562 563 return 1;564 }565 566 int SayText(string in_text) {567 568 char snd[1024];569 570 snprintf(snd, 1024, "%s\n", in_text.c_str());571 MungeToShell(snd, 1024);572 573 if (write(speechpair[1], snd, strlen(snd)) < 0) {574 char status[STATUS_MAX];575 if (!silent)576 fprintf(stderr, "ERROR: Write error, closing speech pipe.\n");577 snprintf(status, STATUS_MAX, "ERROR: Write error on speech pipe, closing speech connection");578 NetWriteStatus(status);579 580 return 0;581 }582 583 return 1;584 }585 586 330 void KisLocalAlert(const char *in_text) { 587 331 time_t now = time(0); 588 332 if (!silent) 589 333 fprintf(stderr, "ALERT %.24s %s\n", ctime(&now), in_text); 590 591 if (sound == 1)592 sound = PlaySound("alert");593 594 334 } 595 335 596 336 void KisLocalStatus(const char *in_status) { … … 639 379 640 380 char tmpstr[32]; 641 381 642 GPS_data gdata;643 644 if (gps_enable) {645 float lat, lon, alt, spd, hed;646 int mode;647 648 gps->FetchLoc(&lat, &lon, &alt, &spd, &hed, &mode);649 650 snprintf(tmpstr, 32, "%f", lat);651 gdata.lat = tmpstr;652 snprintf(tmpstr, 32, "%f", lon);653 gdata.lon = tmpstr;654 snprintf(tmpstr, 32, "%f", alt);655 gdata.alt = tmpstr;656 snprintf(tmpstr, 32, "%f", spd);657 gdata.spd = tmpstr;658 snprintf(tmpstr, 32, "%f", hed);659 gdata.heading = tmpstr;660 snprintf(tmpstr, 32, "%d", mode);661 gdata.mode = tmpstr;662 } else {663 gdata.lat = "0.0";664 gdata.lon = "0.0";665 gdata.alt = "0.0";666 gdata.spd = "0.0";667 gdata.heading = "0.0";668 gdata.mode = "0";669 }670 671 ui_server.SendToAll(gps_ref, (void *) &gdata);672 673 382 INFO_data idata; 674 383 snprintf(tmpstr, 32, "%d", tracker.FetchNumNetworks()); 675 384 idata.networks = tmpstr; … … 790 499 } 791 500 } 792 501 793 int GpsEvent(Timetracker::timer_event *evt, void *parm) {794 char status[STATUS_MAX];795 796 // The GPS only provides us a new update once per second we might797 // as well only update it here once a second798 799 // If we're disconnected, try to reconnect.800 if (gpsd_reconnect_attempt > 0) {801 // Increment the time between connection attempts802 if (last_gpsd_reconnect + ((gpsd_reconnect_attempt - 1) * 2) < time(0)) {803 if (gps->OpenGPSD() < 0) {804 last_gpsd_reconnect = time(0);805 806 if (gpsd_reconnect_attempt < 20)807 gpsd_reconnect_attempt++;808 809 snprintf(status, STATUS_MAX, "Unable to reconnect to GPSD, trying "810 "again in %d seconds.", ((gpsd_reconnect_attempt - 1) * 2));811 812 if (!silent || NetWriteStatus(status) == 0)813 fprintf(stderr, "WARNING: %s\n", status);814 815 return 1;816 } else {817 gpsd_reconnect_attempt = 0;818 819 snprintf(status, STATUS_MAX, "Reopened connection to GPSD");820 if (!silent || NetWriteStatus(status) == 0)821 fprintf(stderr, "NOTICE: %s\n", status);822 }823 } else {824 // Don't process more if we haven't woken up yet825 return 1;826 }827 828 }829 830 if (gps_enable) {831 int gpsret;832 gpsret = gps->Scan();833 834 if (gpsret < 0) {835 snprintf(status, STATUS_MAX, "GPS error requesting data: %s",836 gps->FetchError());837 838 if (!silent || NetWriteStatus(status) == 0)839 fprintf(stderr, "WARNING: %s\n", status);840 841 gpsd_reconnect_attempt = 1;842 }843 844 if (gpsret == 0 && gpsmode != 0) {845 if (!silent || NetWriteStatus("Lost GPS signal.") == 0)846 fprintf(stderr, "Lost GPS signal.\n");847 if (sound == 1)848 sound = PlaySound("gpslost");849 850 gpsmode = 0;851 } else if (gpsret != 0 && gpsmode == 0) {852 if (!silent || NetWriteStatus("Acquired GPS signal.") == 0)853 fprintf(stderr, "Acquired GPS signal.\n");854 if (sound == 1)855 sound = PlaySound("gpslock");856 857 gpsmode = 1;858 }859 }860 861 if (gps_log == 1 && gpsmode != 0 && gps != NULL) {862 gpsdump.DumpTrack(gps);863 }864 865 // We want to be rescheduled866 return 1;867 }868 502 869 503 // Simple redirect to the network info drawer. We don't want to change netwriteinfo to a 870 504 // timer event since we call it un-timed too … … 885 519 return 1; 886 520 } 887 521 888 // Write the waypoints for gpsdrive889 int WaypointSyncEvent(Timetracker::timer_event *evt, void *parm) {890 tracker.WriteGpsdriveWaypt(waypoint_file);891 892 return 1;893 }894 895 522 // Handle tracker maintenance 896 523 int TrackerTickEvent(Timetracker::timer_event *evt, void *parm) { 897 524 tracker.Tick(); … … 1160 787 " -c, --capture-source <src> Packet capture source line (type,interface,name)\n" 1161 788 " -C, --enable-capture-sources Comma separated list of named packet sources to use.\n" 1162 789 " -l, --log-types <types> Comma separated list of types to log,\n" 1163 " (ie, dump,cisco,weak,network ,gps)\n"790 " (ie, dump,cisco,weak,network)\n" 1164 791 " -d, --dump-type <type> Dumpfile type (wiretap)\n" 1165 792 " -m, --max-packets <num> Maximum number of packets before starting new dump\n" 1166 " -q, --quiet Don't play sounds\n"1167 " -g, --gps <host:port> GPS server (host:port or off)\n"1168 793 " -p, --port <port> TCPIP server port for GUI connections\n" 1169 794 " -a, --allowed-hosts <hosts> Comma separated list of hosts allowed to connect\n" 1170 795 " -b, --bind-address <address> Bind to this address. Default INADDR_ANY\n." … … 1289 914 ip_track = 1; 1290 915 } 1291 916 1292 1293 if (conf->FetchOpt("waypoints") == "true") {1294 if(conf->FetchOpt("waypointdata") == "") {1295 fprintf(stderr, "WARNING: Waypoint logging requested but no waypoint data file given.\n"1296 "Waypoint logging will be disabled.\n");1297 waypoint = 0;1298 } else {1299 waypointfile = conf->ExpandLogPath(conf->FetchOpt("waypointdata"), "", "", 0, 1);1300 waypoint = 1;1301 }1302 if(conf->FetchOpt("waypoint_essid") == "true") {1303 waypointformat = 1;1304 } else {1305 waypointformat = 0;1306 }1307 }1308 1309 917 if (conf->FetchOpt("metric") == "true") { 1310 918 fprintf(stderr, "Using metric measurements.\n"); 1311 919 metric = 1; … … 1423 1031 } 1424 1032 1425 1033 } 1426 1427 if (strstr(logtypes, "gps")) {1428 if (gps_log == 0) {1429 fprintf(stderr, "WARNING: Disabling GPS logging.\n");1430 } else {1431 gps_log = 1;1432 1433 if (conf->FetchOpt("logtemplate") == "") {1434 fprintf(stderr, "FATAL: Logging (gps coordinates) enabled but no logtemplate given in config.\n");1435 ErrorShutdown();1436 }1437 }1438 1439 }1440 1441 if (gps_log == 1 && !net_log) {1442 fprintf(stderr, "WARNING: Logging (gps coordinates) enabled but XML logging (networks) was not.\n"1443 "It will be enabled now.\n");1444 xml_log = 1;1445 }1446 1034 } 1447 1035 1448 1036 if (conf->FetchOpt("decay") != "") { … … 1563 1151 legal_ipblock_vec.push_back(ipb); 1564 1152 } 1565 1153 1566 // Process sound stuff1567 if (conf->FetchOpt("sound") == "true" && sound == -1) {1568 if (conf->FetchOpt("soundplay") != "") {1569 sndplay = conf->FetchOpt("soundplay");1570 1571 if (conf->FetchOpt("soundopts") != "")1572 sndplay += " " + conf->FetchOpt("soundopts");1573 1574 sound = 1;1575 1576 if (conf->FetchOpt("sound_new") != "")1577 wav_map["new"] = conf->FetchOpt("sound_new");1578 if (conf->FetchOpt("sound_new_wep") != "")1579 wav_map["new_wep"] = conf->FetchOpt("sound_new_wep");1580 if (conf->FetchOpt("sound_traffic") != "")1581 wav_map["traffic"] = conf->FetchOpt("sound_traffic");1582 if (conf->FetchOpt("sound_junktraffic") != "")1583 wav_map["junktraffic"] = conf->FetchOpt("sound_traffic");1584 if (conf->FetchOpt("sound_gpslock") != "")1585 wav_map["gpslock"] = conf->FetchOpt("sound_gpslock");1586 if (conf->FetchOpt("sound_gpslost") != "")1587 wav_map["gpslost"] = conf->FetchOpt("sound_gpslost");1588 if (conf->FetchOpt("sound_alert") != "")1589 wav_map["alert"] = conf->FetchOpt("sound_alert");1590 1591 } else {1592 fprintf(stderr, "ERROR: Sound alerts enabled but no sound playing binary specified.\n");1593 sound = 0;1594 }1595 } else if (sound == -1)1596 sound = 0;1597 1598 /* Added by Shaw Innes 17/2/02 */1599 /* Modified by Andrew Etter 15/9/02 */1600 if (conf->FetchOpt("speech") == "true" && speech == -1) {1601 if (conf->FetchOpt("festival") != "") {1602 festival = strdup(conf->FetchOpt("festival").c_str());1603 speech = 1;1604 1605 if (conf->FetchOpt("flite") == "true")1606 flite = 1;1607 1608 string speechtype = conf->FetchOpt("speech_type");1609 1610 if (!strcasecmp(speechtype.c_str(), "nato"))1611 speech_encoding = SPEECH_ENCODING_NATO;1612 else if (!strcasecmp(speechtype.c_str(), "spell"))1613 speech_encoding = SPEECH_ENCODING_SPELL;1614 else1615 speech_encoding = SPEECH_ENCODING_NORMAL;1616 1617 // Make sure we have encrypted text lines1618 if (conf->FetchOpt("speech_encrypted") == "" || conf->FetchOpt("speech_unencrypted") == "") {1619 fprintf(stderr, "ERROR: Speech request but speech_encrypted or speech_unencrypted line missing.\n");1620 speech = 0;1621 }1622 1623 speech_sentence_encrypted = conf->FetchOpt("speech_encrypted");1624 speech_sentence_unencrypted = conf->FetchOpt("speech_unencrypted");1625 } else {1626 fprintf(stderr, "ERROR: Speech alerts enabled but no path to festival has been specified.\n");1627 speech = 0;1628 }1629 } else if (speech == -1)1630 speech = 0;1631 1632 1154 if (conf->FetchOpt("writeinterval") != "") { 1633 1155 if (sscanf(conf->FetchOpt("writeinterval").c_str(), "%d", &datainterval) != 1) { 1634 1156 fprintf(stderr, "FATAL: Illegal config file value for data interval.\n"); … … 1648 1170 fprintf(stderr, "WARNING: No client_manuf file specified. Client manufacturers will not be detected.\n"); 1649 1171 } 1650 1172 1651 // Fork and find the sound options1652 if (sound) {1653 if (pipe(soundpair) == -1) {1654 fprintf(stderr, "WARNING: Unable to create pipe for audio. Disabling sound.\n");1655 sound = 0;1656 } else {1657 soundpid = fork();1658 1659 if (soundpid < 0) {1660 fprintf(stderr, "WARNING: Unable to fork for audio. Disabling sound.\n");1661 sound = 0;1662 } else if (soundpid == 0) {1663 SoundHandler(soundpair, sndplay.c_str(), wav_map);1664 exit(0);1665 }1666 1667 close(soundpair[0]);1668 }1669 }1670 1671 if (speech) {1672 if (pipe(speechpair) == -1) {1673 fprintf(stderr, "WARNING: Unable to create pipe for speech. Disabling speech.\n");1674 speech = 0;1675 } else {1676 speechpid = fork();1677 1678 if (speechpid < 0) {1679 fprintf(stderr, "WARNING: Unable to fork for speech. Disabling speech.\n");1680 speech = 0;1681 } else if (speechpid == 0) {1682 SpeechHandler(speechpair, festival);1683 exit(0);1684 }1685 1686 close(speechpair[0]);1687 }1688 }1689 1690 1173 // Grab the filtering 1691 1174 string filter_bit; 1692 1175 … … 1712 1195 } 1713 1196 1714 1197 if ((filter_bit = conf->FetchOpt("filter_export")) != "") { 1715 fprintf(stderr, "Enabling filtering on exported (csv, xml, network , gps) files.\n");1198 fprintf(stderr, "Enabling filtering on exported (csv, xml, network) files.\n"); 1716 1199 filter_export = 1; 1717 1200 if (ConfigFile::ParseFilterLine(filter_bit, &filter_export_bssid, &filter_export_source, 1718 1201 &filter_export_dest, &filter_export_bssid_invert, … … 1818 1301 1819 1302 } 1820 1303 1821 if (waypoint) {1822 if ((waypoint_file = fopen(waypointfile.c_str(), "a")) == NULL) {1823 fprintf(stderr, "WARNING: Could not open waypoint file '%s' for writing: %s\n",1824 waypointfile.c_str(), strerror(errno));1825 waypoint = 0;1826 }1827 }1828 1829 1304 // Create all the logs and title/number them appropriately 1830 1305 // We need to save this for after we toast the conf record 1831 1306 int logfile_matched = 0; … … 1873 1348 continue; 1874 1349 } 1875 1350 1876 if (gps_log == 1) {1877 gpslogfile = conf->ExpandLogPath(conf->FetchOpt("logtemplate"), logname, "gps", run_num);1878 1879 if (gpslogfile == "")1880 continue;1881 }1882 1883 1351 // if we made it this far we're cool -- all the logfiles we're writing to matched 1884 1352 // this number 1885 1353 logfile_matched = 1; … … 1908 1376 if (cisco_log) 1909 1377 fprintf(stderr, "Logging cisco product information to %s\n", ciscologfile.c_str()); 1910 1378 1911 if (gps_log == 1)1912 fprintf(stderr, "Logging gps coordinates to %s\n", gpslogfile.c_str());1913 1914 1379 if (data_log) 1915 1380 fprintf(stderr, "Logging data to %s\n", dumplogfile.c_str()); 1916 1381 … … 2058 1523 { "dump-type", required_argument, 0, 'd' }, 2059 1524 { "max-packets", required_argument, 0, 'm' }, 2060 1525 { "quiet", no_argument, 0, 'q' }, 2061 { "gps", required_argument, 0, 'g' },2062 1526 { "port", required_argument, 0, 'p' }, 2063 1527 { "allowed-hosts", required_argument, 0, 'a' }, 2064 1528 { "bind-address", required_argument, 0, 'b'}, … … 2140 1604 Usage(argv[0]); 2141 1605 } 2142 1606 break; 2143 case 'g':2144 // GPS2145 if (strcmp(optarg, "off") == 0) {2146 gps_enable = 0;2147 }2148 else if (sscanf(optarg, "%1023[^:]:%d", gpshost, &gpsport) < 2) {2149 fprintf(stderr, "Invalid GPS host '%s' (host:port or off required)\n",2150 optarg);2151 gps_enable = 1;2152 Usage(argv[0]);2153 }2154 break;2155 1607 case 'p': 2156 1608 // Port 2157 1609 if (sscanf(optarg, "%d", &tcpport) != 1) { … … 2173 1625 break; 2174 1626 case 'q': 2175 1627 // Quiet 2176 sound = 0;2177 1628 break; 2178 1629 case 'v': 2179 1630 // version … … 2331 1782 // And we're done 2332 1783 fclose(pid_file); 2333 1784 2334 2335 // Set up the GPS object to give to the children2336 if (gpsport == -1 && gps_enable) {2337 if (conf->FetchOpt("gps") == "true") {2338 if (sscanf(conf->FetchOpt("gpshost").c_str(), "%1023[^:]:%d", gpshost,2339 &gpsport) != 2) {2340 fprintf(stderr, "Invalid GPS host in config (host:port required)\n");2341 exit(1);2342 }2343 2344 gps_enable = 1;2345 } else {2346 gps_enable = 0;2347 gps_log = 0;2348 }2349 }2350 2351 if (gps_enable == 1) {2352 gps = new GPSD(gpshost, gpsport);2353 2354 // Lock GPS position2355 if (conf->FetchOpt("gpsmodelock") == "true") {2356 fprintf(stderr, "Enabling GPS position lock override (broken GPS unit "2357 "reports 0 always)\n");2358 gps->SetOptions(GPSD_OPT_FORCEMODE);2359 }2360 2361 } else {2362 gps_log = 0;2363 }2364 2365 // Register the gps and timetracker with the sourcetracker2366 sourcetracker.AddGpstracker(gps);2367 1785 sourcetracker.AddTimetracker(&timetracker); 2368 1786 2369 1787 // Handle errors here maybe in the future … … 2530 1948 fprintf(stderr, "Dump file format: %s\n", dumpfile->FetchType()); 2531 1949 } 2532 1950 2533 if (gps_enable && gps_log == 1) {2534 if (gpsdump.OpenDump(gpslogfile.c_str(), xmllogfile.c_str()) < 0) {2535 fprintf(stderr, "FATAL: GPS dump error: %s\n", gpsdump.FetchError());2536 ErrorShutdown();2537 }2538 }2539 2540 1951 // Open our files first to make sure we can, we'll unlink the empties later. 2541 1952 FILE *testfile = NULL; 2542 1953 if (net_log) { … … 2608 2019 */ 2609 2020 2610 2021 if (data_log || net_log || crypt_log) { 2611 snprintf(status, STATUS_MAX, "Logging%s%s%s%s%s%s %s",2022 snprintf(status, STATUS_MAX, "Logging%s%s%s%s%s%s", 2612 2023 data_log ? " data" : "" , 2613 2024 net_log ? " networks" : "" , 2614 2025 csv_log ? " CSV" : "" , 2615 2026 xml_log ? " XML" : "" , 2616 2027 crypt_log ? " weak" : "", 2617 cisco_log ? " cisco" : "", 2618 gps_log == 1 ? " gps" : ""); 2028 cisco_log ? " cisco" : ""); 2619 2029 fprintf(stderr, "%s\n", status); 2620 2030 } else if (no_log) { 2621 2031 snprintf(status, STATUS_MAX, "Not logging any data."); … … 2633 2043 } 2634 2044 } 2635 2045 2636 if (gps_enable) {2637 // Open the GPS2638 if (gps->OpenGPSD() < 0) {2639 fprintf(stderr, "%s\n", gps->FetchError());2640 2641 gps_enable = 0;2642 gps_log = 0;2643 } else {2644 fprintf(stderr, "Opened GPS connection to %s port %d\n",2645 gpshost, gpsport);2646 2647 gpsmode = gps->FetchMode();2648 2649 last_gpsd_reconnect = time(0);2650 }2651 }2652 2653 2046 fprintf(stderr, "Listening on port %d.\n", tcpport); 2654 2047 for (unsigned int ipvi = 0; ipvi < legal_ipblock_vec.size(); ipvi++) { 2655 2048 char *netaddr = strdup(inet_ntoa(legal_ipblock_vec[ipvi]->network)); … … 2690 2083 &Protocol_NETWORK, &ProtocolNetworkEnable); 2691 2084 client_ref = ui_server.RegisterProtocol("CLIENT", 0, CLIENT_fields_text, 2692 2085 &Protocol_CLIENT, &ProtocolClientEnable); 2693 gps_ref = ui_server.RegisterProtocol("GPS", 0, GPS_fields_text,2694 &Protocol_GPS, NULL);2695 2086 info_ref = ui_server.RegisterProtocol("INFO", 0, INFO_fields_text, 2696 2087 &Protocol_INFO, NULL); 2697 2088 remove_ref = ui_server.RegisterProtocol("REMOVE", 0, REMOVE_fields_text, … … 2746 2137 // Write network info and tick the tracker once per second 2747 2138 timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &NetWriteEvent, NULL); 2748 2139 timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &TrackerTickEvent, NULL); 2749 // Update GPS coordinates and handle signal loss if defined2750 timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &GpsEvent, NULL);2751 2140 // Sync the data files if requested 2752 2141 if (datainterval > 0 && no_log == 0) 2753 2142 timetracker.RegisterTimer(datainterval * SERVER_TIMESLICES_SEC, NULL, 1, &ExportSyncEvent, NULL); 2754 // Write waypoints if requested2755 if (waypoint)2756 timetracker.RegisterTimer(decay * SERVER_TIMESLICES_SEC, NULL, 1, &WaypointSyncEvent, NULL);2757 2143 // Channel hop if requested 2758 2144 if (channel_hop) { 2759 2145 if (channel_dwell) … … 2777 2163 snprintf(status, 1024, "%s", TIMESTAMP); 2778 2164 kdata.timestamp = status; 2779 2165 2780 time_t last_click = 0;2781 2166 int num_networks = 0, num_packets = 0, num_noise = 0, num_dropped = 0; 2782 2167 2783 2168 … … 2926 2311 2927 2312 } 2928 2313 2929 if (gps_log == 1 && info.type != packet_noise &&2930 info.type != packet_unknown && info.type != packet_phy &&2931 info.corrupt == 0) {2932 if (gpsdump.DumpPacket(&info) < 0) {2933 snprintf(status, STATUS_MAX, "%s", gpsdump.FetchError());2934 if (!silent || NetWriteStatus(status) == 0)2935 fprintf(stderr, "%s\n", status);2936 }2937 }2938 2939 2314 // tracker.ProcessPacket(info); 2940 2315 tracker.ProcessPacket(&packet, &info, &bssid_wep_map, 2941 2316 wep_identity); 2942 2317 2943 if (tracker.FetchNumNetworks() > num_networks) {2944 if (sound == 1)2945 if (info.crypt_set &&2946 wav_map.find("new_wep") != wav_map.end())2947 sound = PlaySound("new_wep");2948 else2949 sound = PlaySound("new");2950 if (speech == 1) {2951 string text;2952 2953 if (info.crypt_set)2954 text = ExpandSpeechString(speech_sentence_encrypted, &info,2955 speech_encoding);2956 else2957 text = ExpandSpeechString(speech_sentence_unencrypted,2958 &info, speech_encoding);2959 2960 speech = SayText(MungeToShell(text).c_str());2961 }2962 }2963 2318 num_networks = tracker.FetchNumNetworks(); 2964 2319 2965 2320 if (tracker.FetchNumPackets() != num_packets) { 2966 if (cur_time - last_click >= decay && sound == 1) {2967 if (tracker.FetchNumPackets() - num_packets >2968 tracker.FetchNumDropped() + localdropnum - num_dropped) {2969 sound = PlaySound("traffic");2970 } else {2971 sound = PlaySound("junktraffic");2972 }2973 2974 last_click = cur_time;2975 }2976 2977 2321 num_packets = tracker.FetchNumPackets(); 2978 2322 num_noise = tracker.FetchNumNoise(); 2979 2323 num_dropped = tracker.FetchNumDropped() + localdropnum; -
kismet_server.h
diff -urN kismet.dev/kismet_server.h kismet.dev2/kismet_server.h
old new 33 33 void handle_command(TcpServer *tcps, client_command *cc); 34 34 int NetWriteStatus(const char *in_status); 35 35 void NetWriteInfo(); 36 int SayText(string in_text);37 int PlaySound(string in_sound);38 void SpeechHandler(int *fds, const char *player);39 void SoundHandler(int *fds, const char *player, map<string, string> soundmap);40 36 void ProtocolAlertEnable(int in_fd); 41 37 void ProtocolNetworkEnable(int in_fd); 42 38 void ProtocolClientEnable(int in_fd); -
kis_packsources.cc
diff -urN kismet.dev/kis_packsources.cc kismet.dev2/kis_packsources.cc
old new 64 64 pcapsource_11g_registrant, 65 65 monitor_wext, unmonitor_wext, 66 66 chancontrol_wext, 1); 67 sourcetracker->RegisterPacketsource("cisco", 1, "IEEE80211b", 6, 68 pcapsource_wext_registrant, 69 monitor_cisco, unmonitor_cisco, 70 chancontrol_wext, 1); 71 sourcetracker->RegisterPacketsource("cisco_wifix", 1, "IEEE80211b", 6, 72 pcapsource_ciscowifix_registrant, 73 monitor_cisco_wifix, NULL, NULL, 1); 67 REG_EMPTY_CARD(sourcetracker, "cisco"); 68 REG_EMPTY_CARD(sourcetracker, "cisco_wifix"); 74 69 sourcetracker->RegisterPacketsource("hostap", 1, "IEEE80211b", 6, 75 70 pcapsource_wext_registrant, 76 71 monitor_hostap, unmonitor_hostap, … … 83 78 pcapsource_wext_registrant, 84 79 monitor_orinoco, unmonitor_orinoco, 85 80 chancontrol_orinoco, 1); 86 sourcetracker->RegisterPacketsource("acx100", 1, "IEEE80211b", 6, 87 pcapsource_wext_registrant, 88 monitor_acx100, unmonitor_acx100, 89 chancontrol_wext, 1); 90 sourcetracker->RegisterPacketsource("admtek", 1, "IEEE80211b", 6, 91 pcapsource_wext_registrant, 92 monitor_admtek, unmonitor_admtek, 93 chancontrol_wext, 1); 94 sourcetracker->RegisterPacketsource("vtar5k", 1, "IEEE80211a", 36, 95 pcapsource_wext_registrant, 96 monitor_vtar5k, NULL, chancontrol_wext, 1); 97 sourcetracker->RegisterPacketsource("atmel_usb", 1, "IEEE80211b", 6, 98 pcapsource_wext_registrant, 99 monitor_wext, unmonitor_wext, 100 chancontrol_wext, 1); 81 REG_EMPTY_CARD(sourcetracker, "acx100"); 82 REG_EMPTY_CARD(sourcetracker, "admtek"); 83 REG_EMPTY_CARD(sourcetracker, "vtar5k"); 84 REG_EMPTY_CARD(sourcetracker, "atmel_usb"); 101 85 102 86 sourcetracker->RegisterPacketsource("madwifi_a", 1, "IEEE80211a", 36, 103 87 pcapsource_wextfcs_registrant, … … 146 130 monitor_prism54g, unmonitor_prism54g, 147 131 chancontrol_prism54g, 1); 148 132 149 sourcetracker->RegisterPacketsource("wlanng_wext", 1, "IEEE80211b", 6, 150 pcapsource_wlanng_registrant, 151 monitor_wlanng_avs, NULL, 152 chancontrol_wext, 1); 153 154 sourcetracker->RegisterPacketsource("ipw2100", 1, "IEEE80211b", 6, 155 pcapsource_wext_registrant, 156 monitor_ipw2100, unmonitor_ipw2100, 157 chancontrol_ipw2100, 1); 158 159 sourcetracker->RegisterPacketsource("ipw2200", 1, "IEEE80211g", 6, 160 pcapsource_wext_registrant, 161 monitor_ipw2200, unmonitor_ipw2200, 162 chancontrol_ipw2200, 1); 163 164 sourcetracker->RegisterPacketsource("ipw2915", 1, "IEEE80211ab", 6, 165 pcapsource_wext_registrant, 166 monitor_ipw2200, unmonitor_ipw2200, 167 chancontrol_ipw2200, 1); 168 169 sourcetracker->RegisterPacketsource("ipw3945", 1, "IEEE80211ab", 6, 170 pcapsource_wext_registrant, 171 monitor_ipw3945, unmonitor_ipw3945, 172 chancontrol_ipw2200, 1); 173 174 sourcetracker->RegisterPacketsource("ipwlivetap", 1, "IEEE80211b", 0, 175 pcapsource_wext_registrant, 176 monitor_ipwlivetap, 177 unmonitor_ipwlivetap, 178 NULL, 1); 179 180 sourcetracker->RegisterPacketsource("rt2400", 1, "IEEE80211b", 6, 181 pcapsource_wext_registrant, 182 monitor_wext, unmonitor_wext, 183 chancontrol_wext, 1); 184 sourcetracker->RegisterPacketsource("rt2500", 1, "IEEE80211g", 6, 185 pcapsource_11g_registrant, 186 monitor_wext, unmonitor_wext, 187 chancontrol_wext, 1); 188 sourcetracker->RegisterPacketsource("rt8180", 1, "IEEE80211b", 6, 189 pcapsource_wext_registrant, 190 monitor_wext, unmonitor_wext, 191 chancontrol_wext, 1); 133 REG_EMPTY_CARD(sourcetracker, "wlanng_wext"); 134 REG_EMPTY_CARD(sourcetracker, "ipw2100"); 135 REG_EMPTY_CARD(sourcetracker, "ipw2200"); 136 REG_EMPTY_CARD(sourcetracker, "ipw2915"); 137 REG_EMPTY_CARD(sourcetracker, "ipw3945"); 138 REG_EMPTY_CARD(sourcetracker, "ipwlivetap"); 192 139 140 REG_EMPTY_CARD(sourcetracker, "rt2400"); 141 REG_EMPTY_CARD(sourcetracker, "rt2500"); 142 REG_EMPTY_CARD(sourcetracker, "rt8180"); 143 193 144 sourcetracker->RegisterPacketsource("zd1211", 1, "IEEE80211g", 6, 194 145 pcapsource_wext_registrant, 195 146 monitor_wext, unmonitor_wext, … … 233 184 REG_EMPTY_CARD(sourcetracker, "zd1211"); 234 185 #endif 235 186 236 #if defined(HAVE_LIBPCAP) && defined(SYS_LINUX)237 sourcetracker->RegisterPacketsource("wlanng", 1, "IEEE80211b", 6,238 pcapsource_wlanng_registrant,239 monitor_wlanng, NULL, chancontrol_wlanng, 1);240 sourcetracker->RegisterPacketsource("wlanng_avs", 1, "IEEE80211b", 6,241 pcapsource_wlanng_registrant,242 monitor_wlanng_avs, NULL,243 chancontrol_wlanng_avs, 1);244 187 sourcetracker->RegisterPacketsource("wrt54g", 1, "na", 0, 245 188 pcapsource_wrt54g_registrant, 246 monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0);247 #else 189 monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0); 190 248 191 REG_EMPTY_CARD(sourcetracker, "wlanng"); 249 192 REG_EMPTY_CARD(sourcetracker, "wlanng_avs"); 250 REG_EMPTY_CARD(sourcetracker, "wrt54g");251 #endif252 253 #if defined(SYS_LINUX) && defined(HAVE_LINUX_NETLINK)254 sourcetracker->RegisterPacketsource("wlanng_legacy", 1, "IEEE80211b", 6,255 prism2source_registrant,256 monitor_wlanng_legacy, NULL,257 chancontrol_wlanng_legacy, 1);258 #else259 193 REG_EMPTY_CARD(sourcetracker, "wlanng_legacy"); 260 #endif261 194 262 195 #if defined(HAVE_LIBPCAP) && defined(SYS_OPENBSD) 263 196 sourcetracker->RegisterPacketsource("cisco_openbsd", 1, "IEEE80211b", 6, … … 291 224 REG_EMPTY_CARD(sourcetracker, "radiotap_bsd_b"); 292 225 #endif 293 226 294 #if defined(HAVE_LIBWIRETAP)295 sourcetracker->RegisterPacketsource("wtapfile", 0, "na", 0,296 wtapfilesource_registrant,297 NULL, NULL, NULL, 0);298 #else299 227 REG_EMPTY_CARD(sourcetracker, "wtapfile"); 300 #endif301 228 302 #if defined(HAVE_WSP100)303 sourcetracker->RegisterPacketsource("wsp100", 0, "IEEE80211b", 6,304 wsp100source_registrant,305 monitor_wsp100, NULL, chancontrol_wsp100, 0);306 #else307 229 REG_EMPTY_CARD(sourcetracker, "wsp100"); 308 #endif309 230 310 #if defined(HAVE_VIHAHEADERS)311 sourcetracker->RegisterPacketsource("viha", 1, "IEEE80211b", 6,312 vihasource_registrant,313 NULL, NULL, chancontrol_viha, 0);314 #else315 231 REG_EMPTY_CARD(sourcetracker, "viha"); 316 #endif317 232 318 233 return 1; 319 234 } -
kis_packsources.h
diff -urN kismet.dev/kis_packsources.h kismet.dev2/kis_packsources.h
old new 22 22 #include "config.h" 23 23 24 24 #include "packetsource.h" 25 #include "prism2source.h"26 25 #include "pcapsource.h" 27 #include "wtapfilesource.h"28 #include "wsp100source.h"29 #include "vihasource.h"30 26 #include "dronesource.h" 31 27 #include "packetsourcetracker.h" 32 28 -
Makefile.in
diff -urN kismet.dev/Makefile.in kismet.dev2/Makefile.in
old new 39 39 DEPEND = .depend 40 40 41 41 # Objects 42 PSO = util.o ringbuf.o configfile.o speech.o ifcontrol.o iwcontrol.o packet.o \ 43 pcapsource.o prism2source.o wtapfilesource.o wsp100source.o \ 44 dronesource.o vihasource.o packetsourcetracker.o kis_packsources.o \ 45 wtapdump.o wtaplocaldump.o gpsdump.o airsnortdump.o fifodump.o \ 46 gpsd.o manuf.o \ 42 PSO = util.o ringbuf.o configfile.o ifcontrol.o iwcontrol.o packet.o \ 43 pcapsource.o manuf.o \ 44 dronesource.o packetsourcetracker.o kis_packsources.o \ 45 wtapdump.o wtaplocaldump.o airsnortdump.o fifodump.o \ 47 46 packetracker.o timetracker.o alertracker.o finitestate.o \ 48 47 getopt.o \ 49 48 tcpserver.o server_protocols.o server_globals.o kismet_server.o 50 49 PS = kismet_server 51 50 52 51 DRONEO = util.o ringbuf.o configfile.o getopt.o ifcontrol.o iwcontrol.o packet.o \ 53 tcpstreamer.o p rism2source.o pcapsource.o wtapfilesource.o wsp100source.o \54 dronesource.o vihasource.opacketsourcetracker.o kis_packsources.o \55 timetracker.o gpsd.oserver_globals.o kismet_drone.o52 tcpstreamer.o pcapsource.o \ 53 dronesource.o packetsourcetracker.o kis_packsources.o \ 54 timetracker.o server_globals.o kismet_drone.o 56 55 DRONE = kismet_drone 57 56 58 NCO = util.o configfile.o speech.omanuf.o tcpclient.o \57 NCO = util.o configfile.o manuf.o tcpclient.o \ 59 58 frontend.o cursesfront.o \ 60 59 panelfront.o panelfront_display.o panelfront_input.o \ 61 g psd.o getopt.o kismet_client.o60 getopt.o kismet_client.o 62 61 NC = kismet_client 63 62 64 63 GPSLO = getopt.o util.o configfile.o expat.o manuf.o \ -
packetracker.cc
diff -urN kismet.dev/packetracker.cc kismet.dev2/packetracker.cc
old new 2443 2443 2444 2444 } 2445 2445 2446 // Write a gpsdrive compatable waypoint file2447 int Packetracker::WriteGpsdriveWaypt(FILE *in_file) {2448 fseek(in_file, 0L, SEEK_SET);2449 ftruncate(fileno(in_file), 0);2450 2451 // Convert the map to a vector and sort it2452 for (map<mac_addr, wireless_network *>::const_iterator i = bssid_map.begin();2453 i != bssid_map.end(); ++i) {2454 wireless_network *net = i->second;2455 2456 float lat, lon;2457 lat = (net->min_lat + net->max_lat) / 2;2458 lon = (net->min_lon + net->max_lon) / 2;2459 fprintf(in_file, "%s\t%f %f\n", waypointformat == 1 ? net->ssid.c_str() : net->bssid.Mac2String().c_str(), lat, lon);2460 }2461 2462 fflush(in_file);2463 2464 return 1;2465 } -
packetracker.h
diff -urN kismet.dev/packetracker.h kismet.dev2/packetracker.h
old new 30 30 #include <string> 31 31 32 32 #include "util.h" 33 #include "gpsd.h"34 33 #include "packet.h" 35 34 #include "tracktypes.h" 36 35 #include "manuf.h" … … 85 84 int WriteXMLNetworks(string in_fname); 86 85 int WriteCisco(string in_fname); 87 86 88 int WriteGpsdriveWaypt(FILE *in_file);89 90 87 void WriteSSIDMap(FILE *in_file); 91 88 void ReadSSIDMap(FILE *in_file); 92 89 -
packetsourcetracker.cc
diff -urN kismet.dev/packetsourcetracker.cc kismet.dev2/packetsourcetracker.cc
old new 27 27 Packetsourcetracker::Packetsourcetracker() { 28 28 next_packsource_id = 0; 29 29 next_meta_id = 0; 30 gpsd = NULL;31 30 timetracker = NULL; 32 31 chanchild_pid = 0; 33 32 sockpair[0] = sockpair[1] = 0; … … 694 693 695 694 // Register the trackers with it 696 695 meta->capsource->AddTimetracker(timetracker); 697 meta->capsource->AddGpstracker(gpsd);698 696 699 697 // Open it 700 698 fprintf(stderr, "Source %d (%s): Opening %s source interface %s...\n", -
packetsourcetracker.h
diff -urN kismet.dev/packetsourcetracker.h kismet.dev2/packetsourcetracker.h
old new 30 30 #include <string> 31 31 32 32 #include "timetracker.h" 33 #include "gpsd.h"34 33 #include "packetsource.h" 35 34 36 35 // Sentinel for starting a new packet … … 144 143 // Register a timer event handler for us to use 145 144 void AddTimetracker(Timetracker *in_tracker) { timetracker = in_tracker; } 146 145 147 // Register the GPS server for us to use148 void AddGpstracker(GPSD *in_gpsd) { gpsd = in_gpsd; }149 150 146 // Register a packet prototype source... Card type string, root binding requirement, 151 147 // function to generate an instance of the source, and function to change channel 152 148 // for this card type. This fills out the prototype. Sources that don't hop … … 221 217 uint16_t channel; 222 218 } chanchild_changepacket; 223 219 224 GPSD *gpsd;225 220 Timetracker *timetracker; 226 221 227 222 char errstr[1024]; -
panelfront.cc
diff -urN kismet.dev/panelfront.cc kismet.dev2/panelfront.cc
old new 37 37 " Key Action", 38 38 " e List Kismet servers", 39 39 " z Toggle fullscreen zoom of network view", 40 " m Toggle muting of sound and speech",41 40 " t Tag (or untag) selected network", 42 41 " g Group tagged networks", 43 42 " u Ungroup current group", … … 121 120 "Key Action", 122 121 " e List Kismet servers", 123 122 " z Toggle fullscreen net list", 124 " m Toggle muting",125 123 " t Tag (or untag) selected", 126 124 " g Group tagged networks", 127 125 " u Ungroup current group", … … 237 235 }; 238 236 239 237 240 char *KismetHelpGps[] = {241 "KISMET NETWORK FOLLOW",242 "This panel estimates the center of a network, the current",243 "direction of travel, and the direction of the network center",244 "and distance relative to the current direction of movement.",245 " Key Action",246 " s Follow location of strongest packet",247 " c Follow location of estimated network center",248 " q Close popup",249 NULL250 };251 252 253 238 char *KismetHelpStats[] = { 254 239 "KISMET NETWORK STATISTICS", 255 240 "This panel displays overall statistics about the wireless", … … 678 663 } 679 664 680 665 // Enable all the protocols we handle 681 in_client->EnableProtocol("GPS");682 666 in_client->EnableProtocol("INFO"); 683 667 in_client->EnableProtocol("REMOVE"); 684 668 in_client->EnableProtocol("NETWORK"); … … 1282 1266 if (con->client == NULL) 1283 1267 continue; 1284 1268 1285 // Update GPS1286 float newlat, newlon, newalt, newspd, newheading;1287 int newfix;1288 con->client->FetchLoc(&newlat, &newlon, &newalt, &newspd, &newheading, &newfix);1289 1290 if (GPSD::EarthDistance(newlat, newlon, last_lat, last_lon) > 10) {1291 con->last_lat = con->lat;1292 con->last_lon = con->lon;1293 con->last_spd = con->spd;1294 con->last_alt = con->alt;1295 con->last_fix = con->fix;1296 con->last_heading = con->heading;1297 }1298 1299 con->lat = newlat;1300 con->lon = newlon;1301 con->alt = newalt;1302 con->spd = newspd;1303 con->heading = newheading;1304 con->fix = newfix;1305 1306 1269 // Update quality 1307 1270 con->quality = con->client->FetchQuality(); 1308 1271 con->power = con->client->FetchPower(); -
panelfront_display.cc
diff -urN kismet.dev/panelfront_display.cc kismet.dev2/panelfront_display.cc
old new 727 727 mvwaddstr(netwin, netwin->_maxy, netwin->_maxx - 14, ptxt); 728 728 } 729 729 730 #if def HAVE_GPS730 #if 0 731 731 732 732 733 733 if (!(lat == 0 && lon == 0 && alt == 0 && spd == 0 && fix == 0)) { … … 1496 1496 snprintf(output, print_width, "Networks: %d", (int) details_network->networks.size()); 1497 1497 kwin->text.push_back(output); 1498 1498 1499 if (details_network->virtnet->gps_fixed != -1) {1500 if ((details_network->virtnet->min_lat == 90) && (details_network->virtnet->min_lon == 180) &&1501 (details_network->virtnet->max_lat == -90) && (details_network->virtnet->max_lon == -180)) {1502 snprintf(output, print_width, "Min Loc : N/A");1503 kwin->text.push_back(output);1504 snprintf(output, print_width, "Max Loc : N/A");1505 kwin->text.push_back(output);1506 snprintf(output, print_width, "Range : N/A");1507 kwin->text.push_back(output);1508 }1509 else {1510 snprintf(output, print_width, "Min Loc : Lat %f Lon %f Alt %f Spd %f",1511 details_network->virtnet->min_lat, details_network->virtnet->min_lon,1512 metric ? details_network->virtnet->min_alt / 3.3 : details_network->virtnet->min_alt,1513 metric ? details_network->virtnet->min_spd * 1.6093 : details_network->virtnet->min_spd);1514 kwin->text.push_back(output);1515 snprintf(output, print_width, "Max Loc : Lat %f Lon %f Alt %f Spd %f",1516 details_network->virtnet->max_lat, details_network->virtnet->max_lon,1517 metric ? details_network->virtnet->max_alt / 3.3 : details_network->virtnet->max_alt,1518 metric ? details_network->virtnet->max_spd * 1.6093 : details_network->virtnet->max_spd);1519 kwin->text.push_back(output);1520 1521 double diagdist = GPSD::EarthDistance(details_network->virtnet->min_lat,1522 details_network->virtnet->min_lon,1523 details_network->virtnet->max_lat,1524 details_network->virtnet->max_lon);1525 1526 if (finite(diagdist)) {1527 if (metric) {1528 if (diagdist < 1000)1529 snprintf(output, print_width, "Range : %.3f meters", diagdist);1530 else1531 snprintf(output, print_width, "Range : %.3f kilometers", diagdist / 1000);1532 } else {1533 diagdist *= 3.3;1534 if (diagdist < 5280)1535 snprintf(output, print_width, "Range : %.3f feet", diagdist);1536 else1537 snprintf(output, print_width, "Range : %.3f miles", diagdist / 5280);1538 }1539 kwin->text.push_back(output);1540 }1541 }1542 }1543 1544 1499 if (details_network->virtnet->carrier_set & (1 << (int) carrier_80211b)) { 1545 1500 snprintf(output, print_width, "Carrier : IEEE 802.11b"); 1546 1501 kwin->text.push_back(output); … … 1853 1808 dnet->ipdata.range_ip[2], dnet->ipdata.range_ip[3]); 1854 1809 kwin->text.push_back(output); 1855 1810 } 1856 1857 if (dnet->gps_fixed != -1) {1858 if ((dnet->min_lat == 90) && (dnet->min_lon == 180) &&1859 (dnet->max_lat == -90) && (dnet->max_lon == -180)) {1860 snprintf(output, print_width, "Min Loc : N/A");1861 kwin->text.push_back(output);1862 snprintf(output, print_width, "Max Loc : N/A");1863 kwin->text.push_back(output);1864 snprintf(output, print_width, "Range : N/A");1865 kwin->text.push_back(output);1866 }1867 else {1868 snprintf(output, print_width, "Min Loc : Lat %f Lon %f Alt %f Spd %f",1869 dnet->min_lat, dnet->min_lon,1870 metric ? dnet->min_alt / 3.3 : dnet->min_alt,1871 metric ? dnet->min_spd * 1.6093 : dnet->min_spd);1872 kwin->text.push_back(output);1873 snprintf(output, print_width, "Max Loc : Lat %f Lon %f Alt %f Spd %f",1874 dnet->max_lat, dnet->max_lon,1875 metric ? dnet->max_alt / 3.3 : dnet->max_alt,1876 metric ? dnet->max_spd * 1.6093 : dnet->max_spd);1877 kwin->text.push_back(output);1878 1879 double diagdist = GPSD::EarthDistance(dnet->min_lat, dnet->min_lon,1880 dnet->max_lat, dnet->max_lon);1881 1882 if (finite(diagdist)) {1883 if (metric) {1884 if (diagdist < 1000)1885 snprintf(output, print_width, "Range : %f meters", diagdist);1886 else1887 snprintf(output, print_width, "Range : %f kilometers", diagdist / 1000);1888 } else {1889 diagdist *= 3.3;1890 if (diagdist < 5280)1891 snprintf(output, print_width, "Range : %f feet", diagdist);1892 else1893 snprintf(output, print_width, "Range : %f miles", diagdist / 5280);1894 }1895 kwin->text.push_back(output);1896 }1897 }1898 }1899 1811 } 1900 1812 1901 1813 // Now we just use the text printer to handle the rest for us … … 1903 1815 return TextPrinter(in_window); 1904 1816 } 1905 1817 1906 int PanelFront::GpsPrinter(void *in_window) {1907 kis_window *kwin = (kis_window *) in_window;1908 1909 char output[1024];1910 kwin->text.clear();1911 1912 if (details_network == NULL) {1913 kwin->text.push_back("The network or group being displayed");1914 kwin->text.push_back("has been deleted. Please select a ");1915 kwin->text.push_back("different network.");1916 return TextPrinter(in_window);1917 }1918 1919 wireless_network *dnet = details_network->virtnet;1920 1921 int print_width = kwin->print_width;1922 if (print_width > 1024)1923 print_width = 1023;1924 1925 if (print_width < 32) {1926 kwin->text.push_back("Display not wide enough");1927 return TextPrinter(in_window);1928 }1929 1930 if (dnet->aggregate_points == 0) {1931 kwin->text.push_back("No GPS data.");1932 return TextPrinter(in_window);1933 }1934 1935 float center_lat, center_lon;1936 1937 // We hijack the "selected" field as a toggle1938 if (kwin->selected == 1) {1939 center_lat = dnet->best_lat;1940 center_lon = dnet->best_lon;1941 } else {1942 center_lat = dnet->aggregate_lat / dnet->aggregate_points;1943 center_lon = dnet->aggregate_lon / dnet->aggregate_points;1944 }1945 1946 // Get bearing to the center1947 float center_angle = GPSD::CalcHeading(center_lat, center_lon, lat, lon);1948 1949 float difference_angle = heading - center_angle;1950 if (difference_angle < 0)1951 difference_angle += 360;1952 1953 double diagdist = GPSD::EarthDistance(lat, lon, center_lat, center_lon);1954 1955 // Now we know everything - where we are, where we are headed, where we SHOULD be headed1956 // to get to the supposed center of the network, how far it is, and the orientation on our1957 // compass to get to it. Time to start drawing our output.1958 1959 char compass[5][10];1960 memset(compass, 0, sizeof(char) * 5 * 10);1961 1962 // | 41.12345x-74.12345 .-|-/ |1963 // | Bearing: / |/ \ |1964 // | 123.23 degrees | O | |1965 // | \ \ / |1966 // | Estimated center: '---\ |1967 1968 1969 // Find the orientation on our compass:1970 if (difference_angle > 330 || difference_angle <= 22) {1971 snprintf(compass[0], 10, " .-|-. ");1972 snprintf(compass[1], 10, " / | \\ ");1973 snprintf(compass[2], 10, "| O |");1974 snprintf(compass[3], 10, " \\ / ");1975 snprintf(compass[4], 10, " '---' ");1976 } else if (difference_angle > 22 && difference_angle <= 66) {1977 snprintf(compass[0], 10, " .---/ ");1978 snprintf(compass[1], 10, " / / \\ ");1979 snprintf(compass[2], 10, "| O |");1980 snprintf(compass[3], 10, " \\ / ");1981 snprintf(compass[4], 10, " '---' ");1982 } else if (difference_angle > 66 && difference_angle <= 110) {1983 snprintf(compass[0], 10, " .---. ");1984 snprintf(compass[1], 10, " / \\ ");1985 snprintf(compass[2], 10, "| O----");1986 snprintf(compass[3], 10, " \\ / ");1987 snprintf(compass[4], 10, " '---' ");1988 } else if (difference_angle > 110 && difference_angle <= 154) {1989 snprintf(compass[0], 10, " .---. ");1990 snprintf(compass[1], 10, " / \\ ");1991 snprintf(compass[2], 10, "| O |");1992 snprintf(compass[3], 10, " \\ \\ / ");1993 snprintf(compass[4], 10, " '---\\ ");1994 } else if (difference_angle > 154 && difference_angle <= 198) {1995 snprintf(compass[0], 10, " .---. ");1996 snprintf(compass[1], 10, " / \\ ");1997 snprintf(compass[2], 10, "| O |");1998 snprintf(compass[3], 10, " \\ | / ");1999 snprintf(compass[4], 10, " '-|-' ");2000 } else if (difference_angle > 198 && difference_angle <= 242) {2001 snprintf(compass[0], 10, " .---. ");2002 snprintf(compass[1], 10, " / \\ ");2003 snprintf(compass[2], 10, "| O |");2004 snprintf(compass[3], 10, " \\ / / ");2005 snprintf(compass[4], 10, " /---' ");2006 } else if (difference_angle > 242 && difference_angle <= 286) {2007 snprintf(compass[0], 10, " .---. ");2008 snprintf(compass[1], 10, " / \\ ");2009 snprintf(compass[2], 10, "----O |");2010 snprintf(compass[3], 10, " \\ / ");2011 snprintf(compass[4], 10, " '---' ");2012 } else if (difference_angle > 286 && difference_angle <= 330) {2013 snprintf(compass[0], 10, " \\---. ");2014 snprintf(compass[1], 10, " / \\ \\ ");2015 snprintf(compass[2], 10, "| O |");2016 snprintf(compass[3], 10, " \\ / ");2017 snprintf(compass[4], 10, " '---' ");2018 } else {2019 snprintf(compass[0], 10, "%f\n", difference_angle);2020 }2021 2022 2023 // - Network GPS ---------------------|2024 // | Current: |2025 // | 41.12345x-74.12345 .-|-. |2026 // | Bearing: / | \ |2027 // | 123.23 degrees | O | |2028 // | \ \ / |2029 // | Estimated center: '---\ |2030 // | -73.12345x43.12345 |2031 // | 120 feet |2032 // ------------------------------------2033 char textfrag[23];2034 2035 snprintf(output, print_width, "Current:");2036 kwin->text.push_back(output);2037 2038 snprintf(textfrag, 23, "%.3f x %.3f", lat, lon);2039 snprintf(output, print_width, "%-22s%s", textfrag, compass[0]);2040 kwin->text.push_back(output);2041 2042 snprintf(textfrag, 23, " Bearing:");2043 snprintf(output, print_width, "%-22s%s", textfrag, compass[1]);2044 kwin->text.push_back(output);2045 2046 snprintf(textfrag, 23, " %.2f*", heading);2047 snprintf(output, print_width, "%-22s%s", textfrag, compass[2]);2048 kwin->text.push_back(output);2049 2050 snprintf(textfrag, 23, " ");2051 snprintf(output, print_width, "%-22s%s", textfrag, compass[3]);2052 kwin->text.push_back(output);2053 2054 if (kwin->selected == 1)2055 snprintf(textfrag, 23, "Strongest signal:");2056 else2057 snprintf(textfrag, 23, "Estimated Center:");2058 snprintf(output, print_width, "%-22s%s", textfrag, compass[4]);2059 kwin->text.push_back(output);2060 2061 snprintf(textfrag, 23, "%.3f x %.3f", center_lat, center_lon);2062 snprintf(output, print_width, "%-22s%.2f*", textfrag, difference_angle);2063 kwin->text.push_back(output);2064 2065 if (metric) {2066 if (diagdist < 1000)2067 snprintf(textfrag, 23, "%.2f m", diagdist);2068 else2069 snprintf(textfrag, 23, "%.2f km", diagdist / 1000);2070 } else {2071 diagdist *= 3.3;2072 if (diagdist < 5280)2073 snprintf(textfrag, 23, "%.2f ft", diagdist);2074 else2075 snprintf(textfrag, 23, "%.2f mi", diagdist / 5280);2076 }2077 2078 snprintf(output, print_width, "%-22s%s", "", textfrag);2079 kwin->text.push_back(output);2080 2081 return TextPrinter(in_window);2082 }2083 2084 1818 int PanelFront::PackPrinter(void *in_window) { 2085 1819 kis_window *kwin = (kis_window *) in_window; 2086 1820 … … 3049 2783 details_client->ipdata.ip[2], details_client->ipdata.ip[3]); 3050 2784 kwin->text.push_back(output); 3051 2785 3052 if (details_client->gps_fixed != -1) {3053 kwin->text.push_back("");3054 3055 if ((details_client->min_lat == 90) && (details_client->min_lon == 180) &&3056 (details_client->max_lat == -90) && (details_client->max_lon == -180)) {3057 snprintf(output, print_width, "Min Loc : N/A");3058 kwin->text.push_back(output);3059 snprintf(output, print_width, "Max Loc : N/A");3060 kwin->text.push_back(output);3061 snprintf(output, print_width, "Range : N/A");3062 kwin->text.push_back(output);3063 }3064 else {3065 snprintf(output, print_width, "Min Loc : Lat %f Lon %f Alt %f Spd %f",3066 details_client->min_lat, details_client->min_lon,3067 metric ? details_client->min_alt / 3.3 : details_client->min_alt,3068 metric ? details_client->min_spd * 1.6093 : details_client->min_spd);3069 kwin->text.push_back(output);3070 snprintf(output, print_width, "Max Loc : Lat %f Lon %f Alt %f Spd %f",3071 details_client->max_lat, details_client->max_lon,3072 metric ? details_client->max_alt / 3.3 : details_client->max_alt,3073 metric ? details_client->max_spd * 1.6093 : details_client->max_spd);3074 kwin->text.push_back(output);3075 3076 double diagdist = GPSD::EarthDistance(details_client->min_lat,3077 details_client->min_lon,3078 details_client->max_lat,3079 details_client->max_lon);3080 3081 if (finite(diagdist)) {3082 if (metric) {3083 if (diagdist < 1000)3084 snprintf(output, print_width, "Range : %f meters", diagdist);3085 else3086 snprintf(output, print_width, "Range : %f kilometers", diagdist / 1000);3087 } else {3088 diagdist *= 3.3;3089 if (diagdist < 5280)3090 snprintf(output, print_width, "Range : %f feet", diagdist);3091 else3092 snprintf(output, print_width, "Range : %f miles", diagdist / 5280);3093 }3094 kwin->text.push_back(output);3095 }3096 }3097 kwin->text.push_back("");3098 }3099 2786 3100 2787 snprintf(output, print_width, "Packets :"); 3101 2788 kwin->text.push_back(output); -
panelfront.h
diff -urN kismet.dev/panelfront.h kismet.dev2/panelfront.h
old new 65 65 #define SORT_SIZE 10 66 66 extern char *KismetHelpPower[]; 67 67 extern char *KismetHelpRate[]; 68 extern char *KismetHelpGps[];69 68 extern char *KismetHelpStats[]; 70 69 extern char *KismetHelpDump[]; 71 70 extern char *KismetHelpPack[]; … … 269 268 int RatePrinter(void *in_window); 270 269 int StatsPrinter(void *in_window); 271 270 int PackPrinter(void *in_window); 272 int GpsPrinter(void *in_window);273 271 int AlertPrinter(void *in_window); 274 272 275 273 int MainClientPrinter(void *in_window); … … 298 296 int PackInput(void *in_window, int in_chr); 299 297 // Help has a generic handler 300 298 int TextInput(void *in_window, int in_chr); 301 int GpsInput(void *in_window, int in_chr);302 299 int AlertInput(void *in_window, int in_chr); 303 300 304 301 int MainClientInput(void *in_window, int in_chr); -
panelfront_input.cc
diff -urN kismet.dev/panelfront_input.cc kismet.dev2/panelfront_input.cc
old new 300 300 break; 301 301 case 'f': 302 302 case 'F': 303 if (sortby != sort_auto && last_displayed.size() > 0) {304 details_network = last_displayed[kwin->selected];305 SpawnWindow("Network Location", &PanelFront::GpsPrinter, &PanelFront::GpsInput, 8, 34);306 } else {307 WriteStatus("Cannot view network GPS info in autofit sort mode. Sort by a different method.");308 }309 303 break; 310 304 case 'm': 311 305 case 'M': 312 MuteToggle();313 306 break; 314 307 case 'e': 315 308 case 'E': … … 447 440 switch(in_chr) { 448 441 case 'm': 449 442 case 'M': 450 MuteToggle();451 443 break; 452 444 case 'p': 453 445 case 'P': … … 546 538 return 1; 547 539 } 548 540 549 int PanelFront::GpsInput(void *in_window, int in_chr) {550 kis_window *kwin = (kis_window *) in_window;551 552 switch (in_chr) {553 case 's':554 case 'S':555 kwin->selected = 1;556 break;557 case 'c':558 case 'C':559 kwin->selected = 0;560 break;561 case 'h':562 case 'H':563 SpawnHelp(KismetHelpGps);564 break;565 case 'x':566 case 'X':567 case 'q':568 case 'Q':569 return 0;570 break;571 }572 573 return 1;574 }575 576 541 int PanelFront::RateInput(void *in_window, int in_chr) { 577 542 switch (in_chr) { 578 543 case 'h': … … 645 610 return 1; 646 611 } 647 612 648 void PanelFront::MuteToggle() {649 if (muted) {650 speech = old_speech;651 sound = old_sound;652 muted = 0;653 WriteStatus("Restoring sound");654 } else if (sound != 0 || speech != 0) {655 old_speech = speech;656 old_sound = sound;657 sound = 0;658 speech = 0;659 muted = 1;660 WriteStatus("Muting sound");661 } else if (sound == 0 && speech == 0) {662 WriteStatus("Sound not enabled.");663 }664 }665 666 613 int PanelFront::AlertInput(void *in_window, int in_chr) { 667 614 kis_window *kwin = (kis_window *) in_window; 668 615 -
pcapsource.cc
diff -urN kismet.dev/pcapsource.cc kismet.dev2/pcapsource.cc
old new 343 343 packet->moddata = moddata; 344 344 packet->modified = 0; 345 345 346 if (gpsd != NULL) {347 gpsd->FetchLoc(&packet->gps_lat, &packet->gps_lon, &packet->gps_alt,348 &packet->gps_spd, &packet->gps_heading, &packet->gps_fix);349 }350 351 346 if (datalink_type == DLT_PRISM_HEADER) { 352 347 ret = Prism2KisPack(packet, data, moddata); 353 348 } else if (datalink_type == KDLT_BSD802_11) { … … 1157 1152 1158 1153 // Monitor commands 1159 1154 #ifdef HAVE_LINUX_WIRELESS 1160 // Cisco uses its own config file in /proc to control modes1161 int monitor_cisco(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1162 FILE *cisco_config;1163 char cisco_path[128];1164 1165 linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));1166 (*in_if) = ifparm;1167 1168 if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {1169 return -1;1170 }1171 1172 if (Iwconfig_Get_SSID(in_dev, in_err, ifparm->essid) < 0)1173 return -1;1174 1175 if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)1176 return -1;1177 1178 if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)1179 return -1;1180 1181 if (Ifconfig_Delta_Flags(in_dev, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)1182 return -1;1183 1184 // Try the iwpriv1185 if (Iwconfig_Set_IntPriv(in_dev, "setRFMonitor", 1, 0, in_err) >= 0) {1186 return 0;1187 }1188 1189 // Zero the ssid - nonfatal1190 Iwconfig_Set_SSID(in_dev, in_err, NULL);1191 1192 // Build the proc control path1193 snprintf(cisco_path, 128, "/proc/driver/aironet/%s/Config", in_dev);1194 1195 if ((cisco_config = fopen(cisco_path, "w")) == NULL) {1196 snprintf(in_err, STATUS_MAX, "Unable to open cisco control file '%s' %d:%s",1197 cisco_path, errno, strerror(errno));1198 return -1;1199 }1200 1201 fprintf(cisco_config, "Mode: r\n");1202 fprintf(cisco_config, "Mode: y\n");1203 fprintf(cisco_config, "XmitPower: 1\n");1204 1205 fclose(cisco_config);1206 1207 // Channel can't be set on cisco with these drivers.1208 1209 return 0;1210 }1211 1212 int unmonitor_cisco(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1213 linux_ifparm *ifparm = (linux_ifparm *) (*in_if);1214 int ret = -1;1215 1216 // Try the iwpriv1217 if (Iwconfig_Set_IntPriv(in_dev, "setRFMonitor", 0, 0, in_err) >= 0) {1218 // If we're the new drivers, unmonitor1219 if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {1220 return -1;1221 }1222 1223 // Reset the SSID since monitor mode nukes it1224 if (Iwconfig_Set_SSID(in_dev, in_err, ifparm->essid) < 0)1225 return -1;1226 1227 if (ifparm->channel > 0) {1228 if (Iwconfig_Set_Channel(in_dev, ifparm->channel, in_err) < 0)1229 return -1;1230 }1231 1232 ret = 1;1233 }1234 1235 free(ifparm);1236 1237 return ret;1238 }1239 1240 // Cisco uses its own config file in /proc to control modes1241 //1242 // I was doing this with ioctls but that seems to cause lockups while1243 // this method doesn't. I don't think I like these drivers.1244 int monitor_cisco_wifix(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1245 FILE *cisco_config;1246 char cisco_path[128];1247 vector<string> devbits = StrTokenize(in_dev, ":");1248 1249 if (devbits.size() < 2) {1250 snprintf(in_err, STATUS_MAX, "Invalid device pair '%s'. Proper device "1251 "for cisco_wifix is eth?:wifi?.", in_dev);1252 return -1;1253 }1254 1255 // Bring the device up, zero its ip, and set promisc1256 if (Ifconfig_Delta_Flags(devbits[0].c_str(), in_err,1257 IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)1258 return -1;1259 if (Ifconfig_Delta_Flags(devbits[1].c_str(), in_err,1260 IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)1261 return -1;1262 1263 // Zero the ssid, nonfatally1264 Iwconfig_Set_SSID(devbits[0].c_str(), in_err, NULL);1265 Iwconfig_Set_SSID(devbits[1].c_str(), in_err, NULL);1266 1267 // Build the proc control path1268 snprintf(cisco_path, 128, "/proc/driver/aironet/%s/Config", devbits[0].c_str());1269 1270 if ((cisco_config = fopen(cisco_path, "w")) == NULL) {1271 snprintf(in_err, STATUS_MAX, "Unable to open cisco control file '%s' %d:%s",1272 cisco_path, errno, strerror(errno));1273 return -1;1274 }1275 1276 fprintf(cisco_config, "Mode: r\n");1277 fprintf(cisco_config, "Mode: y\n");1278 fprintf(cisco_config, "XmitPower: 1\n");1279 1280 fclose(cisco_config);1281 1282 // Channel can't be set on cisco with these drivers.1283 1284 return 0;1285 }1286 1287 1155 // Hostap uses iwpriv and iwcontrol settings to control monitor mode 1288 1156 int monitor_hostap(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) { 1289 1157 int ret; … … 1433 1301 1434 1302 } 1435 1303 1436 // Acx100 uses the packhdr iwpriv control to set link state, rest is normal1437 int monitor_acx100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1438 int ret;1439 1440 // Allocate a tracking record for the interface settings and remember our1441 // setup1442 linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));1443 (*in_if) = ifparm;1444 1445 if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {1446 return -1;1447 }1448 1449 if (Iwconfig_Get_SSID(in_dev, in_err, ifparm->essid) < 0)1450 return -1;1451 1452 if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)1453 return -1;1454 1455 if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)1456 return -1;1457 1458 // it looks like an orinoco now, apparently1459 if ((ret = Iwconfig_Set_IntPriv(in_dev, "monitor", 1, initch, in_err)) < 0) {1460 if (ret == -2)1461 snprintf(in_err, 1024, "Could not find 'monitor' private ioctl "1462 "Make sure you have the latest ACX100 development release.");1463 return -1;1464 }1465 1466 if (chancontrol_wext(in_dev, initch, in_err, NULL) < 0)1467 return -1;1468 1469 return 0;1470 }1471 1472 int unmonitor_acx100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1473 // Restore the IP settings1474 linux_ifparm *ifparm = (linux_ifparm *) (*in_if);1475 1476 if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {1477 return -1;1478 }1479 1480 Iwconfig_Set_IntPriv(in_dev, "monitor", 0, ifparm->channel, in_err);1481 Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode);1482 1483 if (Iwconfig_Set_SSID(in_dev, in_err, ifparm->essid) < 0)1484 return -1;1485 1486 free(ifparm);1487 1488 return 1;1489 }1490 1491 int monitor_admtek(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1492 // Allocate a tracking record for the interface settings and remember our1493 // setup1494 linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));1495 (*in_if) = ifparm;1496 1497 // Try to figure out the name so we know if we have fcs bytes or not1498 char iwname[IFNAMSIZ+1];1499 if (Iwconfig_Get_Name(in_dev, in_err, iwname) < 0)1500 return -1;1501 1502 if (strncmp(iwname, "IEEE 802.11b", IFNAMSIZ) == 0) {1503 // Looks like the GPL driver, we need to adjust the fcsbytes1504 PcapSource *psrc = (PcapSource *) in_ext;1505 psrc->fcsbytes = 4;1506 }1507 1508 if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {1509 return -1;1510 }1511 1512 if ((ifparm->flags & IFF_UP)) {1513 if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)1514 return -1;1515 1516 if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)1517 return -1;1518 1519 if (Iwconfig_Get_SSID(in_dev, in_err, ifparm->essid) < 0)1520 return -1;1521 1522 } else {1523 ifparm->channel = -1;1524 ifparm->mode = -1;1525 }1526 1527 int ret = monitor_wext(in_dev, initch, in_err, in_if, in_ext);1528 1529 if (ret < 0 && ret != -2)1530 return ret;1531 1532 if (Iwconfig_Set_SSID(in_dev, in_err, "") < 0)1533 return -1;1534 1535 return 0;1536 }1537 1538 int unmonitor_admtek(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1539 linux_ifparm *ifparm = (linux_ifparm *) (*in_if);1540 1541 if (unmonitor_wext(in_dev, initch, in_err, in_if, in_ext))1542 return -1;1543 1544 if (Iwconfig_Set_SSID(in_dev, in_err, ifparm->essid) < 0)1545 return -1;1546 1547 return 1;1548 }1549 // vtar5k iwpriv control to set link state, rest is normal1550 int monitor_vtar5k(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1551 // Set the prism iwpriv control to 11552 if (Iwconfig_Set_IntPriv(in_dev, "prism", 1, 0, in_err) < 0) {1553 return -1;1554 }1555 1556 // The rest is standard wireless extensions1557 if (monitor_wext(in_dev, initch, in_err, in_if, in_ext) < 0)1558 return -1;1559 1560 return 0;1561 }1562 1304 1563 1305 /* Madwifi NG ioctls from net80211 */ 1564 1306 #define SIOC80211IFCREATE (SIOCDEVPRIVATE+7) … … 1927 1669 return unmonitor_wext(in_dev, initch, in_err, in_if, in_ext); 1928 1670 } 1929 1671 1930 int monitor_ipw2100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1931 // Allocate a tracking record for the interface settings and remember our1932 // setup1933 linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));1934 (*in_if) = ifparm;1935 1936 if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {1937 return -1;1938 }1939 1940 if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)1941 return -1;1942 1943 if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)1944 return -1;1945 1946 // Call the normal monitor mode1947 return (monitor_wext(in_dev, initch, in_err, in_if, in_ext));1948 }1949 1950 int unmonitor_ipw2100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {1951 // Restore initial monitor header1952 // linux_ifparm *ifparm = (linux_ifparm *) (*in_if);1953 1954 linux_ifparm *ifparm = (linux_ifparm *) (*in_if);1955 1956 if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {1957 return -1;1958 }1959 1960 if (Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode) < 0)1961 return -1;1962 1963 free(ifparm);1964 1965 return 1;1966 }1967 1968 int monitor_ipw2200(const char *in_dev, int initch, char *in_err,1969 void **in_if, void *in_ext) {1970 // Allocate a tracking record for the interface settings and remember our1971 // setup1972 linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));1973 (*in_if) = ifparm;1974 1975 if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {1976 return -1;1977 }1978 1979 if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)1980 return -1;1981 1982 if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)1983 return -1;1984 1985 // Call the normal monitor mode1986 return (monitor_wext(in_dev, initch, in_err, in_if, in_ext));1987 }1988 1989 int unmonitor_ipw2200(const char *in_dev, int initch, char *in_err,1990 void **in_if, void *in_ext) {1991 // Restore initial monitor header1992 // linux_ifparm *ifparm = (linux_ifparm *) (*in_if);1993 1994 linux_ifparm *ifparm = (linux_ifparm *) (*in_if);1995 1996 if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {1997 return -1;1998 }1999 2000 if (Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode) < 0)2001 return -1;2002 2003 // James says this wants to be set to channel 0 for proper scanning operation2004 if (Iwconfig_Set_Channel(in_dev, 0, in_err) < 0)2005 return -1;2006 2007 free(ifparm);2008 2009 return 1;2010 }2011 2012 // (Unless we learn different) the 3945 in full rfmon acts the same as2013 // an ipw2200, so we'll use the same control mechanisms2014 int monitor_ipw3945(const char *in_dev, int initch, char *in_err,2015 void **in_if, void *in_ext) {2016 // Allocate a tracking record for the interface settings and remember our2017 // setup2018 linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));2019 (*in_if) = ifparm;2020 2021 if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {2022 return -1;2023 }2024 2025 if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)2026 return -1;2027 2028 if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)2029 return -1;2030 2031 // Call the normal monitor mode2032 return (monitor_wext(in_dev, initch, in_err, in_if, in_ext));2033 }2034 2035 int unmonitor_ipw3945(const char *in_dev, int initch, char *in_err,2036 void **in_if, void *in_ext) {2037 // Restore initial monitor header2038 // linux_ifparm *ifparm = (linux_ifparm *) (*in_if);2039 2040 linux_ifparm *ifparm = (linux_ifparm *) (*in_if);2041 2042 if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {2043 return -1;2044 }2045 2046 if (Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode) < 0)2047 return -1;2048 2049 // James says this wants to be set to channel 0 for proper scanning operation2050 if (Iwconfig_Set_Channel(in_dev, 0, in_err) < 0)2051 return -1;2052 2053 free(ifparm);2054 2055 return 1;2056 }2057 2058 // The 3945 in "parasite" mode (until James names it) is a different2059 // beast entirely. It uses a dynamically added tap interface to give us2060 // realtime rtap formatted frames off the interface, so we need to2061 // turn it on via sysfs and then push the new rtapX interface into the source2062 // before the open happens2063 int monitor_ipwlivetap(const char *in_dev, int initch, char *in_err,2064 void **in_if, void *in_ext) {2065 // We don't try to remember settings because we aren't going to do2066 // anything with them, we're leeching off a dynamic interface made2067 // just for us.2068 char dynif[32];2069 FILE *sysf;2070 char path[1024];2071 short int ifflags;2072 2073 // Try to get the flags off the master interface2074 if (Ifconfig_Get_Flags(in_dev, in_err, &ifflags) < 0) {2075 return -1;2076 }2077 2078 // If the master interface isn't even up, blow up.2079 if ((ifflags & IFF_UP) == 0) {2080 snprintf(in_err, 1024, "The ipw control interface (%s) is not "2081 "configured as 'up'. The ipwlivetap mode reports "2082 "traffic from a currently running interface. For pure "2083 "rfmon monitor mode, use ipwXXXX instead.", in_dev);2084 return -1;2085 }2086 2087 // Use the .../net/foo/device symlink into the .../bus/pci/drivers/2088 // ipw3945/foo/ pci bus interface2089 snprintf(path, 1024, "/sys/class/net/%s/device/rtap_iface",2090 in_dev);2091 2092 // Open it in RO mode first and get the current state. I'm not sure2093 // how well frewind works on a dynamic system file so we'll just2094 // close it off and re-open it when we go to set modes, if we need2095 // to.2096 if ((sysf = fopen(path, "r")) == NULL) {2097 snprintf(in_err, 1024, "Failed to open ipw sysfs tap control file, "2098 "check that the version of the ipw drivers you are running "2099 "is recent enough, and that your system has sysfs properly "2100 "set up.");2101 return -1;2102 }2103 2104 fgets(dynif, 32, sysf);2105 2106 // We're done with the RO2107 fclose(sysf);2108 2109 // If it's -1, we aren't turned on and we need to.2110 if (strncmp(dynif, "-1", 32) == 0) {2111 if ((sysf = fopen(path, "w")) == NULL) {2112 snprintf(in_err, 1024, "Failed to open the ipw sysfs tap control "2113 "file for writing (%s). Check that Kismet has the proper "2114 "privilege levels and that you are running a version of the "2115 "ipw drivers which supports associated rfmon.", strerror(errno));2116 return -1;2117 }2118 2119 fprintf(sysf, "1\n");2120 fclose(sysf);2121 2122 // Reopen it again for reading for the last time, and get the2123 // interface we changed to. Do some minor error checking to make2124 // sure the new interface isn't called -1, 0, or 1, which I'm going2125 // to guess would imply an older driver2126 if ((sysf = fopen(path, "r")) == NULL) {2127 snprintf(in_err, 1024, "Failed to open the ipw sysfs tap "2128 "control to find the interface allocated. Something strange "2129 "has happened, because the control file was available "2130 "previously for setting. Check your system messages.");2131 return -1;2132 }2133 2134 fgets(dynif, 32, sysf);2135 2136 fclose(sysf);2137 2138 // Wait for the distro to settle if its going to rename an interface2139 sleep(1);2140 }2141 2142 // Sanity check the interface we were told to use. A 0, 1, -1 probably2143 // means a bad driver version.2144 if (strncmp(dynif, "-1", 32) == 0 || strncmp(dynif, "0", 32) == 0 ||2145 strncmp(dynif, "1", 32) == 0) {2146 snprintf(in_err, 1024, "Got a nonsense interface from the ipw "2147 "sysfs tap control file. This probably means your ipw "2148 "drivers are out of date, or that there is something strange "2149 "happening in the drivers. Check your system messages.");2150 return -1;2151 }2152 2153 // Now that we've gone through that nonsense, make sure the2154 // dynamic rtap interface is up2155 if (Ifconfig_Delta_Flags(dynif, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)2156 return -1;2157 2158 // And push the config into the packetsoure2159 ((KisPacketSource *) in_ext)->SetInterface(dynif);2160 2161 return 1;2162 }2163 2164 int unmonitor_ipwlivetap(const char *in_dev, int initch, char *in_err,2165 void **in_if, void *in_ext) {2166 // Actually there isn't anything to do here. Right now, I don't2167 // think I care if we leave the parasite rtap interface hanging around.2168 // Newcore might do this better, but this isn't newcore.2169 2170 return 1;2171 }2172 2173 1672 // "standard" wireless extension monitor mode 2174 1673 int monitor_wext(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) { 2175 1674 int mode; … … 2231 1730 #endif 2232 1731 2233 1732 #ifdef SYS_LINUX 2234 // wlan-ng modern standard2235 int monitor_wlanng(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {2236 // I really didn't want to do this...2237 char cmdline[2048];2238 2239 // Sanitize the device just to be safe. The ifconfig should fail if2240 // the device is invalid, but why take risks2241 for (unsigned int x = 0; x < strlen(in_dev); x++) {2242 if (!isalnum(in_dev[x])) {2243 snprintf(in_err, STATUS_MAX, "Invalid device '%s'", in_dev);2244 return -1;2245 }2246 }2247 2248 if (Ifconfig_Delta_Flags(in_dev, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)2249 return -1;2250 2251 // Enable the interface2252 snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_ifstate ifstate=enable >/dev/null 2>/dev/null", in_dev);2253 if (RunSysCmd(cmdline) < 0) {2254 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2255 return -1;2256 }2257 2258 // Turn off WEP2259 snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "2260 "mibattribute=dot11PrivacyInvoked=false >/dev/null 2>/dev/null", in_dev);2261 if (RunSysCmd(cmdline) < 0) {2262 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2263 return -1;2264 }2265 2266 // Don't exclude packets2267 snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "2268 "mibattribute=dot11ExcludeUnencrypted=false >/dev/null 2>/dev/null", in_dev);2269 if (RunSysCmd(cmdline) < 0) {2270 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2271 return -1;2272 }2273 2274 // Turn on rfmon on the initial channel2275 snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d "2276 "enable=true prismheader=true >/dev/null 2>/dev/null", in_dev, initch);2277 if (RunSysCmd(cmdline) < 0) {2278 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2279 return -1;2280 }2281 2282 return 0;2283 }2284 2285 // wlan-ng avs2286 int monitor_wlanng_avs(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {2287 // I really didn't want to do this...2288 char cmdline[2048];2289 2290 // Sanitize the device just to be safe. The ifconfig should fail if2291 // the device is invalid, but why take risks2292 for (unsigned int x = 0; x < strlen(in_dev); x++) {2293 if (!isalnum(in_dev[x])) {2294 snprintf(in_err, STATUS_MAX, "Invalid device '%s'", in_dev);2295 return -1;2296 }2297 }2298 2299 if (Ifconfig_Delta_Flags(in_dev, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)2300 return -1;2301 2302 // Enable the interface2303 snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_ifstate ifstate=enable >/dev/null 2>/dev/null", in_dev);2304 if (RunSysCmd(cmdline) < 0) {2305 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2306 return -1;2307 }2308 2309 // Turn off WEP2310 snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "2311 "mibattribute=dot11PrivacyInvoked=false >/dev/null 2>/dev/null", in_dev);2312 if (RunSysCmd(cmdline) < 0) {2313 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2314 return -1;2315 }2316 2317 // Don't exclude packets2318 snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "2319 "mibattribute=dot11ExcludeUnencrypted=false >/dev/null 2>/dev/null", in_dev);2320 if (RunSysCmd(cmdline) < 0) {2321 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2322 return -1;2323 }2324 2325 // Turn on rfmon on the initial channel2326 snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d prismheader=false "2327 "wlanheader=true stripfcs=false keepwepflags=false enable=true >/dev/null 2>/dev/null", in_dev, initch);2328 if (RunSysCmd(cmdline) < 0) {2329 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2330 return -1;2331 }2332 2333 return 0;2334 }2335 2336 1733 int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, 2337 1734 void *in_ext) { 2338 1735 char cmdline[2048]; … … 2342 1739 snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 1'. " 2343 1740 "Some custom firmware images require you to specify the origial " 2344 1741 "device and a new dynamic device and use the iwconfig controls. " 2345 "see the README for how to configure your capture source." );1742 "see the README for how to configure your capture source.", in_dev); 2346 1743 return -1; 2347 1744 } 2348 1745 … … 2359 1756 snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 0'. " 2360 1757 "Some custom firmware images require you to specify the origial " 2361 1758 "device and a new dynamic device and use the iwconfig controls. " 2362 "see the README for how to configure your capture source." );1759 "see the README for how to configure your capture source.", in_dev); 2363 1760 return -1; 2364 1761 } 2365 1762 … … 2607 2004 return 0; 2608 2005 } 2609 2006 2610 int chancontrol_ipw2100(const char *in_dev, int in_ch, char *in_err, void *in_ext) {2611 // Introduce a slight delay to let the driver settle, a la orinoco. I don't2612 // like doing this at all since it introduces hiccups into the channel control2613 // process, but....2614 2615 int ret = 0;2616 2617 ret = chancontrol_wext(in_dev, in_ch, in_err, in_ext);2618 usleep(5000);2619 2620 return ret;2621 }2622 2623 int chancontrol_ipw2200(const char *in_dev, int in_ch, char *in_err, void *in_ext) {2624 // Lets see if this really needs the channel change delay like the 2100 did2625 int ret = 0;2626 2627 ret = chancontrol_wext(in_dev, in_ch, in_err, in_ext);2628 // Drop a tiny sleep in here to let the channel set settle, otherwise we2629 // run the risk of the card freaking out2630 usleep(7000);2631 2632 return ret;2633 }2634 2635 #endif2636 2637 #ifdef SYS_LINUX2638 int chancontrol_wlanng(const char *in_dev, int in_ch, char *in_err, void *in_ext) {2639 // I really didn't want to do this...2640 char cmdline[2048];2641 2642 // Turn on rfmon on the initial channel2643 snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d enable=true "2644 "prismheader=true >/dev/null 2>&1", in_dev, in_ch);2645 if (RunSysCmd(cmdline) < 0) {2646 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2647 return -1;2648 }2649 2650 if (in_ext != NULL) {2651 PcapSourceWlanng *src = (PcapSourceWlanng *) in_ext;2652 src->last_channel = in_ch;2653 }2654 2655 return 0;2656 }2657 2658 int chancontrol_wlanng_avs(const char *in_dev, int in_ch, char *in_err, void *in_ext) {2659 // I really didn't want to do this...2660 char cmdline[2048];2661 2662 // Turn on rfmon on the initial channel2663 snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d "2664 "prismheader=false wlanheader=true stripfcs=false keepwepflags=false "2665 "enable=true >/dev/null 2>&1", in_dev, in_ch);2666 2667 if (RunSysCmd(cmdline) < 0) {2668 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);2669 return -1;2670 }2671 2672 if (in_ext != NULL) {2673 PcapSourceWlanng *src = (PcapSourceWlanng *) in_ext;2674 src->last_channel = in_ch;2675 }2676 2677 return 0;2678 }2679 2007 #endif 2680 2008 2681 2009 #ifdef SYS_OPENBSD -
tcpstreamer.cc
diff -urN kismet.dev/tcpstreamer.cc kismet.dev2/tcpstreamer.cc
old new 30 30 serv_fd = 0; 31 31 32 32 max_fd = 0; 33 34 gpsd = NULL;35 33 } 36 34 37 35 TcpStreamer::~TcpStreamer() … … 287 285 hdr.frame_len = (uint32_t) htonl(sizeof(struct stream_version_packet)); 288 286 289 287 vpkt.drone_version = (uint16_t) htons(STREAM_DRONE_VERSION); 290 if (gpsd != NULL)291 vpkt.gps_enabled = 1;292 else293 vpkt.gps_enabled = 0;294 288 295 289 if (!FD_ISSET(in_fd, &client_fds)) 296 290 return -1; -
tcpstreamer.h
diff -urN kismet.dev/tcpstreamer.h kismet.dev2/tcpstreamer.h
old new 42 42 #include "ringbuf.h" 43 43 #include "packet.h" 44 44 #include "packetstream.h" 45 #include "gpsd.h"46 45 47 46 // Global in kismet_drone.cc 48 47 extern int silent; … … 76 75 77 76 int FetchDescriptor() { return serv_fd; } 78 77 79 // Register the GPS server for us to use80 void AddGpstracker(GPSD *in_gpsd) { gpsd = in_gpsd; }81 82 78 void Kill(int in_fd); 83 79 84 80 int Poll(fd_set& in_rset, fd_set& in_wset); … … 124 120 fd_set client_fds; 125 121 126 122 unsigned int max_fd; 127 128 GPSD *gpsd;129 123 }; 130 124 131 125 #endif
Note:
See TracBrowser
for help on using the repository browser.
