Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money

preface

If the background Bool parameter is not supported at the same time [0,1]; And [true false], get requests require special handling.

I. Use NSNumber to pass BOOL

When NSNumber is used to transmit BOOL parameters, the get and Post parameters need to be distinguished.

1.1 Problem Analysis:

When NSNumber is used to transmit BOOL values, the parameters corresponding to GET and POST are inconsistent

    [params setValue:[NSNumber numberWithBool:self.viewModel.multipleSwitchCellTableViewCellModel.IsSon] forKey:@"IsSon"];//

Copy the code

This code uses Post to automatically change the request parameter IsSon to true/false

However, the default values of 0 and 1 for get requests do not automatically convert IsSon to true/false

1.2 Solutions

If the background get request is not supported [0,1]; And [true false], which require special handling when only true false is supported.

  • Proper handling of GET requests
    // get does not automatically convert "IsSon": true,// "IsSon": false,
//get needs to handle itself
    if(self.viewModel.multipleSwitchCellTableViewCellModel.IsSon){
        [params setValue:@"true" forKey:@"IsSon"];//

        
    }else{
        
        [params setValue:@"false" forKey:@"IsSon"];//

    }

Copy the code

II. Extension: Protection of sensitive logic

2.1. Hide the function name in the structure and store it as a pointer member

The function name is hidden in the structure and stored as a pointer member of the function.

After compiling, only the address is left, the name and parameter list are removed, and the reverse cost and attack threshold are raised

// Created by devzkn on 18/09/2017.
// Copyright © 2017. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface KNUtil : NSObject



/** The function name is hidden in the structure and stored as a pointer member of the function. After compiling, only the address is left, the name and parameter list are removed, raising the reverse cost and attack threshold */
typedef struct _util {
    void (*checkKNSign)(char *keys[], unsigned char *output);
}CheckKNSignUtil_t ;


#define ShareKNUtil ([KNUtil sharedUtil])

+ (CheckKNSignUtil_t *)sharedUtil;
Copy the code
  • A method is called
     ShareKNUtil->checkKNSign(key, output);

Copy the code

Use macros to replace strings

  • Search the class name and method name to be confused according to the prefix, and generate the corresponding macro file
#define run OmWJoTZfCqoPshvr
#define iosre egnjoOFDrFiQVRgr

Copy the code

Disassembly tools such as Hopper cannot search for key characters based on string in static analysis

III, see also

For more information and services, please check out # Applets: iOS Reverse, only for you to present valuable information, focusing on mobile technology research field.