'낙서장' 카테고리의 다른 글

gitignore 기본 세팅  (0) 2022.04.22
openssl 로컬 키 만들기  (0) 2021.08.17
인텔리제이 output 한글깨짐  (0) 2021.01.12
스프링부트 jar 배포하면 404에러  (0) 2021.01.12
인텔리제이 자동 빌드  (0) 2021.01.01

 

타입 스크립트 버전으로 설치

 

next js (ts 버전) 설치

npx create-next-app 앱이름 --ts
# or
yarn create next-app 앱이름 --typescript

 

작동

해당 앱폴더로 이동하여

npm dev

#or

yarn dev

 

상대경로 -> 절대경로로 바꾸기

 

 

tsconfig.json 파일에 아래를 추가

{
  [기타내용],
  "compilerOptions": {
  	[기타내용],
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./*"
      ]
    }
  },
  [기타내용],
 }

 

mobx 설치

yarn add mobx
또는
npm install --save mobx

 

 

설치 후 작동이 안될 경우

.next / node_modules / package-lock.json 을 지우고 

yarn install
또는
npm install

한 뒤 실행해본다

 

참고 사이트

velog.io/@soncl_97/Next.js-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0

 

📋Next.js 시작하기

next 시작하기

velog.io

 

noogoonaa.tistory.com/65

 

next.js 와 typescript를 끼얹어 보자

최근 프론트엔드 생태계는 React, Vue, Angular 이 삼대장이 주류를 이루고 최근 Typescript 또한 각광 받고 있습니다. 저 또한 프론트엔드쪽 일을 자주하는 개발자로써 자연스럽게 이 삼대장 중 React를

noogoonaa.tistory.com

 

sumini.dev/guide/003-react-typescript-absolute-import/

 

React+Typescript 절대경로 import 설정하기

상대 경로를 사용하면 package 구조가 깊어질 수록 파일 간의 관계를 파악하기 어려워지고, 파일 이동시 귀찮게 경로를 수정해야 합니다. 예시 절대 경로를 사용하면 depth와 상관 없이 일관되고 짧

sumini.dev

 

chanyeong.com/blog/post/35

 

타입스크립트에서 절대경로(alias) 사용하기! - chanyeong

개요 요즘 부스트캠프에서 프로젝트를 진행하고 있는데 서버를 타입스크립트로 구현하고 있다. 그런데 설계 과정에서 폴더 및 파일이 나눠지고 import, export하는 과정에서 상대경로를 사용하다

chanyeong.com

 

velog.io/@sji7532/Next-Next-js%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC-SSR-CSR-%EA%B5%AC%ED%98%84

 

[Next] Next js를 사용하여 SSR, CSR 구현

Next.js를 사용하면 React에서도 CSR, SSR을 혼합하여 빠른 성능을 구현할 수 있다.

velog.io

 

mobx.js.org/installation.html

 

Installation · MobX

mobx.js.org

 

'Web > ReactJS' 카테고리의 다른 글

intellij 인텔리제이 eslint typescript prettier  (0) 2021.02.19
react js / next js quill 적용  (0) 2021.02.17
react // 리덕스 실습  (0) 2020.08.14
리액트 // redux 리덕스  (0) 2020.08.12
리액트 // useEffect 연습  (0) 2020.08.05

메서드를 선택하고

ctrl shift T 를 누르면 테스트 패키지에 자동으로 생성됨.

 

 

 

연구 목적 : 내부 값 난독화 목적

결과 : 값 난독화에는 의미가 적음 // 자체제작 라이브러리 난독화에는 의미가 있음(C++)

- 값은 되도록 서버에 저장

- proguard를 이용

 

여러 사이트를 참고하여 ndk를 이용한 키 난독화 작업을 테스트 해보았음.

다만 구글링으로 구성하려고 하면 쉽지 않다.

오히려 안드로이드스튜디오의 템플레이트로 연습해보는 것이 좋다.

 

Native C++ 프로젝트를 열어보면

아래와 같이 cpp 폴더와 함께 CMake 관련 파일들이 생성된다.

 

native-lib.cpp 파일을 보면

Hello from C++을 리턴하게 되어있다.

 

MainActivity를 열어보면 스태틱으로 네이티브 라이브러리와 함수를 로드하게 되어있고

빌드후 실행해보면 Hello from C++가 나오는 간단한 프로젝트이다.

 

 

난독화로서 의미가 적은 이유

apk파일로 만들고 툴을 이용하여 디컴파일 해보면

아래와 같은 파일들이 만들어진다. (jniLibs)

 

위의 예제와 같은 이름의 프로젝트를 만들고 

Project구조로 변경한뒤 

main 폴더 안에 jniLibs라는 폴더를 만들고 그안에 위 파일들을 넣어준다.

그러고난 뒤 메인액티비티의 xml과 클래스파일을 예제 프로젝트와 똑같이 만든 후

빌드 실행 해보면 함수가 호출되어 같은 값이 출력된다.

(큰 의미 없다는 것)

 

jniLibs에 들어간 것은 so 파일인데

c파일은 so파일로 만들어져도 아래 사이트에 업로드해보면 대충 값을 확인할 수 있다.

onlinedisassembler.com/odaweb/

 

ODA - The Online Disassembler

You need to upgrade your browser or enable javascript to view this site!

onlinedisassembler.com

 

cpp파일은 so파일로 만들어지면 위 사이트로 열어봐도 보기 어렵다.

즉 내부코드를 확인하기는 쉽지 않다는 뜻이다. (코드 보안에는 좋을듯 함)

하지만 apk를 디컴파일하여 해당라이브러리를 사용하는 코드를 확인하여 작동해보면 값은 가져올 수 있다.

 

추가로 proguard 로 앱자체를 난독화하여 찾기 어렵게 만들어도 디컴파일 툴을 이용하면

아래와 같이 큰 힘을 들이지 않아도 찾아 낼 수 있다.

 

아이디어라면 라이브러리 이름과 매서드를 한글자(a 등)로 하여 분석하기 매우 힘들게는 가능 할 것 같다.

 

 

사용한 툴

안드로이드 스튜디오
sublimetext
apktool
dex2jar
jd-gui

 

ndk cmark 사용법 관련 주소

(다시 말씀드리지만 ndk cmark 연습은 샘플프로젝트를 이용하는 것이 가장 빠름)

developer.android.com/studio/projects/install-ndk?hl=ko

 

NDK 및 CMake 설치 및 구성  |  Android 개발자  |  Android Developers

앱의 네이티브 코드를 컴파일하고 디버그하려면 다음 구성요소가 필요합니다. Android 네이티브 개발 키트(NDK): Android에서 C 및 C++ 코드를 사용할 수 있도록 해주는 도구 모음입니다. CMake: Gradle과

developer.android.com

 

developer.android.com/studio/projects/add-native-code?hl=ko

 

C 및 C++ 코드를 프로젝트에 추가  |  Android 개발자  |  Android Developers

C 및 C++ 코드를 Android 프로젝트에 추가하는 방법을 알아보세요.

developer.android.com

 

developer.android.com/ndk/samples/sample_hellojni

 

샘플: hello-jni  |  Android NDK  |  Android Developers

이 샘플에서는 NDK로 빌드한 작은 C/C++ 애플리케이션인 hello-jni를 살펴봅니다. 이 샘플은 android-mk 분기 내 ndk-samples 저장소의 hello-jni 디렉터리에 있습니다. Android.mk 다음 두 줄은 네이티브 소스 파

developer.android.com

 

medium.com/programming-lite/securing-api-keys-in-android-app-using-ndk-native-development-kit-7aaa6c0176be

 

Securing API Keys in Android App using NDK (Native Development Kit)

Securing API keys in Android application has become a challenging by traditional methods (storing them in strings.xml or in Gradle etc.)…

medium.com

 

thepassion.tistory.com/332

 

[Android] ndk-build를 이용한 Native Code 빌드 및 사용방법

ndk-build를 이용한 Native Code 빌드 및 사용방법 다음과 같은 이유로 Android App에서 Native Code(C/C++등)로 코드를 작성하여 사용해야 할 경우가 존재합니다. 처리 속도 및 성능향상 C/C++로 만들어진 코드.

thepassion.tistory.com

 

medium.com/@abhi007tyagi/storing-api-keys-using-android-ndk-6abb0adcadad

 

Securing API Keys using Android NDK

Today there are thousands of third-party libraries and APIs available to developers for creating cool, amazing mobile apps. These APIs are…

medium.com

 

blog.mindorks.com/securing-api-keys-using-android-ndk

 

Securing API Keys using Android NDK (Native Development Kit)

In this blog, we will learn how to secure our API Keys that are used in Android applications using the Android NDK (Native Development Kit). We have created a detailed blog of securing the API Keys.

blog.mindorks.com

 

yoo-hyeok.tistory.com/72

 

[Android] NDK를 이용한 C/C++ 연동 개발

NDK란 무엇인가? Android NDK는 C와 C++ 같은 네이티브 코드 언어를 사용하여 앱의 일부를 구현하는 도구모음입니다. 어떤 유형의 앱에서는 네이티브 코드 언어로 작성된 코드 라이브러리를 재사용하

yoo-hyeok.tistory.com

 

 

 

1. app 단위 gradle에서 minifyEnabled true 세팅

 

2. proguard-rules.pro 파일을 수정

외부 라이브러리 등의 난독화 설정을 해줘야한다.
라이브러리 docs에 proguard 관련 내용이 있으니 참고하면 된다.

또한 retrofit2와 rxjava 등을 사용한다면 통신에 필요한 모델들도 난독화에서 제외해야한다.

인텔리제이에서 아래와 같이 빨간줄이 뜨지만 정상작동한다.
(오히려 빨간줄을 없애려고 * 하나 줄이는 등의 작업을 하면 빌드 후 문제가 발생하는 듯 하다.)

 

3. 빌드 후 테스트하여 에러 등을 확인한다.

 

4. apktool / dex2jar / jd-gui 등의 디컴파일 툴 등을 이용하여 디컴파일해서 난독화가 잘되었는지 확인한다.

 

5. 기타

아래는 proguard-rules.pro파일을 수정할 때 필요한 코드 등을 정리한 것이다.
아래 내용에 없는 라이브러리는 해당 라이브러리 사이트나 docs에서 proguard 설정 코드를 찾아본다.
그래도 안된다면 구글링을 하여 선배님들이 만들어 놓은 코드를 사용하자.

더보기
# If you keep the line number information, uncomment this to
# hide the original source file name.
# 소스 파일 변수 명 바꾸는 옵션
-renamesourcefileattribute SourceFile

# Uncomment this to preserve the line number information for
# debugging stack traces.
# 소스 파일의 라인을 섞지 않는 옵션 (이거 안해주면 나중에 stacktrace보고 어느 line에서 오류가 난 것인지 확인 불가)
-keepattributes SourceFile,LineNumberTable

# Retrofit2
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
# Retrofit2

# 카카오 지도 앱 (빨간줄 뜨지만 정상)
-keep class net.daum.** {*;}
-keep class android.opengl.** {*;}
-keep class com.kakao.util.maps.helper.** {*;}
-keepattributes Signature
-keepclassmembers class * {
    public static <fields>;
    public *;
}
# 카카오 지도 앱 (빨간줄 뜨지만 정상)

# 카카오 로그인
-keep class com.kakao.sdk.**.model.* { <fields>; }
-keep class * extends com.google.gson.TypeAdapter
# 카카오 로그인

# 네이버 로그인
-keep public class com.nhn.android.naverlogin.** {
       public protected *;
}
# 네이버 로그인

# firebase 구글 로그인
-keepattributes Signature
-keepattributes *Annotation*
# firebase 구글 로그인

# sqlite
-keep class org.sqlite.** { *; }
-keep class org.sqlite.database.** { *; }
-keep class net.sqlcipher.** { *; }
-dontwarn net.sqlcipher.**
# sqlite

# roomdb (androidx)
-keep class * extends androidx.room.RoomDatabase
-dontwarn androidx.room.paging.**
# roomdb

#glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}
#glide


# okhttp3
-dontwarn okhttp3.**
-dontwarn okio.**
-dontnote okhttp3.**
# okhttp3


# support v4 ,v7
-dontwarn android.support.**
# support v4 ,v7


## gson (gson 컨버터와 다른 것)
###---------------Begin: proguard configuration for Gson  ----------
## Gson uses generic type information stored in a class file when working with fields. Proguard
## removes such information by default, so configure it to keep all of it.
#-keepattributes Signature
#
## For using GSON @Expose annotation
#-keepattributes *Annotation*
#
## Gson specific classes
#-dontwarn sun.misc.**
##-keep class com.google.gson.stream.** { *; }
#
## Application classes that will be serialized/deserialized over Gson
#-keep class com.google.gson.examples.android.model.** { *; }
#
## Prevent proguard from stripping interface information from TypeAdapterFactory,
## JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
#-keep class * implements com.google.gson.TypeAdapterFactory
#-keep class * implements com.google.gson.JsonSerializer
#-keep class * implements com.google.gson.JsonDeserializer
#
###---------------End: proguard configuration for Gson  ----------
## gson (gson 컨버터와 다른 것)

 

 

참고 사이트들

medium.com/ics-lab/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%95%B1-%EB%82%9C%EB%8F%85%ED%99%94-proguard-dexguard-%EB%A5%BC-%ED%95%B4%EB%B3%B4%EC%9E%90-1-%ED%94%84%EB%A1%9C%EA%B0%80%EB%93%9C-%ED%8E%B8-799999a43c4d

 

안드로이드 앱 난독화(Proguard & Dexguard)를 해보자! 1. 프로가드 편

Google play store에서 앱을 받아 apk 파일을 추출하는 어플을 사용하면 쉽게 apk을 얻을 수 있다.

medium.com

 

black-jin0427.tistory.com/89

 

[Android, Proguard] 안드로이드 프로가드 설정하기

안녕하세요. 블랙진입니다. 이번에는 코드 난독화 및 APK 최적화를 위한 프로가드에 대해 알아보겠습니다. Android Proguard 가 필요한 이유 1. 코드 난독화를 통해 디컴파일시 본인의 코드가 노출되

black-jin0427.tistory.com

 

namget.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-proguard-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-retrofitgsonzxingglideokhttp3supportrxjava

 

안드로이드 proguard 적용하기 (retrofit,gson,zxing,glide,okhttp3,support,rxjava)

안녕하세요 남갯입니다 오늘은 안드로이드 proguard 적용 (난독화)하는 방법에대해 알려드리겠습니다. 일단 release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'progu..

namget.tistory.com

 

bigmatch.i-um.net/2016/08/05/retrofit2-rxjava-proguard-settings/

 

Retrofit2 + RxJava proguard 설정하기

안녕하세요, 이음소시어스에서 안드로이드 앱 개발을 맡고 있는 김범준(준) 입니다. 최근 안드로이드 HTTP Client 라이브러

bigmatch.i-um.net

 

developer88.tistory.com/118

 

ProGuard Rules 정리 (Retrofit & OkHttp, JSoup, GSon, RxJava, Glide etc)

다양한 라이브러리를 사용하는 만큼, 다양한 ProGuard를 사용해야 합니다. 그런데, 어떤 라이브러리는 이 부분에 대해서 명확히 정리하고 있고, 또 어떤 라이브러리는 그렇지 못합니다. 오늘은 제

developer88.tistory.com

 

gogorchg.tistory.com/entry/Android-Project%EC%97%90-Proguard-%EC%A0%81%EC%9A%A9-%ED%95%98%EA%B8%B0

 

[Android] Project에 Proguard 적용 하기

ProGuard를 적용하는 방법은 쉽습니다. build.gradle 파일 에 아래 소스만 넣어주면 땡입니다. buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'pro..

gogorchg.tistory.com

 

 

+ Recent posts