nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <pthread.h>
5  
6 #include "ghosting.h"
7 #include "osdep.h"
8  
9 #ifdef __linux__
10  
11 unsigned int ghosting_period = 100;
12 int ghosting_maxrate, ghosting_minpower;
13  
14 /* ZERO_CHAOS says:
15 * If you want to make the WIDS vendors hate you,
16 * change tx power of the card while injecting, so you can evade location tracking.
17 * If you turn the radio's power up and down every few ms, the trackers will have a much harder time finding you
18 * (basicly you will hop all over the place depending on sensor position). At least madwifi can do it.
19 *
20 * Also change speed every few ms, not a fantastic evasion technique but it may cause more location tracking oddity.
21 */
22  
23 char *ghost_help ="###### This version supports IDS Evasion (Ghosting) ######\n"
24 "# Just append --ghost <period>,<max_rate>,<min_txpower> #\n"
25 "# after your attack mode identifier to enable ghosting! #\n"
26 "# <period> : How often (in ms) to switch rate/power #\n"
27 "# <max_rate> : Maximum Bitrate to use in MBit #\n"
28 "# <min_txpower> : Minimum TX power in dBm to use #\n"
29 "# NOTE: Does not fully work with every driver, YMMV... #\n"
30 "##########################################################\n";
31  
32 void ghosting_print_help() {
33 printf("%s\n", ghost_help);
34 }
35  
36 void txpower_ghosting_thread() {
37 while(1) {
38 osdep_random_txpower(ghosting_minpower);
39 usleep(1000 * ghosting_period);
40 }
41 }
42  
43 void bitrate_ghosting_thread() {
44 int maxrate = ghosting_maxrate * 1000000;
45 long rnd;
46  
47 if (maxrate == 5000000) maxrate = 5500000; //5.5 MBit crap :(
48  
49 while(1) {
50 do {
51 rnd = random() % VALID_RATE_COUNT;
52 } while (VALID_BITRATES[rnd] > maxrate);
53  
54 osdep_set_rate(VALID_BITRATES[rnd]);
55  
56 usleep(1000 * ghosting_period);
57 }
58 }
59  
60 //If you set rate or power to -1, ghosting will be disabled for this!
61 //So If you just want to change your tx power every 100 ms from 10 dBm to your cards max:
62 //start_ghosting(100, -1, 10);
63 void start_ghosting(unsigned int period, int max_bitrate, int min_tx_power) {
64 pthread_t rateghost, powerghost;
65  
66 //Gotta get stuff away from the stack:
67 ghosting_period = period;
68 ghosting_maxrate = max_bitrate;
69 ghosting_minpower = min_tx_power;
70  
71 osdep_init_txpowers(); //don't forget to init stuff!
72  
73 printf("Ghosting has been activated: ");
74  
75 if (max_bitrate < 1) {
76 printf("You're a funny guy... Your maximum bitrate is less than 1....\n");
77 return;
78 }
79  
80 if (min_tx_power > osdep_get_max_txpower()) {
81 printf("Your minimum TX power is greater than your cards maximum. You want to fry stuff?\n");
82 return;
83 }
84  
85 if (max_bitrate != -1) {
86 printf("Change Bitrate from 1 to %d MBit, ", max_bitrate);
87 pthread_create(&rateghost, NULL, (void *) bitrate_ghosting_thread, (void *) NULL);
88 }
89  
90 if (min_tx_power != -1) {
91 printf("Change TX Power from %d to %d dBm, ", min_tx_power, osdep_get_max_txpower());
92 pthread_create(&powerghost, NULL, (void *) txpower_ghosting_thread, (void *) NULL);
93 }
94  
95 printf("every %d milliseconds\n", period);
96 }
97  
98 void parse_ghosting(const char *input) {
99 int parseok;
100 int per, rate, pow;
101  
102 parseok = sscanf(input, "%d,%d,%d", &per, &rate, &pow);
103  
104 if (parseok != 3) {
105 printf("Your ghosting parameters are unparseable...\n");
106 exit(-1);
107 }
108  
109 start_ghosting(per, rate, pow);
110 }
111 #endif