Skip to content

Commit

Permalink
*code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ikorich committed Oct 21, 2013
1 parent 01ad21d commit 553cfdc
Show file tree
Hide file tree
Showing 30 changed files with 889 additions and 685 deletions.
10 changes: 9 additions & 1 deletion KisMAC_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@
#define POLARSSL_MD4_C

#define MD4_DIGEST_LENGTH 16
#define SHA_DIGEST_LENGTH 20
#define SHA_DIGEST_LENGTH 20

#define BAD_ADDRESS 0xFFFFFFFF
#define ERROR_FREE_ADDRESS 0xDEBB20E3
#define LAST_BIT 256

#define SRET { [[WaveHelper importController] terminateWithCode: 1]; return; }
#define RET { [[WaveHelper importController] terminateWithCode: -1]; return; }
#define CHECK { if (_password != nil) RET; if (_isWep != encryptionTypeWEP && _isWep != encryptionTypeWEP40) RET; if ([_packetsLog count] < 8) RET; }
8 changes: 4 additions & 4 deletions Sources/Controller/ScanController.m
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ - (IBAction)updateNetworkTable:(id)sender complete:(bool)complete {
}
}
else {
row = [_container nextChangedRow:0xFFFFFFFF];
while (row != 0xFFFFFFFF) {
row = [_container nextChangedRow:BAD_ADDRESS];
while (row != BAD_ADDRESS) {
net = [_container netAtIndex:row];

if ([net isCorrectSSID] && net == _curNet)
Expand Down Expand Up @@ -341,8 +341,8 @@ - (IBAction)updateNetworkTable:(id)sender complete:(bool)complete {
}
}
} else {
row = [_container nextChangedRow:0xFFFFFFFF];
while (row != 0xFFFFFFFF) {
row = [_container nextChangedRow:BAD_ADDRESS];
while (row != BAD_ADDRESS) {
net = [_container netAtIndex:row];
if ([net isCorrectSSID] && net == _curNet)
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/Controller/ScanControllerScriptable.m
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ - (BOOL)bruteforce40bitAll {

_crackType = 2;
[self startCrackDialogWithTitle:NSLocalizedString(@"Bruteforce attack against WEP-40...", "busy dialog")];
[_importController setMax:256];
[_importController setMax:LAST_BIT];

[NSThread detachNewThreadSelector:@selector(performBruteforce40bitAll:) toTarget:_curNet withObject:nil];

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/80211b.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ typedef struct _special_set {
UInt16 wi_port;
UInt16 wi_beaconint;
UInt16 wi_ssidlen;
char wi_ssid[256];
char wi_ssid[LAST_BIT];
char wi_mac[6];
} special_set;

Expand Down
16 changes: 8 additions & 8 deletions Sources/Core/WaveContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,13 @@ - (BOOL)IDFiltered:(const unsigned char*)ID
- (unsigned int) findNetwork:(const unsigned char*)ID
{
unsigned int i, lentry;
unsigned int entry = 0xFFFFFFFF;
unsigned int entry = BAD_ADDRESS;
unsigned int l = 0;


//see if it is filtered
if ([self IDFiltered:ID])
return 0xFFFFFFFF;
return BAD_ADDRESS;


//lookup the net in the hashtable
Expand All @@ -824,14 +824,14 @@ - (unsigned int) findNetwork:(const unsigned char*)ID
i=_lookup[l];
}

if (entry==0xFFFFFFFF)
if (entry == BAD_ADDRESS)
{
//the net does not exist - add it

if (_netCount == MAXNETS)
{
DBNSLog(@"Found network, but could not add it since you reached MAXNETS. Please recompile with a higher value");
return 0xFFFFFFFF;
return BAD_ADDRESS;
}

++_netCount;
Expand Down Expand Up @@ -877,7 +877,7 @@ - (bool) addPacket:(WavePacket*)p liveCapture:(bool)live
return YES;

entry = [self findNetwork:ID];
if (entry == 0xFFFFFFFF)
if (entry == BAD_ADDRESS)
return NO; //the object is filtered...

@synchronized(_idList[entry].net) {
Expand Down Expand Up @@ -915,7 +915,7 @@ - (bool) addAppleAPIData:(CWNetwork*)net
}

entry = [self findNetwork: macData];
if (entry == 0xFFFFFFFF) return NO; //the object is filtered...
if (entry == BAD_ADDRESS) return NO; //the object is filtered...

@synchronized(_idList[entry].net)
{
Expand Down Expand Up @@ -1009,7 +1009,7 @@ - (unsigned int) nextChangedRow:(unsigned int)lastRow
{
unsigned int nxt;

if (lastRow==0xFFFFFFFF)
if (lastRow == BAD_ADDRESS)
nxt=0;
else
nxt = lastRow + 1;
Expand All @@ -1025,7 +1025,7 @@ - (unsigned int) nextChangedRow:(unsigned int)lastRow
++nxt;
}

return 0xFFFFFFFF;
return BAD_ADDRESS;
}
#pragma mark -

Expand Down
1 change: 0 additions & 1 deletion Sources/Core/WaveNet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#define WEP_GEM_GREEN_LEVEL 130000

#define AMOD(x, y) ((x) % (y) < 0 ? ((x) % (y)) + (y) : (x) % (y))
#define N 256

#define min(a, b) (a) < (b) ? a : b

Expand Down
11 changes: 5 additions & 6 deletions Sources/Core/WavePacket.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#import <pcap.h>

#define AMOD(x, y) ((x) % (y) < 0 ? ((x) % (y)) + (y) : (x) % (y))
#define N 256

bool is8021xPacket(const UInt8* fileData) {
if (fileData[0] == 0xAA &&
Expand All @@ -52,7 +51,7 @@ @implementation WavePacket
-(void) parseTaggedData:(unsigned char*) packet length:(int) length {
int len;
UInt32 *vendorID;
char ssid[256];
char ssid[LAST_BIT];

_primaryChannel = 0;

Expand Down Expand Up @@ -716,17 +715,17 @@ - (int)isResolved {
return _revelsKeyByte;
}

int a = (_payload[0] + _payload[1]) % N;
int b = AMOD((_payload[0] + _payload[1]) - _payload[2], N);
int a = (_payload[0] + _payload[1]) % LAST_BIT;
int b = AMOD((_payload[0] + _payload[1]) - _payload[2], LAST_BIT);

for(UInt8 B = 0; B < 13; ++B) {
if((((0 <= a && a < B) ||
(a == B && b == (B + 1) * 2)) &&
(B % 2 ? a != (B + 1) / 2 : 1)) ||
(a == B + 1 && (B == 0 ? b == (B + 1) * 2 : 1)) ||
(_payload[0] == B + 3 && _payload[1] == N - 1) ||
(_payload[0] == B + 3 && _payload[1] == LAST_BIT - 1) ||
(B != 0 && !(B % 2) ? (_payload[0] == 1 && _payload[1] == (B / 2) + 1) ||
(_payload[0] == (B / 2) + 2 && _payload[1] == (N - 1) - _payload[0]) : 0)) {
(_payload[0] == (B / 2) + 2 && _payload[1] == (LAST_BIT - 1) - _payload[0]) : 0)) {
//DBNSLog(@"We got a weak packet reveling byte: %u",B);
_revelsKeyByte = B;
return _revelsKeyByte;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/WaveScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
double aFreq;
int _driver;

unsigned char aFrameBuf[2364]; //for reading in pcaps (still messy)
unsigned char aFrameBuf[MAX_FRAME_BYTES]; //for reading in pcaps (still messy)
KFrame* aWF;
pcap_t* _pcapP;

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/WaveScanner.mm
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ -(KFrame*) nextFrame:(bool*)corrupted
aWF->ctrl.len = h.caplen;

//corrupted frame
if ( h.caplen > 2364 ) return NULL;
if ( h.caplen > MAX_FRAME_BYTES ) return NULL;

switch (pcap_datalink(_pcapP))
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/WaveWeakContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@interface WaveWeakContainer : NSObject {
UInt8 **_data[256];
UInt8 **_data[LAST_BIT];
UInt32 _count;
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/Core/WaveWeakContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ - (NSData*)data {
d = malloc(_count * 5);
m = d;

for(x = 0; x < 256; ++x) {
for(x = 0; x < LAST_BIT; ++x) {
if (_data[x] != nil) {
for (y = 0; y < 256; ++y) {
for (y = 0; y < LAST_BIT; ++y) {
if ((_data[x])[y] != nil) {
for (z = 0; z < (256 * 3); z+=3) {
for (z = 0; z < (LAST_BIT * 3); z+=3) {
if (((_data[x])[y])[z] != 0) {
m[0] = (z / 3) & 0xFF;
m[1] = y & 0xFF;
Expand All @@ -133,9 +133,9 @@ - (NSData*)data {
- (void) dealloc {
int x, y;

for(x = 0; x < 256; ++x) {
for(x = 0; x < LAST_BIT; ++x) {
if (_data[x] != nil) {
for (y = 0; y < 256; ++y) {
for (y = 0; y < LAST_BIT; ++y) {
if ((_data[x])[y] != nil) {
free((_data[x])[y]);
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Crypto/AirCrackWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ enum KoreK_attacks
unsigned char *ivbuf; /* buffer for the unique IVs */
unsigned long nb_ivs; /* number of elements in ivbuf */
unsigned long tried; /* total # of keys tried so far */
int mc_pipe[256][2]; /* master->child control pipe */
int cm_pipe[256][2]; /* child->master results pipe */
int mc_pipe[LAST_BIT][2]; /* master->child control pipe */
int cm_pipe[LAST_BIT][2]; /* child->master results pipe */
int fudge[13]; /* bruteforce level (1 to 256) */
int depth[13]; /* how deep we are in the fudge */
int _votes[13][N_ATTACKS][256];
int _votes[13][N_ATTACKS][LAST_BIT];

ImportController *_im;

struct byte_stat
{
int index;
int votes;
} wpoll[13][256]; /* FMS + Korek attacks: stats. */
} wpoll[13][LAST_BIT]; /* FMS + Korek attacks: stats. */
}

- (void)setKeyID:(int)keyID;
Expand Down
Loading

0 comments on commit 553cfdc

Please sign in to comment.