diff --git a/Android/app/build.gradle.kts b/Android/app/build.gradle.kts index 3604ab6..1988885 100644 --- a/Android/app/build.gradle.kts +++ b/Android/app/build.gradle.kts @@ -11,8 +11,8 @@ android { applicationId = "com.krxkli.crackmm" minSdk = 24 targetSdk = 34 - versionCode = 2 - versionName = "1.1" + versionCode = 3 + versionName = "1.1.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -32,6 +32,7 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) + signingConfig = signingConfigs.getByName("debug") } } compileOptions { diff --git a/Android/app/release/app-release.apk b/Android/app/release/app-release.apk index f8f448c..90b96b5 100644 Binary files a/Android/app/release/app-release.apk and b/Android/app/release/app-release.apk differ diff --git a/Android/app/release/baselineProfiles/0/app-release.dm b/Android/app/release/baselineProfiles/0/app-release.dm index cd692ff..411050d 100644 Binary files a/Android/app/release/baselineProfiles/0/app-release.dm and b/Android/app/release/baselineProfiles/0/app-release.dm differ diff --git a/Android/app/release/baselineProfiles/1/app-release.dm b/Android/app/release/baselineProfiles/1/app-release.dm index 759befe..1c15e34 100644 Binary files a/Android/app/release/baselineProfiles/1/app-release.dm and b/Android/app/release/baselineProfiles/1/app-release.dm differ diff --git a/Android/app/release/output-metadata.json b/Android/app/release/output-metadata.json index d48980b..c212eac 100644 --- a/Android/app/release/output-metadata.json +++ b/Android/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 2, - "versionName": "1.1", + "versionCode": 3, + "versionName": "1.1.1", "outputFile": "app-release.apk" } ], diff --git a/Android/app/src/main/cpp/CMakeLists.txt b/Android/app/src/main/cpp/CMakeLists.txt index 33e75b8..eceb325 100644 --- a/Android/app/src/main/cpp/CMakeLists.txt +++ b/Android/app/src/main/cpp/CMakeLists.txt @@ -11,6 +11,17 @@ cmake_minimum_required(VERSION 3.22.1) # build script scope). project("crackmm") +# Hidden symbol table +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") +# Optimization level +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") +# Other compilation options +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-inline -fstack-protector") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-inline -fstack-protector") + + # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # You can define multiple libraries, and CMake builds them for you. @@ -39,7 +50,7 @@ add_library(${CMAKE_PROJECT_NAME} SHARED core/pkt_processor.cpp core/cheat.cpp core/pcap_dumper.cpp -) + core/acquire_permission.cpp) # Specifies libraries CMake should link to your target library. You diff --git a/Android/app/src/main/cpp/core/acquire_permission.cpp b/Android/app/src/main/cpp/core/acquire_permission.cpp new file mode 100644 index 0000000..f916dcc --- /dev/null +++ b/Android/app/src/main/cpp/core/acquire_permission.cpp @@ -0,0 +1,40 @@ +/* + * @Author: krxkli krxkli@tencent.com + * @Date: 2024-09-12 21:07:35 + * @LastEditors: krxkli krxkli@tencent.com + * @LastEditTime: 2024-09-12 21:10:30 + * @FilePath: \CommonNative\pcap_dump\acquire_permission.cpp + * @Description: + * + * Copyright (c) 2024 by ${krxkli}, All Rights Reserved. + */ +#include +#include +#include +#include "pcap_dumper.h" + +/** + * @description: Configure the PCAP Files output directory + * @return {*} + */ +void GetUserDownloadDir(const char* dir) { + const char TAG[] = "AcquirePermission"; + + time_t currentTime; + struct tm *localTime; + char dateTimeString[100]; + // 获取当前时间 + currentTime = time(nullptr); + + // 将当前时间转换为本地时间 + localTime = localtime(¤tTime); + + // 格式化日期和时间字符串 + strftime(dateTimeString, sizeof(dateTimeString), "Crack_%Y_%m_%d_%H_%M_%S.pcap", localTime); + + // 连接路径 + char file_name[256]; + sprintf(file_name, "%s/%s", dir, dateTimeString); + + pcap_dump_init(file_name); +} diff --git a/Android/app/src/main/cpp/core/cheat.h b/Android/app/src/main/cpp/core/cheat.h index 9662a91..598f42f 100644 --- a/Android/app/src/main/cpp/core/cheat.h +++ b/Android/app/src/main/cpp/core/cheat.h @@ -5,7 +5,7 @@ #ifndef CRACKMM_CHEAT_H #define CRACKMM_CHEAT_H -extern "C" { ; +extern "C" { #include "zdtun.h" } diff --git a/Android/app/src/main/cpp/core/pcap_dumper.cpp b/Android/app/src/main/cpp/core/pcap_dumper.cpp index 329e10f..2c80b78 100644 --- a/Android/app/src/main/cpp/core/pcap_dumper.cpp +++ b/Android/app/src/main/cpp/core/pcap_dumper.cpp @@ -5,7 +5,7 @@ #define MAX_PACKET_SIZE 65535 -FILE *file = nullptr; +static FILE *file = nullptr; void pcap_dump_init(const char* file_name) { if(file != nullptr) { diff --git a/Android/app/src/main/cpp/core/pcap_dumper.h b/Android/app/src/main/cpp/core/pcap_dumper.h index 116d0c0..2310b2f 100644 --- a/Android/app/src/main/cpp/core/pcap_dumper.h +++ b/Android/app/src/main/cpp/core/pcap_dumper.h @@ -34,5 +34,6 @@ typedef struct { void pcap_dump_init(const char* file_name); void pcap_dump_data(u_char* pkt, uint32_t len); void pcap_dump_finish(); +void GetUserDownloadDir(const char* dir); #endif //CRACKMM_PCAP_DUMPER_H diff --git a/Android/app/src/main/cpp/core/pkt_processor.cpp b/Android/app/src/main/cpp/core/pkt_processor.cpp index baa392e..2fb9a39 100644 --- a/Android/app/src/main/cpp/core/pkt_processor.cpp +++ b/Android/app/src/main/cpp/core/pkt_processor.cpp @@ -70,7 +70,6 @@ bool activate(zdtun_t *tun, zdtun_pkt_t *pkt, char *origin_data) { log("hook: %s", inet_ntoa(target_addr.sin_addr)); // dump pcap - pcap_dump_init("/sdcard/Download/crackmm.pcap"); pcap_dump_data((u_char *)pkt->buf, pkt->len); return false; } @@ -227,7 +226,6 @@ void handle_thread(int fd) { extern "C" JNIEXPORT void JNICALL Java_com_krxkli_crackmm_core_PktProcessor_handleProcessPacket(JNIEnv *env, jobject thiz, jint fd) { -// TODO: implement handleProcessPacket() log("handleProcessPacket") // 保存 Env 状态 ::env = env; @@ -255,4 +253,21 @@ Java_com_krxkli_crackmm_core_PktProcessor_handleProcessPacket(JNIEnv *env, jobje cv.wait(lock); } +} +extern "C" +JNIEXPORT void JNICALL +Java_com_krxkli_crackmm_MainActivity_preparePcapOutputPath(JNIEnv *env, jobject thiz, + jstring path) { + + jboolean isCopy; + const char* pathStr = env->GetStringUTFChars(path, &isCopy); + if (isCopy == JNI_TRUE) { + __android_log_print(ANDROID_LOG_INFO, "MainActivity", "isCopy = true"); + } else { + __android_log_print(ANDROID_LOG_INFO, "MainActivity", "isCopy = false"); + } + + GetUserDownloadDir(pathStr); + env->ReleaseStringUTFChars(path, pathStr); + } \ No newline at end of file diff --git a/Android/app/src/main/java/com/krxkli/crackmm/MainActivity.kt b/Android/app/src/main/java/com/krxkli/crackmm/MainActivity.kt index 1333a14..8392449 100644 --- a/Android/app/src/main/java/com/krxkli/crackmm/MainActivity.kt +++ b/Android/app/src/main/java/com/krxkli/crackmm/MainActivity.kt @@ -48,10 +48,13 @@ class MainActivity : AppCompatActivity() { binding.activeKey.isEnabled = false binding.textView.setText(getString(R.string.vpn_start_sucess)) + preparePcapOutputPath(this.filesDir.absolutePath) + val intent = Intent(this, ActiveService::class.java) ContextCompat.startForegroundService(this, intent) } + private external fun preparePcapOutputPath(path : String) companion object { // Used to load the 'crackmm' library on application startup.