콘텐츠로 이동

iOS 보안 침입을 위한 간단한 GUI 추가

앱 내의 DoveRunner Mobile App Security 라이브러리는 앱이 실행된 직후 자동으로 활성화됩니다. DoveRunner Mobile App Security 라이브러리가 비정상적인 환경(탈옥된 기기, 실행 파일이 복호화되었거나 디버거가 연결됨)을 감지하면 사용자 액션과 관계없이 20초 후에 앱을 종료하므로, 앱은 탐지 결과를 사용자에게 알리고 사용자가 자신의 기기에 잘못된 환경이 있음을 인식할 수 있도록 적절한 메시지 상자를 표시해야 합니다.

React Native에서는 JavaScript 코드를 통해 보안 상태를 확인하고 알림을 표시할 수 있습니다.

import React, {useEffect, useState} from 'react';
import {Alert, NativeModules} from 'react-native';
const {AppSealingModule} = NativeModules;
const checkSecurityStatus = async () => {
try {
const securityStatus = await AppSealingModule.checkSecurity();
if (securityStatus.isAbnormal) {
let message = '비정상적인 환경이 감지되었습니다!';
if (securityStatus.isJailbroken) {
message += '\n- 기기가 탈옥되었습니다';
}
if (securityStatus.isDecrypted) {
message += '\n- 실행 파일이 암호화되지 않았습니다';
}
if (securityStatus.isDebugged) {
message += '\n- 디버거가 감지되었습니다';
}
if (securityStatus.isModified) {
message += '\n- 앱이 변조되었습니다';
}
Alert.alert(
'보안 경고',
message,
[{text: '확인', style: 'default'}],
{cancelable: false}
);
}
} catch (error) {
console.error('보안 상태 확인 중 오류:', error);
}
};
const SecurityCheck = () => {
useEffect(() => {
// 앱 시작 시 보안 상태 확인
checkSecurityStatus();
}, []);
return null; // 이 컴포넌트는 UI를 렌더링하지 않음
};
// 메인 앱 컴포넌트에서 사용
const App = () => {
return (
<>
<SecurityCheck />
{/* 나머지 앱 컴포넌트들 */}
</>
);
};

네이티브 쪽에서는 다음과 같이 보안 상태를 확인하는 모듈을 구현합니다:

#import <React/RCTBridgeModule.h>
@interface AppSealingModule : NSObject <RCTBridgeModule>
@end
#import "AppSealingModule.h"
#import "AppsealingiOS.h"
@implementation AppSealingModule
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(checkSecurity:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
int tamper = ObjC_IsAbnormalEnvironmentDetected();
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
[result setObject:@(tamper > 0) forKey:@"isAbnormal"];
[result setObject:@((tamper & DETECTED_JAILBROKEN) > 0) forKey:@"isJailbroken"];
[result setObject:@((tamper & DETECTED_DRM_DECRYPTED) > 0) forKey:@"isDecrypted"];
[result setObject:@((tamper & DETECTED_DEBUG_ATTACHED) > 0) forKey:@"isDebugged"];
[result setObject:@((tamper & (DETECTED_HASH_INFO_CORRUPTED | DETECTED_HASH_MODIFIED)) > 0) forKey:@"isModified"];
resolve(result);
}
@end

더 고급 사용자 인터페이스를 원한다면 React Native의 모달이나 사용자 정의 컴포넌트를 사용할 수 있습니다:

import React, {useState, useEffect} from 'react';
import {Modal, View, Text, Button, StyleSheet} from 'react-native';
const SecurityAlert = () => {
const [visible, setVisible] = useState(false);
const [securityMessage, setSecurityMessage] = useState('');
useEffect(() => {
checkAndShowSecurity();
}, []);
const checkAndShowSecurity = async () => {
try {
const status = await AppSealingModule.checkSecurity();
if (status.isAbnormal) {
setSecurityMessage(buildSecurityMessage(status));
setVisible(true);
}
} catch (error) {
console.error('보안 확인 오류:', error);
}
};
const buildSecurityMessage = (status) => {
let message = '보안 위협이 감지되었습니다:\n\n';
if (status.isJailbroken) message += '• 기기 탈옥 감지\n';
if (status.isDecrypted) message += '• 앱 암호화 손상\n';
if (status.isDebugged) message += '• 디버깅 도구 감지\n';
if (status.isModified) message += '• 앱 변조 감지\n';
return message;
};
return (
<Modal
visible={visible}
transparent={true}
animationType="fade"
onRequestClose={() => setVisible(false)}>
<View style={styles.overlay}>
<View style={styles.modal}>
<Text style={styles.title}>보안 경고</Text>
<Text style={styles.message}>{securityMessage}</Text>
<Button
title="확인"
onPress={() => setVisible(false)}
/>
</View>
</View>
</Modal>
);
};
const styles = StyleSheet.create({
overlay: {
flex: 1,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
justifyContent: 'center',
alignItems: 'center',
},
modal: {
backgroundColor: 'white',
padding: 20,
borderRadius: 10,
minWidth: 300,
},
title: {
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 10,
},
message: {
fontSize: 14,
textAlign: 'center',
marginBottom: 20,
},
});
  • 보안 알림은 사용자에게 명확하고 이해하기 쉬운 메시지를 제공해야 합니다
  • 알림이 표시된 후에도 앱은 20초 후에 자동으로 종료됩니다
  • 릴리스 모드에서만 실제 보안 탐지가 활성화됩니다
  • 개발 중에는 테스트 모드를 사용하여 GUI를 확인하세요