Last active
December 14, 2015 03:39
-
-
Save fqrouter/5022480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int Apple80211Associate(struct Apple80211 *handle, CFDictionaryRef *network, CFString *wpa_key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc -Wall -Os -framework Foundation -framework CoreFoundation main.c -o net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
#include <stdio.h> | |
#include <CoreFoundation/CoreFoundation.h> | |
int main() { | |
void *handle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY); | |
int (*open)(void *) = dlsym(handle, "Apple80211Open"); | |
int (*bind)(void *, CFStringRef) = dlsym(handle, "Apple80211BindToInterface"); | |
int (*close)(void *) = dlsym(handle, "Apple80211Close"); | |
int (*scan)(void *, CFArrayRef *, void *) = dlsym(handle, "Apple80211Scan"); | |
void *airportHandle; | |
open(&handle); | |
bind(handle, CFSTR("en0")); | |
CFDictionaryRef parameters = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); | |
CFArrayRef networks; | |
scan(handle, &networks, parameters); | |
int i; | |
for (i = 0; i < CFArrayGetCount(networks); i++) { | |
CFDictionaryRef network = CFArrayGetValueAtIndex(networks, i); | |
CFShow(CFDictionaryGetValue(network, CFSTR("BSSID"))); | |
} | |
close(handle); | |
dlclose(handle); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment