Objective-C 检查手机网络是否设置了代理以及越狱手机的
内容并非原创,都是参考别处的文章,好记性不如烂笔头,记录一下,以备使用。
1、检查手机是否设计了代理(原文地址):
- (BOOL)getProxyStatus {
NSDictionary *proxySettings = (__bridge NSDictionary *)(CFNetworkCopySystemProxySettings()); NSArray *proxies = (__bridge NSArray *)(CFNetworkCopyProxiesForURL((__bridge CFURLRef _Nonnull)([NSURL URLWithString:@"http://www.baidu.com"]), (__bridge CFDictionaryRef _Nonnull)(proxySettings)));
NSDictionary *settings = [proxies objectAtIndex:0];
NSLog(@"host=%@", [settings objectForKey:(NSString *)kCFProxyHostNameKey]);
NSLog(@"port=%@", [settings objectForKey:(NSString *)kCFProxyPortNumberKey]);
NSLog(@"type=%@", [settings objectForKey:(NSString *)kCFProxyTypeKey]);
if ([[settings objectForKey:(NSString *)kCFProxyTypeKey] isEqualToString:@"kCFProxyTypeNone"]) {
//没有设置代理
return NO;
}else{
//设置代理了 return YES;
}
}
2、越狱手机的基本检查:
来源于:【iOS应用安全】hook及越狱的基本防护与检测