1 回答

TA貢獻1846條經驗 獲得超7個贊
是的,在大多數情況下,覆蓋密鑰字節應該可以做到這一點。
請注意,目前 Go CMS 垃圾回收器是一個非移動的世代 GC,這意味著如果您不創建對象的副本,則 GC 也不會創建副本。這是實現細節,將來可能會更改。
此外,根據部件的功能,該部件也可能將密鑰泄漏到堆上。例如,讀取 PEM 格式的文件可能會泄漏 PEM 編碼的字符串。// acquire and use the private key
要真正確定,請在覆蓋密鑰后立即闖入并將整個堆轉儲到文件中。然后在其中搜索密鑰字節。gdb
$ go build -gcflags "-N -l"
$ gdb ./test
(gdb) source /usr/go/src/runtime/runtime-gdb.py
Loading Go Runtime support.
(gdb) b test.go:16
(gdb) r
Thread 1 "test" hit Breakpoint 1, main.main () at test/test.go:16
(gdb) info i
Num Description Executable
* 1 process 14176 test/test
(gdb) (Ctrl-Z)
[1]+ Stopped gdb ./test
$ cat /proc/14176/maps|grep '\[heap\]'|(read a; x=(${a//-/ }); dd if=/proc/14176/mem bs=4096 iflag=skip_bytes,count_bytes skip=$((0x${x[0]})) count=$((0x${x[1]}-0x${x[0]})) of=heap.bin)
$ grep -obUaP "\x01\x02\x03..." heap.bin
$ fg
(gdb) q
- 1 回答
- 0 關注
- 72 瀏覽
添加回答
舉報