App Safer iOS SDK 적용 가이드
App Safer iOS는 네이버 클라우드 플랫폼이 제공하는 모바일 보안 솔루션으로서, 모바일 기기나 서비스에 위협이 되는 행위를 탐지하는 API를 제공합니다. iOS용 App Safer 라이브러리는 하나의 프레임워크로 구성되어 있으며, Bitcode Enable/Disable 환경을 모두 지원합니다.
App Safer iOS 기능
- Jailbreak 탐지
- Simulator 탐지
- Debugging 탐지
- Memory Tampered 탐지
- Unauthorized Signature 탐지
App Safer iOS 지원 환경
파일 이름 | OS 버전 |
---|---|
AppSaferFramework.framework | iOS 8.0 이상 |
App Safer iOS SDK 적용 가이드
AppSaferFramework를 적용하는 방법은 아래와 같습니다.
Xcode 8.0 이상의 환경에서 빌드를 권고합니다.
AppSaferFramework.framework를 프로젝트의 최상단에 위치 시킵니다.
프로젝트 설정에서 General > Frameworks, Libraries, and Embedded Content에 모든 프레임워크를 추가합니다.
- AppSaferFramework.framework 및 하위 폴더 내 프레임워크(Nelo2SDK, CrashReporter)
- Bitcode Enable 버전이면 Build Settings > Enable Bitcode를 Yes로 설정합니다.
- Bitcode Disable 버전이면 Build Settings > Enable Bitcode를 No로 설정합니다.
(선택사항) Build Settings > Framework Search Paths를 AppSaferFramework.framework 파일이 있는 경로로 설정합니다.
App Safer iOS API 목록
클래스 이름 | API 이름 | API 설명 |
---|---|---|
AppSafer |
- (int) initAppSafer:(id serviceCode:(NSString *)serviceCode key:(NSString *)appsaferKey |
AppSafer을 사용하기 위해 초기화 |
- (int)checkTampering | 실시간 보안 탐지
|
|
- (int)setUserId:(NSString *)userId | 사용자 ID를 설정 |
Delegate 이름 | 필수 여부 | API 이름 | API 설명 |
---|---|---|---|
AppSaferDelegate | Required | - (void)appSaferDidInitFinish:(NSUInteger)result msg:(NSString *)message | App Safer의 초기화 결과를 전달받음 |
Required | - (void)appSaferDidCheckTamperingFinish:(int)result | checkTampering 함수 수행이 완료되면 결과를 전달 | |
Optional | - (void)appSaferDetectedJailbreak | Jailbreak 탐지 시점에 호출 | |
Optional | - (void)appSaferDetectedSimulator | Simulator 탐지 시점에 호출 | |
Optional | - (void)appSaferDetectedDebugging | Debugging 탐지 시점에 호출 | |
Optional | - (void)appSaferDetectedMemoryTampered | Memory Tampered 탐지 시점에 호출 |
App Safer iOS API 설명
- (int) initAppSafer:(id)delegate serviceCode:(NSString )serviceCode key:(NSString )appsaferKey
App Safer를 사용하기 위해 초기화합니다. 로그를 전송하는 데 필요한 정보 및 전역으로 사용되는 변수를 초기화합니다.
- App Safer의 모든 API는 initAppSafer()가 성공적으로 호출된 후에 사용할 수 있습니다.
- 초기화 성공 여부를 전달받기 위해 AppSaferDelegate를 구현해야 합니다.
매개변수
매개변수 | 설명 |
---|---|
delegate | AppSaferDelegate가 구현된 인스턴스 |
serviceCode | App Safer 서비스를 이용하기 위한 코드 네이버 클라우드 플랫폼 사용자는 반드시 'ncloud'를 전달 |
appsaferKey | 콘솔에서 앱 등록 시 생성된 appsaferKey값 |
반환 값
반환 값 | 설명 |
---|---|
SUCCESS(0) | 성공 |
FAIL(-1) | 실패 |
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (IBAction)initAppSafer:(id)sender {
AppSafer *appSafer = [[AppSafer alloc] init];
int res = FAIL;
if(appSafer != nil) {
// APP_SAFER_KEY generated when registering an app to the Console
res = [appSafer initAppSafer:self serviceCode:@"ncloud" key:"<APP_SAFER_KEY>"];
NSLog(@"initAppSafer result %d", res);
if(res == SUCCESS) {
// init success
} else if(res == FAIL) {
// init fail
}
} else {
NSLog(@"AppSafer is nil");
}
}
- (int)checkTampering
실시간 보안 탐지(Jailbreak 탐지, Simulator 탐지, Debugging 탐지, Memory Tampered 탐지, Unauthorized Signature 탐지)를 수행합니다. 검사 결과를 전달받으려면 AppSaferDelegate를 설정해야 합니다.
반환 값
반환 값 | 설명 |
---|---|
SUCCESS(0) | 검사 시작 성공 |
FAIL(-1) | 검사 시작 실패 |
BLOCK(2) | 보안 정책을 위반하여 차단 |
BEFOREINIT(3) | AppSafer가 초기화되지 않음 |
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (IBAction)checkAppSafer:(id)sender {
AppSafer *appSafer = [[AppSafer alloc] init];
if(appSafer != nil) {
int res = [appSafer checkTampering];
switch(res) {
case FAIL:
NSLog(@"Failed to check tampering");
break;
case SUCCESS:
NSLog(@"Check Tampering Success");
break;
case BLOCK:
NSLog(@"Device is blocked");
break;
case BEFOREINIT:
NSLog(@"AppSafer is not initialized");
break;
}
} else {
NSLog(@"AppSafer is nil");
}
}
@end
- (int)setUserId:(NSString *)userId
초기화 및 탐지 이벤트 발생 시 App Safer 서버에 전송되는 로그에 사용자 ID를 포함하고자 할 때 설정합니다.
매개변수
매개변수 | 설명 |
---|---|
userId | 설정하고자 하는 사용자 식별자 |
반환 값
반환 값 | 설명 |
---|---|
SUCCESS(0) | 설정 성공 |
FAIL(-1) | 설정 실패 |
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (IBAction)setUserId:(id)sender {
AppSafer *appSafer = [[AppSafer alloc] init];
if(appSafer != nil) {
NSLog(@"setUserId text %@", [self.useridText text]);
int res = [appSafer setUserId:[self.useridText text]];
switch(res) {
case FAIL:
NSLog(@"Failed to set userId");
break;
case SUCCESS:
NSLog(@"setUserId Success");
break;
}
} else {
NSLog(@"AppSafer is nil");
}
}
App Safer iOS 콜백 함수 설명
App Safer의 검사 함수는 모두 비동기로 동작하며, 결과 처리는 AppSaferDelegate를 통해 위임됩니다.
만약 검사 결과를 받고 싶다면 App Safer에서 제공하는 AppSaferDelegate를 구현하고 initAppSafer() 함수를 이용해 등록해야 합니다.
- (void)appSaferDidInitFinish:(int)result
initAppSafer() 함수 호출 후 초기화 완료 시 결과를 전달합니다.
매개변수
매개변수 | 설명 |
---|---|
SUCCESS(0) | 초기화 성공 |
FAIL(-1) | 초기화 실패 |
BLOCK(2) | 보안 정책 위반으로 차단 됨 |
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (void)appSaferDidInitFinish:(NSUInteger)result msg:(NSString *)message {
NSLog(@"appSaferDidInitFinish result %d", result);
if(result == BLOCK) {
NSLog(@"Device is blocked!");
// add to exit application logic
}
}
- (void)appSaferDidCheckTamperingFinish:(int)result
checkTampering 함수 호출 후 검사가 완료되면 검사 결과를 전달하기 위해 호출됩니다.
매개변수
매개변수 | 설명 |
---|---|
FAIL(-1) | 검사 실패 |
SAFE(0) | 이벤트가 탐지되지 않음 |
DETECT(1) | 이벤트 탐지 |
BLOCK(2) | 차단 됨 |
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (void)appSaferDidCheckTamperingFinish:(int)result {
NSLog(@"appSaferDidCheckTamperingFinish result %@",
result == FAIL ? @"FAIL" :
result == SAFE ? @"SAFE" :
result == DETECT ? @"DETECT" :
result == BLOCK ? @"BLOCK": @"UNKNOWN");
if(result == BLOCK) {
NSLog(@"Device is blocked!");
// add to exit application logic
}
}
- (void)appSaferDetectedJailbreak
checkTampering() 함수 호출 후 탈옥이 탐지되는 시점에 호출됩니다.
checkTampering() 함수 동작이 완료되지 않았더라도 결과를 받고 싶을 때 사용합니다.
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (void)appSaferDetectedJailbreak {
NSLog(@"[DETECT] appSaferDetectedJailbreak");
}
- (void)appSaferDetectedSimulator
checkTampering() 함수 호출 후 가상 머신이 탐지되는 시점에 호출됩니다.
checkTampering() 함수 동작이 완료되지 않았더라도 결과를 받고 싶을 때 사용합니다.
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (void)appSaferDetectedSimulator {
NSLog(@"[DETECT] appSaferDetectedSimulator");
}
- (void)appSaferDetectedDebugging
checkTampering() 함수 호출 후 디버깅이 탐지되는 시점에 호출됩니다.
checkTampering() 함수 동작이 완료되지 않았더라도 결과를 받고 싶을 때 사용합니다.
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (void)appSaferDetectedDebugging {
NSLog(@"[DETECT] appSaferDetectedDebugging");
}
- (void)appSaferDetectedMemoryTampered
checkTampering() 함수 호출 후 메모리 변조가 탐지되는 시점에 호출됩니다.
checkTampering() 함수 동작이 완료되지 않았더라도 결과를 받고 싶을 때 사용합니다.
예제
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (void)appSaferDetectedMemoryTampered {
NSLog(@"[DETECT] appSaferDetectedMemoryTampered");
}
App Safer iOS Use Case
초기화
#import <AppSaferFramework/AppSaferFramework.h>
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
AppSafer *appSafer = [[AppSafer alloc] init];
int res = FAIL;
if(appSafer != nil) {
// APP_SAFER_KEY generated when registering an app to the Console
res = [appSafer initAppSafer:self serviceCode:@"ncloud" key:"<APP_SAFER_KEY>"];
NSLog(@"initAppSafer result %d", res);
if(res == SUCCESS) {
// init success
} else if(res == FAIL) {
// init fail
}
} else {
NSLog(@"AppSafer is nil");
}
}
- (void)appSaferDidInitFinish:(NSUInteger)result msg:(NSString *)message {
NSLog(@"appSaferDidInitFinish result %d", result);
if(result == BLOCK) {
NSLog(@"Device is blocked!");
// add to exit application logic
}
}
실시간 보안 탐지
@implementation ViewController
- (IBAction)checkAppSafer:(id)sender {
AppSafer *appSafer = [[AppSafer alloc] init];
if(appSafer != nil) {
int res = [appSafer checkTampering];
switch(res) {
case FAIL:
NSLog(@"Failed to check tampering");
break;
case SUCCESS:
NSLog(@"Check Tampering Success");
break;
case BLOCK:
NSLog(@"Device is blocked");
break;
case BEFOREINIT:
NSLog(@"AppSafer is not initialized");
break;
}
} else {
NSLog(@"AppSafer is nil");
}
}
- (void)appSaferDidCheckTamperingFinish:(int)result {
if(result == BLOCK) {
[self.msgbox setText:@"Device is blocked!"];
// add to exit application
}
NSLog(@"appSaferDidCheckTamperingFinish result %@",
result == FAIL ? @"FAIL" :
result == SAFE ? @"SAFE" :
result == DETECT ? @"DETECT" :
result == BLOCK ? @"BLOCK": @"UNKNOWN");
}
- (void)appSaferDetectedJailbreak {
NSLog(@"[DETECT] appSaferDetectedJailbreak");
}
- (void)appSaferDetectedSimulator {
NSLog(@"[DETECT] appSaferDetectedSimulator");
}
- (void)appSaferDetectedDebugging {
NSLog(@"[DETECT] appSaferDetectedDebugging");
}
- (void)appSaferDetectedMemoryTampered {
NSLog(@"[DETECT] appSaferDetectedMemoryTampered");
}
참고 사항
본 상품은 글로벌 리전 서비스로도 제공됩니다.
연관 정보 바로가기
아래 가이드에서 연관 정보를 확인할 수 있습니다.