Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-29-2009, 05:23 PM   #19 (permalink)
Damian
Registered Member
 
Join Date: Jan 2009
Location: Dublin
Posts: 5
Default

Quote:
Originally Posted by Shmoopi View Post

The last method I have for you today is the best:
Code:
#import 
#import 
#import 

/* 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;
}
This is one of the best Anti-Piracy implementations that I've seen; no strings attached What you're doing here is taking the Executable file and checking to see if their is any encryption on it. You can also check this on your mac by taking an executable file and typing in "otool -l *exectuable file*" in terminal. you can also check out Dr. Touch's Anti-Crack commercial to see it in action. Whenever a pirate cracks an application it strips the encryption in order to run it, with this implementation it's very easy to check if your executable is encrypted.

Continued...
One question, if I add "is_encrypted" to "main.m" how do I call it from the App Delegate? Thanks.
Damian is offline   Reply With Quote
 

» Advertisements
» Online Users: 291
21 members and 270 guests
ADY, antonwilliams, apatsufas, dacapo, dcool, HemiMG, iosdevjtp, jakerocheleau, leahov, MarkC, masc2279, morands, MozyMac, PsychoChris, sly24, smithdale87, sneaky, Sunny46, thh022, timle8n1, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,720
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:11 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.