2013-07-19 23 views

Odpowiedz

3

Kod z odpowiedzi powyżej zostało zamieszczone pierwotnie na tej stronie: http://www.codeproject.com/Articles/621213/Non-Standard-Way-to-Get-Inaccessible-Data-from-iOS

Nawiasem mówiąc, dla ten kod zadziała, musisz zawrzeć odpowiednie pliki nagłówkowe z #include <mach/mach.h>, aby twój kompilator rozpoznał NDR_record_t ndr.

Jednak ta cała konfiguracja właściwie nie zwróciła mi trybu szyfrowania bieżącego WiFi, ale raczej konfigurację AirPort (zmienna key w kodzie z góry musi być wcześniej ustawiona na NSString *key = @"Setup:/Network/Interface/en0/AirPort";). Próbowałem różnych wartości zamiast lotniska, które dostałam od uruchomiony $scutil w terminalu moim Mac (takie jak Setup:/Network/Interface/en0/IPv4 lub Setup:/Network/Interface/en0/Modem lub od this website)

nadzieję, że ktoś pomoże podobnych problemów ...

+0

co jeszcze muszę dodać oprócz mach.h jak dostaję ** domyślna deklaracja funkcji 'bootstrap_look_up2' jest nieprawidłowa w C99 ** –

1

Dla iOS 5:

aslmsg asl, message; 
    aslresponse searchResult; 
    int i; 
    const char *key, *val; 
    NSMutableArray *result_dicts = [NSMutableArray array]; 

    asl = asl_new(ASL_TYPE_QUERY); 
    if (!asl) 
    { 
     DDLogCError(@"Failed creating ASL query"); 
    } 
    asl_set_query(asl, "Sender", "kernel", ASL_QUERY_OP_EQUAL); 
    asl_set_query(asl, "Message", "AppleBCMWLAN Joined BSS:", ASL_QUERY_OP_PREFIX|ASL_QUERY_OP_EQUAL); 
    searchResult = asl_search(NULL, asl); 
    while (NULL != (message = aslresponse_next(searchResult))) 
    { 
     NSMutableDictionary *tmpDict = [NSMutableDictionary dictionary]; 

     for (i = 0; (NULL != (key = asl_key(message, i))); i++) 
     { 
      NSString *keyString = [NSString stringWithUTF8String:(char *)key]; 

      val = asl_get(message, key); 

      NSString *string = [NSString stringWithUTF8String:val]; 
      [tmpDict setObject:string forKey:keyString]; 
     } 
     [result_dicts addObject:tmpDict]; 
    } 
    aslresponse_free(searchResult); 
    asl_free(asl); 

Dla iOS 6:

#define kMachPortConfigd "com.apple.SystemConfiguration.configd" 

-(NSDictionary *)getSCdata:(NSString *)key 
{ 

if(SYSTEM_VERSION_LESS_THAN(@"6.0")) 
{ 
    // It does not work on iOS 5.* 
    return nil; 
} 

struct send_body {mach_msg_header_t header; int count; UInt8 *addr; CFIndex size0; int flags; NDR_record_t ndr; CFIndex size; int retB; int rcB; int f24; int f28;}; 

mach_port_t bootstrapport = MACH_PORT_NULL; 
mach_port_t configport = MACH_PORT_NULL; 
mach_msg_header_t *msg; 
mach_msg_return_t msg_return; 
struct send_body send_msg; 
// Make request 
CFDataRef extRepr; 
extRepr = CFStringCreateExternalRepresentation(NULL, (__bridge CFStringRef)(key), kCFStringEncodingUTF8, 0); 

// Connect to Mach MIG port of configd 
task_get_bootstrap_port(mach_task_self(), &bootstrapport); 
bootstrap_look_up2(bootstrapport, kMachPortConfigd, &configport, 0, 8LL); 
// Make request 

send_msg.count = 1; 
send_msg.addr = (UInt8*)CFDataGetBytePtr(extRepr); 
send_msg.size0 = CFDataGetLength(extRepr); 
send_msg.size = CFDataGetLength(extRepr); 
send_msg.flags = 0x1000100u; 
send_msg.ndr = NDR_record; 

// Make message header 

msg = &(send_msg.header); 
msg->msgh_bits = 0x80001513u; 
msg->msgh_remote_port = configport; 
msg->msgh_local_port = mig_get_reply_port(); 
msg->msgh_id = 20010; 
// Request server 
msg_return = mach_msg(msg, 3, 0x34u, 0x44u, msg->msgh_local_port, 0, 0); 
if(msg_return) 
{ 
    if (msg_return - 0x10000002u >= 2 && msg_return != 0x10000010) 
    { 
     mig_dealloc_reply_port(msg->msgh_local_port); 
    } 
    else 
    { 
     mig_put_reply_port(msg->msgh_local_port); 
    } 
} 
else if (msg->msgh_id != 71 && msg->msgh_id == 20110 && msg->msgh_bits <= -1) 
{ 
    if ((send_msg.flags & 0xFF000000) == 0x1000000) 
    { 
     CFDataRef deserializedData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, send_msg.addr,send_msg.size0, kCFAllocatorNull); 
     CFPropertyListRef proplist = CFPropertyListCreateWithData(kCFAllocatorDefault, deserializedData, kCFPropertyListImmutable, NULL, NULL); 
     mig_dealloc_reply_port(msg->msgh_local_port); 
     mach_port_deallocate(mach_task_self(), bootstrapport); 
     mach_port_deallocate(mach_task_self(), configport); 
     mach_msg_destroy(msg); 
     NSDictionary *property_list = (__bridge NSDictionary*)proplist; 
     if(proplist) 
      CFRelease(proplist); 
     CFRelease(deserializedData); 
     CFRelease(extRepr); 
     return property_list; 
    } 
} 
mig_dealloc_reply_port(msg->msgh_local_port); 
mach_port_deallocate(mach_task_self(), bootstrapport); 
mach_port_deallocate(mach_task_self(), configport); 
mach_msg_destroy(msg); 
CFRelease(extRepr); 
return nil; 
} 
+0

Czy ktoś wie, czy ten kod przejdzie proces recenzowania jabłek? –

+0

Czy istnieje sposób uzyskać te informacje dla OS X –

+0

@isox @ chris \ conway otrzymuję: niejawne deklaracji bootstrap_look_up2 niedozwolone w C99 ... co to jest poprawka? –

Powiązane problemy