00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <include.h>
00026 #include <src/crt_io.h>
00027 #include <src/functions.h>
00028 #include <src/airjack.h>
00029 #include <src/driver.h>
00030 #include <src/analyse.h>
00031 #include <src/interface.h>
00032
00033 static const char svnid[] = "@(#) $Id: keyboard.c 175 2007-07-25 15:44:55Z poggij $";
00034
00035 char keystring[KEYBOARD_BUFFER];
00036 int keyindex = 0;
00037
00038 extern UINT8 stop_sniffing;
00039 extern pthread_mutex_t screen_mutex;
00040 extern WINDOW *Title_WND, *Panel_WND, *Sum_WND, *RealTime_WND;
00041 extern ConfigStruct config;
00042
00043
00044
00045
00046
00047 #define CLEAR_KEYBOARD_BUFFER memset (keystring, 0, KEYBOARD_BUFFER);keyindex = 0;
00048
00049 void parse_keystring()
00050 {
00051 register int chan = 0;
00052 register int ret = 0;
00053
00054 switch (keyindex) {
00055 case 1:
00056 switch (keystring[0]) {
00057 case '+':
00058 case '-':
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);
00072 config.SingleChannel = chan;
00073 warning("Channel %d is forbidden (%d)\n", chan, ret);
00074 }
00075 CLEAR_KEYBOARD_BUFFER;
00076 break;
00077 case 'a':
00078 case 'w':
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':
00091
00092 if (!stop_sniffing) {
00093 #ifdef WITH_THREAD
00094
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
00104
00105 ResetAllDetectedClient();
00106 ClearPanel();
00107 CLEAR_KEYBOARD_BUFFER;
00108 break;
00109 case 's':
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':
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':
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
00156
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
00167
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':
00180 case 'j':
00181 case 'v':
00182 case 'n':
00183 break;
00184 default:
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 '+':
00196 if (config.ChannelHop < HOP_MAX)
00197 config.ChannelHop++;
00198 break;
00199 case '-':
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 '+':
00212 if (config.DebugLevel < MAX_DEBUG_LEVEL)
00213 config.DebugLevel++;
00214 break;
00215 case '-':
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
00270
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;
00283 } else {
00284 selectChannel(config.devname, config.SingleChannel);
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:
00296 CLEAR_KEYBOARD_BUFFER;
00297 break;
00298 }
00299 }
00300
00301
00302
00303
00304 #ifdef WITH_THREAD
00305 void check_keys_th(void)
00306 {
00307 UINT8 car;
00308
00309 nodelay(stdscr, TRUE);
00310 while (stop_sniffing == 0) {
00311
00312 if ((car = getch()) != ERR) {
00313 if ((car >= ' ') && (car <= '~')) {
00314
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
00327 usleep(100000);
00328 }
00329 }
00330 #else
00331 void check_keys(void)
00332 {
00333 nodelay(stdscr, TRUE);
00334
00335 if ((keystring[keyindex] = getch()) != ERR) {
00336 if ((keystring[keyindex] >= ' ') && (keystring[keyindex] <= '~')) {
00337
00338 debug(3, "We Hit : #%c# - keyindex=%d\n", keystring[keyindex],
00339 keyindex);
00340 keyindex = (keyindex + 1) % KEYBOARD_BUFFER;
00341 mvwprintw(Sum_WND, 11, 11, "(%-4s)", keystring);
00342 wrefresh(Sum_WND);
00343 parse_keystring();
00344 } else {
00345 keystring[keyindex] = 0;
00346 }
00347 }
00348 }
00349 #endif