It looks like you're new here. If you want to get involved, click one of these buttons!
#if !TARGET_IPHONE_SIMULATOR
int root = getgid();
if (root <= 10) {
//Pirated
}
#endif
#define kInfoSize 500
//Place your NSLog Plist Size into the above Define statment
NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
NSString* path = [NSString stringWithFormat:@\"%@/Info.plist\", bundlePath ];
NSDictionary *fileInfo = [[NSBundle mainBundle] infoDictionary];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDictionary *fileAttributes = [fileManager fileAttributesAtPath:path traverseLink:YES];
if (fileAttributes != nil) {
NSNumber *fileSize;
if(fileSize = [fileAttributes objectForKey:NSFileSize]){
NSLog(@\"File Size: %qi\n\", [fileSize unsignedLongLongValue]);
//Best to see the File Size and change it accordingly first
NSString *cSID = [[NSString alloc] initWithFormat:@\"%@%@%@%@%@\",@\"Si\",@\"gne\",@\"rIde\",@\"ntity\",@\"\"];
BOOL checkedforPir = false;
if([fileInfo objectForKey:cSID] == nil || [fileInfo objectForKey:cSID] != nil) {
if([fileSize unsignedLongLongValue] == kInfoSize) {
checkedforPir = true;
}
}
if(!checkedforPir){
//Pirated
}
[cSID release];
}
}
NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:(@\"%@/_CodeSignature\", bundlePath)];
if (!fileExists) {
//Pirated
NSLog(@\"Pirated\");
}
BOOL fileExists2 = [[NSFileManager defaultManager] fileExistsAtPath:(@\"%@/CodeResources\", bundlePath)];
if (!fileExists2) {
//Pirated
NSLog(@\"Pirated2\");
}
BOOL fileExists3 = [[NSFileManager defaultManager] fileExistsAtPath:(@\"%@/ResourceRules.plist\", bundlePath)];
if (!fileExists3) {
//Pirated
NSLog(@\"Pirated3\");
}
NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
NSString* path = [NSString stringWithFormat:@\"%@/Info.plist\", bundlePath];
NSString* path2 = [NSString stringWithFormat:@\"%@/AppName\", bundlePath];
NSDate* infoModifiedDate = [[[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES] fileModificationDate];
NSDate* infoModifiedDate2 = [[[NSFileManager defaultManager] fileAttributesAtPath:path2 traverseLink:YES] fileModificationDate];
NSDate* pkgInfoModifiedDate = [[[NSFileManager defaultManager] fileAttributesAtPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@\"PkgInfo\"] traverseLink:YES] fileModificationDate];
if([infoModifiedDate timeIntervalSinceReferenceDate] > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {
//Pirated
}
if([infoModifiedDate2 timeIntervalSinceReferenceDate] > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {
//Pirated
}
#import <dlfcn.h>
#import <sys/types.h>
#import <Foundation/Foundation.h>
#import <TargetConditionals.h>
// The iPhone SDK doesn't have <sys/ptrace.h>, but it does have ptrace, and it
// works just fine.
typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data);
#if !defined(PT_DENY_ATTACH)
#define PT_DENY_ATTACH 31
#endif // !defined(PT_DENY_ATTACH)
void ZNDebugIntegrity() {
// If all assertions are enabled, we're in a legitimate debug build.
#if TARGET_IPHONE_SIMULATOR || defined(DEBUG) || (!defined(NS_BLOCK_ASSERTIONS) && !defined(NDEBUG))
return;
#endif
// Lame obfuscation of the string \"ptrace\".
char* ptrace_root = \"socket\";
char ptrace_name[] = {0xfd, 0x05, 0x0f, 0xf6, 0xfe, 0xf1, 0x00};
for (size_t i = 0; i < sizeof(ptrace_name); i++) {
ptrace_name[i] += ptrace_root[i];
}
void* handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW);
ptrace_ptr_t ptrace_ptr = dlsym(handle, ptrace_name);
ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0);
dlclose(handle);
}
#import <dlfcn.h>
#import <mach-o/dyld.h>
#import <TargetConditionals.h>
/* The encryption info struct and constants are missing from the iPhoneSimulator SDK, but not from the iPhoneOS or
* Mac OS X SDKs. Since one doesn't ever ship a Simulator binary, we'll just provide the definitions here. */
#if TARGET_IPHONE_SIMULATOR && !defined(LC_ENCRYPTION_INFO)
#define LC_ENCRYPTION_INFO 0x21
struct encryption_info_command {
uint32_t cmd;
uint32_t cmdsize;
uint32_t cryptoff;
uint32_t cryptsize;
uint32_t cryptid;
};
#endif
int main (int argc, char *argv[]);
static BOOL is_encrypted () {
const struct mach_header *header;
Dl_info dlinfo;
/* Fetch the dlinfo for main() */
if (dladdr(main, &dlinfo) == 0 || dlinfo.dli_fbase == NULL) {
NSLog(@\"Could not find main() symbol (very odd)\");
return NO;
}
header = dlinfo.dli_fbase;
/* Compute the image size and search for a UUID */
struct load_command *cmd = (struct load_command *) (header+1);
for (uint32_t i = 0; cmd != NULL && i < header->ncmds; i++) {
/* Encryption info segment */
if (cmd->cmd == LC_ENCRYPTION_INFO) {
struct encryption_info_command *crypt_cmd = (struct encryption_info_command *) cmd;
/* Check if binary encryption is enabled */
if (crypt_cmd->cryptid < 1) {
/* Disabled, probably pirated */
return NO;
}
/* Probably not pirated? */
return YES;
}
cmd = (struct load_command *) ((uint8_t *) cmd + cmd->cmdsize);
}
/* Encryption info not found */
return NO;
}
Replies
Probably the second most searched thing by iPhone crackers in a hex editor, is Close(0). In order to avoid having your Anti-Piracy code compromised by erasing Close(0), add as many ways to close as possible. Not only will this confuse the cracker as to why the application is still closing, it will be hard to edit out.
Well, thats everything. Enjoy it, and good luck to everyone with apps in the App store!
Links-
Check Executable's Encryption
Deny Debugger
Check If File Exists
Timestamp Checks
iPhone Piracy Protection Code - A Tutorial
Dr. Touch Anti-Crack
JavaConvert
Source Code
Check Out The Official Shmoopi LLC Website
iPrivateBrowser | <a href="http:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf this is too specific of a question or the answer could help pirates defeat the code, feel free to PM it to me instead.
Thanks!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI don't know about anyone else, but the way you've worded your post makes me very suspicious of your actual interests...
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAs far as being "far from even making an actual application," I don't think anything in my post would indicate that. While I wouldn't call myself an experienced iPhone developer by any means, using C directly in an iPhone program is not necessary for many basic applications. The Objective-C Cocoa libraries are more than enough to create a wide variety of applications.
Seeing as how my motives have been questioned here, I don't expect my question about implementation to be answered here (despite this being a tutorial forum).
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeCheck Out The Official Shmoopi LLC Website
iPrivateBrowser | <a href="http:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeBut I have some problem.
If I want to test those function is workable, I need to crack my app first, right??
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeCheck Out The Official Shmoopi LLC Website
iPrivateBrowser | <a href="http:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeHi Shmoopi,
Thanks for sharing the great info.
where do i put that last block of code for encryption check?
Also, do I need to call this method then do something w/ it output?
Doesn't sdk3.0+ has a function that is something like IsAppLegitCheck?
I'm not sure if it's any good though.
Can you please tell me how can I crack my app to check this?
(please PM me if required)
Thanks again,
-FerrariX
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeJust out out of curiosity is there any way to know the effectiveness of these methods. For example someone whose apps have a history of being cracked, have you seen a delay in your app being cracked after implementing anti-cracking measures?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeCheck Out The Official Shmoopi LLC Website
iPrivateBrowser | <a href="http:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome"infoModifiedDate2" is always greater than "pkgInfoModifiedDate" for me even after a clean build.
Apart from that everything else in these two tutorials is fantastic!! Thank you very much.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome*Update
I just checked a couple of my apps to see if the timestamps mix-match, and they did. It just so happens that if you build at the end of a minute, say you do a clean build at 5:14 and it finishes building at 5:15, the timestamps on the first couple files and the last couple files are different. You're absolutely right, I'll update the tutorial with this comment. If anyone is having trouble with this code sample, try building at the beginning of a minute. Thanks for catching that!
Check Out The Official Shmoopi LLC Website
iPrivateBrowser | <a href="http:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeCheck Out The Official Shmoopi LLC Website
iPrivateBrowser | <a href="http:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomefirst, do your checks often, and most importantly, DO NOT reuse the picracy checks. resusing the code allows for an easy point of entry to circumvent the checks.
second, once you understand the algorithm for the anti piracy code, alter the algorithm enough to preserve the logic flow, but alter the generated ASM code. This will make it harder to find ALL the AP checks in your code.
third, I think the combination of detecting the stripped encryption and debugger launch detection should be enough to deter most crackers.
Can I stop 100% of the attacks? probably not, but I will make it as hard as possible.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomethanks for your reply,
can I place your is_encrypted{} method somewhere else like the viewDidLoad?
or it absolutely has to be in the int main{}?
if it has to be in int main{}, would it close out if your is_encrypted{} returns a no?
in other words, I'd like to display an UIAlertView that "This App has been modified" then close the app out after one minute.
How caan I pass/receive the output of is_encrypted{} to the rest of my app?
Thanks again for sharing this great information,
-FerrariX
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome10 Detailed Steps to Submit Apps To AppStore
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome