修改wifi名稱與地址

z小志發表於2018-01-23
%hook CaptiveNetwork

static CFDictionaryRef __nullable
(*oldCNCopyCurrentNetworkInfo)	(CFStringRef interfaceName);

CFDictionaryRef __nullable newCNCopyCurrentNetworkInfo	(CFStringRef interfaceName){

NSDictionary *oldDic = (__bridge NSDictionary*)oldCNCopyCurrentNetworkInfo(interfaceName);
NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithDictionary:oldDic];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:PlistPath];
if (dict) {
NSString *bundleId = [NSBundle mainBundle].bundleIdentifier;
NSArray *selectApp = [dict objectForKey:@"selectApp"];
if (selectApp) {
if ([selectApp containsObject:bundleId]){
NSString *mySSID = dict[bundleId][@"SSID"];
NSString *myBSSID = dict[bundleId][@"BSSID"];
if (mySSID || myBSSID){
if (mySSID) {
[dic setValue:mySSID forKey:@"SSID"];
}
if (myBSSID) {
[dic setValue:myBSSID forKey:@"BSSID"];
}
return (__bridge CFDictionaryRef)dic;
}
}
}
}
return oldCNCopyCurrentNetworkInfo(interfaceName);
}

__attribute__((constructor)) static void initialize() {
MSHookFunction(CNCopyCurrentNetworkInfo,newCNCopyCurrentNetworkInfo,&oldCNCopyCurrentNetworkInfo);
}


%end

複製程式碼

相關文章