Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cant found RET offset in gotls mode. fix #502. #512

Merged
merged 4 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions builder/Makefile.release
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ endif

OUTPUT_DIR = ./bin
TAR_DIR = ecapture-$(SNAPSHOT_VERSION)-linux-$(UNAME_M)
TAR_DIR_NOCORE = ecapture-$(SNAPSHOT_VERSION)-linux-nocore
TAR_DIR_ANDROID = ecapture-$(SNAPSHOT_VERSION)-android-$(UNAME_M)
TAR_DIR_ANDROID_NOCORE = ecapture-$(SNAPSHOT_VERSION)-android-$(UNAME_M)-nocore

# from CLI args.
RELEASE_NOTES ?= $(OUTPUT_DIR)/release_notes.txt
Expand All @@ -71,7 +73,9 @@ BUILD_DIR = build
#

OUT_ARCHIVE := $(OUTPUT_DIR)/$(TAR_DIR).tar.gz
OUT_ARCHIVE_ANDROID := $(OUTPUT_DIR)/$(TAR_DIR_ANDROID)-nocore.tar.gz
OUT_ARCHIVE_NOCORE := $(OUTPUT_DIR)/$(TAR_DIR_NOCORE).tar.gz
OUT_ARCHIVE_ANDROID := $(OUTPUT_DIR)/$(TAR_DIR_ANDROID).tar.gz
OUT_ARCHIVE_ANDROID_NOCORE := $(OUTPUT_DIR)/$(TAR_DIR_ANDROID_NOCORE).tar.gz
OUT_CHECKSUMS := $(OUTPUT_DIR)/checksum-$(SNAPSHOT_VERSION).txt


Expand Down Expand Up @@ -183,7 +187,7 @@ snapshot: \
$(CMD_CP) $(OUTPUT_DIR)/ecapture $(TAR_DIR)/ecapture
$(CMD_TAR) -czf $(OUT_ARCHIVE) $(TAR_DIR)
cd $(OUTPUT_DIR)
$(CMD_CHECKSUM) $(TAR_DIR).tar.gz > ./../$(OUT_CHECKSUMS)
$(CMD_CHECKSUM) $(OUT_ARCHIVE_ANDROID) > ./../$(OUT_CHECKSUMS)
cd ../

.PHONY: snapshot_android
Expand All @@ -198,29 +202,29 @@ snapshot_android: \
$(MAKE) clean
ANDROID=1 $(MAKE) nocore RELEASE_TAG=$(SNAPSHOT_VERSION)
# create the tar ball and checksum files
$(CMD_MKDIR) -p $(TAR_DIR_ANDROID)
$(CMD_CP) LICENSE $(TAR_DIR_ANDROID)/LICENSE
$(CMD_CP) CHANGELOG.md $(TAR_DIR_ANDROID)/CHANGELOG.md
$(CMD_CP) README.md $(TAR_DIR_ANDROID)/README.md
$(CMD_CP) README_CN.md $(TAR_DIR_ANDROID)/README_CN.md
$(CMD_CP) $(OUTPUT_DIR)/ecapture $(TAR_DIR_ANDROID)/ecapture
$(CMD_TAR) -czf $(OUT_ARCHIVE_ANDROID) $(TAR_DIR_ANDROID)
$(CMD_MKDIR) -p $(TAR_DIR_ANDROID_NOCORE)
$(CMD_CP) LICENSE $(TAR_DIR_ANDROID_NOCORE)/LICENSE
$(CMD_CP) CHANGELOG.md $(TAR_DIR_ANDROID_NOCORE)/CHANGELOG.md
$(CMD_CP) README.md $(TAR_DIR_ANDROID_NOCORE)/README.md
$(CMD_CP) README_CN.md $(TAR_DIR_ANDROID_NOCORE)/README_CN.md
$(CMD_CP) $(OUTPUT_DIR)/ecapture $(TAR_DIR_ANDROID_NOCORE)/ecapture
$(CMD_TAR) -czf $(OUT_ARCHIVE_ANDROID_NOCORE) $(TAR_DIR_ANDROID_NOCORE)
cd $(OUTPUT_DIR)
$(CMD_CHECKSUM) $(TAR_DIR_ANDROID).tar.gz >> ./../$(OUT_CHECKSUMS)
$(CMD_CHECKSUM) $(OUT_ARCHIVE_ANDROID_NOCORE) >> ./../$(OUT_CHECKSUMS)
cd ../

.PHONY: publish
publish: \
$(OUTPUT_DIR) \
$(OUT_ARCHIVE) \
$(OUT_ARCHIVE_ANDROID) \
$(OUT_ARCHIVE_ANDROID_NOCORE) \
$(OUT_CHECKSUMS) \
$(OUT_DEB_FILE) \
| .check_tree \
.check_$(CMD_GITHUB)
#
# release it!
$(CMD_GITHUB) release create $(SNAPSHOT_VERSION) $(OUT_ARCHIVE) $(OUT_ARCHIVE_ANDROID) $(OUT_DEB_FILE) $(OUT_CHECKSUMS) --title "eCapture $(SNAPSHOT_VERSION)" --notes-file $(RELEASE_NOTES)
$(CMD_GITHUB) release create $(SNAPSHOT_VERSION) $(OUT_ARCHIVE) $(OUT_ARCHIVE_ANDROID_NOCORE) $(OUT_DEB_FILE) $(OUT_CHECKSUMS) --title "eCapture $(SNAPSHOT_VERSION)" --notes-file $(RELEASE_NOTES)

.PHONY: clean
clean:
Expand Down
14 changes: 10 additions & 4 deletions kern/gotls_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ static __always_inline int gotls_write(struct pt_regs *ctx,
len_ptr = (void *)go_get_argument(ctx, is_register_abi, 4);
bpf_probe_read_kernel(&len, sizeof(len), (void *)&len_ptr);

debug_bpf_printk("gotls_write record_type:%d\n", record_type);
if (len == 0) {
return 0;
}
debug_bpf_printk("gotls_write record_type:%d, len:%d\n", record_type, len);
if (record_type != recordTypeApplicationData) {
return 0;
}
Expand All @@ -115,7 +118,7 @@ static __always_inline int gotls_write(struct pt_regs *ctx,
if (!event) {
return 0;
}

len = len & 0xFFFF;
event->data_len = len;
int ret =
bpf_probe_read_user(&event->data, sizeof(event->data), (void *)str);
Expand Down Expand Up @@ -157,7 +160,10 @@ static __always_inline int gotls_read(struct pt_regs *ctx,
// Read函数的返回值第一个是int类型,存放在栈里的顺序是5
ret_len_ptr = (void *)go_get_argument_by_stack(ctx, 5);
bpf_probe_read_kernel(&ret_len, sizeof(ret_len), (void *)&ret_len_ptr);
if (len == 0) {
if (len <= 0) {
return 0;
}
if (ret_len <= 0 ) {
return 0;
}

Expand Down Expand Up @@ -251,7 +257,7 @@ static __always_inline int gotls_mastersecret(struct pt_regs *ctx,
return 0;
}

debug_bpf_printk("gotls_mastersecret read mastersecret label%s\n",
debug_bpf_printk("gotls_mastersecret read mastersecret label:%s\n",
mastersecret_gotls.label);
ret = bpf_probe_read_user_str(&mastersecret_gotls.client_random,
sizeof(mastersecret_gotls.client_random),
Expand Down
Loading
Loading