#import <substrate.h>
#include <mach-o/dyld.h>
#import <dlfcn.h>
#import <CommonCrypto/CommonDigest.h>
#include <unistd.h>
#include <sys/types.h>
#include <mach/mach.h>
%hook NSURL
- (id)initWithString:(NSString*)url {
if ([url containsString:@"ib-soft.net"])
{
NSLog(@"[+] 网络访问->:%@",url);
%log;
/* code */
return %orig(@"http://127.0.0.1");
}
return %orig(url);
}
%end
static NSString *uniqueDeviceID(void) {
static CFStringRef (*$MGCopyAnswer)(CFStringRef);
void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY);
$MGCopyAnswer = (dlsym(gestalt, "MGCopyAnswer"));
return (__bridge NSString *)$MGCopyAnswer(CFSTR("UniqueDeviceID"));
}
static NSString *md5(NSString *str) {
const char *cStr = [str UTF8String];
unsigned char result[16];
CC_MD5( cStr, strlen(cStr),result );
NSMutableString *hash =[NSMutableString string];
for (int i = 0; i < 16; i++) {
[hash appendFormat:@"%02x", result[i]];
}
return hash;
}
static void genLicenseFile(NSString* hash) {
// NSLog(@"[+]Hash:%@",hash);
NSLog(@"[+] 写入注册信息");
[hash writeToFile:@"/var/mobile/Library/iCleaner/license.cached" atomically:YES encoding:NSUTF8StringEncoding error:nil];
}
%ctor
{
NSString* udid = uniqueDeviceID();
NSLog(@"[+] 获取 did->:%@",udid);
NSString* tmpStr = [NSString stringWithFormat:@"%@%@%@%@",[udid substringWithRange:NSMakeRange(18,5)],[udid substringToIndex:27],[udid substringWithRange:NSMakeRange(13,10)],[udid substringFromIndex:31]];
NSLog(@"[+] 取值 tmpStr->:%@",tmpStr);
NSString* hash = md5(tmpStr);
NSLog(@"[+] 计算 MD5_hash->:%@",hash);
[[NSUserDefaults standardUserDefaults] setObject:hash forKey:@"lastRequestValue"];
genLicenseFile(hash);
}
{
Filter = {
Bundles = (
"com.exile90.icleanerpro",
"com.ivanobilenchi.icleaner",
);
};
}