|
|
@@ -58,8 +58,9 @@ func (t *Tracer) AttachJavaNioReadUprobes(pid uint32, insID utils.ID, codeType c
|
|
|
}
|
|
|
defer ef.Close()
|
|
|
|
|
|
- symbols, err := ef.Symbols()
|
|
|
+ symbols, err := ef.DynamicSymbols()
|
|
|
if err != nil {
|
|
|
+ fmt.Println("can not get symbols")
|
|
|
if errors.Is(err, elf.ErrNoSymbols) {
|
|
|
return nil
|
|
|
}
|
|
|
@@ -68,10 +69,12 @@ func (t *Tracer) AttachJavaNioReadUprobes(pid uint32, insID utils.ID, codeType c
|
|
|
|
|
|
textSection := ef.Section(".text")
|
|
|
if textSection == nil {
|
|
|
+ fmt.Println("can not find .text section")
|
|
|
return nil
|
|
|
}
|
|
|
textSectionData, err := textSection.Data()
|
|
|
if err != nil {
|
|
|
+ fmt.Println("can not get .text section data", err)
|
|
|
return nil
|
|
|
}
|
|
|
textSectionLen := uint64(len(textSectionData) - 1)
|
|
|
@@ -115,6 +118,7 @@ func (t *Tracer) AttachJavaNioReadUprobes(pid uint32, insID utils.ID, codeType c
|
|
|
sBytes := textSectionData[sStart:sEnd]
|
|
|
returnOffsets := getCallNextMoveOffsets(ef.Machine, sBytes)
|
|
|
if len(returnOffsets) == 0 {
|
|
|
+ fmt.Println("failed to attach uprobe_ret_Java_sun_nio_ch_FileDispatcherImpl_read0 uprobe")
|
|
|
return nil
|
|
|
}
|
|
|
for _, offset := range returnOffsets {
|
|
|
@@ -131,7 +135,7 @@ func (t *Tracer) AttachJavaNioReadUprobes(pid uint32, insID utils.ID, codeType c
|
|
|
if len(links) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
- fmt.Println("jvm uprobes attached, pid is ", pid)
|
|
|
+ fmt.Println("[jvm] libnio attached, pid is ", pid)
|
|
|
return links
|
|
|
}
|
|
|
|
|
|
@@ -145,7 +149,7 @@ func (t *Tracer) AttachJavaNetWriteUprobes(pid uint32, insID utils.ID) []link.Li
|
|
|
if runtime.GOARCH == "arm64" {
|
|
|
libnetSo = "/root/cwlibnet.so"
|
|
|
sys = "CW_Java_java_net_SocketOutputStream_socketWrite0"
|
|
|
- offset = 0
|
|
|
+ offset = 8
|
|
|
}
|
|
|
var links []link.Link
|
|
|
ex, err := link.OpenExecutable(libnetSo)
|
|
|
@@ -165,8 +169,7 @@ func (t *Tracer) AttachJavaNetWriteUprobes(pid uint32, insID utils.ID) []link.Li
|
|
|
if len(links) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
- fmt.Println("jvm client uprobes attached", pid)
|
|
|
-
|
|
|
+ fmt.Println("[jvm] libnet attached", pid)
|
|
|
return links
|
|
|
}
|
|
|
|
|
|
@@ -213,7 +216,7 @@ func getSoPath(pid uint32, soname string) string {
|
|
|
// 读取maps文件内容
|
|
|
mapsData, err := ioutil.ReadFile(mapsPath)
|
|
|
if err != nil {
|
|
|
- fmt.Println("无法读取maps文件")
|
|
|
+ fmt.Println("lookup so error.")
|
|
|
return ""
|
|
|
}
|
|
|
|