Created
December 6, 2021 14:11
-
-
Save shibukk/e858f1578aab99aeed7959dcb465f057 to your computer and use it in GitHub Desktop.
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
str = "Hello, world!" | |
=> "Hello, world!" | |
# object_idを確認してみる | |
str.object_id | |
=> 47382279417420 | |
# 左にビットシフトしてオブジェクトの実際のポインタ値を確認してみる | |
str.object_id.<<(1).to_s(16) | |
=> "563017dddc98" | |
# https://udzura.hatenablog.jp/entry/2021/07/28/154920 | |
# を参考にアドレスに文字列が格納されているか確認してみる | |
mem = open("/proc/self/mem") | |
=> #<File:/proc/self/mem> | |
# 先ほど確認したポインタ値までseekする | |
mem.seek 0x0000563017dddc98 | |
=> 0 | |
dump = mem.read 32 | |
=> "e@S\x00\x00\x00\x00\x00\xC8{\xA5\x170V\x00\x00Hello, world!\x00\x00\x00" | |
dump.unpack "Q! Q! Z*" | |
=> [5455973, 94764555140040, "Hello, world!"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment