-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
180 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "Android/app/src/main/cpp/submodules/zdtun"] | ||
path = Android/app/src/main/cpp/submodules/zdtun | ||
url = [email protected]:KrxkGit/zdtun.git | ||
[submodule "Android/app/src/main/cpp/submodules/libpcap"] | ||
path = Android/app/src/main/cpp/submodules/libpcap | ||
url = [email protected]:the-tcpdump-group/libpcap.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Log/OS Files | ||
*.log | ||
|
||
# Android Studio generated files and folders | ||
captures/ | ||
.externalNativeBuild/ | ||
.cxx/ | ||
*.apk | ||
output.json | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/ | ||
misc.xml | ||
deploymentTargetDropDown.xml | ||
render.experimental.xml | ||
|
||
# Keystore files | ||
*.jks | ||
*.keystore | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
google-services.json | ||
|
||
# Android Profiling | ||
*.hprof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// Created by krxkli on 2024/8/13. | ||
// | ||
#include "pcap_dumper.h" | ||
|
||
#define MAX_PACKET_SIZE 65535 | ||
|
||
FILE *file = nullptr; | ||
|
||
void pcap_dump_init(const char* file_name) { | ||
if(file != nullptr) { | ||
return; | ||
} | ||
pcap_file_header file_header; | ||
|
||
// 打开输出文件 | ||
file = fopen(file_name, "wb"); | ||
|
||
// 设置pcap文件头部信息 | ||
file_header.magic_number = 0xa1b2c3d4; // 网络字节序 | ||
file_header.version_major = 2; | ||
file_header.version_minor = 4; | ||
file_header.thiszone = 0; | ||
file_header.sigfigs = 0; | ||
file_header.snaplen = MAX_PACKET_SIZE; | ||
file_header.network = 101; // raw IP | ||
|
||
// 写入pcap文件头部 | ||
fwrite(&file_header, sizeof(file_header), 1, file); | ||
fflush(file); | ||
} | ||
|
||
void pcap_dump_data(u_char* pkt, uint32_t len) { | ||
if(file == nullptr) { | ||
return; | ||
} | ||
pcap_packet_header packet_header; | ||
// 设置数据包头部信息 | ||
packet_header.ts_sec = clock() / CLOCKS_PER_SEC; | ||
packet_header.ts_usec = clock() % CLOCKS_PER_SEC; | ||
packet_header.incl_len = len; | ||
packet_header.orig_len = len; | ||
|
||
// 写入数据包头部 | ||
fwrite(&packet_header, sizeof(packet_header), 1, file); | ||
|
||
// 写入数据包 | ||
fwrite(pkt, len, 1, file); | ||
|
||
// 关闭输出文件 | ||
// fflush(file); | ||
} | ||
|
||
void pcap_dump_finish() { | ||
fclose(file); | ||
file = nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Created by krxkli on 2024/8/13. | ||
// | ||
|
||
#ifndef PCAP_DUMPER_H | ||
#define PCAP_DUMPER_H | ||
|
||
#include <ctime> | ||
#include <cstdio> | ||
|
||
/** | ||
* 请保证全局单例使用本库 | ||
*/ | ||
|
||
// 定义pcap文件头部结构体 | ||
typedef struct { | ||
uint32_t magic_number; // 文件魔术数 | ||
uint16_t version_major; // 主版本号 | ||
uint16_t version_minor; // 次版本号 | ||
int32_t thiszone; // 时区修正 | ||
uint32_t sigfigs; // 时间戳精度 | ||
uint32_t snaplen; // 最大捕获包长度 | ||
uint32_t network; // 数据链路类型 | ||
} pcap_file_header; | ||
|
||
// 定义数据包头部结构体 | ||
typedef struct { | ||
uint32_t ts_sec; // 时间戳(秒) | ||
uint32_t ts_usec; // 时间戳(微秒) | ||
uint32_t incl_len; // 捕获包长度 | ||
uint32_t orig_len; // 原始包长度 | ||
} pcap_packet_header; | ||
|
||
void pcap_dump_init(const char* file_name); | ||
void pcap_dump_data(u_char* pkt, uint32_t len); | ||
void pcap_dump_finish(); | ||
|
||
#endif //CRACKMM_PCAP_DUMPER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters