零碎知识点

手机序列号
NSString* identifierNumber = [[UIDevice currentDevice] uniqueIdentifier];  
NSLog(@"手机序列号: %@",identifierNumber);  
手机别名: 用户定义的名称
NSString* userPhoneName = [[UIDevice currentDevice] name];  
NSLog(@"手机别名: %@", userPhoneName);  
设备名称
NSString* deviceName = [[UIDevice currentDevice] systemName];  
NSLog(@"设备名称: %@",deviceName );  
手机系统版本
NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];  
NSLog(@"手机系统版本: %@", phoneVersion);  
手机型号
NSString* phoneModel = [[UIDevice currentDevice] model];  
NSLog(@"手机型号: %@",phoneModel );  
地方型号 (国际化区域名称)
NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];  
NSLog(@"国际化区域名称: %@",localPhoneModel );  
当前应用名称
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
NSString *appCurName = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
NSLog(@"当前应用名称:%@",appCurName);  
当前应用软件版本 比如:1.0.1
NSString *appCurVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];  
NSLog(@"当前应用软件版本:%@",appCurVersion);  
当前应用版本号码 int类型
NSString *appCurVersionNum = [infoDictionary objectForKey:@"CFBundleVersion"];  
NSLog(@"当前应用版本号码:%@",appCurVersionNum);  
越狱检测:
- (int)getenv
{
    //以下检测的过程是越往下,越狱越高级
    
    //    /Applications/Cydia.app, /privte/var/stash
    int jailbroken = -99999;
    NSString *cydiaPath = @"/Applications/Cydia.app";
    NSString *aptPath = @"/private/var/lib/apt/";
    if ([[NSFileManager defaultManager] fileExistsAtPath:cydiaPath]) {
        jailbroken = 111;
    }
    if ([[NSFileManager defaultManager] fileExistsAtPath:aptPath]) {
        jailbroken = 222;
    }
    
    //可能存在hook了NSFileManager方法,此处用底层C stat去检测
    struct stat stat_info;
    if (0 == stat("/Library/MobileSubstrate/MobileSubstrate.dylib", &stat_info)) {
        jailbroken = 333;
    }
    if (0 == stat("/Applications/Cydia.app", &stat_info)) {
        jailbroken = 444;
    }
    if (0 == stat("/var/lib/cydia/", &stat_info)) {
        jailbroken = 555;
    }
    if (0 == stat("/var/cache/apt", &stat_info)) {
        jailbroken = 666;
    }

    //可能存在stat也被hook了,可以看stat是不是出自系统库,有没有被攻击者换掉,这种情况的可能性很小
    int ret;
    Dl_info dylib_info;
    int (*func_stat)(const char *,struct stat *) = stat;
    if ((ret = dladdr(func_stat, &dylib_info))) {
        NSLog(@"lib:%s",dylib_info.dli_fname);      //如果不是系统库,肯定被攻击了
        if (strcmp(dylib_info.dli_fname, "/usr/lib/system/libsystem_kernel.dylib")) {   //不相等,肯定被攻击了,相等为0
            jailbroken = 777;
        }
    }
    
### // 此方法存在appStore审核不通过的情况:
    //检测链接动态库,看下是否被链接了异常动态库
    //通常,越狱机的输出结果会包含字符串: Library/MobileSubstrate/MobileSubstrate.dylib——之所以用检测链接动态库的方法,是可能存在前面的方法被hook的情况。这个字符串,前面的stat已经做了  
      
    //如果攻击者给MobileSubstrate改名,但是原理都是通过DYLD_INSERT_LIBRARIES注入动态库  
    //那么可以,检测当前程序运行的环境变量  
    charchar *env = getenv("DYLD_INSERT_LIBRARIES");  
    if (env != NULL) {  
        jailbroken = YES;  
    }  

    return jailbroken;
}
注释和标记的几种方式:
/*! 按钮1 */
@property(nonatomic,strong)UIButton * btn1;

/** 按钮2 */
@property(nonatomic,strong)UIButton * btn2;

/// 按钮3
@property(nonatomic,strong)UIButton * btn3;

@property(nonatomic,strong)UIButton * btn4;/**< 按钮4 */

//按钮5 (快捷键 cmd + /)
@property(nonatomic,strong)UIButton * btn5;

/* 按钮6 */
@property(nonatomic,strong)UIButton * btn6;

前面4种加了特效,可以显示出自己给属性、方法、成员变量等添加上去的描述。后面2种,则不可以。

标记

6种主流标记

// MARK: ~~~~~~~~~~~~~~~~~~~~
// TODO: puti is not a tree
// FIXME: mirror is not a table
// !!!: it is empty at all here
// ???: why pm 2.5 is so high
#pragma mark - UITableViewDelegate (中间的 ‘-’ 号,可以添加一条分割线)

2种非主流标记:
#warning >>>>>>>>>>>>>>
#error <<<<<<<<<<<<<<

链接:https://www.jianshu.com/p/ba4ecbdfe0e3

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 【杂乱中的杂乱】 MRC和ARC混编设置方式 1、调用代码使APP进入后台,达到点击Home键的效果 2、带有中文...
    SunshineBrother阅读 743评论 1 15
  • 一、子类对父类属性的覆盖 案例代码 输出结果 子类静态变量父类常量子类静态常量 结论 由于private变量受访问...
    AndroidMaster阅读 148评论 0 0
  • 两块石头碰撞在一起 却像鸡蛋一样碎的惨烈 两个鸡蛋碰撞在一起 却发出一道璀璨的星光 再柔软一点 像两团面粉一样 揉...
    锦_琵琶阅读 226评论 0 0
  • 午夜时分,伊兰怀里抱着宝宝,宝宝的牙咬痛她,发出一声痛苦的低吼声,一念之间想到没有人可以分担自己的忧虑,似...
    无翼野菲阅读 219评论 1 0
  • d特质的人用对方法: 当你遇到d特质的人的时候,不能硬碰硬,要以柔克刚,并且他们都是我们的朋友,我们要学会与之友好...
    张俊豪阅读 628评论 0 0

友情链接更多精彩内容