Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
krxkli committed Sep 20, 2024
2 parents 9ca11aa + b48fd04 commit 68ea931
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -32,6 +32,7 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
}
}
compileOptions {
Expand Down
Binary file modified Android/app/release/app-release.apk
Binary file not shown.
Binary file modified Android/app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified Android/app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
4 changes: 2 additions & 2 deletions Android/app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 2,
"versionName": "1.1",
"versionCode": 3,
"versionName": "1.1.1",
"outputFile": "app-release.apk"
}
],
Expand Down
13 changes: 12 additions & 1 deletion Android/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions Android/app/src/main/cpp/core/acquire_permission.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* @Author: krxkli [email protected]
* @Date: 2024-09-12 21:07:35
* @LastEditors: krxkli [email protected]
* @LastEditTime: 2024-09-12 21:10:30
* @FilePath: \CommonNative\pcap_dump\acquire_permission.cpp
* @Description:
*
* Copyright (c) 2024 by ${krxkli}, All Rights Reserved.
*/
#include <cstring>
#include <cstdlib>
#include <ctime>
#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(&currentTime);

// 格式化日期和时间字符串
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);
}
2 changes: 1 addition & 1 deletion Android/app/src/main/cpp/core/cheat.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef CRACKMM_CHEAT_H
#define CRACKMM_CHEAT_H

extern "C" { ;
extern "C" {
#include "zdtun.h"
}

Expand Down
2 changes: 1 addition & 1 deletion Android/app/src/main/cpp/core/pcap_dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions Android/app/src/main/cpp/core/pcap_dumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 17 additions & 2 deletions Android/app/src/main/cpp/core/pkt_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

}
3 changes: 3 additions & 0 deletions Android/app/src/main/java/com/krxkli/crackmm/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 68ea931

Please sign in to comment.