iOS security attacks and defenses (24): Sensitive protection scheme Logic (1)

Source: Internet
Author: User

iOS security attacks and defenses (24): Sensitive protection scheme Logic (1)



Objective-c code Easy is hook. Exposure information is too naked, for security, use C to write it!





Of course not all the code is written in C, I'm referring to the sensitive business logic code.

This article introduces a kind of low learning cost. Easy to do. The OBJECTIVE-C logic code overrides the C code method.


Perhaps there is a similar class in the program:

@interface xxutil:nsobject+ (BOOL) isverified;+ (BOOL) isneedsomething;+ (void) ResetPassword: (NSString *) password;@ End


After being class-dump out. Use Cycript very easy to achieve attacks, easy to be hook. There is a very large security risk.

Want to change, but do not want to change the structure of the program, swollen?





Hides the function name in the struct and stores it as a function pointer member.

The advantage of doing this is. After compiling, just leave the address, remove the name and the tables. Improved reverse cost and attack threshold.



The rewritten programs such as the following:

Xxutil.h#import <foundation/foundation.h>typedef struct _util {    BOOL (*isverified) (void);    BOOL (*isneedsomething) (void);    void (*resetpassword) (NSString *password);} xxutil_t, #define XXUTIL ([_xxutil sharedutil]) @interface _xxutil:nsobject+ (xxutil_t *) Sharedutil; @end


Xxutil.m#import "XXUtil.h" static BOOL _isverified (void) {    //bala bala ...    return YES;} Static BOOL _isneedsomething (void) {    //bala bala    ... return YES;} static void _resetpassword (NSString *password) {    //bala Bala ...} Static xxutil_t * util = NULL, @implementation _xxutil+ (xxutil_t *) sharedutil{    static dispatch_once_t Oncetoken;    Dispatch_once (&oncetoken, ^{        util = malloc (sizeof (xxutil_t));        util->isverified = _isverified;        util->isneedsomething = _isneedsomething;        Util->resetpassword = _resetpassword;    });    return util;} + (void) destroy{    util free (util): 0;    Util = NULL;} @end



Finally, based on Xcode's error guidelines. Put this call once

[Xxutil isverified];

Change accordingly:

Xxutil->isverified ();

will be able to.


Yes, not a bit of brain.




Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

iOS security attacks and defenses (24): Sensitive protection scheme Logic (1)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.