keyboard.c File Reference

#include <include.h>
#include <src/crt_io.h>
#include <src/functions.h>
#include <src/airjack.h>
#include <src/driver.h>
#include <src/analyse.h>
#include <src/interface.h>

Include dependency graph for keyboard.c:

Go to the source code of this file.

Defines

#define CLEAR_KEYBOARD_BUFFER   memset (keystring, 0, KEYBOARD_BUFFER);keyindex = 0;

Functions

void parse_keystring ()
void check_keys_th (void)

Variables

static const char svnid [] = "@(#) $Id: keyboard.c 175 2007-07-25 15:44:55Z poggij $"
char keystring [8]
int keyindex = 0
UINT8 stop_sniffing
pthread_mutex_t screen_mutex
 MUTEX for lock screen, so only one func write to it at the same time.
WINDOW * Title_WND
WINDOW * Panel_WND
WINDOW * Sum_WND
WINDOW * RealTime_WND
ConfigStruct config


Define Documentation

#define CLEAR_KEYBOARD_BUFFER   memset (keystring, 0, KEYBOARD_BUFFER);keyindex = 0;

Definition at line 47 of file keyboard.c.

Referenced by parse_keystring().


Function Documentation

void parse_keystring ( void   ) 

Definition at line 49 of file keyboard.c.

References AIRJACK_CARD, CHANNEL_MAX, ConfigStruct::ChannelHop, CLEAR_KEYBOARD_BUFFER, ClearPanel(), debug, ConfigStruct::DebugLevel, ConfigStruct::devname, DISPLAY_ACK_BIT, DISPLAY_BEACON_BIT, DISPLAY_CONTROL_BIT, DISPLAY_DATA_BIT, DISPLAY_PROBE_BIT, DISPLAY_STATION_BIT, ConfigStruct::DoNotDisplay, EXIT_WITH_Q, FALSE, ConfigStruct::FirstNIC, HOP_MAX, HOP_MIN, ConfigStruct::JammingNow, KEYBOARD_BUFFER, keyindex, keystring, MAX_DEBUG_LEVEL, ResetAllDetectedClient(), screen_mutex, selectChannel(), Send_To_All_BSSID_A_Deauth(), ConfigStruct::SingleChannel, stop_sniffing, SWITCH_BIT, TIME_TO_SLEEP_BEFORE_CHANGE_CHANNEL, ConfigStruct::TimeToSleepBeforeChangeChannel, TRUE, ConfigStruct::TypeOfCard, and warning().

Referenced by check_keys_th().

00050 {
00051   register int chan = 0;
00052   register int ret = 0;
00053 
00054   switch (keyindex) {
00055   case 1:
00056     switch (keystring[0]) {
00057     case '+':                  // Go to next channel
00058     case '-':                  // Go to previous channel
00059       chan = config.SingleChannel;
00060       if ((keystring[0] == '+')
00061           && (config.SingleChannel < 14))
00062         config.SingleChannel++;
00063       if ((keystring[0] == '-')
00064           && (config.SingleChannel > 0))
00065         config.SingleChannel--;
00066 
00067       config.SingleChannel = (config.SingleChannel % (CHANNEL_MAX + 1));
00068 
00069       ret = selectChannel(config.devname, config.SingleChannel);
00070       if (ret != 0) {
00071         selectChannel(config.devname, chan);    // PB, so go back previous channel
00072         config.SingleChannel = chan;
00073         warning("Channel %d is forbidden (%d)\n", chan, ret);
00074       }
00075       CLEAR_KEYBOARD_BUFFER;
00076       break;
00077     case 'a':                  // Go to next channel
00078     case 'w':                  // Go to previous channel
00079       if ((keystring[0] == 'a') && (config.FirstNIC > 0))
00080         config.FirstNIC--;
00081       if (keystring[0] == 'w')
00082         config.FirstNIC++;
00083       debug(3, "config.FirstNIC = %d\n", config.FirstNIC);
00084       CLEAR_KEYBOARD_BUFFER;
00085       break;
00086     case 'q':
00087       warning(" UPPER Q to Quit\n");
00088       CLEAR_KEYBOARD_BUFFER;
00089       break;
00090     case 'Q':                  // It's time to exit
00091       // We don't need to stop, if we know that we will stop
00092       if (!stop_sniffing) {
00093 #ifdef WITH_THREAD
00094         // Clean and Force STOP the thread
00095         pthread_mutex_unlock(&screen_mutex);
00096         pthread_mutex_destroy(&screen_mutex);
00097 #endif
00098         warning("Q was hit - sniffing aborted\n\n");
00099         stop_sniffing = EXIT_WITH_Q;
00100       }
00101       break;
00102     case 'r':
00103       // Do a reset of all captured station
00104       // Thank's to Guillaume Lehembre for the Idea
00105       ResetAllDetectedClient();
00106       ClearPanel();
00107       CLEAR_KEYBOARD_BUFFER;
00108       break;
00109     case 's':                  // change channel more Slowly
00110       if (config.TimeToSleepBeforeChangeChannel < 500)
00111         config.TimeToSleepBeforeChangeChannel += 10;
00112       else
00113         config.TimeToSleepBeforeChangeChannel += 100;
00114       debug(2,
00115             "config.TimeToSleepBeforeChangeChannel = %d ms\n",
00116             config.TimeToSleepBeforeChangeChannel);
00117       CLEAR_KEYBOARD_BUFFER;
00118       break;
00119     case 'f':                  // change channel more Fast
00120       if (config.TimeToSleepBeforeChangeChannel < 500)
00121         config.TimeToSleepBeforeChangeChannel -= 10;
00122       else
00123         config.TimeToSleepBeforeChangeChannel -= 100;
00124       if (config.TimeToSleepBeforeChangeChannel < 25)
00125         config.TimeToSleepBeforeChangeChannel = 25;
00126       debug(2,
00127             "config.TimeToSleepBeforeChangeChannel = %d ms\n",
00128             config.TimeToSleepBeforeChangeChannel);
00129       CLEAR_KEYBOARD_BUFFER;
00130       break;
00131     case 'd':                  // default TimeToSleepBeforeChangeChannel
00132       config.TimeToSleepBeforeChangeChannel =
00133           TIME_TO_SLEEP_BEFORE_CHANGE_CHANNEL;
00134       debug(2,
00135             "config.TimeToSleepBeforeChangeChannel = %d ms\n",
00136             config.TimeToSleepBeforeChangeChannel);
00137       CLEAR_KEYBOARD_BUFFER;
00138       break;
00139     case 'h':
00140       warning("Help :\n" "Q for quit\n"
00141               "c??c to scan channel ??\n"
00142               "+ - to increment or decrement channel to scan\n"
00143               "a w to scroll in the upper window\n"
00144               "f s d for scan more fast, more slow and default time\n"
00145               "j+ j- for changing channel hop\n"
00146               "v+ v- for changing verbose level\n"
00147               "n abcdps for hiding/showing Ack, Beacon, Control, Data, Probe and Stations\n"
00148         "r reset all detected packet\n"
00149               "D Send de-authentication to all BSSID\n"
00150               "J Start/Stop jamming\n"
00151               "Q exit, stop, quit, goback home ...\n");
00152       CLEAR_KEYBOARD_BUFFER;
00153       break;
00154     case 'D':
00155       // Send De-authentification to ALL BSSID :-)
00156       // Work only with AIRJACK driver
00157       if (config.TypeOfCard == AIRJACK_CARD) {
00158         Send_To_All_BSSID_A_Deauth();
00159       } else {
00160         warning
00161             ("De-authentication is only available with Airjack26 driver\n");
00162       }
00163       CLEAR_KEYBOARD_BUFFER;
00164       break;
00165     case 'J':
00166       // Activate the Jamming process
00167       //  send de-authentication to FF:FF:FF:FF:FF:FF when a beacon is detected
00168       if (config.TypeOfCard == AIRJACK_CARD) {
00169         if (config.JammingNow == TRUE) {
00170           config.JammingNow = FALSE;
00171         } else {
00172           config.JammingNow = TRUE;
00173         }
00174       } else {
00175         warning("Jamming is only available with Airjack26 driver\n");
00176       }
00177       CLEAR_KEYBOARD_BUFFER;
00178       break;
00179     case 'c':                  // a 4 key option
00180     case 'j':                  // a 2 key option
00181     case 'v':                  // a 2 key option
00182     case 'n':                  // a 2 key option
00183       break;
00184     default:                   // the user hit the keyboard, but don't know what he do
00185       CLEAR_KEYBOARD_BUFFER;
00186       break;
00187     }
00188     break;
00189   case 2:
00190     switch (keystring[0]) {
00191     case 'c':
00192       break;
00193     case 'j':
00194       switch (keystring[1]) {
00195       case '+':                // Go to next channel hop
00196         if (config.ChannelHop < HOP_MAX)
00197           config.ChannelHop++;
00198         break;
00199       case '-':                // Go to previous channel hop
00200         if (config.ChannelHop > HOP_MIN)
00201           config.ChannelHop--;
00202         break;
00203       default:
00204         break;
00205       }
00206       debug(2, "config.ChannelHop = %d\n", config.ChannelHop);
00207       CLEAR_KEYBOARD_BUFFER;
00208       break;
00209     case 'v':
00210       switch (keystring[1]) {
00211       case '+':                // Be more verbose
00212         if (config.DebugLevel < MAX_DEBUG_LEVEL)
00213           config.DebugLevel++;
00214         break;
00215       case '-':                // Be less verbose
00216         if (config.DebugLevel > 0)
00217           config.DebugLevel--;
00218         break;
00219       default:
00220         CLEAR_KEYBOARD_BUFFER;
00221         break;
00222       }
00223       debug(1, "DebugLevel=%d\n", config.DebugLevel);
00224       CLEAR_KEYBOARD_BUFFER;
00225       keyindex = 0;
00226       memset(keystring, 0, KEYBOARD_BUFFER);
00227       break;
00228     case 'n':
00229       switch (keystring[1]) {
00230       case 'a':
00231         SWITCH_BIT(config.DoNotDisplay, DISPLAY_ACK_BIT);
00232         debug(1, "Switch display of ACK\n");
00233         break;
00234       case 'b':
00235         SWITCH_BIT(config.DoNotDisplay, DISPLAY_BEACON_BIT);
00236         debug(1, "Switch display of BEACON\n");
00237         break;
00238       case 'c':
00239         SWITCH_BIT(config.DoNotDisplay, DISPLAY_CONTROL_BIT);
00240         debug(1, "Switch display of CONTROL\n");
00241         break;
00242       case 'd':
00243         SWITCH_BIT(config.DoNotDisplay, DISPLAY_DATA_BIT);
00244         debug(1, "Switch display of DATA\n");
00245         break;
00246       case 'p':
00247         SWITCH_BIT(config.DoNotDisplay, DISPLAY_PROBE_BIT);
00248         debug(1, "Switch display of PROBE REQ/RES\n");
00249         break;
00250       case 's':
00251         SWITCH_BIT(config.DoNotDisplay, DISPLAY_STATION_BIT);
00252         debug(1, "Switch display of STATION\n");
00253   ClearPanel();
00254         break;
00255       default:
00256         CLEAR_KEYBOARD_BUFFER;
00257         break;
00258       }
00259       CLEAR_KEYBOARD_BUFFER;
00260       break;
00261     default:
00262       CLEAR_KEYBOARD_BUFFER;
00263       break;
00264     }
00265     break;
00266   case 3:
00267     break;
00268   case 4:
00269     // Sequence : C??C
00270     // Change channel to a fixed channel
00271     if (keystring[0] == 'c' && keystring[3] == 'c') {
00272       keystring[3] = '\0';
00273 
00274       if (keystring[1] == '0')
00275         chan = atoi(keystring + 2);
00276       else
00277         chan = atoi(keystring + 1);
00278 
00279       if (chan >= 0 && chan <= CHANNEL_MAX) {
00280         ret = selectChannel(config.devname, chan);
00281         if (ret == 0) {
00282           config.SingleChannel = (UINT8) chan;  // All is OK
00283         } else {
00284           selectChannel(config.devname, config.SingleChannel);  // PB, so go back previous channel
00285           warning("Channel %d is forbidden (%d)\n", chan, ret);
00286         }
00287         memset(keystring, 0, KEYBOARD_BUFFER);
00288         keyindex = 0;
00289       }
00290       debug(2, "Scan only channel %d\n", config.SingleChannel);
00291     } else {
00292       CLEAR_KEYBOARD_BUFFER;
00293     }
00294     break;
00295   default:                     // the user hit the keyboard, but don't know what he do
00296     CLEAR_KEYBOARD_BUFFER;      // So we think that it was sleeping  ;-) and forget ...
00297     break;
00298   }
00299 }

void check_keys_th ( void   ) 

Definition at line 305 of file keyboard.c.

References debug, KEYBOARD_BUFFER, keyindex, keystring, parse_keystring(), screen_mutex, stop_sniffing, Sum_WND, and TRUE.

Referenced by main().

00306 {
00307   UINT8 car;
00308 
00309   nodelay(stdscr, TRUE);        // FIXME move it ...
00310   while (stop_sniffing == 0) {
00311     //if ((car = tolower(getch())) != ERR) {
00312     if ((car = getch()) != ERR) {
00313       if ((car >= ' ') && (car <= '~')) {
00314         // Check if it's not a bad char
00315         keystring[keyindex] = car;
00316         debug(3, "We Hit : #%c# - keyindex=%d\n", keystring[keyindex],
00317               keyindex);
00318         keyindex = (keyindex + 1) % KEYBOARD_BUFFER;
00319         pthread_mutex_lock(&screen_mutex);
00320         mvwprintw(Sum_WND, 11, 11, "(%-4s)", keystring);
00321         wrefresh(Sum_WND);
00322         pthread_mutex_unlock(&screen_mutex);
00323         parse_keystring();
00324       }
00325     }
00326     //pthread_delay_np (&delay);
00327     usleep(100000);
00328   }
00329 }


Variable Documentation

const char svnid[] = "@(#) $Id: keyboard.c 175 2007-07-25 15:44:55Z poggij $" [static]

Definition at line 33 of file keyboard.c.

char keystring[8]

Definition at line 35 of file keyboard.c.

Referenced by check_keys_th(), and parse_keystring().

int keyindex = 0

Definition at line 36 of file keyboard.c.

Referenced by check_keys_th(), and parse_keystring().

Definition at line 69 of file scanner.c.

pthread_mutex_t screen_mutex

MUTEX for lock screen, so only one func write to it at the same time.

Definition at line 67 of file scanner.c.

WINDOW* Title_WND

Definition at line 61 of file scanner.c.

WINDOW * Panel_WND

Definition at line 61 of file scanner.c.

WINDOW * Sum_WND

Definition at line 61 of file scanner.c.

WINDOW * RealTime_WND

Definition at line 61 of file scanner.c.

Definition at line 58 of file scanner.c.


Generated on Fri Jul 25 17:11:07 2008 for WifiScanner by  doxygen 1.5.5