Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Networks without encryption marked as insecure #6

Merged
merged 3 commits into from
Nov 5, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 53 additions & 45 deletions Classes/NetworkDetailsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -237,52 +237,60 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section == COPY_KEYS_BUTTON_SECTION && indexPath.row == 0) {
// Network data
NSString *wlanESSID = [NSString stringWithFormat:@"%@",[networkDetails objectForKey:@"SSID_STR"]];
NSString *wlanBSSID = [[self formattedBSSIDfrom:[networkDetails objectForKey:@"BSSID"]]uppercaseString];

// Key calculation
NSPredicate *wlanxxxx = [NSPredicate predicateWithFormat:@"SELF MATCHES 'WLAN_....|JAZZTEL_....'"];
NSPredicate *wifixxxxxx = [NSPredicate predicateWithFormat:@"SELF MATCHES 'WLAN......|YACOM......|WiFi......'"];

// Result
if ([wlanxxxx evaluateWithObject:wlanESSID]){
// WLAN_XXXX Code
self.wlanKeys = [WLANXXXXKeyCalculator calculateKeyWithESSID:wlanESSID BSSID:wlanBSSID];
}else if([wifixxxxxx evaluateWithObject:wlanESSID]) {
// WiFiXXXXXX Code
self.wlanKeys = [WiFiXXXXXXKeyCalculator calculateKeyWithESSID:wlanESSID BSSID:wlanBSSID];
}else {
self.wlanKeys = nil;
}


// Result display
if (wlanKeys != nil && [wlanKeys count] == 1) {
// There's only one key
UIAlertView *msgBox = [[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"unsafe_ap_title",@"AP Inseguro, clave encontrada")
message:[NSString stringWithFormat:NSLocalizedString(@"unsafe_ap_message",
@"Se pudo calcular una posible clave por defecto a traves de los datos publicos.\n\nSi no se trata de tu AP, avisa a su propietario de que cambie la clave de su red.\n\nLa clave de la red %@ parece ser:\n%@"),
wlanESSID,[self.wlanKeys objectAtIndex:0]]
delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:NSLocalizedString(@"copy_button",@"Copiar"),nil] autorelease];
[msgBox show];

}else if (wlanKeys != nil && [wlanKeys count] > 1){
// Multiple keys need to be displayed
KeyListController *keyListController = [[KeyListController alloc] initWithNibName:@"KeyListController" bundle:nil];
keyListController.keyList = self.wlanKeys;
keyListController.wlanESSID = wlanESSID;
[self.navigationController pushViewController:keyListController animated:YES];
[keyListController release];
}else {
UIAlertView *msgBox = [[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"safe_ap_title",@"AP seguro, clave no encontrada")
message:NSLocalizedString(@"safe_ap_message",@"No se pudo encontrar la clave, el AP no tiene una clave que pueda ser calculada mediante sus datos publicos.")
delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] autorelease];
[msgBox show];
}
if(indexPath.section == COPY_KEYS_BUTTON_SECTION && indexPath.row == 0) {
if (!([networkDetails objectForKey:@"WPA_IE"] || [[networkDetails objectForKey:@"WEP"] boolValue])) {
UIAlertView *msgBox = [[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"unsafe_ap_title",@"AP seguro, no tiene clave")
message:NSLocalizedString(@"no_key_ap_message",@"El AP no tiene clave.")
delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] autorelease];
[msgBox show];
} else {

// Network data
NSString *wlanESSID = [NSString stringWithFormat:@"%@",[networkDetails objectForKey:@"SSID_STR"]];
NSString *wlanBSSID = [[self formattedBSSIDfrom:[networkDetails objectForKey:@"BSSID"]]uppercaseString];

// Key calculation
NSPredicate *wlanxxxx = [NSPredicate predicateWithFormat:@"SELF MATCHES 'WLAN_....|JAZZTEL_....'"];
NSPredicate *wifixxxxxx = [NSPredicate predicateWithFormat:@"SELF MATCHES 'WLAN......|YACOM......|WiFi......'"];

// Result
if ([wlanxxxx evaluateWithObject:wlanESSID]){
// WLAN_XXXX Code
self.wlanKeys = [WLANXXXXKeyCalculator calculateKeyWithESSID:wlanESSID BSSID:wlanBSSID];
}else if([wifixxxxxx evaluateWithObject:wlanESSID]) {
// WiFiXXXXXX Code
self.wlanKeys = [WiFiXXXXXXKeyCalculator calculateKeyWithESSID:wlanESSID BSSID:wlanBSSID];
}else {
self.wlanKeys = nil;
}


// Result display
if (wlanKeys != nil && [wlanKeys count] == 1) {
// There's only one key
UIAlertView *msgBox = [[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"unsafe_ap_title",@"AP Inseguro, clave encontrada")
message:[NSString stringWithFormat:NSLocalizedString(@"unsafe_ap_message",
@"Se pudo calcular una posible clave por defecto a traves de los datos publicos.\n\nSi no se trata de tu AP, avisa a su propietario de que cambie la clave de su red.\n\nLa clave de la red %@ parece ser:\n%@"),
wlanESSID,[self.wlanKeys objectAtIndex:0]]
delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:NSLocalizedString(@"copy_button",@"Copiar"),nil] autorelease];
[msgBox show];

}else if (wlanKeys != nil && [wlanKeys count] > 1){
// Multiple keys need to be displayed
KeyListController *keyListController = [[KeyListController alloc] initWithNibName:@"KeyListController" bundle:nil];
keyListController.keyList = self.wlanKeys;
keyListController.wlanESSID = wlanESSID;
[self.navigationController pushViewController:keyListController animated:YES];
[keyListController release];
}else {
UIAlertView *msgBox = [[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"safe_ap_title",@"AP seguro, clave no encontrada")
message:NSLocalizedString(@"safe_ap_message",@"No se pudo encontrar la clave, el AP no tiene una clave que pueda ser calculada mediante sus datos publicos.")
delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] autorelease];
[msgBox show];
}
}

}
}
}

#pragma mark -
Expand Down
3 changes: 3 additions & 0 deletions en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
/* AP Inseguro, clave encontrada */
"unsafe_ap_title" = "Unsafe AP, key found";

/* El AP no tiene clave. */
"no_key_ap_message" = "AP has no key.";

/* Channel */
"channel" = "Channel";

Expand Down
Binary file modified es.lproj/Localizable.strings
Binary file not shown.