某 *cloud js, html解密

1 ios要先越狱
2 mac上安装iosopendev
3 编译成tweak安装到手机(/Library/MobileSubstrate/DynamicLibraries),修改对应plist

文件保存在 widget_dump 目录



#import 
#import 
#import 

bool isSecurity();
NSString * GetKey();
bool dumper();
bool isXXXCloudApp();
NSData *dataWithRC4(id fileContent, id key);



NSData *dataWithRC4(id fileContent, id key){
    NSData * data = nil;
    Class uzrc4 = objc_getClass("UZRC4");
    if(nil != uzrc4){
        Method m = class_getClassMethod(uzrc4, @selector(dataWithRC4:key:));
        if (nil != m){
            typedef NSData* (*xxx)(id, SEL, id, id);
            xxx imp = (xxx)method_getImplementation(m);
            if(nil != imp){
                data = imp(uzrc4, @selector(dataWithRC4:key:), fileContent, key);
            }
        }
    }

    return data;
}


NSString * GetKey(){
    NSString* key = nil;
    Class uzprivacy = objc_getClass("UZPrivacy");
    if(nil != uzprivacy){
        Method m = class_getClassMethod(uzprivacy, @selector(getSecurityKey));
        if (nil != m){
            IMP imp = method_getImplementation(m);
            if(nil != imp){
                key = imp(uzprivacy, @selector(getSecurityKey));
            }
        }
    }


    NSLog(@"tieyan: GetKey:%@", key);

    return key;
}


bool isSecurity(){
    bool bret = false;
    Class uzprivacy = objc_getClass("UZPrivacy");
    if(nil != uzprivacy){
        Method m = class_getClassMethod(uzprivacy, @selector(isSecurity));
        if (nil != m){
            IMP imp = method_getImplementation(m);
            if(nil != imp){
                bret = imp(uzprivacy, @selector(isSecurity));
            }
        }
    }

    NSLog(@"tieyan: isSecurity:%d", bret);

    return  bret;
}



bool dumper(){

    @try{
        if (isXXXCloudApp()){
            if(isSecurity()){
                NSString* key = GetKey();
                if(nil != key){
                    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
                    NSLog(@"tieyan: dumper begin, bundleIdentifier:%@, DisplayName:%@", [infoDictionary objectForKey:@"CFBundleIdentifier"], [infoDictionary objectForKey:@"CFBundleDisplayName"]);

                    NSString* path =  [[NSBundle mainBundle] resourcePath];
                    NSFileManager *fileManager = [[NSFileManager alloc] init];
                    NSString* widgetDir = [path stringByAppendingPathComponent:@"widget"];

                    BOOL isDirectory = NO;
                    if([fileManager fileExistsAtPath:widgetDir isDirectory:&isDirectory]
                            && isDirectory){

                        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                        NSString *docDir = [paths objectAtIndex:0];
                        NSString* widget_dump = [docDir stringByAppendingPathComponent:@"widget_dump"];
                        [fileManager createDirectoryAtPath:widget_dump withIntermediateDirectories:YES attributes:nil error:nil];

                        NSArray *array = [fileManager subpathsAtPath:widgetDir];
                        [array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                            NSString * subpath = [widgetDir stringByAppendingPathComponent:obj];
                            NSString * subpath_dump = [widget_dump stringByAppendingPathComponent:obj];

                            BOOL subisDirectory = NO;
                            [fileManager fileExistsAtPath:subpath isDirectory:&subisDirectory];
                            if (subisDirectory){
                                NSLog(@"tieyan: createDirectoryAtPath: %@", subpath);

                                //创建目录
                                [fileManager createDirectoryAtPath:subpath_dump withIntermediateDirectories:YES attributes:nil error:nil];
                            }
                            else{
                                NSLog(@"tieyan: createFileAtPath: %@", subpath_dump);

                                [fileManager removeItemAtPath:subpath_dump error:nil];

                                //图片不加密貌似
                                //写文件
                                NSString* ext = [[subpath pathExtension] lowercaseString];
                                if([obj isEqualToString:@"config.xml"]
                                        || [ext isEqualToString:@"js"]
                                        || [ext isEqualToString:@"css"]
                                        || [ext isEqualToString:@"html"]
                                        || [ext isEqualToString:@"htm"]){

                                    NSData *filedata = dataWithRC4([fileManager contentsAtPath:subpath], key);
                                    if (filedata) {
                                        [fileManager createFileAtPath:subpath_dump contents:filedata attributes:nil];
                                    }

                                } else {
                                    [fileManager copyItemAtPath:subpath toPath:subpath_dump error:nil];
                                }

                            }
                        }];
                    }


                    NSLog(@"tieyan: dumper end");
                }
            }
        }
    }
    @catch(NSException *exception){
        NSLog(@"tieyan: exception:%@ %@", [exception name], [exception reason]);
    }

    return  true;
}

bool isXXXCloudApp(){
    return (nil != objc_getClass("UZPrivacy") && nil != objc_getClass("UZRC4") && nil != objc_getClass("UZWidget"));
}

%ctor{
    dumper();
};



posted @ 2015-05-16 16:05  tieyan  阅读(383)  评论(0编辑  收藏  举报