KR102173151B1 - Apparatus and method for automatic extraction of original source code - Google Patents

Apparatus and method for automatic extraction of original source code Download PDF

Info

Publication number
KR102173151B1
KR102173151B1 KR1020180130055A KR20180130055A KR102173151B1 KR 102173151 B1 KR102173151 B1 KR 102173151B1 KR 1020180130055 A KR1020180130055 A KR 1020180130055A KR 20180130055 A KR20180130055 A KR 20180130055A KR 102173151 B1 KR102173151 B1 KR 102173151B1
Authority
KR
South Korea
Prior art keywords
original code
file
application
unpacking
memory
Prior art date
Application number
KR1020180130055A
Other languages
Korean (ko)
Other versions
KR20200048221A (en
Inventor
권오현
곽문수
백준선
이병재
Original Assignee
네이버비즈니스플랫폼 주식회사
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 네이버비즈니스플랫폼 주식회사 filed Critical 네이버비즈니스플랫폼 주식회사
Priority to KR1020180130055A priority Critical patent/KR102173151B1/en
Publication of KR20200048221A publication Critical patent/KR20200048221A/en
Application granted granted Critical
Publication of KR102173151B1 publication Critical patent/KR102173151B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

본 출원은 원본코드 자동추출장치 및 원본코드 자동추출방법에 관한 것으로서, 본 발명의 일 실시예에 의한 원본코드 자동추출장치는 안드로이드 운영체제(android operating system)를 기반으로 하며, 상기 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라, 어플리케이션(application)의 패킹(packing)된 APK(Android Package) 파일을 언패킹하여 원본코드를 생성하고, 상기 원본코드를 메모리 상에 로딩하는 언패킹부; 및 상기 원본코드가 상기 메모리 상에 로딩되면, 메모리 덤프하여 상기 원본코드를 원본코드파일로 저장하는 파일추출부를 포함할 수 있다.The present application relates to a device for automatically extracting an original code and a method for automatically extracting an original code, and the device for automatically extracting an original code according to an embodiment of the present invention is based on an Android operating system, and a runtime environment of the Android operating system An unpacking unit for generating an original code by unpacking an APK (Android Package) file packed in an application according to the (Runtime environment), and loading the original code onto a memory; And a file extracting unit for storing the original code as an original code file by memory dumping when the original code is loaded on the memory.

Description

원본코드 자동추출장치 및 원본코드 자동추출방법 {Apparatus and method for automatic extraction of original source code}Original code automatic extraction device and method for automatic extraction of original source code {Apparatus and method for automatic extraction of original source code}

본 출원은 원본코드 자동추출장치 및 원본코드 자동추출방법에 관한 것으로서, 특히 패킹된 APK(Android Application Package) 파일을 언패킹(unpacking)하여 대응하는 원본코드를 추출할 수 있는 원본코드 자동추출장치 및 원본코드 자동추출방법에 관한 것이다. The present application relates to a device for automatically extracting original code and a method for automatically extracting original code, and in particular, an automatic original code extraction device capable of extracting a corresponding original code by unpacking a packed APK (Android Application Package) file, and It relates to a method of automatically extracting original code

최근 스마트폰을 비롯한 다양한 모바일 기기 보급이 급속도로 증가하고 있고, 이들 기기에 저장된 각종 개인정보에 대한 불법적 접근을 노리는 악성 어플리케이션들로 인한 피해가 발생하고 있다. 이들 악성 어플리케이션들에 대한 분석을 수행하기 위해서는, 악성 어플리케이션 실행파일에 대한 디컴파일(decompile)을 수행할 필요가 있다. 디컴파일이란 이미 컴파일된 기계어나 어셈블러 부호로부터 컴파일 전의 본래 소스 코드를 추출하는 것으로, 최근 다양한 종류의 디컴파일 프로그램들이 제공되고 있다. Recently, the spread of various mobile devices including smartphones is increasing rapidly, and damage is caused by malicious applications aiming at illegal access to various personal information stored in these devices. In order to analyze these malicious applications, it is necessary to decompile the malicious application executable file. Decompilation refers to extracting the original source code before compilation from an already compiled machine language or assembler code. Recently, various types of decompile programs have been provided.

일반적으로, 안드로이드의 실행파일인 APK(Android Application Package) 파일은 ZIP 파일 포맷에 기반을 두고 있으며, AndroidManifest.xml, Classes.dex, META-INF, res, lib 등을 포함할 수 있다. 여기서, AndroidManifest.xml는 APK 파일의 전체적인 구조, 그리고 부가적인 권한 설정이나 기능을 사용하는 class를 명시하고, Classes.dex는 안드로이드 어플리케이션의 실행 코드를 저장한다. 또한, META-INF는 인증된 키값이 저장된 폴더이고, res는 그래픽과 관련된 이미지 및 레이아웃, lib은 달빅 가상머신을 이용하지 않는 SO(Shared Object) 라이브러리에 해당한다. In general, the APK (Android Application Package) file, which is an Android executable file, is based on the ZIP file format, and may include AndroidManifest.xml, Classes.dex, META-INF, res, lib, and the like. Here, AndroidManifest.xml specifies the overall structure of the APK file, and classes that use additional permission settings or functions, and Classes.dex stores the execution code of the Android application. In addition, META-INF is a folder in which the authenticated key value is stored, res is an image and layout related to graphics, and lib is a shared object (SO) library that does not use the Dalvik virtual machine.

안드로이드 어플리케이션들의 경우, APK 파일에 대한 디컴파일을 수행하여 해당 어플리케이션의 소스 코드를 추출하는 것이 가능하다. 다만, 최근 어플리케이션의 디컴파일을 방지하기 위하여, 실행파일 등에 코드 난독화 또는 암호화 등의 패킹(packing) 기법이 적용되고 있으며, 디컴파일을 통한 어플리케이션 분석이 점차 어려워지고 있다.In the case of Android applications, it is possible to extract the source code of the application by decompiling the APK file. However, in order to prevent decompilation of an application recently, a packing technique such as code obfuscation or encryption has been applied to an executable file, and analysis of an application through decompilation is becoming increasingly difficult.

본 출원은, 패킹된 APK 파일을 언패킹하여 대응하는 원본코드를 추출할 수 있는 원본코드 자동추출장치 및 원본코드 자동추출방법을 제공하고자 한다.The present application is intended to provide an original code automatic extraction apparatus and a method for automatically extracting original codes capable of extracting a corresponding original code by unpacking a packed APK file.

본 출원은, 컴파일시 메모리 내에 원본코드가 로딩되는 시점을 파악하여, 메모리로부터 직접 원본코드를 추출할 수 있는 원본코드 자동추출장치 및 원본코드 자동추출방법을 제공하고자 한다. The present application seeks to provide an original code automatic extraction device and a method for automatically extracting original code by grasping when the original code is loaded into the memory during compilation and extracting the original code directly from the memory.

본 출원은, 달빅 가상머신(Dalvik Virtual Machine) 또는 안드로이드 런타임(Android Runtime)을 이용하는 안드로이드 운영체제에 대한 원본코드 자동추출장치 및 원본코드 자동추출방법을 제공하고자 한다.The present application is intended to provide a device for automatically extracting an original code and a method for automatically extracting an original code for an Android operating system using a Dalvik Virtual Machine or Android Runtime.

본 발명의 일 실시예에 의한 원본코드 자동추출장치는, 안드로이드 운영체제(android operating system)를 기반으로 하는 원본코드 자동추출장치에 관한 것으로서, 상기 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라, 어플리케이션(application)의 패킹(packing)된 APK(Android Package) 파일을 언패킹하여 원본코드를 생성하고, 상기 원본코드를 메모리 상에 로딩하는 언패킹부; 및 상기 원본코드가 상기 메모리 상에 로딩되면, 메모리 덤프하여 상기 원본코드를 원본코드파일로 저장하는 파일추출부를 포함할 수 있다. An original code automatic extraction device according to an embodiment of the present invention relates to an original code automatic extraction device based on an Android operating system, and according to a runtime environment of the Android operating system, an application ( an unpacking unit for generating an original code by unpacking the packed APK (Android Package) file of application), and loading the original code onto a memory; And a file extracting unit for storing the original code as an original code file by memory dumping when the original code is loaded on the memory.

본 발명의 일 실시예에 의한 원본코드 자동추출방법은, 안드로이드 운영체제(android operating system)를 기반으로 하는 원본코드 자동추출방법에 관한 것으로, 상기 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라, 어플리케이션(application)의 패킹(packing)된 APK(Android Package) 파일을 언패킹하여 원본코드를 생성하고, 상기 원본코드를 메모리 상에 로딩하는 단계; 및 상기 원본코드가 상기 메모리 상에 로딩되면, 메모리 덤프하여 상기 원본코드를 원본코드파일로 저장하는 단계를 포함할 수 있다. An original code automatic extraction method according to an embodiment of the present invention relates to a method for automatically extracting original code based on an Android operating system, and according to a runtime environment of the Android operating system, an application ( generating an original code by unpacking a packed APK (Android Package) file of (application), and loading the original code onto a memory; And when the original code is loaded onto the memory, memory dumping and storing the original code as an original code file.

덧붙여 상기한 과제의 해결수단은, 본 발명의 특징을 모두 열거한 것이 아니다. 본 발명의 다양한 특징과 그에 따른 장점과 효과는 아래의 구체적인 실시형태를 참조하여 보다 상세하게 이해될 수 있을 것이다. In addition, the solution to the above-described problem does not enumerate all the features of the present invention. Various features of the present invention and advantages and effects thereof may be understood in more detail with reference to the following specific embodiments.

본 발명의 일 실시예에 의한 원본코드 자동추출장치 및 원본코드 자동추출방법에 의하면, 패킹된 APK 파일을 용이하게 언패킹하여, 해당 APK 파일에 대응하는 원본코드를 추출할 수 있다. According to the original code automatic extraction apparatus and the original code automatic extraction method according to an embodiment of the present invention, the packed APK file can be easily unpacked, and the original code corresponding to the corresponding APK file can be extracted.

본 발명의 일 실시예에 의한 원본코드 자동추출장치 및 원본코드 자동추출방법에 의하면, 메모리 내에 언패킹된 원본코드가 로딩되는 시점을 파악하여 메모리로부터 직접 원본코드를 추출할 수 있으므로, 컴파일시 원본코드가 별도의 파일로 저장되지 않는 경우에도, 용이하게 원본코드를 추출할 수 있다. According to the original code automatic extraction device and the original code automatic extraction method according to an embodiment of the present invention, the original code can be extracted directly from the memory by grasping the time when the unpacked original code is loaded in the memory. Even if the code is not saved as a separate file, the original code can be easily extracted.

본 발명의 일 실시예에 의한 원본코드 자동추출장치 및 원본코드 자동추출방법은, 달빅 가상머신을 이용하는 안드로이드 운영체제와 안드로이드 런타임을 이용하는 안드로이드 운영체제에 각각 적용가능하다. The original code automatic extraction device and the original code automatic extraction method according to an embodiment of the present invention are applicable to an Android operating system using a Dalvik virtual machine and an Android operating system using an Android runtime, respectively.

다만, 본 발명의 실시예들에 따른 원본코드 자동추출장치 및 원본코드 자동추출방법이 달성할 수 있는 효과는 이상에서 언급한 것들로 제한되지 않으며, 언급하지 않은 또 다른 효과들은 아래의 기재로부터 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 명확하게 이해될 수 있을 것이다.However, the effects that can be achieved by the automatic original code extraction device and the automatic original code extraction method according to the embodiments of the present invention are not limited to those mentioned above, and other effects not mentioned are seen from the following description. It will be clearly understood by those of ordinary skill in the art to which the invention belongs.

도1은 본 발명의 일 실시예에 의한 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출장치를 나타내는 블록도이다.
도2는 본 발명의 일 실시예에 의한 달빅 가상머신을 이용하는 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출장치를 나타내는 블록도이다.
도3은 본 발명의 일 실시예에 의한 안드로이드 런타임을 이용하는 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출장치를 나타내는 블록도이다.
도4는 본 발명의 일 실시예에 의한 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출방법을 나타내는 순서도이다.
도5는 본 발명의 일 실시예에 의한 달빅 가상머신을 이용하는 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출방법을 나타내는 순서도이다.
도6은 본 발명의 일 실시예에 의한 안드로이드 런타임을 이용하는 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출방법을 나타내는 순서도이다.
1 is a block diagram showing an apparatus for automatically extracting original codes based on an Android operating system according to an embodiment of the present invention.
2 is a block diagram showing an apparatus for automatically extracting original codes based on an Android operating system using a Dalvik virtual machine according to an embodiment of the present invention.
3 is a block diagram showing an apparatus for automatically extracting original codes based on an Android operating system using an Android runtime according to an embodiment of the present invention.
4 is a flow chart showing a method for automatically extracting original codes based on an Android operating system according to an embodiment of the present invention.
5 is a flow chart showing a method of automatically extracting original codes based on an Android operating system using a Dalvik virtual machine according to an embodiment of the present invention.
6 is a flowchart illustrating a method of automatically extracting original codes based on an Android operating system using an Android runtime according to an embodiment of the present invention.

이하, 첨부된 도면을 참조하여 본 명세서에 개시된 실시 예를 상세히 설명하되, 도면 부호에 관계없이 동일하거나 유사한 구성요소는 동일한 참조 번호를 부여하고 이에 대한 중복되는 설명은 생략하기로 한다. 이하의 설명에서 사용되는 구성요소에 대한 접미사 "모듈" 및 "부"는 명세서 작성의 용이함만이 고려되어 부여되거나 혼용되는 것으로서, 그 자체로 서로 구별되는 의미 또는 역할을 갖는 것은 아니다. 즉, 본 발명에서 사용되는 '부'라는 용어는 소프트웨어, FPGA 또는 ASIC과 같은 하드웨어 구성요소를 의미하며, '부'는 어떤 역할들을 수행한다. 그렇지만 '부'는 소프트웨어 또는 하드웨어에 한정되는 의미는 아니다. '부'는 어드레싱할 수 있는 저장 매체에 있도록 구성될 수도 있고 하나 또는 그 이상의 프로세서들을 재생시키도록 구성될 수도 있다. 따라서, 일 예로서 '부'는 소프트웨어 구성요소들, 객체지향 소프트웨어 구성요소들, 클래스 구성요소들 및 태스크 구성요소들과 같은 구성요소들과, 프로세스들, 함수들, 속성들, 프로시저들, 서브루틴들, 프로그램 코드의 세그먼트들, 드라이버들, 펌웨어, 마이크로 코드, 회로, 데이터, 데이터베이스, 데이터 구조들, 테이블들, 어레이들 및 변수들을 포함한다. 구성요소들과 '부'들 안에서 제공되는 기능은 더 작은 수의 구성요소들 및 '부'들로 결합되거나 추가적인 구성요소들과 '부'들로 더 분리될 수 있다.Hereinafter, exemplary embodiments disclosed in the present specification will be described in detail with reference to the accompanying drawings, but identical or similar elements are denoted by the same reference numerals regardless of reference numerals, and redundant descriptions thereof will be omitted. The suffixes "module" and "unit" for components used in the following description are given or used interchangeably in consideration of only the ease of preparation of the specification, and do not have meanings or roles that are distinguished from each other by themselves. That is, the term'unit' used in the present invention means a hardware component such as software, FPGA or ASIC, and the'unit' performs certain roles. However,'part' is not limited to software or hardware. The'unit' may be configured to be in an addressable storage medium, or may be configured to reproduce one or more processors. Thus, as an example,'unit' refers to components such as software components, object-oriented software components, class components, and task components, processes, functions, properties, procedures, Includes subroutines, segments of program code, drivers, firmware, microcode, circuitry, data, database, data structures, tables, arrays and variables. The functions provided in the components and'units' may be combined into a smaller number of components and'units', or may be further divided into additional components and'units'.

또한, 본 명세서에 개시된 실시 예를 설명함에 있어서 관련된 공지 기술에 대한 구체적인 설명이 본 명세서에 개시된 실시 예의 요지를 흐릴 수 있다고 판단되는 경우 그 상세한 설명을 생략한다. 또한, 첨부된 도면은 본 명세서에 개시된 실시 예를 쉽게 이해할 수 있도록 하기 위한 것일 뿐, 첨부된 도면에 의해 본 명세서에 개시된 기술적 사상이 제한되지 않으며, 본 발명의 사상 및 기술 범위에 포함되는 모든 변경, 균등물 내지 대체물을 포함하는 것으로 이해되어야 한다.In addition, in describing the embodiments disclosed in the present specification, when it is determined that a detailed description of related known technologies may obscure the subject matter of the embodiments disclosed in the present specification, the detailed description thereof will be omitted. In addition, the accompanying drawings are for easy understanding of the embodiments disclosed in the present specification, and the technical idea disclosed in the present specification is not limited by the accompanying drawings, and all modifications included in the spirit and scope of the present invention It should be understood to include equivalents or substitutes.

안드로이드 운영체제(Android Operating System)를 기반으로 하는 어플리케이션들을 분석하는 경우, 리버스 엔지니어링(Reverse Engineering) 기법을 활용할 수 있다. 즉, APK(Android Application Package) 파일의 원본 바이너리(binary) 등 원본코드를 추출한 후, 추출한 원본코드를 이용하여 해당 어플리케이션에 대한 분석을 수행할 수 있다. When analyzing applications based on the Android Operating System, a reverse engineering technique can be used. That is, after extracting an original code such as an original binary of an APK (Android Application Package) file, analysis of the corresponding application may be performed using the extracted original code.

다만, 실시예에 따라서는, APK 파일의 원본코드를 은닉하기 위하여, 암호화 또는 인코딩을 적용하여 APK 파일을 패킹(packing)할 수 있다. 즉, 타인이 임의로 어플리케이션을 분석하는 경우 보안상의 문제 등이 발생할 수 있으므로, 원본코드를 패킹하여 APK 파일을 보호할 수 있다. 그러나, 패킹된 APK 파일의 경우에도, 어플리케이션의 실행시에는 동적으로 복호화 또는 디코딩하는 등 원본코드를 언패킹(unpacking)하게 되므로, 이를 활용하여 언패킹된 원본코드들을 추출하는 것이 가능하다. However, in some embodiments, in order to hide the original code of the APK file, the APK file may be packed by applying encryption or encoding. That is, if someone else randomly analyzes the application, security problems may occur, and the APK file may be protected by packing the original code. However, even in the case of a packed APK file, since the original code is dynamically decoded or decoded when the application is executed, it is possible to extract the unpacked original codes using this.

종래에는 어플리케이션의 원본코드 추출을 위하여, 후킹(hooking) 기술을 이용하였다. 즉, 안드로이드 운영체제의 자이고트(zygote)에 선탑재(preload)되는 라이브러리 함수를 가로채기(hooking)하고, 이를 이용하여 패킹된 원본코드가 디코딩되어 메모리로 로드하는 시점을 파악한 후, 원본코드가 메모리에 로드하는 시점에 메모리를 파일로 덤프하는 방식을 활용하였다. 그러나, 어플리케이션에 후킹 탐지를 대응하기 위한 프로텍터 기능 등을 포함하는 경우에는, 후킹을 이용한 원본코드 추출이 어려워지는 등의 문제점이 존재하였다. Conventionally, in order to extract the original code of an application, a hooking technique was used. In other words, after hooking the library function preloaded on the zygote of the Android operating system, and using this to determine when the original code packed is decoded and loaded into memory, the original code is At the time of loading into a file, a method of dumping the memory to a file was used. However, when the application includes a protector function for responding to hooking detection, there is a problem in that it is difficult to extract the original code using hooking.

또한, 안드로이드 런타임(ART: Android Runtime) 환경의 안드로이드 운영체제의 경우, dex2oat 도구의 동작시점에 매개변수로 전달되는 원본파일의 경로를 가로채기(hooking)하여 확인한 후, 원본파일로부터 원본코드를 추출하는 방식을 활용하였다. 즉, dex2oat 도구는 OAT 파일 생성을 위해 원본코드가 저장된 원본파일을 제공받을 수 있으며, 이 때 후킹 기술을 이용하여 원본파일의 경로를 가로채기할 수 있다. 다만, OAT 파일 생성시 원본파일을 생성하지 않고, 메모리 상에서만 원본코드를 읽고 쓰도록 구현한 경우에는, 후킹을 이용하여 원본파일의 경로를 가로챌 수 없으므로, 원본코드를 추출하기 어려운 문제점이 존재하였다. In addition, in the case of the Android operating system in the Android Runtime (ART) environment, the source code is extracted from the original file after checking the path of the original file passed as a parameter when the dex2oat tool is operated. Method was used. That is, the dex2oat tool can receive the original file in which the original code is stored to generate the OAT file, and at this time, it can intercept the path of the original file by using hooking technology. However, if the original file is not created when the OAT file is created, and the original code is read and written only in memory, there is a problem that it is difficult to extract the original code because the path of the original file cannot be intercepted using hooking. I did.

반면에, 본 발명의 일 실시예에 의한 원본코드 자동추출장치 및 원본코드 자동추출방법에 의하면, 안드로이드 운영체제의 런타임 환경(runtime environment)에 따라, 메모리 상에 원본코드가 로딩되는 시점을 파악할 수 있으며, 메모리 상에 로딩된 원본코드를 메모리로부터 직접 추출하여 사용자에게 제공하는 것이 가능하다. 즉, 어플리케이션에 후킹 탐지를 위한 프로텍터 기능이 적용되거나, 원본코드가 파일로 저장되지 않는 등의 경우에도, 언패킹된 원본코드를 메모리로부터 직접 추출하여 사용자에게 제공하는 것이 가능하다. 이하, 도1을 참조하여 본 발명의 일 실시예에 의한 원본코드 자동추출장치를 설명한다. On the other hand, according to the original code automatic extraction device and the original code automatic extraction method according to an embodiment of the present invention, it is possible to grasp the time when the original code is loaded on the memory according to the runtime environment of the Android operating system. , It is possible to directly extract the original code loaded on the memory from the memory and provide it to the user. That is, even when a protector function for detecting hooking is applied to the application or the original code is not saved as a file, it is possible to directly extract the unpacked original code from the memory and provide it to the user. Hereinafter, an apparatus for automatically extracting an original code according to an embodiment of the present invention will be described with reference to FIG. 1.

도1은 본 발명의 일 실시예에 의한 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출장치를 나타내는 블록도이다. 1 is a block diagram showing an apparatus for automatically extracting original codes based on an Android operating system according to an embodiment of the present invention.

도1에 도시한 바와 같이, 본 발명의 일 실시예에 의한 원본코드 자동추출장치(100)는 언패킹부(110) 및 파일추출부(120)를 포함할 수 있다. As shown in FIG. 1, the original code automatic extraction apparatus 100 according to an embodiment of the present invention may include an unpacking unit 110 and a file extracting unit 120.

언패킹부(110)는 안드로이드 운영체제의 런타임 환경에 따라, 어플리케이션의 패킹된 APK(Android Package) 파일을 언패킹하여 원본코드를 생성할 수 있다. 언패킹부(110)는 어플리케이션의 실행을 위해 APK 파일을 언패킹할 수 있으며, 패킹된 APK 파일에 대응하는 원본코드를 메모리 상에 로딩할 수 있다. 여기서, 언패킹부(110)가 언패킹을 실행하는 시점은 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라 각각 상이하게 설정될 수 있다. 즉, 언패킹부(110)는 안드로이드 운영체제에 적용가능한 각각의 런타임 환경에 따라 다양하게 구현될 수 있다. The unpacking unit 110 may generate the original code by unpacking the packed APK (Android Package) file of the application according to the runtime environment of the Android operating system. The unpacking unit 110 may unpack the APK file to execute the application, and may load the original code corresponding to the packed APK file onto the memory. Here, a time point at which the unpacking unit 110 performs unpacking may be set differently according to a runtime environment of the Android operating system. That is, the unpacking unit 110 may be variously implemented according to respective runtime environments applicable to the Android operating system.

예를들어, 달빅 가상머신(Dalvik Virtual Machine)을 이용하는 런타임 환경의 경우에는, 어플리케이션의 실행시마다 APK 파일을 컴파일할 수 있다. 즉, JIT 컴파일러(Just-In-Time compiler)는 어플리케이션의 실행시마다 APK 파일에 대한 컴파일을 수행하므로, 언패킹부(110)는 JIT 컴파일러의 컴파일을 위하여, 어플리케이션의 실행시마다 APK 파일에 대한 언패킹을 수행할 수 있다.For example, in the case of a runtime environment using a Dalvik Virtual Machine, an APK file can be compiled every time an application is executed. That is, since the JIT compiler (Just-In-Time compiler) compiles the APK file every time the application is executed, the unpacking unit 110 unpacks the APK file every time the application is executed for the JIT compiler compilation. Can be done.

또한, 안드로이드 런타임(ART: Android Runtime, 이하 ART)을 이용하는 런타임 환경의 경우에는, 어플리케이션의 최초 실행시에 컴파일할 수 있다. 즉, ART에서 사용되는 AOT 컴파일러(Ahead-Of-Time Compiler)는 어플리케이션의 최초 실행시 1회 컴파일을 수행하므로, 언패킹부(110)는 AOT 컴파일러의 컴파일을 위하여, 어플리케이션의 최초 실행시 패킹된 APK 파일에 대한 언패킹을 수행할 수 있다. In addition, in the case of a runtime environment that uses Android Runtime (ART), it can be compiled when the application is first executed. That is, since the AOT compiler (Ahead-Of-Time Compiler) used in ART performs compilation once when the application is first executed, the unpacking unit 110 is packed when the application is first executed for compilation of the AOT compiler. Unpacking of APK files can be performed.

이와 같이, 언패킹부(110)는 안드로이드 운영체제의 런타임환경에 따라 다양한 방식으로 언패킹을 수행하도록 설정될 수 있다. As such, the unpacking unit 110 may be configured to perform unpacking in various ways according to the runtime environment of the Android operating system.

파일추출부(120)는 원본코드가 메모리 상에 로딩(loading)되면 메모리 덤프(memory dump)를 수행하여 원본코드를 추출할 수 있으며, 추출한 원본코드를 원본코드파일로 저장하여 사용자에게 제공할 수 있다. 즉, 언패킹부(110)는 언패킹된 원본코드를 메모리 상에 노출시킬 수 있으며, 파일추출부(120)는 이를 감지하여 메모리를 덤프하는 방식으로 원본코드를 추출할 수 있다.When the original code is loaded onto the memory, the file extractor 120 can extract the original code by performing a memory dump, and store the extracted original code as an original code file and provide it to the user. have. That is, the unpacking unit 110 may expose the unpacked original code to the memory, and the file extracting unit 120 may detect this and extract the original code by dumping the memory.

도2는 본 발명의 일 실시예에 의한 원본코드 자동추출장치를 나타내는 블록도이다. 여기서, 본 발명의 일 실시예에 의한 원본코드 자동추출장치(100)는, 런타임 환경으로 달빅 가상머신(Dalvik Virtual Machine)을 이용하는 안드로이드 운영체제(Android Operating System)를 기반으로 하는 것일 수 있다. 2 is a block diagram showing an apparatus for automatically extracting an original code according to an embodiment of the present invention. Here, the original code automatic extraction apparatus 100 according to an embodiment of the present invention may be based on an Android Operating System using a Dalvik Virtual Machine as a runtime environment.

구체적으로, 본 발명의 일 실시예에 의한 원본코드 자동추출장치(100)는 언패킹부(110a) 및 파일추출부(120)를 포함할 수 있다. Specifically, the original code automatic extraction apparatus 100 according to an embodiment of the present invention may include an unpacking unit 110a and a file extracting unit 120.

달빅 가상머신은 자바머신(JVM: Java Virtual Machine)에 대응하는 것으로, 원본코드로 작성된 어플리케이션이 안드로이드 운영체제 내에서 실행될 수 있도록 해석하는 기능을 수행할 수 있다. 즉, 어플리케이션은 자바(java)나 코틀린(kotlin) 등의 소스 코드(source code)로 작성될 수 있으며, 이후 바이트코드로 표시되는 원본코드로 컴파일될 수 있다. 이 경우, 달빅 가상머신은 해당 원본코드를 안드로이드 운영체제가 설치된 각각의 단말들의 CPU 등 하드웨어와 플랫폼 환경에 맞춰서 기계어로 변환하여 제공할 수 있다. 이에 따라, 어플리케이션은 안드로이드 운영체제 내에서 호환성을 가지면서 실행될 수 있다. The Dalvik virtual machine corresponds to a Java Virtual Machine (JVM) and can perform a function of interpreting an application written in the original code to be executed in the Android operating system. That is, the application can be written in source code such as Java or Kotlin, and then compiled into original code displayed as bytecode. In this case, the Dalvik virtual machine can convert the original code into a machine language in accordance with the hardware and platform environment such as CPU of each terminal on which the Android operating system is installed. Accordingly, the application can be executed with compatibility within the Android operating system.

달빅 가상머신을 런타임 환경으로 활용하는 안드로이드 운영체제의 경우, JIT(Just-In-Time) 컴파일러를 포함할 수 있다. JIT 컴파일러는 어플리케이션이 실행될 때마다 APK파일에 대한 컴파일을 수행할 수 있으며, JIT 컴파일러가 컴파일을 수행할 수 있도록 메모리 상에는 APK 파일의 원본코드가 로드(load)될 수 있다. 즉, 달빅 가상머신을 런타임 환경으로 활용하는 안드로이드 운영체제의 경우, 어플리케이션이 실행될 때마다, 메모리 상에 해당 어플리케이션의 원본코드를 로드한 후, 원본코드를 컴파일하여 해당 어플리케이션을 실행하게 된다. In the case of an Android operating system that uses the Dalvik virtual machine as a runtime environment, a JIT (Just-In-Time) compiler may be included. The JIT compiler may compile the APK file every time the application is executed, and the original code of the APK file may be loaded onto the memory so that the JIT compiler may compile. That is, in the case of the Android operating system that uses the Dalvik virtual machine as a runtime environment, each time the application is executed, the original code of the application is loaded into memory, and the original code is compiled to execute the application.

다만, APK 파일은 패킹되어 있을 수 있으므로, 달빅 가상머신을 런타임 환경으로 활용하는 안드로이드 운영체제의 경우, 어플리케이션의 실행시 먼저 APK 파일을 언패킹하여 메모리 상에 로드할 수 있으며, 이후 JIT 컴파일러가 메모리에 접근하여 언패킹된 바이트코드를 컴파일할 수 있다. 따라서, 도2에 도시한 바와 같이, 달빅 가상머신을 활용하는 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출장치는, 어플리케이션의 실행시 메모리에 로드된 언패킹된 바이트코드를 추출하는 방식으로 원본코드를 추출할 수 있다. However, since the APK file may be packed, in the case of the Android operating system that uses the Dalvik virtual machine as a runtime environment, the APK file can be unpacked and loaded into memory first when the application is executed, and then the JIT compiler You can access it and compile the unpacked bytecode. Therefore, as shown in Fig. 2, the original code automatic extraction device based on the Android operating system using the Dalvik virtual machine extracts the original code by extracting the unpacked bytecode loaded into the memory when the application is executed. Can be extracted.

구체적으로, 언패킹부(110a)는 어플리케이션이 실행되면, 어플리케이션에 대응하는 APK 파일(a)을 언패킹하여 원본코드를 생성할 수 있다. JIT 컴파일러(미도시) 는 어플리케이션의 실행시마다 APK 파일(a)에 대한 컴파일을 수행할 수 있으며, 컴파일을 실행하기 위하여, 원본코드를 메모리(m) 상에 로드하도록 요청할 수 있다. 이에 대응하여, 언패킹부(110a)는 어플리케이션의 실행시마다 APK 파일(a)에 대한 언패킹을 수행하여 원본코드를 생성할 수 있다. 여기서, 언패킹부(110a)는 APK 파일(a)에 적용된 보안 솔루션에 따라 APK 파일(a)에 대한 언패킹을 수행할 수 있다. Specifically, when the application is executed, the unpacking unit 110a may unpack the APK file (a) corresponding to the application to generate the original code. The JIT compiler (not shown) may compile the APK file (a) every time the application is executed, and may request to load the original code onto the memory (m) in order to execute the compilation. In response to this, the unpacking unit 110a may generate the original code by performing unpacking of the APK file (a) each time the application is executed. Here, the unpacking unit 110a may unpack the APK file (a) according to the security solution applied to the APK file (a).

APK 파일(a)은 안드로이드의 어플리케이션 배포에 사용되는 패키지 파일로, class.dex 등 dex 파일을 포함하는 압축 파일일 수 있다. 여기서, 언패킹부(110a)는 APK 파일(a)에 포함된 dex 파일을 언패킹하여 dex 바이트코드를 생성할 수 있으며, 생성한 dex 바이트코드가 어플리케이션의 원본코드에 해당하게 된다. The APK file (a) is a package file used for distribution of an Android application, and may be a compressed file including a dex file such as class.dex. Here, the unpacking unit 110a may generate a dex bytecode by unpacking the dex file included in the APK file (a), and the generated dex bytecode corresponds to the original code of the application.

한편, 언패킹부(110a)는 DexClassLoader, BaseDexClassLoader, PathClassLoader 및 OpenDexFile 등의 안드로이드 API(Application Progamming Interface)를 이용하여 APK 파일(a)에 포함된 dex 파일들을 호출할 수 있다. 이후, 호출된 dex 파일들은 언패킹되며, 호출된 dex 파일에 대응하는 언패킹된 dex 바이트코드가 메모리(m) 상에 저장될 수 있다. 즉, 패킹된 APK 파일(a)은 언패킹부(110a)에 의해 언패킹된 후, 안드로이드 API에 의하여 메모리(m)로 로드될 수 있다. Meanwhile, the unpacking unit 110a may call dex files included in the APK file (a) using an Android API (Application Progamming Interface) such as DexClassLoader, BaseDexClassLoader, PathClassLoader, and OpenDexFile. Thereafter, the called dex files are unpacked, and an unpacked dex bytecode corresponding to the called dex file may be stored in the memory m. That is, the packed APK file (a) may be unpacked by the unpacking unit 110a and then loaded into the memory (m) by the Android API.

파일추출부(120)는 원본코드가 메모리(m) 상에 로딩(loading)되면, 메모리 덤프(memory dump)를 수행하여 원본코드를 추출할 수 있다. 이후, 추출한 원본코드를 원본코드파일(b)로 저장하여, 사용자에게 제공할 수 있다. 즉, 달빅 가상머신을 이용하는 안드로이드 운영체제의 경우, 어플리케이션의 실행시 언패킹된 원본코드가 메모리(m) 상에 노출되므로, 파일추출부(120)는 어플리케이션의 실행시에 메모리를 덤프하는 방식으로 원본코드를 추출할 수 있다. When the original code is loaded onto the memory m, the file extraction unit 120 may extract the original code by performing a memory dump. Thereafter, the extracted original code can be stored as an original code file (b) and provided to the user. That is, in the case of the Android operating system using the Dalvik virtual machine, since the unpacked original code is exposed on the memory m when the application is executed, the file extractor 120 dumps the memory when the application is executed. You can extract the code.

이후, 사용자는 파일추출부(120)에서 생성한 원본코드파일(b)을 이용하여, 해당 어플리케이션에 대한 분석을 수행할 수 있다. 또한, 원본코드파일(b)에서 추출한 원본코드를 리패키징(repackaging)하여 원본 APK 파일을 복원하거나, 추출한 원본코드를 커스터마이징(customizing)하여 새로운 APK 파일을 생성할 수 있다. Thereafter, the user may analyze the application by using the original code file (b) generated by the file extraction unit 120. In addition, the original APK file may be restored by repackaging the original code extracted from the original code file (b), or a new APK file may be generated by customizing the extracted original code.

도3는 본 발명의 일 실시예에 의한 원본코드 자동추출장치를 나타내는 블록도이다. 여기서, 본 발명의 일 실시예에 의한 원본코드 자동추출장치(100)는 런타임 환경으로 안드로이드 런타임(ART: Android Runtime)을 이용하는 안드로이드 운영체제(Android Operating System)를 기반으로 하는 것일 수 있다.3 is a block diagram showing an apparatus for automatically extracting an original code according to an embodiment of the present invention. Here, the original code automatic extraction apparatus 100 according to an embodiment of the present invention may be based on an Android Operating System using an Android Runtime (ART) as a runtime environment.

구체적으로, 본 발명의 일 실시예에 의한 원본코드 자동추출장치(100)는 언패킹부(110b) 및 파일추출부(120)를 포함할 수 있다. Specifically, the original code automatic extraction apparatus 100 according to an embodiment of the present invention may include an unpacking unit 110b and a file extracting unit 120.

ART는 달빅 가상머신을 대체하기 위한 것으로, ART를 이용하는 경우, 어플리케이션의 최초 실행시 한번 컴파일할 수 있으며, 이후 어플리케이션의 실행시에는 추가적인 컴파일을 수행하지 않을 수 있다. 즉, 최초 실행시에만 컴파일을 수행하므로, 상대적으로 어플리케이션의 로딩속도가 빠르고, 컴파일 수행에 따른 과도한 전력소모 등을 방지할 수 있다. ART is to replace the Dalvik virtual machine. When using ART, the application may be compiled once when the application is first executed, and additional compilation may not be performed when the application is executed afterwards. That is, since compilation is performed only at the first execution, the loading speed of the application is relatively fast, and excessive power consumption due to the compilation can be prevented.

구체적으로, AOT 컴파일러(미도시)는 어플리케이션의 최초 실행시, 어플리케이션에 대응하는 APK 파일(a)을 컴파일하여 OAT 파일(c)을 생성할 수 있다. 즉, AOT 컴파일러는 어플리케이션의 실행시마다 컴파일을 수행하지 않고, 해당 어플리케이션의 최초 실행시 APK 파일(a)을 컴파일하여 OAT 파일(c)을 생성할 수 있다. 이후, 어플리케이션의 실행시에는 OAT 파일(c)을 참조하여 어플리케이션을 구동하도록 할 수 있다. Specifically, the AOT compiler (not shown) may generate an OAT file (c) by compiling an APK file (a) corresponding to the application when the application is first executed. That is, the AOT compiler may not compile the application every time the application is executed, but may compile the APK file (a) when the application is first executed to generate the OAT file (c). Thereafter, when the application is executed, the application may be driven by referring to the OAT file c.

여기서, 언패킹부(110b)는 먼저 APK 파일(a)을 언패킹하여 원본코드를 생성할 수 있으며, 이후 AOT 컴파일러는 원본코드를 활용하여 OAT 파일(c)을 생성할 수 있다. 즉, 언패킹부(110b)는 AOT 컴파일러가 OAT 파일(c)을 생성할 수 있도록 APK 파일(a)을 언패킹할 수 있으며, Dex2oat 도구를 이용하여 언패킹된 원본코드를 메모리(m) 상에 로딩할 수 있다. 이후 AOT 컴파일러는 Dex2oat 도구를 이용하여 메모리(m) 상에 로딩된 원본코드를 어플리케이션의 실행을 위한 OAT 파일(c)로 변환할 수 있다. 여기서, APK 파일(a)은 안드로이드의 어플리케이션 배포에 사용되는 패키지 파일로, class.dex 등 dex 파일을 포함하는 압축 파일일 수 있다. 언패킹부(110b)는 APK 파일(a)에 포함된 dex 파일을 언패킹하여 dex 바이트코드를 생성할 수 있으며, 이 경우 dex 바이트코드가 해당 어플리케이션의 원본코드에 해당하게 된다.Here, the unpacking unit 110b may first unpack the APK file (a) to generate the original code, and then the AOT compiler may use the original code to generate the OAT file (c). That is, the unpacking unit 110b can unpack the APK file (a) so that the AOT compiler can generate the OAT file (c), and use the Dex2oat tool to store the unpacked original code on the memory (m). Can be loaded into Thereafter, the AOT compiler may convert the original code loaded on the memory m into an OAT file c for execution of the application using the Dex2oat tool. Here, the APK file (a) is a package file used for application distribution of Android, and may be a compressed file including a dex file such as class.dex. The unpacking unit 110b may unpack the dex file included in the APK file (a) to generate a dex bytecode. In this case, the dex bytecode corresponds to the original code of the application.

한편, AOT 컴파일러는 어플리케이션의 최초 실행시에만 컴파일을 실행하므로, 언패킹부(110b)는 먼저 해당 어플리케이션에 대응하는 OAT 파일(c)이 존재하는지 여부를 확인할 수 있다. 즉, OAT 파일(c)이 저장장치 내에 존재하지 않는 경우에는 어플리케이션의 최초 실행시에 해당하므로, APK 파일(a)에 대한 언패킹을 수행할 수 있다. Meanwhile, since the AOT compiler compiles only when the application is initially executed, the unpacking unit 110b may first check whether the OAT file c corresponding to the application exists. That is, if the OAT file c does not exist in the storage device, it corresponds to the first execution of the application, and thus the APK file a may be unpacked.

반면에, 해당 어플리케이션에 대응하는 OAT 파일(c)이 저장장치 내에 이미 존재하는 경우에는 최초 실행시에 해당하지 않는 것으로 판별할 수 있다. 이 경우, 언패킹부(110b)는 언패킹을 실행하지 않고, ART는 기존에 존재하는 OAT 파일(c)을 활용하여 어플리케이션을 실행할 수 있다. 여기서, OAT 파일(c)이 저장되는 저장장치는 안드로이드 파일 시스템(android file system) 등에 의하여 관리될 수 있다. On the other hand, if the OAT file (c) corresponding to the application already exists in the storage device, it may be determined that it does not correspond to the initial execution. In this case, the unpacking unit 110b does not perform unpacking, and the ART may execute the application using the existing OAT file c. Here, the storage device in which the OAT file c is stored may be managed by an Android file system or the like.

파일추출부(120)는, APK 파일(a)을 언패킹한 원본코드가 메모리(m) 상에 로딩되면, 메모리 덤프를 수행하여 원본코드를 추출할 수 있다. 즉, ART를 이용하는 안드로이드 운영체제의 경우, 어플리케이션의 최초 실행시 언패킹된 원본코드가 메모리(m) 상에 노출되므로, 파일추출부(120)는 어플리케이션의 최초 실행시에 메모리를 덤프하는 방식으로 원본코드를 추출할 수 있다. 이후, 파일추출부(120)는 추출한 원본코드를 원본코드파일(b)로 저장하여 사용자에게 제공할 수 있다. 실시예에 따라서는, 언패킹부(110b)가 원본코드를 언패킹하여 메모리(m) 상에 로딩하는 시점에 메모리 덤프를 수행하도록 할 수 있다. When the original code obtained by unpacking the APK file (a) is loaded on the memory (m), the file extracting unit 120 may perform a memory dump to extract the original code. That is, in the case of the Android operating system using ART, since the unpacked original code is exposed on the memory m when the application is first executed, the file extractor 120 dumps the memory when the application is first executed. You can extract the code. Thereafter, the file extracting unit 120 may store the extracted original code as an original code file (b) and provide it to the user. Depending on the embodiment, the unpacking unit 110b may perform a memory dump at the time when the original code is unpacked and loaded onto the memory m.

이후, 사용자는 파일추출부(120)에서 생성한 원본코드파일(b)을 이용하여 해당 어플리케이션에 대한 분석을 수행할 수 있다. 또한, 원본코드파일(b)에서 추출한 원본코드를 리패키징(repackaging)하여 원본 APK 파일을 복원하거나, 추출한 원본코드를 커스터마이징(customizing)하여 새로운 APK 파일을 생성하는 것도 가능하다. Thereafter, the user may analyze the application by using the original code file (b) generated by the file extraction unit 120. In addition, it is possible to restore the original APK file by repackaging the original code extracted from the original code file (b), or to create a new APK file by customizing the extracted original code.

한편, 본 발명의 일 실시예에 의한 원본코드 자동추출장치(100)는 가상화(virtualization)하여 구현하는 것도 가능하다. 즉, 원본코드 자동추출장치(100)를 안드로이드 에뮬레이터 등과 같은 형태로 구현한 후, 분석하고자 하는 어플리케이션을 입력할 수 있다. 이 경우, 원본코드 자동추출장치(100)는 내부에서 해당 어플리케이션을 실행 또는 설치하는 동작을 수행한 후, 해당 어플리케이션에 대응하는 원본코드파일을 생성할 수 있다. 나아가, 클라우드 서버 상에 원본코드 자동추출장치(100)를 가상화하여 구현함으로써, ASP(Application Service Provider) 서비스의 형태로 제공하는 것도 가능하다. On the other hand, the original code automatic extraction device 100 according to an embodiment of the present invention may be implemented by virtualization (virtualization). That is, after the original code automatic extraction device 100 is implemented in a form such as an Android emulator, an application to be analyzed may be input. In this case, the original code automatic extraction apparatus 100 may generate an original code file corresponding to the application after executing or installing the corresponding application therein. Furthermore, by implementing the original code automatic extraction device 100 on a cloud server by virtualization, it is also possible to provide it in the form of an ASP (Application Service Provider) service.

도4는 본 발명의 일 실시예에 의한 안드로이드 운영체제(android operating system)를 기반으로 하는 원본코드 자동추출방법을 나타내는 순서도이다. 4 is a flow chart showing a method of automatically extracting original codes based on an Android operating system according to an embodiment of the present invention.

도4에 도시한 바와 같이, 본 발명의 일 실시예에 의한 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출방법은, 언패킹 단계(S10) 및 파일추출단계(S20)를 포함할 수 있다. As shown in FIG. 4, the method for automatically extracting the original code based on the Android operating system according to an embodiment of the present invention may include an unpacking step (S10) and a file extraction step (S20).

이하 도4를 참조하여, 본 발명의 일 실시예에 안드로이드 운영체제를 기반으로 하는 원본코드 자동추출방법을 설명한다. Hereinafter, a method of automatically extracting an original code based on an Android operating system according to an embodiment of the present invention will be described with reference to FIG. 4.

언패킹 단계(S10)에서는, 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라, 어플리케이션(application)의 패킹(packing)된 APK(Android Package) 파일을 언패킹하여 원본코드를 추출할 수 있다. 이후, 언패킹(unpacking)된 원본코드는 메모리 상에 로딩될 수 있다. 여기서, 언패킹 단계(S10)에서 언패킹을 실행하는 시점은, 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라 각각 상이하게 설정될 수 있다. In the unpacking step S10, the original code may be extracted by unpacking an APK (Android Package) file packed in an application according to a runtime environment of the Android operating system. Thereafter, the unpacked original code may be loaded onto the memory. Here, the time point at which the unpacking is executed in the unpacking step S10 may be set differently according to the runtime environment of the Android operating system.

예를들어, 달빅 가상머신(Dalvik Virtual Machine)을 이용하는 런타임 환경의 경우에는, 어플리케이션의 실행시마다 패킹된 APK 파일을 컴파일할 수 있으며, 언패킹단계(S10)에서는 JIT(Just-In-Time) 컴파일러의 컴파일을 위하여 APK 파일을 언패킹하여 제공할 수 있다. 또한, 안드로이드 런타임(ART: Android Runtime, 이하 ART)을 이용하는 런타임 환경의 경우에는, 어플리케이션의 최초 실행시 컴파일될 수 있으며, 이때 언패킹 단계(S20)에서는 AOT 컴파일러(Ahead-Of-Time Compiler)의 컴파일을 위하여 미리 APK 파일을 언패킹하여 제공할 수 있다. 이와 같이, 언패킹 단계(S10)에서는 안드로이드 운영체제의 런타임환경에 따라 다양한 종류의 컴파일러에 대응하는 시점에 언패킹을 수행할 수 있다. For example, in the case of a runtime environment using a Dalvik Virtual Machine, a packed APK file can be compiled every time the application is executed, and in the unpacking step (S10), a JIT (Just-In-Time) compiler APK files can be unpacked and provided for compiling of. In addition, in the case of a runtime environment that uses Android Runtime (ART), the application may be compiled when the application is first executed. In this case, in the unpacking step (S20), the AOT compiler (Ahead-Of-Time Compiler) For compilation, the APK file can be unpacked and provided in advance. In this way, in the unpacking step S10, unpacking may be performed at a time point corresponding to various types of compilers according to the runtime environment of the Android operating system.

파일추출단계(S120)에서는, 원본코드가 메모리 상에 로딩되면, 메모리 덤프하여 원본코드를 원본코드파일로 저장할 수 있다. 즉, 언패킹 단계(S10)에서 언패킹된 원본코드은 메모리 상에 노출될 수 있으며, 이때 파일추출단계(S20)를 수행하여, 메모리 덤프함으로써, 원본코드를 추출할 수 있다. 이때, 메모리 덤프된 원본코드는 원본코드파일로 저장할 수 있으며, 원본코드파일을 사용자에게 제공할 수 있다. In the file extraction step (S120), when the original code is loaded onto the memory, it is possible to dump the memory and store the original code as an original code file. That is, the original code unpacked in the unpacking step S10 may be exposed on the memory. At this time, the original code may be extracted by performing the file extraction step S20 and dumping the memory. At this time, the memory dumped original code can be saved as an original code file, and the original code file can be provided to the user.

도5는 본 발명의 일 실시예에 의한 원본코드 자동추출방법을 나타내는 순서도이다. 5 is a flow chart showing a method for automatically extracting an original code according to an embodiment of the present invention.

여기서, 본 발명의 일 실시예에 의한 원본코드 자동추출방법은 달빅 가상머신(Dalvik Virtual Machine)을 이용하는 안드로이드 운영체제(Android Operating System)를 기반으로 하는 것일 수 있다. 구체적으로, 언패킹 단계(S110) 및 파일추출단계(S120)를 포함할 수 있다. Here, the method for automatically extracting the original code according to an embodiment of the present invention may be based on an Android Operating System using a Dalvik Virtual Machine. Specifically, it may include an unpacking step (S110) and a file extraction step (S120).

이하 도5를 참조하여, 본 발명의 일 실시예에 원본코드 자동추출방법을 설명한다. Hereinafter, a method of automatically extracting an original code according to an embodiment of the present invention will be described with reference to FIG. 5.

언패킹 단계(S110)에서는, 어플리케이션의 실행시마다, 어플리케이션에 대응하는 APK 파일을 언패킹하여, 언패킹된 원본코드를 생성할 수 있으며, 이후, 생성한 원본코드는 메모리 상에 로딩할 수 있다. JIT 컴파일러는 어플리케이션의 실행시마다 APK 파일에 대한 컴파일을 수행할 수 있으며, 언패킹 단계(S110)에서는 JIT 컴파일러가 컴파일을 수행할 수 있도록, APK 파일을 언패킹하여 언패킹된 원본코드를 제공할 수 있다. 여기서, APK 파일은 안드로이드의 어플리케이션 배포에 사용되는 패키지 파일로, class.dex 등 dex 파일을 포함하는 압축 파일일 수 있다. 실시예에 따라서는, APK 파일에 포함된 dex 파일을 언패킹하여 dex 바이트코드를 생성할 수 있으며, 이 경우 dex 바이트코드가 어플리케이션의 원본코드에 해당하게 된다.In the unpacking step S110, each time the application is executed, the APK file corresponding to the application is unpacked to generate the unpacked original code, and then the generated original code may be loaded onto a memory. The JIT compiler can compile the APK file every time the application is executed, and in the unpacking step (S110), the APK file can be unpacked to provide the unpacked original code so that the JIT compiler can compile. have. Here, the APK file is a package file used for application distribution of Android, and may be a compressed file including a dex file such as class.dex. Depending on the embodiment, the dex bytecode may be generated by unpacking the dex file included in the APK file, and in this case, the dex bytecode corresponds to the original code of the application.

한편, 언패킹 단계(S110)에서는 DexClassLoader, BaseDexClassLoader, PathClassLoader 및 OpenDexFile 등의 안드로이드 API(Application Progamming Interface)를 이용하여 APK 파일에 포함된 dex 파일들을 호출할 수 있다. 여기서, 호출된 dex 파일들은 언패킹될 수 있으며, 호출된 dex 파일에 대응하는 언패킹된 dex 바이트코드들이 메모리 상에 로드될 수 있다. Meanwhile, in the unpacking step S110, dex files included in the APK file may be called using Android API (Application Progamming Interface) such as DexClassLoader, BaseDexClassLoader, PathClassLoader, and OpenDexFile. Here, the called dex files may be unpacked, and unpacked dex bytecodes corresponding to the called dex files may be loaded onto the memory.

파일추출단계(S120)에서는, 메모리 덤프(memory dump)를 수행하여 원본코드를 추출할 수 있으며, 추출한 원본코드를 원본코드파일로 저장할 수 있다. 여기서, 원본코드 파일 저장단계(S120)는 메모리가 원본코드가 로딩되면 메모리 덤프를 수행할 수 있다. 즉, 달빅 가상머신을 이용하는 안드로이드 운영체제의 경우, 어플리케이션의 실행시 언패킹된 원본코드가 메모리 상에 노출되므로, 어플리케이션의 실행시에 메모리를 덤프하는 방식으로 원본코드를 추출할 수 있다. In the file extraction step S120, the original code may be extracted by performing a memory dump, and the extracted original code may be stored as an original code file. Here, in the step S120 of storing the original code file, when the original code is loaded into the memory, a memory dump may be performed. That is, in the case of the Android operating system using the Dalvik virtual machine, since the unpacked original code is exposed on the memory when the application is executed, the original code can be extracted by dumping the memory when the application is executed.

도6은 본 발명의 일 실시예에 의한 원본코드 자동추출방법을 나타내는 순서도이다. 6 is a flow chart showing a method for automatically extracting an original code according to an embodiment of the present invention.

도6을 참조하면, 본 발명의 일 실시예에 의한 원본코드 자동추출방법은 안드로이드 런타임(ART: Android Runtime, 이하 ART라 한다)을 이용하는 안드로이드 운영체제(Android Operating System)를 기반으로 하는 것일 수 있다. 구체적으로, 언패킹단계(S210) 및 파일추출단계(S220)를 포함할 수 있다. Referring to FIG. 6, the method for automatically extracting the original code according to an embodiment of the present invention may be based on an Android Operating System using Android Runtime (ART). Specifically, it may include an unpacking step (S210) and a file extraction step (S220).

이하 도6을 참조하여, 본 발명의 일 실시예에 의한 원본코드 자동추출방법을 설명한다. Hereinafter, a method of automatically extracting an original code according to an embodiment of the present invention will be described with reference to FIG. 6.

언패킹단계(S210)에서는, 어플리케이션의 최초 실행시, AOT 컴파일러가 컴파일하여 OAT 파일을 생성할 수 있도록, 해당 어플리케이션의 APK 파일을 언패킹할 수 있다. 즉, AOT 컴파일러는 어플리케이션의 실행시마다 컴파일을 수행하지 않고, 해당 어플리케이션의 최초 실행시 APK 파일을 컴파일하여 OAT 파일을 생성할 수 있다. 여기서, 언패킹단계(S210)에서는 AOT 컴파일러가 컴파일을 실행하기 전에, 먼저 APK 파일을 언패킹하여 원본코드를 생성할 수 있으며, 이후 AOT 컴파일러는 원본코드를 활용하여 OAT 파일을 생성할 수 있다. 이때, AOT 컴파일러는 OAT 파일 생성시 Dex2oat 도구(tool)를 이용할 수 있다. In the unpacking step S210, when the application is first executed, the APK file of the application may be unpacked so that the AOT compiler can compile and generate the OAT file. That is, the AOT compiler may not compile an application every time an application is executed, but may generate an OAT file by compiling an APK file when the application is first executed. Here, in the unpacking step (S210), before the AOT compiler executes compilation, the APK file may be unpacked to generate the original code, and then the AOT compiler may use the original code to generate the OAT file. In this case, the AOT compiler may use the Dex2oat tool when generating the OAT file.

즉, 언패킹단계(S210)에서 APK 파일을 언패킹하여 원본코드를 메모리 상에 로딩할 수 있으며, 이후 AOT 컴파일러는 Dex2oat 도구를 이용하여 메모리상에 로딩된 원본코드를 어플리케이션의 실행을 위한 OAT 파일로 변환할 수 있다. 여기서, APK 파일은 안드로이드의 어플리케이션 배포에 사용되는 패키지 파일로, class.dex 등 dex 파일을 포함하는 압축 파일일 수 있다. 언패킹 단계(S210)에서는 APK 파일에 포함된 dex 파일을 언패킹하여 dex 바이트코드를 생성할 수 있으며, 이 경우 dex 바이트코드가 해당 어플리케이션의 원본코드에 해당하게 된다.That is, in the unpacking step (S210), the APK file can be unpacked and the original code can be loaded onto the memory. After that, the AOT compiler uses the Dex2oat tool to load the original code into the OAT file for execution of the application. Can be converted to Here, the APK file is a package file used for application distribution of Android, and may be a compressed file including a dex file such as class.dex. In the unpacking step (S210), the dex file included in the APK file may be unpacked to generate a dex bytecode. In this case, the dex bytecode corresponds to the original code of the application.

한편, AOT 컴파일러는 어플리케이션의 최초 실행시에만 컴파일을 실행하므로, 언패킹단계(S210)에서는, 먼저 해당 어플리케이션에 대응하는 OAT 파일이 존재하는지 여부를 확인할 수 있다. 즉, OAT 파일이 존재하지 않는 경우에는 어플리케이션의 최초 실행시에 해당하므로, APK 파일에 대한 언패킹을 수행할 수 있다. 반면에, 해당 어플리케이션에 대응하는 OAT 파일이 이미 존재하는 경우에는 최초 실행에 해당하지 않는 것으로 판별할 수 있다. 이 경우, 언패킹단계(S210)에서는 언패킹을 실행하지 않고, 기존에 존재하는 OAT 파일을 활용하여 어플리케이션을 실행하도록 할 수 있다. Meanwhile, since the AOT compiler compiles only when the application is first executed, in the unpacking step S210, it is first possible to check whether an OAT file corresponding to the application exists. That is, if the OAT file does not exist, it corresponds to the first execution of the application, and thus the APK file can be unpacked. On the other hand, if the OAT file corresponding to the application already exists, it can be determined that it does not correspond to the first execution. In this case, in the unpacking step (S210), the application may be executed by using an existing OAT file without executing the unpacking.

파일추출단계(S220)에서는, APK 파일을 언패킹한 원본코드가 메모리 상에 로딩되면, 메모리 덤프하여 원본코드를 추출할 수 있다. 이후, 추출한 원본코드를 원본코드파일로 저장하여 사용자에게 제공할 수 있다. In the file extraction step S220, when the original code obtained by unpacking the APK file is loaded onto the memory, the original code may be extracted by performing a memory dump. Thereafter, the extracted original code can be stored as an original code file and provided to the user.

즉, ART를 이용하는 안드로이드 운영체제의 경우, 어플리케이션의 최초 실행시 언패킹된 원본코드가 메모리 상에 노출될 수 있다. 따라서, 파일추출단계(S220)에서는, 어플리케이션의 최초 실행시에 메모리를 덤프하여 원본코드를 추출할 수 있다. 실시예에 따라서는, 언패킹단계(S210)에서 원본코드를 언패킹하여 메모리 상에 로딩하는 시점에 메모리 덤프를 수행하도록 할 수 있다. That is, in the case of the Android operating system using ART, the unpacked original code may be exposed on the memory when the application is first executed. Accordingly, in the file extraction step S220, the original code may be extracted by dumping the memory when the application is first executed. Depending on the embodiment, a memory dump may be performed at a time when the original code is unpacked and loaded onto a memory in the unpacking step S210.

전술한 본 발명은, 프로그램이 기록된 매체에 컴퓨터가 읽을 수 있는 코드로서 구현하는 것이 가능하다. 컴퓨터가 읽을 수 있는 매체는, 컴퓨터로 실행 가능한 프로그램을 계속 저장하거나, 실행 또는 다운로드를 위해 임시 저장하는 것일 수도 있다. 또한, 매체는 단일 또는 수개 하드웨어가 결합된 형태의 다양한 기록수단 또는 저장수단일 수 있는데, 어떤 컴퓨터 시스템에 직접 접속되는 매체에 한정되지 않고, 네트워크 상에 분산 존재하는 것일 수도 있다. 매체의 예시로는, 하드 디스크, 플로피 디스크 및 자기 테이프와 같은 자기 매체, CD-ROM 및 DVD와 같은 광기록 매체, 플롭티컬 디스크(floptical disk)와 같은 자기-광 매체(magneto-optical medium), 및 ROM, RAM, 플래시 메모리 등을 포함하여 프로그램 명령어가 저장되도록 구성된 것이 있을 수 있다. 또한, 다른 매체의 예시로, 애플리케이션을 유통하는 앱 스토어나 기타 다양한 소프트웨어를 공급 내지 유통하는 사이트, 서버 등에서 관리하는 기록매체 내지 저장매체도 들 수 있다. 따라서, 상기의 상세한 설명은 모든 면에서 제한적으로 해석되어서는 아니되고 예시적인 것으로 고려되어야 한다. 본 발명의 범위는 첨부된 청구항의 합리적 해석에 의해 결정되어야 하고, 본 발명의 등가적 범위 내에서의 모든 변경은 본 발명의 범위에 포함된다.The present invention described above can be implemented as a computer-readable code in a medium on which a program is recorded. The computer-readable medium may be one that continuously stores a program executable by a computer, or temporarily stores a program for execution or download. In addition, the medium may be a variety of recording means or storage means in a form in which a single piece of hardware or several pieces of hardware are combined. The medium is not limited to a medium directly connected to a computer system, but may be distributed on a network. Examples of media include magnetic media such as hard disks, floppy disks, and magnetic tapes, optical recording media such as CD-ROMs and DVDs, magnetic-optical media such as floptical disks, and And a ROM, RAM, flash memory, and the like, and may be configured to store program instructions. In addition, examples of other media include an app store that distributes applications, a site that supplies or distributes various software, and a recording medium or storage medium managed by a server. Therefore, the detailed description above should not be construed as restrictive in all respects and should be considered as illustrative. The scope of the present invention should be determined by reasonable interpretation of the appended claims, and all changes within the equivalent scope of the present invention are included in the scope of the present invention.

본 발명은 전술한 실시예 및 첨부된 도면에 의해 한정되는 것이 아니다. 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 있어, 본 발명의 기술적 사상을 벗어나지 않는 범위 내에서 본 발명에 따른 구성요소를 치환, 변형 및 변경할 수 있다는 것이 명백할 것이다.The present invention is not limited by the above-described embodiments and the accompanying drawings. It will be apparent to those of ordinary skill in the art to which the present invention pertains, that components according to the present invention can be substituted, modified, and changed within the scope of the technical spirit of the present invention.

100: 원본코드 자동추출장치 110, 110a, 110b: 언패킹부
120: 파일 추출부 S10, S110, S210: 언패킹 단계
S20, S120, S220: 파일추출단계
100: original code automatic extraction device 110, 110a, 110b: unpacking unit
120: file extraction unit S10, S110, S210: unpacking step
S20, S120, S220: file extraction step

Claims (7)

안드로이드 운영체제(android operating system)를 기반으로 하는 원본코드 자동추출장치에 있어서,
상기 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라, 어플리케이션(application)의 패킹(packing)된 APK(Android Package) 파일을 언패킹하여 원본코드를 생성하고, 상기 원본코드를 메모리 상에 로딩하는 언패킹부; 및
상기 원본코드가 상기 메모리 상에 로딩되면, 메모리 덤프하여 상기 원본코드를 원본코드파일로 저장하는 파일추출부를 포함하는 것으로,
상기 원본코드는
상기 언패킹부가 상기 APK 파일에 포함된 dex 파일을 언패킹하여 생성한 dex 바이트코드(bytecode)인 것을 특징으로 하는 원본코드 자동추출장치.
In the original code automatic extraction device based on the Android operating system,
Unpacking to generate an original code by unpacking an APK (Android Package) file packed in an application according to the runtime environment of the Android operating system, and loading the original code onto memory part; And
When the original code is loaded on the memory, it includes a file extracting unit for storing the original code as an original code file by dumping the memory,
The original code above is
The original code automatic extraction device, characterized in that the unpacking unit is a dex bytecode generated by unpacking a dex file included in the APK file.
제1항에 있어서, 상기 언패킹부는
상기 런타임 환경이 달빅 가상머신을 이용하는 것이면, 상기 어플리케이션의 실행시점에 상기 패킹된 APK 파일을 언패킹하고,
상기 런타임 환경이 ART(Android Runtime)를 이용하는 것이면, 상기 어플리케이션의 최초 실행시점에 상기 패킹된 APK 파일을 언패킹하는 것을 특징으로 하는 원본코드 자동추출장치.
The method of claim 1, wherein the unpacking unit
If the runtime environment uses the Dalvik virtual machine, the packed APK file is unpacked at the execution time of the application,
If the runtime environment uses ART (Android Runtime), the original code automatic extraction device, characterized in that unpacking the packed APK file at the first execution time of the application.
삭제delete 제2항에 있어서, 상기 언패킹부는
상기 런타임 환경이 달빅 가상머신을 이용하는 것이면, DexClassLoader, BaseDexClassLoader, PathClassLoader 및 OpenDexFile 중 적어도 어느 하나의 안드로이드 API(Application Programming Interface)를 이용하여 상기 원본코드를 상기 메모리 상에 로딩하는 것을 특징으로 하는 원본코드 자동추출장치.
The method of claim 2, wherein the unpacking unit
If the runtime environment uses a Dalvik virtual machine, the original code is automatically loaded onto the memory using at least one of DexClassLoader, BaseDexClassLoader, PathClassLoader, and OpenDexFile. Extraction device.
제2항에 있어서, 상기 언패킹부는
상기 런타임 환경이 ART(Android Runtime)를 이용하는 것이면, 저장장치내 상기 어플리케이션에 대응하는 OAT 파일의 존재여부를 확인하고, 상기 OAT 파일이 존재하지 않으면, 상기 어플리케이션의 최초 실행으로 판별하는 것을 특징으로 하는 원본코드 자동추출장치.
The method of claim 2, wherein the unpacking unit
If the runtime environment uses ART (Android Runtime), it is characterized in that it checks whether there is an OAT file corresponding to the application in the storage device, and if the OAT file does not exist, it is determined as the first execution of the application. Original code automatic extraction device.
제5항에 있어서, 상기 언패킹부는
Dex2oat 도구를 실행하여, 상기 원본코드를 상기 메모리 상에 로드하는 것을 특징으로 하는 원본코드 자동추출장치.
The method of claim 5, wherein the unpacking unit
The original code automatic extraction device, characterized in that by executing the Dex2oat tool and loading the original code onto the memory.
안드로이드 운영체제(android operating system)를 기반으로 하는 원본코드 자동추출방법에 있어서,
상기 안드로이드 운영체제의 런타임 환경(Runtime environment)에 따라, 어플리케이션(application)의 패킹(packing)된 APK(Android Package) 파일을 언패킹하여 원본코드를 생성하고, 상기 원본코드를 메모리 상에 로딩하는 단계; 및
상기 원본코드가 상기 메모리 상에 로딩되면, 메모리 덤프하여 상기 원본코드를 원본코드파일로 저장하는 단계를 포함하는 것으로,
상기 원본코드는
상기 APK 파일에 포함된 dex 파일을 언패킹하여 생성한 dex 바이트코드(bytecode)인 것을 특징으로 하는 원본코드 자동추출방법.
In the method of automatically extracting the original code based on the Android operating system,
Generating an original code by unpacking an APK (Android Package) file packed in an application according to a runtime environment of the Android operating system, and loading the original code onto a memory; And
When the original code is loaded on the memory, including the step of memory dumping and storing the original code as an original code file,
The original code above is
The original code automatic extraction method, characterized in that a dex bytecode generated by unpacking a dex file included in the APK file.
KR1020180130055A 2018-10-29 2018-10-29 Apparatus and method for automatic extraction of original source code KR102173151B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020180130055A KR102173151B1 (en) 2018-10-29 2018-10-29 Apparatus and method for automatic extraction of original source code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020180130055A KR102173151B1 (en) 2018-10-29 2018-10-29 Apparatus and method for automatic extraction of original source code

Publications (2)

Publication Number Publication Date
KR20200048221A KR20200048221A (en) 2020-05-08
KR102173151B1 true KR102173151B1 (en) 2020-11-03

Family

ID=70677510

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020180130055A KR102173151B1 (en) 2018-10-29 2018-10-29 Apparatus and method for automatic extraction of original source code

Country Status (1)

Country Link
KR (1) KR102173151B1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102530083B1 (en) * 2020-07-10 2023-05-09 주식회사 엔피코어 Virtualization apparatus, system for detecting malicious based on cloud and management method thereof
JP2023550974A (en) * 2020-11-26 2023-12-06 エヌピーコア インコーポレイテッド Image-based malicious code detection method and device and artificial intelligence-based endpoint threat detection and response system using the same

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101518420B1 (en) * 2014-11-11 2015-05-07 주식회사 에스이웍스 Apparatus and method for managing apk file in a android platform

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101740134B1 (en) * 2015-08-10 2017-05-26 라인 가부시키가이샤 System and method for application code obfuscation

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101518420B1 (en) * 2014-11-11 2015-05-07 주식회사 에스이웍스 Apparatus and method for managing apk file in a android platform

Also Published As

Publication number Publication date
KR20200048221A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
Costamagna et al. Artdroid: A virtual-method hooking framework on android art runtime.
Zeng et al. Obfuscation resilient binary code reuse through trace-oriented programming
US9811663B2 (en) Generic unpacking of applications for malware detection
US10372444B2 (en) Android dynamic loading file extraction method, recording medium and system for performing the method
US9223964B2 (en) Detecting JAVA sandbox escaping attacks based on JAVA bytecode instrumentation and JAVA method hooking
US20050108562A1 (en) Technique for detecting executable malicious code using a combination of static and dynamic analyses
US20090271867A1 (en) Virtual machine to detect malicious code
US20170024230A1 (en) Method, apparatus, and computer-readable medium for ofuscating execution of an application on a virtual machine
JP2019502197A (en) System and method for detection of malicious code in runtime generated code
KR20150024842A (en) Adaptive portable libraries
CN109255235B (en) Mobile application third-party library isolation method based on user state sandbox
Xue et al. Packergrind: An adaptive unpacking system for android apps
KR102173151B1 (en) Apparatus and method for automatic extraction of original source code
US20190205528A1 (en) Automated software application verification system
Kreindl et al. Towards efficient, multi-language dynamic taint analysis
CN104537281A (en) Systems and methods for mobile application protection
Suk et al. UnThemida: Commercial obfuscation technique analysis with a fully obfuscated program
El-Harake et al. Blocking advertisements on android devices using monitoring techniques
Tanner et al. Protecting android APPS from repackaging using native code
CN107209815B (en) Method for code obfuscation using return-oriented programming
KR101724412B1 (en) Apparatus for analysis application using expansion code and method usnig the same
Wan et al. Defending application cache integrity of android runtime
KR101562282B1 (en) System and Method for Verifying Integrity of an ODEX
KR102271273B1 (en) Process wrapping method for evading anti-analysis of native codes, recording medium and device for performing the method
KR20130077673A (en) A extended method for eliminating null pointer check using method specialization

Legal Events

Date Code Title Description
E701 Decision to grant or registration of patent right
GRNT Written decision to grant